diff --git a/Test/baseResults/hlsl.emptystruct.init.vert.out b/Test/baseResults/hlsl.emptystruct.init.vert.out new file mode 100644 index 00000000..202e2c06 --- /dev/null +++ b/Test/baseResults/hlsl.emptystruct.init.vert.out @@ -0,0 +1,112 @@ +hlsl.emptystruct.init.vert +WARNING: 0:3: 'Test_Empty' : variable with qualifier 'const' not initialized; zero initializing + +Shader version: 500 +0:? Sequence +0:6 Function Definition: @main(u1; ( temp 4-component vector of float) +0:6 Function Parameters: +0:6 'vertexIndex' ( in uint) +0:? Sequence +0:7 Branch: Return with expression +0:7 Constant: +0:7 0.000000 +0:7 0.000000 +0:7 0.000000 +0:7 0.000000 +0:6 Function Definition: main( ( temp void) +0:6 Function Parameters: +0:? Sequence +0:6 move second child to first child ( temp uint) +0:? 'vertexIndex' ( temp uint) +0:? 'vertexIndex' (layout( location=0) in uint) +0:6 move second child to first child ( temp 4-component vector of float) +0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float) +0:6 Function Call: @main(u1; ( temp 4-component vector of float) +0:? 'vertexIndex' ( temp uint) +0:? Linker Objects +0:? 'Test_Empty' ( const structure{}) +0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float) +0:? 'vertexIndex' (layout( location=0) in uint) + + +Linked vertex stage: + + +Shader version: 500 +0:? Sequence +0:6 Function Definition: @main(u1; ( temp 4-component vector of float) +0:6 Function Parameters: +0:6 'vertexIndex' ( in uint) +0:? Sequence +0:7 Branch: Return with expression +0:7 Constant: +0:7 0.000000 +0:7 0.000000 +0:7 0.000000 +0:7 0.000000 +0:6 Function Definition: main( ( temp void) +0:6 Function Parameters: +0:? Sequence +0:6 move second child to first child ( temp uint) +0:? 'vertexIndex' ( temp uint) +0:? 'vertexIndex' (layout( location=0) in uint) +0:6 move second child to first child ( temp 4-component vector of float) +0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float) +0:6 Function Call: @main(u1; ( temp 4-component vector of float) +0:? 'vertexIndex' ( temp uint) +0:? Linker Objects +0:? 'Test_Empty' ( const structure{}) +0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float) +0:? 'vertexIndex' (layout( location=0) in uint) + +// Module Version 10000 +// Generated by (magic number): 80001 +// Id's are bound by 29 + + Capability Shader + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Vertex 4 "main" 20 23 + Source HLSL 500 + Name 4 "main" + Name 12 "@main(u1;" + Name 11 "vertexIndex" + Name 18 "vertexIndex" + Name 20 "vertexIndex" + Name 23 "@entryPointOutput" + Name 24 "param" + Name 27 "Test" + Decorate 20(vertexIndex) Location 0 + Decorate 23(@entryPointOutput) Location 0 + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeInt 32 0 + 7: TypePointer Function 6(int) + 8: TypeFloat 32 + 9: TypeVector 8(float) 4 + 10: TypeFunction 9(fvec4) 7(ptr) + 14: 8(float) Constant 0 + 15: 9(fvec4) ConstantComposite 14 14 14 14 + 19: TypePointer Input 6(int) + 20(vertexIndex): 19(ptr) Variable Input + 22: TypePointer Output 9(fvec4) +23(@entryPointOutput): 22(ptr) Variable Output + 27(Test): TypeStruct + 28: 27(Test) ConstantComposite + 4(main): 2 Function None 3 + 5: Label + 18(vertexIndex): 7(ptr) Variable Function + 24(param): 7(ptr) Variable Function + 21: 6(int) Load 20(vertexIndex) + Store 18(vertexIndex) 21 + 25: 6(int) Load 18(vertexIndex) + Store 24(param) 25 + 26: 9(fvec4) FunctionCall 12(@main(u1;) 24(param) + Store 23(@entryPointOutput) 26 + Return + FunctionEnd + 12(@main(u1;): 9(fvec4) Function None 10 + 11(vertexIndex): 7(ptr) FunctionParameter + 13: Label + ReturnValue 15 + FunctionEnd diff --git a/Test/hlsl.emptystruct.init.vert b/Test/hlsl.emptystruct.init.vert new file mode 100644 index 00000000..02050f8b --- /dev/null +++ b/Test/hlsl.emptystruct.init.vert @@ -0,0 +1,8 @@ +struct Test { }; + +static const Test Test_Empty; + +float4 main(in uint vertexIndex : VERTEXID) : VS_OUT_POSITION +{ + return 0; +} diff --git a/glslang/MachineIndependent/parseConst.cpp b/glslang/MachineIndependent/parseConst.cpp index 22b55516..1a8e6d99 100644 --- a/glslang/MachineIndependent/parseConst.cpp +++ b/glslang/MachineIndependent/parseConst.cpp @@ -76,12 +76,6 @@ bool TConstTraverser::visitAggregate(TVisit /* visit */, TIntermAggregate* node) return false; } - if (node->getSequence().size() == 0) { - error = true; - - return false; - } - bool flag = node->getSequence().size() == 1 && node->getSequence()[0]->getAsTyped()->getAsConstantUnion(); if (flag) { singleConstantParam = true; diff --git a/gtests/Hlsl.FromFile.cpp b/gtests/Hlsl.FromFile.cpp index 5dcc095b..6129ddee 100644 --- a/gtests/Hlsl.FromFile.cpp +++ b/gtests/Hlsl.FromFile.cpp @@ -106,6 +106,7 @@ INSTANTIATE_TEST_CASE_P( {"hlsl.doLoop.frag", "PixelShaderFunction"}, {"hlsl.emptystructreturn.frag", "main"}, {"hlsl.emptystructreturn.vert", "main"}, + {"hlsl.emptystruct.init.vert", "main"}, {"hlsl.entry-in.frag", "PixelShaderFunction"}, {"hlsl.entry-out.frag", "PixelShaderFunction"}, {"hlsl.float1.frag", "PixelShaderFunction"},