Fix crash from attempting ES precision propagation through a constant folded built-in function call when the expression tree has unknown precisions.
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@24267 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
parent
98434bed00
commit
78fe3ace85
3 changed files with 34 additions and 13 deletions
|
|
@ -299,18 +299,21 @@ TIntermTyped* TIntermediate::addBuiltInFunctionCall(TSourceLoc loc, TOperator op
|
|||
// setAggregateOperater() calls fold() for constant folding
|
||||
TIntermTyped* node = setAggregateOperator(childNode, op, returnType, loc);
|
||||
|
||||
TPrecisionQualifier correctPrecision = returnType.getQualifier().precision;
|
||||
if (correctPrecision == EpqNone && profile == EEsProfile) {
|
||||
// find the maximum precision from the arguments, for the built-in's return precision
|
||||
TIntermSequence& sequence = node->getAsAggregate()->getSequence();
|
||||
for (unsigned int arg = 0; arg < sequence.size(); ++arg)
|
||||
correctPrecision = std::max(correctPrecision, sequence[arg]->getAsTyped()->getQualifier().precision);
|
||||
}
|
||||
// if not folded, we'll still have an aggregate node to propagate precision with
|
||||
if (node->getAsAggregate()) {
|
||||
TPrecisionQualifier correctPrecision = returnType.getQualifier().precision;
|
||||
if (correctPrecision == EpqNone && profile == EEsProfile) {
|
||||
// find the maximum precision from the arguments, for the built-in's return precision
|
||||
TIntermSequence& sequence = node->getAsAggregate()->getSequence();
|
||||
for (unsigned int arg = 0; arg < sequence.size(); ++arg)
|
||||
correctPrecision = std::max(correctPrecision, sequence[arg]->getAsTyped()->getQualifier().precision);
|
||||
}
|
||||
|
||||
// Propagate precision through this node and its children. That algorithm stops
|
||||
// when a precision is found, so start by clearing this subroot precision
|
||||
node->getQualifier().precision = EpqNone;
|
||||
node->propagatePrecision(correctPrecision);
|
||||
// Propagate precision through this node and its children. That algorithm stops
|
||||
// when a precision is found, so start by clearing this subroot precision
|
||||
node->getQualifier().precision = EpqNone;
|
||||
node->propagatePrecision(correctPrecision);
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue