Fix assertion failure in dfdx and dfdy lost bit calculations.
authorJarkko Pöyry <jpoyry@google.com>
Thu, 12 Mar 2015 20:17:38 +0000 (13:17 -0700)
committerJarkko Pöyry <jpoyry@google.com>
Thu, 12 Mar 2015 21:17:55 +0000 (14:17 -0700)
- Fix lost-bits calculation returning negative values when operand
  component range intercepted zero (i.e. operands had different signs).
  This caused verification to expect more significant bits than the
  native (lowp/mediump/highp) float format could store. With highp
  values, error calculation tried to create a error compontent of a
  floating point value with 24 mantissa bits which cannot be stored
  to a native float32.
- Use better terminology, s/nominator/numerator/.

Bug: 19694789
Change-Id: Ifa88fb1c8cb333bab22a550d01f5e310d2d2673d

modules/gles3/functional/es3fShaderDerivateTests.cpp

index a5144f5..150444f 100644 (file)
@@ -497,21 +497,21 @@ static bool reverifyConstantDerivateWithFlushRelaxations (tcu::TestLog&                                                   lo
                        const int                       maxValueExp                             = de::max(de::max(tcu::Float32(forwardComponent.lo()).exponent(),   tcu::Float32(forwardComponent.hi()).exponent()),
                                                                                                                                  de::max(tcu::Float32(backwardComponent.lo()).exponent(),  tcu::Float32(backwardComponent.hi()).exponent()));
 
-                       // subtraction in nominator will likely cause a cancellation of the most
+                       // subtraction in numerator will likely cause a cancellation of the most
                        // significant bits. Apply error bounds.
 
-                       const tcu::Interval     nominator                               (forwardComponent - backwardComponent);
-                       const int                       nominatorLoExp                  = tcu::Float32(nominator.lo()).exponent();
-                       const int                       nominatorHiExp                  = tcu::Float32(nominator.hi()).exponent();
-                       const int                       nominatorLoBitsLost             = maxValueExp - nominatorLoExp;
-                       const int                       nominatorHiBitsLost             = maxValueExp - nominatorHiExp;
-                       const int                       nominatorLoBits                 = de::max(0, numBits - nominatorLoBitsLost);
-                       const int                       nominatorHiBits                 = de::max(0, numBits - nominatorHiBitsLost);
+                       const tcu::Interval     numerator                               (forwardComponent - backwardComponent);
+                       const int                       numeratorLoExp                  = tcu::Float32(numerator.lo()).exponent();
+                       const int                       numeratorHiExp                  = tcu::Float32(numerator.hi()).exponent();
+                       const int                       numeratorLoBitsLost             = de::max(0, maxValueExp - numeratorLoExp); //!< must clamp to zero since if forward and backward components have different
+                       const int                       numeratorHiBitsLost             = de::max(0, maxValueExp - numeratorHiExp); //!< sign, numerator might have larger exponent than its operands.
+                       const int                       numeratorLoBits                 = de::max(0, numBits - numeratorLoBitsLost);
+                       const int                       numeratorHiBits                 = de::max(0, numBits - numeratorHiBitsLost);
 
-                       const tcu::Interval     nominatorRange                  (convertFloorFlushToZero((float)nominator.lo(), minExponent, nominatorLoBits),
-                                                                                                                convertCeilFlushToZero((float)nominator.hi(), minExponent, nominatorHiBits));
+                       const tcu::Interval     numeratorRange                  (convertFloorFlushToZero((float)numerator.lo(), minExponent, numeratorLoBits),
+                                                                                                                convertCeilFlushToZero((float)numerator.hi(), minExponent, numeratorHiBits));
 
-                       const tcu::Interval     divisionRange                   = nominatorRange / 3.0f; // legal sample area is anywhere within this and neighboring pixels (i.e. size = 3)
+                       const tcu::Interval     divisionRange                   = numeratorRange / 3.0f; // legal sample area is anywhere within this and neighboring pixels (i.e. size = 3)
                        const tcu::Interval     divisionResultRange             (convertFloorFlushToZero(addErrorUlp((float)divisionRange.lo(), -divisionErrorUlps, numBits), minExponent, numBits),
                                                                                                                 convertCeilFlushToZero(addErrorUlp((float)divisionRange.hi(), +divisionErrorUlps, numBits), minExponent, numBits));
                        const tcu::Interval     finalResultRange                (divisionResultRange.lo() - surfaceThreshold[c], divisionResultRange.hi() + surfaceThreshold[c]);