Commit 5159d4f1 by John Kessenich

HLSL: Intercept flatten aggregates passed to a function input, and copy member-by-member.

parent f911500d
...@@ -4,10 +4,17 @@ struct InParam { ...@@ -4,10 +4,17 @@ struct InParam {
int2 i2; int2 i2;
}; };
float fun(InParam p)
{
return p.v.y + p.fragCoord.x;
}
float4 PixelShaderFunction(InParam i) : COLOR0 float4 PixelShaderFunction(InParam i) : COLOR0
{ {
InParam local; InParam local;
local = i; local = i;
float ret1 = fun(local);
float ret2 = fun(i);
return local.fragCoord; return local.fragCoord * ret1 * ret2;
} }
...@@ -3,4 +3,4 @@ ...@@ -3,4 +3,4 @@
// For the date, it uses the current date (when then script is run). // For the date, it uses the current date (when then script is run).
#define GLSLANG_REVISION "Overload400-PrecQual.1493" #define GLSLANG_REVISION "Overload400-PrecQual.1493"
#define GLSLANG_DATE "18-Sep-2016" #define GLSLANG_DATE "19-Sep-2016"
...@@ -2241,6 +2241,16 @@ TIntermTyped* HlslParseContext::handleLengthMethod(const TSourceLoc& loc, TFunct ...@@ -2241,6 +2241,16 @@ TIntermTyped* HlslParseContext::handleLengthMethod(const TSourceLoc& loc, TFunct
void HlslParseContext::addInputArgumentConversions(const TFunction& function, TIntermNode*& arguments) const void HlslParseContext::addInputArgumentConversions(const TFunction& function, TIntermNode*& arguments) const
{ {
TIntermAggregate* aggregate = arguments->getAsAggregate(); TIntermAggregate* aggregate = arguments->getAsAggregate();
const auto setArg = [&](int argNum, TIntermNode* arg) {
if (function.getParamCount() == 1)
arguments = arg;
else {
if (aggregate)
aggregate->getSequence()[argNum] = arg;
else
arguments = arg;
}
};
// Process each argument's conversion // Process each argument's conversion
for (int i = 0; i < function.getParamCount(); ++i) { for (int i = 0; i < function.getParamCount(); ++i) {
...@@ -2254,16 +2264,20 @@ void HlslParseContext::addInputArgumentConversions(const TFunction& function, TI ...@@ -2254,16 +2264,20 @@ void HlslParseContext::addInputArgumentConversions(const TFunction& function, TI
// convert to the correct type. // convert to the correct type.
arg = intermediate.addConversion(EOpFunctionCall, *function[i].type, arg); arg = intermediate.addConversion(EOpFunctionCall, *function[i].type, arg);
arg = intermediate.addShapeConversion(EOpFunctionCall, *function[i].type, arg); arg = intermediate.addShapeConversion(EOpFunctionCall, *function[i].type, arg);
if (arg) { setArg(i, arg);
if (function.getParamCount() == 1)
arguments = arg;
else {
if (aggregate)
aggregate->getSequence()[i] = arg;
else
arguments = arg;
}
} }
} else {
if (shouldFlatten(arg->getType())) {
TSourceLoc dummyLoc;
dummyLoc.init();
TVariable* internalAggregate = makeInternalVariable("aggShadow", *function[i].type);
TIntermSymbol* internalSymbolNode = new TIntermSymbol(internalAggregate->getUniqueId(),
internalAggregate->getName(),
internalAggregate->getType());
TIntermAggregate* assignAgg = handleAssign(dummyLoc, EOpAssign, internalSymbolNode, arg)->getAsAggregate();
assignAgg = intermediate.growAggregate(assignAgg, internalSymbolNode);
assignAgg->setOperator(EOpComma);
setArg(i, assignAgg);
} }
} }
} }
......
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