Fix random shader generator
authorGraeme Leese <gleese@broadcom.com>
Thu, 1 Mar 2018 17:48:57 +0000 (17:48 +0000)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Wed, 4 Apr 2018 07:55:05 +0000 (03:55 -0400)
Put parentheses around the RHS when converting L == R into
abs(L - R) < 0.001.

Affects: dEQP-GLES2.functional.shaders.random.*
         dEQP-GLES3.functional.shaders.random.*

Components: OpenGL

VK-GL-CTS issue: 286

Change-Id: I95d43ed40944c2815d7ce464ac4dc4993f87a4e9

framework/randomshaders/rsgBinaryOps.cpp

index 99b78f7..4b383f4 100644 (file)
@@ -283,10 +283,16 @@ Expression* BinaryOp<Precedence, Assoc>::createNextChild (GeneratorState& state)
                        VariableType floatType(VariableType::TYPE_FLOAT, 1);
                        if (m_leftValueRange.getType() == floatType)
                        {
+                               VariableType boolType(VariableType::TYPE_BOOL, 1);
+                               const ValueRange boolRange(boolType);
+
+                               ParenOp* parenRight = new ParenOp(state, boolRange);
+                               parenRight->setChild(m_rightValueExpr);
+
                                typedef CustomBinaryOp<EvaluateSub> CustomSubOp;
                                CustomSubOp* subOperation = new CustomSubOp();
                                subOperation->setLeftValue(m_leftValueExpr);
-                               subOperation->setRightValue(m_rightValueExpr);
+                               subOperation->setRightValue(parenRight);
 
                                CustomAbsOp* absOperation = new CustomAbsOp();
                                absOperation->setChild(subOperation);
@@ -297,8 +303,6 @@ Expression* BinaryOp<Precedence, Assoc>::createNextChild (GeneratorState& state)
                                lessOperation->setLeftValue(absOperation);
                                lessOperation->setRightValue(epsilonLiteral);
 
-                               VariableType boolType(VariableType::TYPE_BOOL, 1);
-                               const ValueRange boolRange(boolType);
                                ParenOp* parenOperation = new ParenOp(state, boolRange);
                                parenOperation->setChild(lessOperation);
                                BoolLiteral* trueLiteral = new BoolLiteral(true);