Commit 82460b5e by John Kessenich

HLSL: Fix #805: Support cast of scalars to structures.

Somewhat complex due to recognizing a general scalar, but not replicating it for each member to avoid side effects.
parent 5ce1e4af
struct VertexOut {
float4 position : SV_Position;
float2 texCoord : TEXCOORD;
};
VertexOut r0() {
const float f = 2.0;
return (VertexOut)f;
}
VertexOut r1() {
const float f = 2.0;
return (VertexOut)(f + 1.0);
}
VertexOut r2() {
const float f = 2.0;
return (VertexOut)(sin(f));
}
VertexOut r3() {
float f = 2.0;
return (VertexOut)f;
}
VertexOut r4() {
float f = 2.0;
return (VertexOut)(f + 1.0);
}
VertexOut r5() {
float f = 2.0;
return (VertexOut)(sin(f));
}
VertexOut main() {
VertexOut v0 = r0();
VertexOut v1 = r1();
VertexOut v2 = r2();
VertexOut v3 = r3();
VertexOut v4 = r4();
VertexOut v5 = r5();
return (VertexOut)1;
}
......@@ -3,4 +3,4 @@
// For the date, it uses the current date (when then script is run).
#define GLSLANG_REVISION "Overload400-PrecQual.1971"
#define GLSLANG_DATE "03-Apr-2017"
#define GLSLANG_DATE "04-Apr-2017"
......@@ -223,6 +223,7 @@ INSTANTIATE_TEST_CASE_P(
{"hlsl.samplelevel.offsetarray.dx10.frag", "main"},
{"hlsl.sample.sub-vec4.dx10.frag", "main"},
{"hlsl.scalar-length.frag", "main"},
{"hlsl.scalarCast.vert", "main"},
{"hlsl.semicolons.frag", "main"},
{"hlsl.shapeConv.frag", "main"},
{"hlsl.shapeConvRet.frag", "main"},
......
......@@ -140,7 +140,7 @@ public:
void declareStruct(const TSourceLoc&, TString& structName, TType&);
TSymbol* lookupUserType(const TString&, TType&);
TIntermNode* declareVariable(const TSourceLoc&, const TString& identifier, TType&, TIntermTyped* initializer = 0);
void lengthenList(const TSourceLoc&, TIntermSequence& list, int size);
void lengthenList(const TSourceLoc&, TIntermSequence& list, int size, TIntermTyped* scalarInit);
TIntermTyped* handleConstructor(const TSourceLoc&, TIntermTyped*, const TType&);
TIntermTyped* addConstructor(const TSourceLoc&, TIntermTyped*, const TType&);
TIntermTyped* constructAggregate(TIntermNode*, const TType&, int, const TSourceLoc&);
......@@ -217,11 +217,12 @@ protected:
TVariable* makeInternalVariable(const TString& name, const TType& type) const {
return makeInternalVariable(name.c_str(), type);
}
TIntermSymbol* makeInternalVariableNode(const TSourceLoc&, const char* name, const TType&) const;
TVariable* declareNonArray(const TSourceLoc&, const TString& identifier, const TType&, bool track);
void declareArray(const TSourceLoc&, const TString& identifier, const TType&, TSymbol*&, bool track);
TIntermNode* executeInitializer(const TSourceLoc&, TIntermTyped* initializer, TVariable* variable);
TIntermTyped* convertInitializerList(const TSourceLoc&, const TType&, TIntermTyped* initializer);
bool isZeroConstructor(const TIntermNode*);
TIntermTyped* convertInitializerList(const TSourceLoc&, const TType&, TIntermTyped* initializer, TIntermTyped* scalarInit);
bool isScalarConstructor(const TIntermNode*);
TOperator mapAtomicOp(const TSourceLoc& loc, TOperator op, bool isImage);
// Return true if this node requires L-value conversion (e.g, to an imageStore).
......
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