Commit 91dfb97d by Nicolas Capens

Fix min/max constant folding.

Change-Id: I9ac2051f5cc8703e804b86c0006bb1b9fe48f521 Reviewed-on: https://swiftshader-review.googlesource.com/5082Tested-by: 's avatarNicolas Capens <capn@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent 341afbba
...@@ -1611,7 +1611,20 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod ...@@ -1611,7 +1611,20 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
tempNode->setLine(getLine()); tempNode->setLine(getLine());
return tempNode; 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: default:
return 0; return 0;
} }
......
...@@ -3581,6 +3581,25 @@ TIntermTyped *TParseContext::addFunctionCallOrMethod(TFunction *fnCall, TIntermN ...@@ -3581,6 +3581,25 @@ TIntermTyped *TParseContext::addFunctionCallOrMethod(TFunction *fnCall, TIntermN
functionCallLValueErrorCheck(fnCandidate, aggregate); functionCallLValueErrorCheck(fnCandidate, aggregate);
callNode = 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 else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment