From 677e78bdced41385bba6598cdfe2476220c737ca Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 23 Oct 2023 07:53:40 -0400 Subject: [PATCH 1/2] gl: Check all swizzle values There is no reason not check the alpha swizzle for being different from its default value. I am thinking about implementing RGBx upload with a swizzle of rgb1, and that would break here. --- gsk/gl/gskglcommandqueue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gsk/gl/gskglcommandqueue.c b/gsk/gl/gskglcommandqueue.c index b1db146785..4b5621623f 100644 --- a/gsk/gl/gskglcommandqueue.c +++ b/gsk/gl/gskglcommandqueue.c @@ -1619,7 +1619,7 @@ gsk_gl_command_queue_do_upload_texture_chunk (GskGLCommandQueue *self, /* Only apply swizzle if really needed, might not even be * supported if default values are set */ - if (gl_swizzle[0] != GL_RED || gl_swizzle[1] != GL_GREEN || gl_swizzle[2] != GL_BLUE) + if (gl_swizzle[0] != GL_RED || gl_swizzle[1] != GL_GREEN || gl_swizzle[2] != GL_BLUE || gl_swizzle[3] != GL_ALPHA) { /* Set each channel independently since GLES 3.0 doesn't support the iv method */ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, gl_swizzle[0]); From 4a749aee6ee6617698572d897b4661680d62916b Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 25 Oct 2023 21:39:52 -0400 Subject: [PATCH 2/2] Fix swizzle values for some memory formats For opaque formats with 3 channels, we should use the default GL_ALPHA, but for opaque formats with an ignored 4th channel, we must use GL_ONE. --- gdk/gdkmemoryformat.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gdk/gdkmemoryformat.c b/gdk/gdkmemoryformat.c index 6fe398acb6..0774e8fca8 100644 --- a/gdk/gdkmemoryformat.c +++ b/gdk/gdkmemoryformat.c @@ -481,7 +481,7 @@ static const GdkMemoryFormatDescription memory_formats[] = { G_ALIGNOF (guchar), GDK_MEMORY_U8, { 0, 0, 0, 0 }, - { GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE, { GL_RED, GL_GREEN, GL_BLUE, GL_ONE } }, + { GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } }, r8g8b8_to_float, r8g8b8_from_float, }, @@ -491,7 +491,7 @@ static const GdkMemoryFormatDescription memory_formats[] = { G_ALIGNOF (guchar), GDK_MEMORY_U8, { 0, 0, G_MAXUINT, G_MAXUINT }, - { GL_RGB8, GL_BGR, GL_UNSIGNED_BYTE, { GL_RED, GL_GREEN, GL_BLUE, GL_ONE } }, + { GL_RGB8, GL_BGR, GL_UNSIGNED_BYTE, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } }, b8g8r8_to_float, b8g8r8_from_float, }, @@ -501,7 +501,7 @@ static const GdkMemoryFormatDescription memory_formats[] = { G_ALIGNOF (guint16), GDK_MEMORY_U16, { 0, 0, 3, 0 }, - { GL_RGB16, GL_RGB, GL_UNSIGNED_SHORT, { GL_RED, GL_GREEN, GL_BLUE, GL_ONE } }, + { GL_RGB16, GL_RGB, GL_UNSIGNED_SHORT, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } }, r16g16b16_to_float, r16g16b16_from_float, }, @@ -531,7 +531,7 @@ static const GdkMemoryFormatDescription memory_formats[] = { G_ALIGNOF (guint16), GDK_MEMORY_FLOAT16, { 0, 0, 3, 0 }, - { GL_RGB16F, GL_RGB, GL_HALF_FLOAT, { GL_RED, GL_GREEN, GL_BLUE, GL_ONE } }, + { GL_RGB16F, GL_RGB, GL_HALF_FLOAT, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } }, r16g16b16_float_to_float, r16g16b16_float_from_float, }, @@ -561,7 +561,7 @@ static const GdkMemoryFormatDescription memory_formats[] = { G_ALIGNOF (float), GDK_MEMORY_FLOAT32, { 0, 0, 3, 0 }, - { GL_RGB32F, GL_RGB, GL_FLOAT, { GL_RED, GL_GREEN, GL_BLUE, GL_ONE } }, + { GL_RGB32F, GL_RGB, GL_FLOAT, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } }, r32g32b32_float_to_float, r32g32b32_float_from_float, },