The attached patch relaxes the error tolerance for the exactRGBA test.

This test fails with many (all?) GL implementations because the most signficant M bits of values passed to glColor4us() and glColor4ui() don't always match the M bits found in the framebuffer. There's typically a 1-bit max error. For example, the GLushort value 0xba00 will wind up as the framebuffer value 0xb9.

The GL spec is a bit self-contradictory here. It says how GLushort and GLuint colors are converted to floats and it says how float color components are converted to framebuffer values (by rounding to nearest int). But if you follow those rules, it's not possible to achive the "M-bit identity" rule.

The attach patch allows a 1-bit error for the glColor4us() and glColor4ui() functions.

Comments?

-Brian

diff --git a/src/glean/treadpix.cpp b/src/glean/treadpix.cpp
index c983f31..00de5e3 100644
--- a/src/glean/treadpix.cpp
+++ b/src/glean/treadpix.cpp
@@ -493,6 +493,18 @@ readPixSanityTest("readPixSanity", "1",
 // ExactRGBATest
 //     Verifies that unsigned RGBA values written to a framebuffer with
 //     sufficient depth are not altered by the OpenGL implementation.
+//
+//      Note that the GL spec is self-contradictory with regard to
+//      uint->float->uint conversion and the glColor4u[bsi]() functions.
+//      In the 2.1 spec, table 2.9 indicates how to convert integer color
+//      components to floating point.  Then the first paragraph of section
+//      2.14.9 says floating point color components are converted to integers
+//      by rounding to a fixed point value with at least m bits.  These two
+//      statements make the second paragraph of 2.14.9 (the top m bits of
+//      glColorub/us/ui() are preserved) impossible to achieve.
+//
+//      Below, we allow no error for the glColor4ub() case but we allow
+//      a 1-bit error for the glColor4u[si]() cases.
 
////////////////////////////////////////////////////////////////////////////////
 
 namespace {
@@ -612,8 +624,16 @@ check(GLEAN::ExactRGBAResult::Flavor& r, 
GLEAN::DrawingSurfaceConfig& config,
                        q += 4;
                }
 
-       // We only pass if the maximum error was zero.
-       r.pass = (r.err == 0);
+       if (type == GL_UNSIGNED_BYTE) {
+               // We only pass if the maximum error was zero.
+               r.pass = (r.err == 0);
+       } else {
+               // a 1 bit error is acceptable
+               int maxBits = max(max(config.r, config.g),
+                                 max(config.b, config.a));
+               int shift = hostBits - maxBits;
+               r.pass = ((r.err >> shift) <= 1);
+       }
 
        delete[] expected;
        delete[] actual;
------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Mesa3d-dev mailing list
Mesa3d-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

Reply via email to