From: Arnaud Vrac <av...@freebox.fr>

In glTexImage2D / glTexSubImage2D calls, the only pixel formats allowed
for the GL_R8 and GL_RG internal formats are respectively GL_RED and
GL_RG [1].

Make sure we match this requirement, as some drivers will fail with the
current code.

[1] 
https://www.khronos.org/registry/OpenGL-Refpages/es3.0/html/glTexImage2D.xhtml, 
Table 2
---
 libweston/gl-renderer.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/libweston/gl-renderer.c b/libweston/gl-renderer.c
index 3dce8c2f..60a7bf06 100644
--- a/libweston/gl-renderer.c
+++ b/libweston/gl-renderer.c
@@ -1391,6 +1391,18 @@ gl_renderer_read_pixels(struct weston_output *output,
        return 0;
 }
 
+static GLenum gl_format_from_internal(GLenum internal_format)
+{
+       switch (internal_format) {
+       case GL_R8_EXT:
+               return GL_RED_EXT;
+       case GL_RG8_EXT:
+               return GL_RG_EXT;
+       default:
+               return internal_format;
+       }
+}
+
 static void
 gl_renderer_flush_damage(struct weston_surface *surface)
 {
@@ -1439,7 +1451,7 @@ gl_renderer_flush_damage(struct weston_surface *surface)
                                     gs->pitch / gs->hsub[j],
                                     buffer->height / gs->vsub[j],
                                     0,
-                                    gs->gl_format[j],
+                                    gl_format_from_internal(gs->gl_format[j]),
                                     gs->gl_pixel_type,
                                     data + gs->offset[j]);
                }
@@ -1461,7 +1473,7 @@ gl_renderer_flush_damage(struct weston_surface *surface)
                                     gs->pitch / gs->hsub[j],
                                     buffer->height / gs->vsub[j],
                                     0,
-                                    gs->gl_format[j],
+                                    gl_format_from_internal(gs->gl_format[j]),
                                     gs->gl_pixel_type,
                                     data + gs->offset[j]);
                }
@@ -1485,7 +1497,7 @@ gl_renderer_flush_damage(struct weston_surface *surface)
                                        r.y1 / gs->vsub[j],
                                        (r.x2 - r.x1) / gs->hsub[j],
                                        (r.y2 - r.y1) / gs->vsub[j],
-                                       gs->gl_format[j],
+                                       
gl_format_from_internal(gs->gl_format[j]),
                                        gs->gl_pixel_type,
                                        data + gs->offset[j]);
                }
-- 
2.15.0

_______________________________________________
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to