Skip to contentSkip to conversation

opengl: Do not convert format with glTexImage2D on OpenGL ES

PATCH In review Akihiko Odaki 2 participants 4 messages Feb 19, 2021 – Mar 11, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 opengl: Do not convert format with glTexImage2D on OpenGL ES

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.

---
 ui/console-gl.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)
ui/console-gl.c +14 -5
index 0a6478161fe..7c9894a51d9 100644
@@ -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);
Signature · 1 line
2.24.3 (Apple Git-128)
#1 lore raw
Quoted 6 lines · Akihiko Odaki

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

#2 lore raw

2021年2月19日(金) 23:14 Gerd Hoffmann <[email protected]>:

Quoted 11 lines · Akihiko Odaki
Quoted 6 lines

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.

Quoted 4 lines

take care,
Gerd

#3 lore raw
In reply to Akihiko Odaki
Quoted 8 lines · Akihiko Odaki

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.

Added to UI patch queue.

thanks,
Gerd