HLSL: Fix result type of passing a flattened-aggregate to a function.

This commit is contained in:
John Kessenich
2016-09-21 17:50:12 -06:00
parent 6873f3d898
commit 6714bcc2ca
3 changed files with 13 additions and 5 deletions

View File

@@ -2277,6 +2277,10 @@ void HlslParseContext::addInputArgumentConversions(const TFunction& function, TI
}
} else {
if (shouldFlatten(arg->getType())) {
// Will make a two-level subtree.
// The deepest will copy member-by-member to build the structure to pass.
// The level above that will be an two-operand EOpComma sequence that follows the copy by the
// object itself.
TSourceLoc dummyLoc;
dummyLoc.init();
TVariable* internalAggregate = makeInternalVariable("aggShadow", *function[i].type);
@@ -2284,9 +2288,13 @@ void HlslParseContext::addInputArgumentConversions(const TFunction& function, TI
TIntermSymbol* internalSymbolNode = new TIntermSymbol(internalAggregate->getUniqueId(),
internalAggregate->getName(),
internalAggregate->getType());
// This makes the deepest level, the member-wise copy
TIntermAggregate* assignAgg = handleAssign(dummyLoc, EOpAssign, internalSymbolNode, arg)->getAsAggregate();
// Now, pair that with the resulting aggregate.
assignAgg = intermediate.growAggregate(assignAgg, internalSymbolNode);
assignAgg->setOperator(EOpComma);
assignAgg->setType(internalAggregate->getType());
setArg(i, assignAgg);
}
}