Shaders Derivate Tests: fix threshold
authorJuan A. Suarez Romero <jasuarez@igalia.com>
Mon, 25 Jun 2018 15:22:48 +0000 (17:22 +0200)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Thu, 12 Jul 2018 07:17:06 +0000 (03:17 -0400)
Derivate tests are calculating the threshold used for validating results
by taking in account a scale. Apparently this is incorrect, and is
causing some tests to fail.

A similar situation happened in Vulkan, and the proper fix was to do not
take in account the scale for the threshold calculation. Hence, applying
the same fix here fixes all the failing tests.

Affects:
dEQP-GLES3.functional.shaders.derivate.*
dEQP-GLES31.functional.shaders.derivate.*

Components: OpenGL

VK-GL-CTS issue: 1237

Change-Id: I106e36a708a6f75768c15ccdb4b064eb562cb28f

modules/gles3/functional/es3fShaderDerivateTests.cpp

index 70e61b4..0ff064c 100644 (file)
@@ -1060,11 +1060,14 @@ bool LinearDerivateCase::verify (const tcu::ConstPixelBufferAccess& result, cons
                const bool                      isX                     = m_func == DERIVATE_DFDX;
                const float                     div                     = isX ? float(result.getWidth()) : float(result.getHeight());
                const tcu::Vec4         scale           = isX ? xScale : yScale;
-               const tcu::Vec4         reference       = ((m_coordMax - m_coordMin) / div) * scale;
-               const tcu::Vec4         opThreshold     = getDerivateThreshold(m_precision, m_coordMin*scale, m_coordMax*scale, reference);
+               tcu::Vec4                       reference       = ((m_coordMax - m_coordMin) / div);
+               const tcu::Vec4         opThreshold     = getDerivateThreshold(m_precision, m_coordMin, m_coordMax, reference);
                const tcu::Vec4         threshold       = max(surfaceThreshold, opThreshold);
                const int                       numComps        = glu::getDataTypeFloatScalars(m_dataType);
 
+               /* adjust the reference value for the correct dfdx or dfdy sample adjacency */
+               reference       = reference * scale;
+
                m_testCtx.getLog()
                        << tcu::TestLog::Message
                        << "Verifying result image.\n"
@@ -1355,11 +1358,14 @@ bool TextureDerivateCase::verify (const tcu::ConstPixelBufferAccess& result, con
                const bool                      isX                     = m_func == DERIVATE_DFDX;
                const float                     div                     = isX ? w : h;
                const tcu::Vec4         scale           = isX ? xScale : yScale;
-               const tcu::Vec4         reference       = ((m_texValueMax - m_texValueMin) / div) * scale;
-               const tcu::Vec4         opThreshold     = getDerivateThreshold(m_precision, m_texValueMin*scale, m_texValueMax*scale, reference);
+               tcu::Vec4                       reference       = ((m_texValueMax - m_texValueMin) / div);
+               const tcu::Vec4         opThreshold     = getDerivateThreshold(m_precision, m_texValueMin, m_texValueMax, reference);
                const tcu::Vec4         threshold       = max(surfaceThreshold, opThreshold);
                const int                       numComps        = glu::getDataTypeFloatScalars(m_dataType);
 
+               /* adjust the reference value for the correct dfdx or dfdy sample adjacency */
+               reference       = reference * scale;
+
                m_testCtx.getLog()
                        << tcu::TestLog::Message
                        << "Verifying result image.\n"