OSDN Git Service

Fix min/max constant folding.
authorNicolas Capens <capn@google.com>
Sun, 10 Apr 2016 03:45:12 +0000 (23:45 -0400)
committerNicolas Capens <capn@google.com>
Mon, 11 Apr 2016 14:26:18 +0000 (14:26 +0000)
Change-Id: I9ac2051f5cc8703e804b86c0006bb1b9fe48f521
Reviewed-on: https://swiftshader-review.googlesource.com/5082
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
src/OpenGL/compiler/Intermediate.cpp
src/OpenGL/compiler/ParseHelper.cpp

index 5f84222..14cd5b2 100644 (file)
@@ -1611,7 +1611,20 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
                 tempNode->setLine(getLine());
 
                 return tempNode;
-
+                       case EOpMax:
+                tempConstArray = new ConstantUnion[objectSize];
+                {// support MSVC++6.0
+                    for (int i = 0; i < objectSize; i++)
+                        tempConstArray[i] = unionArray[i] > rightUnionArray[i] ? unionArray[i] : rightUnionArray[i];
+                }
+                break;
+            case EOpMin:
+                tempConstArray = new ConstantUnion[objectSize];
+                {// support MSVC++6.0
+                    for (int i = 0; i < objectSize; i++)
+                        tempConstArray[i] = unionArray[i] < rightUnionArray[i] ? unionArray[i] : rightUnionArray[i];
+                }
+                break;
             default:
                 return 0;
         }
index df9ffd0..ddf0765 100644 (file)
@@ -3581,6 +3581,25 @@ TIntermTyped *TParseContext::addFunctionCallOrMethod(TFunction *fnCall, TIntermN
                                        functionCallLValueErrorCheck(fnCandidate, aggregate);
 
                                        callNode = aggregate;
+
+                                       if(fnCandidate->getParamCount() == 2)
+                                       {
+                                               TIntermSequence &parameters = paramNode->getAsAggregate()->getSequence();
+                                               TIntermTyped *left = parameters[0]->getAsTyped();
+                                               TIntermTyped *right = parameters[1]->getAsTyped();
+
+                                               TIntermConstantUnion *leftTempConstant = left->getAsConstantUnion();
+                                               TIntermConstantUnion *rightTempConstant = right->getAsConstantUnion();
+                                               if (leftTempConstant && rightTempConstant)
+                                               {
+                                                       TIntermTyped *typedReturnNode = leftTempConstant->fold(op, rightTempConstant, infoSink());
+
+                                                       if(typedReturnNode)
+                                                       {
+                                                               callNode = typedReturnNode;
+                                                       }
+                                               }
+                                       }
                                }
                        }
                        else