From 6714bcc2ca97f668c0358f3d8ce039d61b5ab25e Mon Sep 17 00:00:00 2001 From: John Kessenich Date: Wed, 21 Sep 2016 17:50:12 -0600 Subject: [PATCH] HLSL: Fix result type of passing a flattened-aggregate to a function. --- Test/baseResults/hlsl.entry-in.frag.out | 6 +++--- glslang/Include/revision.h | 4 ++-- hlsl/hlslParseHelper.cpp | 8 ++++++++ 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Test/baseResults/hlsl.entry-in.frag.out b/Test/baseResults/hlsl.entry-in.frag.out index 5baea644..8572fa1c 100755 --- a/Test/baseResults/hlsl.entry-in.frag.out +++ b/Test/baseResults/hlsl.entry-in.frag.out @@ -54,7 +54,7 @@ gl_FragCoord origin is upper left 0:17 move second child to first child (temp float) 0:17 'ret2' (temp float) 0:17 Function Call: fun(struct-InParam-vf2-vf4-vi21; (global float) -0:? Comma (temp float) +0:? Comma (temp structure{temp 2-component vector of float v, temp 4-component vector of float fragCoord, temp 2-component vector of int i2}) 0:? Sequence 0:? move second child to first child (temp 2-component vector of float) 0:? v: direct index for structure (temp 2-component vector of float) @@ -152,7 +152,7 @@ gl_FragCoord origin is upper left 0:17 move second child to first child (temp float) 0:17 'ret2' (temp float) 0:17 Function Call: fun(struct-InParam-vf2-vf4-vi21; (global float) -0:? Comma (temp float) +0:? Comma (temp structure{temp 2-component vector of float v, temp 4-component vector of float fragCoord, temp 2-component vector of int i2}) 0:? Sequence 0:? move second child to first child (temp 2-component vector of float) 0:? v: direct index for structure (temp 2-component vector of float) @@ -256,7 +256,7 @@ gl_FragCoord origin is upper left 48(param): 12(ptr) Variable Function 51(ret2): 20(ptr) Variable Function 52(aggShadow): 12(ptr) Variable Function - 59(param): 20(ptr) Variable Function + 59(param): 12(ptr) Variable Function 33: 7(fvec2) Load 32(v) 35: 34(ptr) AccessChain 30(local) 17 Store 35 33 diff --git a/glslang/Include/revision.h b/glslang/Include/revision.h index 6850d6fc..0fd06e15 100644 --- a/glslang/Include/revision.h +++ b/glslang/Include/revision.h @@ -2,5 +2,5 @@ // For the version, it uses the latest git tag followed by the number of commits. // For the date, it uses the current date (when then script is run). -#define GLSLANG_REVISION "Overload400-PrecQual.1503" -#define GLSLANG_DATE "20-Sep-2016" +#define GLSLANG_REVISION "Overload400-PrecQual.1506" +#define GLSLANG_DATE "21-Sep-2016" diff --git a/hlsl/hlslParseHelper.cpp b/hlsl/hlslParseHelper.cpp index 63cd5ecf..5af79040 100755 --- a/hlsl/hlslParseHelper.cpp +++ b/hlsl/hlslParseHelper.cpp @@ -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); } }