DO NOT MERGE: Fix undefined arg eval order issue in fuzzy compare
authorPyry Haulos <phaulos@google.com>
Tue, 14 Jul 2015 00:06:06 +0000 (17:06 -0700)
committerPyry Haulos <phaulos@google.com>
Tue, 14 Jul 2015 00:06:06 +0000 (17:06 -0700)
compareToNeighbor can give slightly different metrics based on internal
state of rnd parameter, and thus it is not safe to call that from
function call argument list.

This code has been refactored in master and a different patch is needed
there.

Bug: 22405868
Change-Id: Ida91ce6fe2895b6c38f29be7ab943c3773feb085

framework/common/tcuFuzzyImageCompare.cpp

index cfcd576..7d4eda1 100644 (file)
@@ -319,8 +319,9 @@ float fuzzyCompare (const FuzzyCompareParams& params, const ConstPixelBufferAcce
        {
                for (int x = 1; x < width-1; x += params.maxSampleSkip > 0 ? (int)rnd.getInt(0, params.maxSampleSkip) : 1)
                {
-                       float err = deFloatMin(compareToNeighbor<4>(params, rnd, readUnorm8<4>(refAccess, x, y), cmpAccess, x, y),
-                                                                  compareToNeighbor<4>(params, rnd, readUnorm8<4>(cmpAccess, x, y), refAccess, x, y));
+                       const float     err0    = compareToNeighbor<4>(params, rnd, readUnorm8<4>(refAccess, x, y), cmpAccess, x, y);
+                       const float     err1    = compareToNeighbor<4>(params, rnd, readUnorm8<4>(cmpAccess, x, y), refAccess, x, y);
+                       float           err             = deFloatMin(err0, err1);
 
                        err = deFloatPow(err, params.errExp);