renderer-gl: Save all the SHM buffers

Save all SHM buffers properly so that they can be restored during
GPU recovery

Signed-off-by: Trigger Huang <Trigger.Huang@amd.com>
This commit is contained in:
Trigger Huang 2026-04-24 13:51:11 +08:00
parent 3b18e3a69c
commit 49732c40c1
2 changed files with 10 additions and 0 deletions

View file

@ -542,6 +542,7 @@ struct gl_renderer {
bool blend_state;
bool recovering;
struct wl_list shm_bufs;
struct wl_list dmabuf_images;
struct wl_list dmabuf_formats;
struct wl_list pending_capture_list;

View file

@ -302,6 +302,8 @@ struct gl_buffer_state {
int num_textures;
struct wl_listener destroy_listener;
struct wl_list link; /* link to shm_bufs of gl renderer */
};
struct gl_surface_state {
@ -3468,6 +3470,7 @@ destroy_buffer_state(struct gl_buffer_state *gb)
pixman_region32_fini(&gb->texture_damage);
wl_list_remove(&gb->destroy_listener.link);
wl_list_remove(&gb->link);
free(gb);
}
@ -3613,6 +3616,7 @@ gl_renderer_attach_shm(struct weston_surface *es, struct weston_buffer *buffer)
gb->gr = gr;
wl_list_init(&gb->destroy_listener.link);
wl_list_init(&gb->link);
pixman_region32_init(&gb->texture_damage);
gb->pitch = pitch;
@ -3636,6 +3640,8 @@ gl_renderer_attach_shm(struct weston_surface *es, struct weston_buffer *buffer)
texture_format[i].swizzles.array,
false);
}
wl_list_insert(&gr->shm_bufs, &gb->link);
}
static bool
@ -3661,6 +3667,7 @@ gl_renderer_fill_buffer_info(struct weston_compositor *ec,
gb->gr = gr;
pixman_region32_init(&gb->texture_damage);
wl_list_init(&gb->link);
buffer->legacy_buffer = (struct wl_buffer *)buffer->resource;
ret &= gr->query_buffer(gr->egl_display, buffer->legacy_buffer,
@ -4122,6 +4129,7 @@ import_dmabuf(struct gl_renderer *gr,
gb->gr = gr;
pixman_region32_init(&gb->texture_damage);
wl_list_init(&gb->destroy_listener.link);
wl_list_init(&gb->link);
quirks = &gr->compositor->test_data.test_quirks;
if (quirks->gl_force_import_yuv_fallback &&
@ -5434,6 +5442,7 @@ gl_renderer_display_create(struct weston_compositor *ec,
ec->renderer = &gr->base;
wl_signal_init(&gr->destroy_signal);
wl_list_init(&gr->shm_bufs);
if (gl_renderer_init_context(ec, options) < 0)
goto fail_context;