mutter/patches/workarounds/cogl-tests-Avoid-converting-16bpc-float-16bpc.patch
Ward from fusion-voyager-3 a1d3a8b37d
Some checks failed
PikaOS Package Build & Release (Canary) (amd64-v3) / build (push) Has been cancelled
PikaOS Package Build Only (Canary) (amd64-v3) / build (push) Failing after 17s
PikaOS Package Build Only (amd64-v3) / build (push) Failing after 13s
PikaOS Package Build & Release (amd64-v3) / build (push) Failing after 13s
attempt to fix xwayland frac scale
2024-08-13 11:22:25 -04:00

74 lines
3.0 KiB
Diff

From: Daniel van Vugt <daniel.van.vugt@canonical.com>
Date: Thu, 25 Jul 2024 18:17:13 +0800
Subject: cogl/tests: Avoid converting 16bpc -> float -> 16bpc
Instead just assign 16bpc -> 16bpc
This avoids variations in CPU and GL driver behaviour when using
floats as intermediate values.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3582
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3903>
(cherry picked from commit 5360c58fe50080f4532efee46149c016acf558b2)
---
.../cogl/conform/test-offscreen-texture-formats.c | 33 +++++++++++-----------
1 file changed, 17 insertions(+), 16 deletions(-)
diff --git a/src/tests/cogl/conform/test-offscreen-texture-formats.c b/src/tests/cogl/conform/test-offscreen-texture-formats.c
index 8706ec3..170f447 100644
--- a/src/tests/cogl/conform/test-offscreen-texture-formats.c
+++ b/src/tests/cogl/conform/test-offscreen-texture-formats.c
@@ -61,35 +61,36 @@ test_offscreen_texture_formats_store_rgba16161616 (void)
const uint16_t rgba16_green = 61133;
const uint16_t rgba16_blue = 2;
const uint16_t rgba16_alpha = 1111;
- float red;
- float green;
- float blue;
- float alpha;
int i;
-
- red = (rgba16_red / (float) ((1 << 16) - 1));
- green = (rgba16_green / (float) ((1 << 16) - 1));
- blue = (rgba16_blue / (float) ((1 << 16) - 1));
- alpha = (rgba16_alpha / (float) ((1 << 16) - 1));
+ uint16_t tex_data[16];
g_assert_cmpint (rgb8_to_rgb16 (rgb16_to_rgb8 (rgba16_red)), !=, rgba16_red);
g_assert_cmpint (rgb8_to_rgb16 (rgb16_to_rgb8 (rgba16_green)), !=, rgba16_green);
g_assert_cmpint (rgb8_to_rgb16 (rgb16_to_rgb8 (rgba16_blue)), !=, rgba16_blue);
g_assert_cmpint (rgb8_to_rgb16 (rgb16_to_rgb8 (rgba16_alpha)), !=, rgba16_alpha);
+ for (i = 0; i < 4; i++)
+ {
+ uint16_t *pixel_data = (uint16_t *) &tex_data [i * 4];
+
+ pixel_data[0] = rgba16_red;
+ pixel_data[1] = rgba16_green;
+ pixel_data[2] = rgba16_blue;
+ pixel_data[3] = rgba16_alpha;
+ }
+
/* Allocate 2x2 to ensure we avoid any fast paths. */
- tex = cogl_texture_2d_new_with_format (test_ctx,
- 2, 2,
- COGL_PIXEL_FORMAT_RGBA_16161616_PRE);
+ tex = cogl_texture_2d_new_from_data (test_ctx,
+ 2, 2,
+ COGL_PIXEL_FORMAT_RGBA_16161616_PRE,
+ 16,
+ (const uint8_t *) tex_data,
+ NULL);
offscreen = cogl_offscreen_new_with_texture (tex);
cogl_framebuffer_allocate (COGL_FRAMEBUFFER (offscreen), &error);
g_assert_no_error (error);
- cogl_framebuffer_clear4f (COGL_FRAMEBUFFER (offscreen),
- COGL_BUFFER_BIT_COLOR,
- red, green, blue, alpha);
-
cogl_framebuffer_read_pixels (COGL_FRAMEBUFFER (offscreen), 0, 0, 2, 2,
COGL_PIXEL_FORMAT_RG_1616,
(uint8_t *) &readback);