From 8fcd9bc0c4ccaf6540e5531c9f75c4e443c57d31 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 23 Oct 2023 21:21:03 +0200 Subject: [PATCH] gl: Make sure render_texture() sets the right format for high depth Setting the format got lost when converting this coe to the texture builder, because that codepaths avods the texture sniffing and always uses RGBA8. --- gsk/gl/gskgldriver.c | 6 ++++-- gsk/gl/gskgldriverprivate.h | 3 ++- gsk/gl/gskglrenderer.c | 13 ++++++++++--- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/gsk/gl/gskgldriver.c b/gsk/gl/gskgldriver.c index d00becdf5c..0cd14981b4 100644 --- a/gsk/gl/gskgldriver.c +++ b/gsk/gl/gskgldriver.c @@ -1799,8 +1799,9 @@ create_texture_from_texture_destroy (gpointer data) } GdkTexture * -gsk_gl_driver_create_gdk_texture (GskGLDriver *self, - guint texture_id) +gsk_gl_driver_create_gdk_texture (GskGLDriver *self, + guint texture_id, + GdkMemoryFormat format) { GskGLTextureState *state; GdkGLTextureBuilder *builder; @@ -1828,6 +1829,7 @@ gsk_gl_driver_create_gdk_texture (GskGLDriver *self, builder = gdk_gl_texture_builder_new (); gdk_gl_texture_builder_set_context (builder, self->command_queue->context); gdk_gl_texture_builder_set_id (builder, texture_id); + gdk_gl_texture_builder_set_format (builder, format); gdk_gl_texture_builder_set_width (builder, texture->width); gdk_gl_texture_builder_set_height (builder, texture->height); gdk_gl_texture_builder_set_sync (builder, state->sync); diff --git a/gsk/gl/gskgldriverprivate.h b/gsk/gl/gskgldriverprivate.h index c421bed98a..21d21a2b48 100644 --- a/gsk/gl/gskgldriverprivate.h +++ b/gsk/gl/gskgldriverprivate.h @@ -154,7 +154,8 @@ void gsk_gl_driver_begin_frame (GskGLDriver *s void gsk_gl_driver_end_frame (GskGLDriver *self); void gsk_gl_driver_after_frame (GskGLDriver *self); GdkTexture * gsk_gl_driver_create_gdk_texture (GskGLDriver *self, - guint texture_id); + guint texture_id, + GdkMemoryFormat format); void gsk_gl_driver_cache_texture (GskGLDriver *self, const GskTextureKey *key, guint texture_id); diff --git a/gsk/gl/gskglrenderer.c b/gsk/gl/gskglrenderer.c index d61a42258c..cf551eaedc 100644 --- a/gsk/gl/gskglrenderer.c +++ b/gsk/gl/gskglrenderer.c @@ -332,6 +332,7 @@ gsk_gl_renderer_render_texture (GskRenderer *renderer, GskGLRenderJob *job; GdkTexture *texture; guint texture_id; + GdkMemoryFormat gdk_format; int width, height, max_size; int format; @@ -375,9 +376,15 @@ gsk_gl_renderer_render_texture (GskRenderer *renderer, if (gsk_render_node_get_preferred_depth (root) != GDK_MEMORY_U8 && gdk_gl_context_check_version (self->context, "3.0", "3.0")) - format = GL_RGBA32F; + { + gdk_format = GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED; + format = GL_RGBA32F; + } else - format = GL_RGBA8; + { + format = GL_RGBA8; + gdk_format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED; + } gdk_gl_context_make_current (self->context); @@ -394,7 +401,7 @@ gsk_gl_renderer_render_texture (GskRenderer *renderer, #endif gsk_gl_render_job_render_flipped (job, root); texture_id = gsk_gl_driver_release_render_target (self->driver, render_target, FALSE); - texture = gsk_gl_driver_create_gdk_texture (self->driver, texture_id); + texture = gsk_gl_driver_create_gdk_texture (self->driver, texture_id, gdk_format); gsk_gl_driver_end_frame (self->driver); gsk_gl_render_job_free (job);