Increase tolearance for dithering tests
authorsriharsha <quic_spvasu@quicinc.com>
Wed, 29 May 2019 05:02:22 +0000 (10:32 +0530)
committerMatthew Netsch <quic_mnetsch@quicinc.com>
Fri, 15 Oct 2021 18:59:24 +0000 (18:59 +0000)
For small dimension render targets, gradient tests
require more tolerance, as variance in adjacent pixels
will be more compared to bigger render targets.

Cherry pick from AOSP.

Original commit:
https://android.googlesource.com/platform/external/deqp/+/8dc015fa12e41a380b81c1b8fcc63a04bf34311a
https://android-review.googlesource.com/c/platform/external/deqp/+/971506
Submitted on behalf of a third-party: quic_spvasu@quicinc.com

Components: OpenGL

Affected tests:
dEQP-GLES3.functional.dither.*

Bug: 132146940
Change-Id: Ie48e119d164acf5763aa7956c3ff91da20ff9f38

modules/gles3/functional/es3fDitheringTests.cpp

index 5e52d9e4e62ed162af9e5074035fcee40330823a..a677f221afcc6309d87d2646ed30f68c5450dccb 100644 (file)
@@ -105,7 +105,7 @@ public:
        static const char*                                              getPatternTypeName                      (PatternType type);
 
 private:
-       bool                                                                    checkColor                                      (const tcu::Vec4& inputClr, const tcu::RGBA& renderedClr, bool logErrors) const;
+       bool                                                                    checkColor                                      (const tcu::Vec4& inputClr, const tcu::RGBA& renderedClr, bool logErrors, const bool incTol) const;
 
        bool                                                                    drawAndCheckGradient            (bool isVerticallyIncreasing, const tcu::Vec4& highColor) const;
        bool                                                                    drawAndCheckUnicoloredQuad      (const tcu::Vec4& color) const;
@@ -165,7 +165,7 @@ void DitheringCase::deinit (void)
        m_renderer = DE_NULL;
 }
 
-bool DitheringCase::checkColor (const Vec4& inputClr, const tcu::RGBA& renderedClr, const bool logErrors) const
+bool DitheringCase::checkColor (const Vec4& inputClr, const tcu::RGBA& renderedClr, const bool logErrors, const bool incTol) const
 {
        const IVec4             channelBits             = pixelFormatToIVec4(m_renderFormat);
        bool                    allChannelsOk   = true;
@@ -182,6 +182,12 @@ bool DitheringCase::checkColor (const Vec4& inputClr, const tcu::RGBA& renderedC
 
                channelChoices.push_back(de::min(channelMax,    (int)deFloatCeil(scaledInput)));
                channelChoices.push_back(de::max(0,                             (int)deFloatCeil(scaledInput) - 1));
+               // Allow for more tolerance for small dimension render targets
+               if (incTol)
+               {
+                       channelChoices.push_back(de::max(0,(int)deFloatCeil(scaledInput) - 2));
+                       channelChoices.push_back(de::max(0,(int)deFloatCeil(scaledInput) + 1));
+               }
 
                // If the input color results in a scaled value that is very close to an integer, account for a little bit of possible inaccuracy.
                if (useRoundingMargin)
@@ -288,8 +294,9 @@ bool DitheringCase::drawAndCheckGradient (const bool isVerticallyIncreasing, con
                        {
                                const float             inputF          = ((float)(isVerticallyIncreasing ? y : x) + 0.5f) / (float)(isVerticallyIncreasing ? renderedImg.getHeight() : renderedImg.getWidth());
                                const Vec4              inputClr        = (1.0f-inputF)*quadClr0 + inputF*quadClr1;
+                               const bool              increaseTol     = ((renderedImg.getWidth() < 300) || (renderedImg.getHeight() < 300)) ? true : false;
 
-                               if (!checkColor(inputClr, renderedImg.getPixel(x, y), colorChoicesOk))
+                               if (!checkColor(inputClr, renderedImg.getPixel(x, y), colorChoicesOk, increaseTol))
                                {
                                        errorMask.setPixel(x, y, tcu::RGBA::red());
 
@@ -399,7 +406,7 @@ bool DitheringCase::drawAndCheckUnicoloredQuad (const Vec4& quadColor) const
                {
                        for (int x = 0; x < renderedImg.getWidth(); x++)
                        {
-                               if (!checkColor(quadColor, renderedImg.getPixel(x, y), colorChoicesOk))
+                               if (!checkColor(quadColor, renderedImg.getPixel(x, y), colorChoicesOk, false))
                                {
                                        errorMask.setPixel(x, y, tcu::RGBA::red());