HLSL: Fix #1249: Always execute both sides of ternary "?:".

This is semantically required by HLSL, and frequently results in using
OpSelect instead of control flow.
This commit is contained in:
John Kessenich 2018-02-20 21:29:05 -07:00
parent a5cae08259
commit 4bee531fc1
17 changed files with 776 additions and 850 deletions

View file

@ -1672,7 +1672,11 @@ TIntermTyped* TIntermediate::addSelection(TIntermTyped* cond, TIntermTyped* true
// If it's void, go to the if-then-else selection()
if (trueBlock->getBasicType() == EbtVoid && falseBlock->getBasicType() == EbtVoid) {
TIntermNodePair pair = { trueBlock, falseBlock };
return addSelection(cond, pair, loc);
TIntermSelection* selection = addSelection(cond, pair, loc);
if (getSource() == EShSourceHlsl)
selection->setNoShortCircuit();
return selection;
}
//
@ -1743,6 +1747,9 @@ TIntermTyped* TIntermediate::addSelection(TIntermTyped* cond, TIntermTyped* true
else
node->getQualifier().makeTemporary();
if (getSource() == EShSourceHlsl)
node->setNoShortCircuit();
return node;
}