parent
2fb89a0072
commit
8ef6a4cb4d
24 changed files with 120 additions and 73 deletions
|
|
@ -1643,6 +1643,7 @@ public:
|
|||
~TIntermAggregate() { delete pragmaTable; }
|
||||
virtual TIntermAggregate* getAsAggregate() { return this; }
|
||||
virtual const TIntermAggregate* getAsAggregate() const { return this; }
|
||||
virtual void updatePrecision();
|
||||
virtual void setOperator(TOperator o) { op = o; }
|
||||
virtual TIntermSequence& getSequence() { return sequence; }
|
||||
virtual const TIntermSequence& getSequence() const { return sequence; }
|
||||
|
|
|
|||
|
|
@ -416,20 +416,24 @@ TIntermTyped* TIntermediate::addUnaryMath(TOperator op, TIntermTyped* child,
|
|||
// TODO: but, did this bypass constant folding?
|
||||
//
|
||||
switch (op) {
|
||||
case EOpConstructInt8:
|
||||
case EOpConstructUint8:
|
||||
case EOpConstructInt16:
|
||||
case EOpConstructUint16:
|
||||
case EOpConstructInt:
|
||||
case EOpConstructUint:
|
||||
case EOpConstructInt64:
|
||||
case EOpConstructUint64:
|
||||
case EOpConstructBool:
|
||||
case EOpConstructFloat:
|
||||
case EOpConstructDouble:
|
||||
case EOpConstructFloat16:
|
||||
return child;
|
||||
default: break; // some compilers want this
|
||||
case EOpConstructInt8:
|
||||
case EOpConstructUint8:
|
||||
case EOpConstructInt16:
|
||||
case EOpConstructUint16:
|
||||
case EOpConstructInt:
|
||||
case EOpConstructUint:
|
||||
case EOpConstructInt64:
|
||||
case EOpConstructUint64:
|
||||
case EOpConstructBool:
|
||||
case EOpConstructFloat:
|
||||
case EOpConstructDouble:
|
||||
case EOpConstructFloat16: {
|
||||
TIntermUnary* unary_node = child->getAsUnaryNode();
|
||||
if (unary_node != nullptr)
|
||||
unary_node->updatePrecision();
|
||||
return child;
|
||||
}
|
||||
default: break; // some compilers want this
|
||||
}
|
||||
|
||||
//
|
||||
|
|
@ -3776,6 +3780,28 @@ bool TIntermediate::promoteAggregate(TIntermAggregate& node)
|
|||
return false;
|
||||
}
|
||||
|
||||
// Propagate precision qualifiers *up* from children to parent, and then
|
||||
// back *down* again to the children's subtrees.
|
||||
void TIntermAggregate::updatePrecision()
|
||||
{
|
||||
if (getBasicType() == EbtInt || getBasicType() == EbtUint ||
|
||||
getBasicType() == EbtFloat || getBasicType() == EbtFloat16) {
|
||||
TPrecisionQualifier maxPrecision = EpqNone;
|
||||
TIntermSequence operands = getSequence();
|
||||
for (unsigned int i = 0; i < operands.size(); ++i) {
|
||||
TIntermTyped* typedNode = operands[i]->getAsTyped();
|
||||
assert(typedNode);
|
||||
maxPrecision = std::max(maxPrecision, typedNode->getQualifier().precision);
|
||||
}
|
||||
getQualifier().precision = maxPrecision;
|
||||
for (unsigned int i = 0; i < operands.size(); ++i) {
|
||||
TIntermTyped* typedNode = operands[i]->getAsTyped();
|
||||
assert(typedNode);
|
||||
typedNode->propagatePrecision(maxPrecision);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Propagate precision qualifiers *up* from children to parent, and then
|
||||
// back *down* again to the children's subtrees.
|
||||
void TIntermBinary::updatePrecision()
|
||||
|
|
|
|||
|
|
@ -7691,7 +7691,13 @@ TIntermTyped* TParseContext::addConstructor(const TSourceLoc& loc, TIntermNode*
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
return intermediate.setAggregateOperator(aggrNode, op, type, loc);
|
||||
TIntermTyped *ret_node = intermediate.setAggregateOperator(aggrNode, op, type, loc);
|
||||
|
||||
TIntermAggregate *agg_node = ret_node->getAsAggregate();
|
||||
if (agg_node && agg_node->isVector())
|
||||
agg_node->updatePrecision();
|
||||
|
||||
return ret_node;
|
||||
}
|
||||
|
||||
// Function for constructor implementation. Calls addUnaryMath with appropriate EOp value
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue