[Piglit] [PATCH v2 4/4] GL_MESA_pack_invert: make it endian-safe

Oded Gabbay oded.gabbay at gmail.com
Tue Mar 29 09:06:19 UTC 2016


In this test we use GL_BGRA + GL_UNSIGNED_BYTE. However, the test
function constructs the expected colors array as 32-bit values, which is
a wrong way to build expected results values when testing array_of_bytes
(GL_UNSIGNED_BYTE) in an endian-safe way.

This patch fixes this bug by building the expected colors using array of
array_of_bytes.

This fixes the test in llvmpipe, softpipe and r600g in big-endian machine.

Signed-off-by: Oded Gabbay <oded.gabbay at gmail.com>
---
 tests/spec/mesa_pack_invert/readpixels.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/tests/spec/mesa_pack_invert/readpixels.c b/tests/spec/mesa_pack_invert/readpixels.c
index f8fbebe..af508a3 100644
--- a/tests/spec/mesa_pack_invert/readpixels.c
+++ b/tests/spec/mesa_pack_invert/readpixels.c
@@ -47,18 +47,18 @@ PIGLIT_GL_TEST_CONFIG_END
 static bool
 check_unorm(const uint32_t *data, const char *name)
 {
-	static const uint32_t colors[] = {
-		0x000000ff,
-		0xffffffff,
-		0x00ff0000,
-		0x0000ff00
+	static const uint8_t colors[4][4] = {
+		{0xff, 0x00, 0x00, 0x00},
+		{0xff, 0xff, 0xff, 0xff},
+		{0x00, 0x00, 0xff, 0x00},
+		{0x00, 0xff, 0x00, 0x00}
 	};
 	int x, y;
 
 	for (y = 0; y < H; y++) {
 		for (x = 0; x < W; x++) {
 			int i = (y >= H / 2) * 2 + (x >= W / 2);
-			uint32_t expected = colors[i];
+			uint32_t expected = *((uint32_t *) ((uint8_t *) &colors[i][0]));
 
 			if (data[y * W + x] != expected) {
 				fprintf(stderr,
-- 
2.5.5



More information about the Piglit mailing list