Allow glReadPixels() differences due precision errors
authorJuan A. Suarez Romero <jasuarez@igalia.com>
Tue, 19 Jun 2018 07:23:13 +0000 (07:23 +0000)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Thu, 12 Jul 2018 07:15:22 +0000 (03:15 -0400)
When comparing the results from glReadPixels() passing user-space memory
and using a PBO, there could be differences due drivers implementation
following different paths, and thus generating differences because of
precision errors.

Like in dEQP-GLES3.functional.read_pixels.* tests, add a threshold under
which the differences are acceptable.

Affects:
dEQP-GLES3.functional.pbo.*

Components: OpenGL

VK-GL-CTS issue: 1228

Change-Id: I7c9ac5de359cff8deba039b010357eae0da3eaaf

modules/gles3/functional/es3fPixelBufferObjectTests.cpp

index c98d4ab..9a34aad 100644 (file)
@@ -565,9 +565,19 @@ TestCase::IterateResult ReadPixelsTest::iterate(void)
        bool isOk = false;
 
        if (floatCompare)
-               isOk = tcu::floatThresholdCompare(m_log, "Result comparision", "Result of read pixels to memory compared with result of read pixels to buffer", readRefrence.getLevel(0), readResult, tcu::Vec4(0.0f, 0.0f, 0.0f, 0.0f), tcu::COMPARE_LOG_RESULT);
+       {
+               const tcu::IVec4        formatBitDepths = tcu::getTextureFormatBitDepth(readFormat);
+               const float                     redThreshold    = 2.0f / (float)(1 << deMin32(m_context.getRenderTarget().getPixelFormat().redBits,             formatBitDepths.x()));
+               const float                     greenThreshold  = 2.0f / (float)(1 << deMin32(m_context.getRenderTarget().getPixelFormat().greenBits,   formatBitDepths.y()));
+               const float                     blueThreshold   = 2.0f / (float)(1 << deMin32(m_context.getRenderTarget().getPixelFormat().blueBits,    formatBitDepths.z()));
+               const float                     alphaThreshold  = 2.0f / (float)(1 << deMin32(m_context.getRenderTarget().getPixelFormat().alphaBits,   formatBitDepths.w()));
+
+               isOk = tcu::floatThresholdCompare(m_log, "Result comparision", "Result of read pixels to memory compared with result of read pixels to buffer", readRefrence.getLevel(0), readResult, tcu::Vec4(redThreshold, greenThreshold, blueThreshold, alphaThreshold), tcu::COMPARE_LOG_RESULT);
+       }
        else
+       {
                isOk = tcu::intThresholdCompare(m_log, "Result comparision", "Result of read pixels to memory compared with result of read pixels to buffer", readRefrence.getLevel(0), readResult, tcu::UVec4(0, 0, 0, 0), tcu::COMPARE_LOG_RESULT);
+       }
 
        GLU_CHECK_CALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, pixelBuffer));
        GLU_CHECK_CALL(glUnmapBuffer(GL_PIXEL_PACK_BUFFER));