From 623646bbfda7f96aba6af33b1cb4e8d78d3dc48d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Yhuel?= Date: Fri, 8 Sep 2023 19:39:49 +0200 Subject: [PATCH] gl-renderer: Do not attach the first buffer twice MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When gl_renderer_attach is called, surface->buffer_ref.buffer points to the buffer. So if the surface state needs to be created, we have : gl_renderer_attach -> get_surface_state -> gl_renderer_create_surface -> gl_renderer_attach Fixes: 895b1fdcb2 ("gl-renderer: Attach buffer during surface state creation if possible") Signed-off-by: Loïc Yhuel --- libweston/renderer-gl/gl-renderer.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libweston/renderer-gl/gl-renderer.c b/libweston/renderer-gl/gl-renderer.c index a36478028..279da1835 100644 --- a/libweston/renderer-gl/gl-renderer.c +++ b/libweston/renderer-gl/gl-renderer.c @@ -3211,6 +3211,11 @@ gl_renderer_attach(struct weston_surface *es, struct weston_buffer *buffer) struct gl_surface_state *gs = get_surface_state(es); bool ret = false; + /* If get_surface_state called gl_renderer_create_surface, it did + * attach the buffer */ + if (gs->buffer_ref.buffer == buffer) + return; + /* SHM buffers are a little special in that they are allocated * per-surface rather than per-buffer, because we keep a shadow * copy of the SHM data in a GL texture; for these we need to