Commit b07aba07 by Olli Etuaho

Make sure type gets set consistently in folded binary operations

Add a wrapper function that handles creating the folded node and setting the right parameters on it, so that the folding function handles only calculating the folded values. This will fix the precision set to constant folded values in some cases. Previously the precision was always set to be equal to one of the operands to the binary operation, but now both operands are taken into account. Folding binary operations is now in a separate function from folding unary operations. TEST=dEQP-GLES3.functional.shaders.constant_expressions.* BUG=angleproject:817 Change-Id: Id97e765173c6110f49607e21c3fb90019b1ebac7 Reviewed-on: https://chromium-review.googlesource.com/274001Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarOlli Etuaho <oetuaho@nvidia.com>
parent b50788d1
...@@ -299,7 +299,8 @@ class TIntermConstantUnion : public TIntermTyped ...@@ -299,7 +299,8 @@ class TIntermConstantUnion : public TIntermTyped
virtual void traverse(TIntermTraverser *); virtual void traverse(TIntermTraverser *);
virtual bool replaceChildNode(TIntermNode *, TIntermNode *) { return false; } virtual bool replaceChildNode(TIntermNode *, TIntermNode *) { return false; }
TIntermTyped *fold(TOperator op, TIntermConstantUnion *rightNode, TInfoSink &infoSink); TConstantUnion *foldBinary(TOperator op, TIntermConstantUnion *rightNode, TInfoSink &infoSink);
TIntermTyped *foldUnary(TOperator op, TInfoSink &infoSink);
static TIntermTyped *FoldAggregateBuiltIn(TOperator op, TIntermAggregate *aggregate, TInfoSink &infoSink); static TIntermTyped *FoldAggregateBuiltIn(TOperator op, TIntermAggregate *aggregate, TInfoSink &infoSink);
...@@ -362,6 +363,7 @@ class TIntermBinary : public TIntermOperator ...@@ -362,6 +363,7 @@ class TIntermBinary : public TIntermOperator
TIntermTyped *getLeft() const { return mLeft; } TIntermTyped *getLeft() const { return mLeft; }
TIntermTyped *getRight() const { return mRight; } TIntermTyped *getRight() const { return mRight; }
bool promote(TInfoSink &); bool promote(TInfoSink &);
TIntermTyped *fold(TInfoSink &infoSink);
void setAddIndexClamp() { mAddIndexClamp = true; } void setAddIndexClamp() { mAddIndexClamp = true; }
bool getAddIndexClamp() { return mAddIndexClamp; } bool getAddIndexClamp() { return mAddIndexClamp; }
......
...@@ -57,19 +57,10 @@ TIntermTyped *TIntermediate::addBinaryMath( ...@@ -57,19 +57,10 @@ TIntermTyped *TIntermediate::addBinaryMath(
if (!node->promote(mInfoSink)) if (!node->promote(mInfoSink))
return NULL; return NULL;
//
// See if we can fold constants. // See if we can fold constants.
// TIntermTyped *foldedNode = node->fold(mInfoSink);
TIntermConstantUnion *leftTempConstant = left->getAsConstantUnion(); if (foldedNode)
TIntermConstantUnion *rightTempConstant = right->getAsConstantUnion(); return foldedNode;
if (leftTempConstant && rightTempConstant)
{
TIntermTyped *typedReturnNode =
leftTempConstant->fold(node->getOp(), rightTempConstant, mInfoSink);
if (typedReturnNode)
return typedReturnNode;
}
return node; return node;
} }
...@@ -143,7 +134,7 @@ TIntermTyped *TIntermediate::addUnaryMath( ...@@ -143,7 +134,7 @@ TIntermTyped *TIntermediate::addUnaryMath(
if (childTempConstant) if (childTempConstant)
{ {
TIntermTyped *newChild = childTempConstant->fold(op, nullptr, mInfoSink); TIntermTyped *newChild = childTempConstant->foldUnary(op, mInfoSink);
if (newChild) if (newChild)
return newChild; return newChild;
......
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