[PATCH weston] Always use glTexImage2D instead of glTexSubImage2D for first upload
Jason Ekstrand
jason at jlekstrand.net
Fri Apr 4 10:18:56 PDT 2014
Neil,
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.
--Jason Ekstrand
On Fri, Apr 4, 2014 at 10:24 AM, Neil Roberts <neil at linux.intel.com> wrote:
> Previously when uploading SHM data we would initialise the texture
> with glTexImage2D and NULL data when the buffer is attached. Then if
> the GL_EXT_unpack_subimage extension is available we would always use
> glTexSubImage2D to upload the data. The problem with that is that the
> first glTexImage2D was always setting the internal format to
> GL_BGRA_EXT and then if a 16-bit texture is used we would later call
> glTexSubImage2D with a data format of GL_RGBA. Under GLES2 the
> internal format must always match the data format so this is
> technically invalid.
>
> This patch makes it so that it always calls glTexImage2D when flushing
> the damage for the first time. That way it will use the right internal
> format and we don't need to call glTexImage2D with NULL data.
>
> https://bugs.freedesktop.org/show_bug.cgi?id=75251
> ---
> src/gl-renderer.c | 10 +++-------
> 1 file changed, 3 insertions(+), 7 deletions(-)
>
> diff --git a/src/gl-renderer.c b/src/gl-renderer.c
> index 6ef1240..1cebc79 100644
> --- a/src/gl-renderer.c
> +++ b/src/gl-renderer.c
> @@ -1069,9 +1069,9 @@ gl_renderer_flush_damage(struct weston_surface
> *surface)
> glPixelStorei(GL_UNPACK_SKIP_PIXELS_EXT, 0);
> glPixelStorei(GL_UNPACK_SKIP_ROWS_EXT, 0);
> wl_shm_buffer_begin_access(buffer->shm_buffer);
> - glTexSubImage2D(GL_TEXTURE_2D, 0,
> - 0, 0, gs->pitch, buffer->height,
> - format, pixel_type, data);
> + glTexImage2D(GL_TEXTURE_2D, 0, format,
> + gs->pitch, buffer->height, 0,
> + format, pixel_type, data);
> wl_shm_buffer_end_access(buffer->shm_buffer);
> goto done;
> }
> @@ -1168,10 +1168,6 @@ gl_renderer_attach_shm(struct weston_surface *es,
> struct weston_buffer *buffer,
> gs->surface = es;
>
> ensure_textures(gs, 1);
> - glBindTexture(GL_TEXTURE_2D, gs->textures[0]);
> - glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT,
> - gs->pitch, buffer->height, 0,
> - GL_BGRA_EXT, GL_UNSIGNED_BYTE, NULL);
> }
> }
>
> --
> 1.8.5.3
>
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/wayland-devel/attachments/20140404/3fed6612/attachment.html>
More information about the wayland-devel
mailing list