gallium/osmesa: Try to fix the test for big-endian.
[mesa.git] / src / gallium / targets / osmesa / test-render.cpp
index 55d449c2132de1cdaf27342b9b67f6d42e0b110c..2e5ff962d8ec4d428a709799e774a3db4bc9d64e 100644 (file)
@@ -8,6 +8,8 @@
 
 #include "GL/osmesa.h"
 #include "util/macros.h"
+#include "util/u_endian.h"
+#include "util/u_math.h"
 
 typedef struct {
    unsigned format;
@@ -75,6 +77,25 @@ TEST_P(OSMesaRenderTestFixture, Render)
 
    uint64_t expected = p.expected;
 
+   /* All the formats other than 565 and RGB/byte are array formats, but our
+    * expected values are packed, so byte swap appropriately.
+    */
+   if (UTIL_ARCH_BIG_ENDIAN) {
+      switch (p.bpp) {
+      case 8:
+         expected = util_bswap64(expected);
+         break;
+
+      case 4:
+         expected = util_bswap32(expected);
+         break;
+
+      case 3:
+      case 2:
+         break;
+      }
+   }
+
    glClear(GL_COLOR_BUFFER_BIT);
    glFinish();