From 49ee69f316896975c6bf32f32df2ee2b5bc3d8aa Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sun, 1 Sep 2024 22:45:50 +0200 Subject: [PATCH] gpu: Use right GL context when exporting texture We want to use the display's context on the resulting texture, but we do not want to use it for the stufff we need to do while exporting - most importantly the GLsync. Fixes #6976 --- gsk/gpu/gskgpudownloadop.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gsk/gpu/gskgpudownloadop.c b/gsk/gpu/gskgpudownloadop.c index 967fc97a98..435904020f 100644 --- a/gsk/gpu/gskgpudownloadop.c +++ b/gsk/gpu/gskgpudownloadop.c @@ -296,9 +296,7 @@ gsk_gpu_download_op_gl_command (GskGpuOp *op, GdkGLContext *context; guint texture_id; - /* Don't use the renderer context, the texture might survive the frame - * and its surface */ - context = gdk_display_get_gl_context (gsk_gpu_device_get_display (gsk_gpu_frame_get_device (frame))); + context = GDK_GL_CONTEXT (gsk_gpu_frame_get_context (frame)); texture_id = gsk_gl_image_get_texture_id (GSK_GL_IMAGE (self->image)); #ifdef HAVE_DMABUF @@ -334,14 +332,16 @@ gsk_gpu_download_op_gl_command (GskGpuOp *op, #endif data = g_new (GskGLTextureData, 1); - data->context = g_object_ref (context); + /* Don't use the renderer context for the texture, + * the texture might survive the frame and its surface */ + data->context = g_object_ref (gdk_display_get_gl_context (gsk_gpu_device_get_display (gsk_gpu_frame_get_device (frame)))); data->texture_id = texture_id; if (gdk_gl_context_has_feature (context, GDK_GL_FEATURE_SYNC)) data->sync = glFenceSync (GL_SYNC_GPU_COMMANDS_COMPLETE, 0); builder = gdk_gl_texture_builder_new (); - gdk_gl_texture_builder_set_context (builder, context); + gdk_gl_texture_builder_set_context (builder, data->context); gdk_gl_texture_builder_set_id (builder, data->texture_id); gdk_gl_texture_builder_set_format (builder, gsk_gpu_image_get_format (self->image)); gdk_gl_texture_builder_set_width (builder, gsk_gpu_image_get_width (self->image));