<div dir="ltr">Neil,<div>The patch doesn't look like it breaks anything, but I'm not convinced it's 100% correct.  We may still have a problem if the client changes buffer formats mid-stream.  Say it starts out with RGB565 to save memory but latter decides it wants alpha so it switches to ARGB8888.  We should probably detect this and make sure glTexImage2D gets called again to reset the internal format.</div>
<div>--Jason Ekstrand</div><div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Apr 4, 2014 at 10:24 AM, Neil Roberts <span dir="ltr"><<a href="mailto:neil@linux.intel.com" target="_blank">neil@linux.intel.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Previously when uploading SHM data we would initialise the texture<br>
with glTexImage2D and NULL data when the buffer is attached. Then if<br>
the GL_EXT_unpack_subimage extension is available we would always use<br>
glTexSubImage2D to upload the data. The problem with that is that the<br>
first glTexImage2D was always setting the internal format to<br>
GL_BGRA_EXT and then if a 16-bit texture is used we would later call<br>
glTexSubImage2D with a data format of GL_RGBA. Under GLES2 the<br>
internal format must always match the data format so this is<br>
technically invalid.<br>
<br>
This patch makes it so that it always calls glTexImage2D when flushing<br>
the damage for the first time. That way it will use the right internal<br>
format and we don't need to call glTexImage2D with NULL data.<br>
<br>
<a href="https://bugs.freedesktop.org/show_bug.cgi?id=75251" target="_blank">https://bugs.freedesktop.org/show_bug.cgi?id=75251</a><br>
---<br>
 src/gl-renderer.c | 10 +++-------<br>
 1 file changed, 3 insertions(+), 7 deletions(-)<br>
<br>
diff --git a/src/gl-renderer.c b/src/gl-renderer.c<br>
index 6ef1240..1cebc79 100644<br>
--- a/src/gl-renderer.c<br>
+++ b/src/gl-renderer.c<br>
@@ -1069,9 +1069,9 @@ gl_renderer_flush_damage(struct weston_surface *surface)<br>
                glPixelStorei(GL_UNPACK_SKIP_PIXELS_EXT, 0);<br>
                glPixelStorei(GL_UNPACK_SKIP_ROWS_EXT, 0);<br>
                wl_shm_buffer_begin_access(buffer->shm_buffer);<br>
-               glTexSubImage2D(GL_TEXTURE_2D, 0,<br>
-                               0, 0, gs->pitch, buffer->height,<br>
-                               format, pixel_type, data);<br>
+               glTexImage2D(GL_TEXTURE_2D, 0, format,<br>
+                            gs->pitch, buffer->height, 0,<br>
+                            format, pixel_type, data);<br>
                wl_shm_buffer_end_access(buffer->shm_buffer);<br>
                goto done;<br>
        }<br>
@@ -1168,10 +1168,6 @@ gl_renderer_attach_shm(struct weston_surface *es, struct weston_buffer *buffer,<br>
                gs->surface = es;<br>
<br>
                ensure_textures(gs, 1);<br>
-               glBindTexture(GL_TEXTURE_2D, gs->textures[0]);<br>
-               glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT,<br>
-                            gs->pitch, buffer->height, 0,<br>
-                            GL_BGRA_EXT, GL_UNSIGNED_BYTE, NULL);<br>
        }<br>
 }<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
1.8.5.3<br>
<br>
_______________________________________________<br>
wayland-devel mailing list<br>
<a href="mailto:wayland-devel@lists.freedesktop.org">wayland-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/wayland-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/wayland-devel</a><br>
</font></span></blockquote></div><br></div></div></div>