All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] opengl: Do not convert format with glTexImage2D on OpenGL ES
@ 2021-02-19  9:48 Akihiko Odaki
  2021-02-19 14:14 ` Gerd Hoffmann
  2021-03-11 12:51 ` Gerd Hoffmann
  0 siblings, 2 replies; 4+ messages in thread
From: Akihiko Odaki @ 2021-02-19  9:48 UTC (permalink / raw)
  Cc: qemu-devel, Akihiko Odaki, Gerd Hoffmann

OpenGL ES does not support conversion from the given data format
to the internal format with glTexImage2D.

Use the given data format as the internal format, and ignore
the given alpha channels with GL_TEXTURE_SWIZZLE_A in case the
format contains alpha channels.

Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
---
 ui/console-gl.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/ui/console-gl.c b/ui/console-gl.c
index 0a6478161fe..7c9894a51d9 100644
--- a/ui/console-gl.c
+++ b/ui/console-gl.c
@@ -73,11 +73,20 @@ void surface_gl_create_texture(QemuGLShader *gls,
     glBindTexture(GL_TEXTURE_2D, surface->texture);
     glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT,
                   surface_stride(surface) / surface_bytes_per_pixel(surface));
-    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB,
-                 surface_width(surface),
-                 surface_height(surface),
-                 0, surface->glformat, surface->gltype,
-                 surface_data(surface));
+    if (epoxy_is_desktop_gl()) {
+        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB,
+                     surface_width(surface),
+                     surface_height(surface),
+                     0, surface->glformat, surface->gltype,
+                     surface_data(surface));
+    } else {
+        glTexImage2D(GL_TEXTURE_2D, 0, surface->glformat,
+                     surface_width(surface),
+                     surface_height(surface),
+                     0, surface->glformat, surface->gltype,
+                     surface_data(surface));
+        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, GL_ONE);
+    }
 
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-- 
2.24.3 (Apple Git-128)



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] opengl: Do not convert format with glTexImage2D on OpenGL ES
  2021-02-19  9:48 [PATCH] opengl: Do not convert format with glTexImage2D on OpenGL ES Akihiko Odaki
@ 2021-02-19 14:14 ` Gerd Hoffmann
  2021-02-20  5:50   ` Akihiko Odaki
  2021-03-11 12:51 ` Gerd Hoffmann
  1 sibling, 1 reply; 4+ messages in thread
From: Gerd Hoffmann @ 2021-02-19 14:14 UTC (permalink / raw)
  To: Akihiko Odaki; +Cc: qemu-devel

On Fri, Feb 19, 2021 at 06:48:03PM +0900, Akihiko Odaki wrote:
> OpenGL ES does not support conversion from the given data format
> to the internal format with glTexImage2D.
> 
> Use the given data format as the internal format, and ignore
> the given alpha channels with GL_TEXTURE_SWIZZLE_A in case the
> format contains alpha channels.

Hmm.  Do you know what effect this has performance-wise?
Is it maybe useful to not convert for desktop gl too?

take care,
  Gerd



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] opengl: Do not convert format with glTexImage2D on OpenGL ES
  2021-02-19 14:14 ` Gerd Hoffmann
@ 2021-02-20  5:50   ` Akihiko Odaki
  0 siblings, 0 replies; 4+ messages in thread
From: Akihiko Odaki @ 2021-02-20  5:50 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: qemu Developers

2021年2月19日(金) 23:14 Gerd Hoffmann <kraxel@redhat.com>:
>
> On Fri, Feb 19, 2021 at 06:48:03PM +0900, Akihiko Odaki wrote:
> > OpenGL ES does not support conversion from the given data format
> > to the internal format with glTexImage2D.
> >
> > Use the given data format as the internal format, and ignore
> > the given alpha channels with GL_TEXTURE_SWIZZLE_A in case the
> > format contains alpha channels.
>
> Hmm.  Do you know what effect this has performance-wise?
> Is it maybe useful to not convert for desktop gl too?

I have no idea about performance, but I am concerned about
compatibility. OpenGL 4.6 core profile does not support GL_BGRA, which
is aliased as GL_BGRA_EXT by epoxy, as internalformat. I also tested
with Intel HD Graphics 3000/Mesa 20.3.4 but it didn't work.

>
> take care,
>   Gerd
>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] opengl: Do not convert format with glTexImage2D on OpenGL ES
  2021-02-19  9:48 [PATCH] opengl: Do not convert format with glTexImage2D on OpenGL ES Akihiko Odaki
  2021-02-19 14:14 ` Gerd Hoffmann
@ 2021-03-11 12:51 ` Gerd Hoffmann
  1 sibling, 0 replies; 4+ messages in thread
From: Gerd Hoffmann @ 2021-03-11 12:51 UTC (permalink / raw)
  To: Akihiko Odaki; +Cc: qemu-devel

On Fri, Feb 19, 2021 at 06:48:03PM +0900, Akihiko Odaki wrote:
> OpenGL ES does not support conversion from the given data format
> to the internal format with glTexImage2D.
> 
> Use the given data format as the internal format, and ignore
> the given alpha channels with GL_TEXTURE_SWIZZLE_A in case the
> format contains alpha channels.
> 
> Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>

Added to UI patch queue.

thanks,
  Gerd



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-03-11 12:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-19  9:48 [PATCH] opengl: Do not convert format with glTexImage2D on OpenGL ES Akihiko Odaki
2021-02-19 14:14 ` Gerd Hoffmann
2021-02-20  5:50   ` Akihiko Odaki
2021-03-11 12:51 ` Gerd Hoffmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.