Commit ff132135 by John Kessenich

Front-ends GLSL/HLSL: Fix initializer lists for structs of one member.

Single member structs initialized with an initializer list had an incorrect argument for constructor emulation.
parent 96e9f47c
......@@ -51,6 +51,18 @@ struct S4 {
S3 s[2];
};
struct Single1 { int f; };
Single1 single1 = { 10 };
struct Single2 { uvec2 v; };
Single2 single2 = { { 1, 2 } };
struct Single3 { Single1 s1; };
Single3 single3 = { { 3 } };
struct Single4 { Single2 s1; };
Single4 single4 = { { { 4u, 5u } } };
const S4 constructed = S4(uvec2(1, 2),
S3[2](S3(3.0, mat2x3(4.0)),
S3(5.0, mat2x3(6.0))));
......
......@@ -4,6 +4,18 @@ float a2 = 0.2, b2;
float a3, b3 = 0.3;
float a4, b4 = 0.4, c4;
float a5 = 0.5, b5, c5 = 1.5;
struct Single1 { int f; };
Single1 single1 = { 10 };
struct Single2 { uint2 v; };
Single2 single2 = { { 1, 2 } };
struct Single3 { Single1 s1; };
Single3 single3 = { { 3 } };
struct Single4 { Single2 s1; };
Single4 single4 = { { { 4u, 5u } } };
float4 ShaderFunction(float4 input) : COLOR0
{
......
......@@ -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 "SPIRV99.1365"
#define GLSLANG_REVISION "SPIRV99.1367"
#define GLSLANG_DATE "29-Jul-2016"
......@@ -5145,8 +5145,14 @@ TIntermTyped* TParseContext::convertInitializerList(const TSourceLoc& loc, const
return nullptr;
}
// now that the subtree is processed, process this node
return addConstructor(loc, initList, type);
// Now that the subtree is processed, process this node as if the
// initializer list is a set of arguments to a constructor.
TIntermNode* emulatedConstructorArguments;
if (initList->getSequence().size() == 1)
emulatedConstructorArguments = initList->getSequence()[0];
else
emulatedConstructorArguments = initList;
return addConstructor(loc, emulatedConstructorArguments, type);
}
//
......
......@@ -3725,8 +3725,14 @@ TIntermTyped* HlslParseContext::convertInitializerList(const TSourceLoc& loc, co
return nullptr;
}
// now that the subtree is processed, process this node
return addConstructor(loc, initList, type);
// Now that the subtree is processed, process this node as if the
// initializer list is a set of arguments to a constructor.
TIntermNode* emulatedConstructorArguments;
if (initList->getSequence().size() == 1)
emulatedConstructorArguments = initList->getSequence()[0];
else
emulatedConstructorArguments = initList;
return addConstructor(loc, emulatedConstructorArguments, type);
}
//
......
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