diff --git a/Test/baseResults/hlsl.matpack-1.frag.out b/Test/baseResults/hlsl.matpack-1.frag.out new file mode 100644 index 0000000000000000000000000000000000000000..761c8c300a73c4ce025e2a7f0650ca4ac9a06a18 --- /dev/null +++ b/Test/baseResults/hlsl.matpack-1.frag.out @@ -0,0 +1,187 @@ +hlsl.matpack-1.frag +Shader version: 500 +gl_FragCoord origin is upper left +0:? Sequence +0:23 Function Definition: @main( ( temp 4-component vector of float) +0:23 Function Parameters: +0:? Sequence +0:25 Branch: Return with expression +0:24 add ( temp 4-component vector of float) +0:24 vector-times-matrix ( temp 4-component vector of float) +0:24 vec1: direct index for structure ( temp 4-component vector of float) +0:24 g_MyBuffer1: direct index for structure (layout( row_major std140) uniform structure{layout( row_major) temp 4X4 matrix of float mat1, layout( column_major) temp 4X4 matrix of float mat2, temp 4-component vector of float vec1, temp float foo}) +0:24 'anon@0' (layout( row_major std140) uniform block{layout( row_major std140) uniform structure{layout( row_major) temp 4X4 matrix of float mat1, layout( column_major) temp 4X4 matrix of float mat2, temp 4-component vector of float vec1, temp float foo} g_MyBuffer1, layout( row_major std140) uniform structure{layout( column_major) temp 4X4 matrix of float mat1, temp 4-component vector of float vec1} g_MyBuffer2, layout( row_major std140) uniform 4X4 matrix of float mat1a}) +0:24 Constant: +0:24 0 (const uint) +0:24 Constant: +0:24 2 (const int) +0:24 mat1: direct index for structure (layout( row_major) temp 4X4 matrix of float) +0:24 g_MyBuffer1: direct index for structure (layout( row_major std140) uniform structure{layout( row_major) temp 4X4 matrix of float mat1, layout( column_major) temp 4X4 matrix of float mat2, temp 4-component vector of float vec1, temp float foo}) +0:24 'anon@0' (layout( row_major std140) uniform block{layout( row_major std140) uniform structure{layout( row_major) temp 4X4 matrix of float mat1, layout( column_major) temp 4X4 matrix of float mat2, temp 4-component vector of float vec1, temp float foo} g_MyBuffer1, layout( row_major std140) uniform structure{layout( column_major) temp 4X4 matrix of float mat1, temp 4-component vector of float vec1} g_MyBuffer2, layout( row_major std140) uniform 4X4 matrix of float mat1a}) +0:24 Constant: +0:24 0 (const uint) +0:24 Constant: +0:24 0 (const int) +0:25 vector-times-matrix ( temp 4-component vector of float) +0:25 vec1: direct index for structure ( temp 4-component vector of float) +0:25 g_MyBuffer2: direct index for structure (layout( row_major std140) uniform structure{layout( column_major) temp 4X4 matrix of float mat1, temp 4-component vector of float vec1}) +0:25 'anon@0' (layout( row_major std140) uniform block{layout( row_major std140) uniform structure{layout( row_major) temp 4X4 matrix of float mat1, layout( column_major) temp 4X4 matrix of float mat2, temp 4-component vector of float vec1, temp float foo} g_MyBuffer1, layout( row_major std140) uniform structure{layout( column_major) temp 4X4 matrix of float mat1, temp 4-component vector of float vec1} g_MyBuffer2, layout( row_major std140) uniform 4X4 matrix of float mat1a}) +0:25 Constant: +0:25 1 (const uint) +0:25 Constant: +0:25 1 (const int) +0:25 mat1: direct index for structure (layout( column_major) temp 4X4 matrix of float) +0:25 g_MyBuffer2: direct index for structure (layout( row_major std140) uniform structure{layout( column_major) temp 4X4 matrix of float mat1, temp 4-component vector of float vec1}) +0:25 'anon@0' (layout( row_major std140) uniform block{layout( row_major std140) uniform structure{layout( row_major) temp 4X4 matrix of float mat1, layout( column_major) temp 4X4 matrix of float mat2, temp 4-component vector of float vec1, temp float foo} g_MyBuffer1, layout( row_major std140) uniform structure{layout( column_major) temp 4X4 matrix of float mat1, temp 4-component vector of float vec1} g_MyBuffer2, layout( row_major std140) uniform 4X4 matrix of float mat1a}) +0:25 Constant: +0:25 1 (const uint) +0:25 Constant: +0:25 0 (const int) +0:23 Function Definition: main( ( temp void) +0:23 Function Parameters: +0:? Sequence +0:23 move second child to first child ( temp 4-component vector of float) +0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float) +0:23 Function Call: @main( ( temp 4-component vector of float) +0:? Linker Objects +0:? 'anon@0' (layout( row_major std140) uniform block{layout( row_major std140) uniform structure{layout( row_major) temp 4X4 matrix of float mat1, layout( column_major) temp 4X4 matrix of float mat2, temp 4-component vector of float vec1, temp float foo} g_MyBuffer1, layout( row_major std140) uniform structure{layout( column_major) temp 4X4 matrix of float mat1, temp 4-component vector of float vec1} g_MyBuffer2, layout( row_major std140) uniform 4X4 matrix of float mat1a}) +0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float) + + +Linked fragment stage: + + +Shader version: 500 +gl_FragCoord origin is upper left +0:? Sequence +0:23 Function Definition: @main( ( temp 4-component vector of float) +0:23 Function Parameters: +0:? Sequence +0:25 Branch: Return with expression +0:24 add ( temp 4-component vector of float) +0:24 vector-times-matrix ( temp 4-component vector of float) +0:24 vec1: direct index for structure ( temp 4-component vector of float) +0:24 g_MyBuffer1: direct index for structure (layout( row_major std140) uniform structure{layout( row_major) temp 4X4 matrix of float mat1, layout( column_major) temp 4X4 matrix of float mat2, temp 4-component vector of float vec1, temp float foo}) +0:24 'anon@0' (layout( row_major std140) uniform block{layout( row_major std140) uniform structure{layout( row_major) temp 4X4 matrix of float mat1, layout( column_major) temp 4X4 matrix of float mat2, temp 4-component vector of float vec1, temp float foo} g_MyBuffer1, layout( row_major std140) uniform structure{layout( column_major) temp 4X4 matrix of float mat1, temp 4-component vector of float vec1} g_MyBuffer2, layout( row_major std140) uniform 4X4 matrix of float mat1a}) +0:24 Constant: +0:24 0 (const uint) +0:24 Constant: +0:24 2 (const int) +0:24 mat1: direct index for structure (layout( row_major) temp 4X4 matrix of float) +0:24 g_MyBuffer1: direct index for structure (layout( row_major std140) uniform structure{layout( row_major) temp 4X4 matrix of float mat1, layout( column_major) temp 4X4 matrix of float mat2, temp 4-component vector of float vec1, temp float foo}) +0:24 'anon@0' (layout( row_major std140) uniform block{layout( row_major std140) uniform structure{layout( row_major) temp 4X4 matrix of float mat1, layout( column_major) temp 4X4 matrix of float mat2, temp 4-component vector of float vec1, temp float foo} g_MyBuffer1, layout( row_major std140) uniform structure{layout( column_major) temp 4X4 matrix of float mat1, temp 4-component vector of float vec1} g_MyBuffer2, layout( row_major std140) uniform 4X4 matrix of float mat1a}) +0:24 Constant: +0:24 0 (const uint) +0:24 Constant: +0:24 0 (const int) +0:25 vector-times-matrix ( temp 4-component vector of float) +0:25 vec1: direct index for structure ( temp 4-component vector of float) +0:25 g_MyBuffer2: direct index for structure (layout( row_major std140) uniform structure{layout( column_major) temp 4X4 matrix of float mat1, temp 4-component vector of float vec1}) +0:25 'anon@0' (layout( row_major std140) uniform block{layout( row_major std140) uniform structure{layout( row_major) temp 4X4 matrix of float mat1, layout( column_major) temp 4X4 matrix of float mat2, temp 4-component vector of float vec1, temp float foo} g_MyBuffer1, layout( row_major std140) uniform structure{layout( column_major) temp 4X4 matrix of float mat1, temp 4-component vector of float vec1} g_MyBuffer2, layout( row_major std140) uniform 4X4 matrix of float mat1a}) +0:25 Constant: +0:25 1 (const uint) +0:25 Constant: +0:25 1 (const int) +0:25 mat1: direct index for structure (layout( column_major) temp 4X4 matrix of float) +0:25 g_MyBuffer2: direct index for structure (layout( row_major std140) uniform structure{layout( column_major) temp 4X4 matrix of float mat1, temp 4-component vector of float vec1}) +0:25 'anon@0' (layout( row_major std140) uniform block{layout( row_major std140) uniform structure{layout( row_major) temp 4X4 matrix of float mat1, layout( column_major) temp 4X4 matrix of float mat2, temp 4-component vector of float vec1, temp float foo} g_MyBuffer1, layout( row_major std140) uniform structure{layout( column_major) temp 4X4 matrix of float mat1, temp 4-component vector of float vec1} g_MyBuffer2, layout( row_major std140) uniform 4X4 matrix of float mat1a}) +0:25 Constant: +0:25 1 (const uint) +0:25 Constant: +0:25 0 (const int) +0:23 Function Definition: main( ( temp void) +0:23 Function Parameters: +0:? Sequence +0:23 move second child to first child ( temp 4-component vector of float) +0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float) +0:23 Function Call: @main( ( temp 4-component vector of float) +0:? Linker Objects +0:? 'anon@0' (layout( row_major std140) uniform block{layout( row_major std140) uniform structure{layout( row_major) temp 4X4 matrix of float mat1, layout( column_major) temp 4X4 matrix of float mat2, temp 4-component vector of float vec1, temp float foo} g_MyBuffer1, layout( row_major std140) uniform structure{layout( column_major) temp 4X4 matrix of float mat1, temp 4-component vector of float vec1} g_MyBuffer2, layout( row_major std140) uniform 4X4 matrix of float mat1a}) +0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float) + +// Module Version 10000 +// Generated by (magic number): 80001 +// Id's are bound by 39 + + Capability Shader + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Fragment 4 "main" 37 + ExecutionMode 4 OriginUpperLeft + Source HLSL 500 + Name 4 "main" + Name 9 "@main(" + Name 12 "MyBuffer1" + MemberName 12(MyBuffer1) 0 "mat1" + MemberName 12(MyBuffer1) 1 "mat2" + MemberName 12(MyBuffer1) 2 "vec1" + MemberName 12(MyBuffer1) 3 "foo" + Name 13 "MyBuffer2" + MemberName 13(MyBuffer2) 0 "mat1" + MemberName 13(MyBuffer2) 1 "vec1" + Name 14 "Example" + MemberName 14(Example) 0 "g_MyBuffer1" + MemberName 14(Example) 1 "g_MyBuffer2" + MemberName 14(Example) 2 "mat1a" + Name 16 "" + Name 37 "@entryPointOutput" + MemberDecorate 12(MyBuffer1) 0 RowMajor + MemberDecorate 12(MyBuffer1) 0 Offset 0 + MemberDecorate 12(MyBuffer1) 0 MatrixStride 16 + MemberDecorate 12(MyBuffer1) 1 ColMajor + MemberDecorate 12(MyBuffer1) 1 Offset 64 + MemberDecorate 12(MyBuffer1) 1 MatrixStride 16 + MemberDecorate 12(MyBuffer1) 2 Offset 128 + MemberDecorate 12(MyBuffer1) 3 Offset 144 + MemberDecorate 13(MyBuffer2) 0 ColMajor + MemberDecorate 13(MyBuffer2) 0 Offset 0 + MemberDecorate 13(MyBuffer2) 0 MatrixStride 16 + MemberDecorate 13(MyBuffer2) 1 Offset 64 + MemberDecorate 14(Example) 0 Offset 0 + MemberDecorate 14(Example) 1 Offset 160 + MemberDecorate 14(Example) 2 RowMajor + MemberDecorate 14(Example) 2 Offset 240 + MemberDecorate 14(Example) 2 MatrixStride 16 + Decorate 14(Example) Block + Decorate 16 DescriptorSet 0 + Decorate 37(@entryPointOutput) Location 0 + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeFloat 32 + 7: TypeVector 6(float) 4 + 8: TypeFunction 7(fvec4) + 11: TypeMatrix 7(fvec4) 4 + 12(MyBuffer1): TypeStruct 11 11 7(fvec4) 6(float) + 13(MyBuffer2): TypeStruct 11 7(fvec4) + 14(Example): TypeStruct 12(MyBuffer1) 13(MyBuffer2) 11 + 15: TypePointer Uniform 14(Example) + 16: 15(ptr) Variable Uniform + 17: TypeInt 32 1 + 18: 17(int) Constant 0 + 19: 17(int) Constant 2 + 20: TypePointer Uniform 7(fvec4) + 23: TypePointer Uniform 11 + 27: 17(int) Constant 1 + 36: TypePointer Output 7(fvec4) +37(@entryPointOutput): 36(ptr) Variable Output + 4(main): 2 Function None 3 + 5: Label + 38: 7(fvec4) FunctionCall 9(@main() + Store 37(@entryPointOutput) 38 + Return + FunctionEnd + 9(@main(): 7(fvec4) Function None 8 + 10: Label + 21: 20(ptr) AccessChain 16 18 19 + 22: 7(fvec4) Load 21 + 24: 23(ptr) AccessChain 16 18 18 + 25: 11 Load 24 + 26: 7(fvec4) VectorTimesMatrix 22 25 + 28: 20(ptr) AccessChain 16 27 27 + 29: 7(fvec4) Load 28 + 30: 23(ptr) AccessChain 16 27 18 + 31: 11 Load 30 + 32: 7(fvec4) VectorTimesMatrix 29 31 + 33: 7(fvec4) FAdd 26 32 + ReturnValue 33 + FunctionEnd diff --git a/Test/baseResults/hlsl.structIoFourWay.frag.out b/Test/baseResults/hlsl.structIoFourWay.frag.out index d88bb0921fc06a79131e8cf15dd0d90448526ac0..1b6c10d4ee1a6c3c094ad7c802d75f31a2102d1c 100755 --- a/Test/baseResults/hlsl.structIoFourWay.frag.out +++ b/Test/baseResults/hlsl.structIoFourWay.frag.out @@ -68,7 +68,7 @@ using depth_greater 0:15 3 (const int) 0:? Linker Objects 0:? 'anon@0' (layout( row_major std140) uniform block{ uniform structure{layout( offset=68) temp float f, temp float g, temp float d, temp 4-component vector of float normal} s}) -0:? 'anon@1' (layout( row_major std140) uniform block{layout( row_major std140 offset=88) uniform structure{ temp float f, temp float g, temp float d, temp 4-component vector of float normal} t}) +0:? 'anon@1' (layout( row_major std140) uniform block{layout( row_major std140 offset=88) uniform structure{layout( offset=68) temp float f, temp float g, temp float d, temp 4-component vector of float normal} t}) 0:? 'f' (layout( location=0) out float) 0:? 'g' (layout( location=1) out float) 0:? 'd' ( out float FragDepth) @@ -151,7 +151,7 @@ using depth_greater 0:15 3 (const int) 0:? Linker Objects 0:? 'anon@0' (layout( row_major std140) uniform block{ uniform structure{layout( offset=68) temp float f, temp float g, temp float d, temp 4-component vector of float normal} s}) -0:? 'anon@1' (layout( row_major std140) uniform block{layout( row_major std140 offset=88) uniform structure{ temp float f, temp float g, temp float d, temp 4-component vector of float normal} t}) +0:? 'anon@1' (layout( row_major std140) uniform block{layout( row_major std140 offset=88) uniform structure{layout( offset=68) temp float f, temp float g, temp float d, temp 4-component vector of float normal} t}) 0:? 'f' (layout( location=0) out float) 0:? 'g' (layout( location=1) out float) 0:? 'd' ( out float FragDepth) @@ -163,7 +163,7 @@ using depth_greater // Module Version 10000 // Generated by (magic number): 80001 -// Id's are bound by 66 +// Id's are bound by 65 Capability Shader 1: ExtInstImport "GLSL.std.450" @@ -200,14 +200,9 @@ using depth_greater Name 59 "$Global" MemberName 59($Global) 0 "s" Name 61 "" - Name 62 "T" - MemberName 62(T) 0 "f" - MemberName 62(T) 1 "g" - MemberName 62(T) 2 "d" - MemberName 62(T) 3 "normal" - Name 63 "buff" - MemberName 63(buff) 0 "t" - Name 65 "" + Name 62 "buff" + MemberName 62(buff) 0 "t" + Name 64 "" Decorate 22(f) Location 0 Decorate 27(g) Centroid Decorate 27(g) Location 1 @@ -224,13 +219,9 @@ using depth_greater MemberDecorate 59($Global) 0 Offset 0 Decorate 59($Global) Block Decorate 61 DescriptorSet 0 - MemberDecorate 62(T) 0 Offset 0 - MemberDecorate 62(T) 1 Offset 4 - MemberDecorate 62(T) 2 Offset 8 - MemberDecorate 62(T) 3 Offset 16 - MemberDecorate 63(buff) 0 Offset 96 - Decorate 63(buff) Block - Decorate 65 DescriptorSet 0 + MemberDecorate 62(buff) 0 Offset 96 + Decorate 62(buff) Block + Decorate 64 DescriptorSet 0 2: TypeVoid 3: TypeFunction 2 6: TypeFloat 32 @@ -261,10 +252,9 @@ using depth_greater 59($Global): TypeStruct 58(T) 60: TypePointer Uniform 59($Global) 61: 60(ptr) Variable Uniform - 62(T): TypeStruct 6(float) 6(float) 6(float) 7(fvec4) - 63(buff): TypeStruct 62(T) - 64: TypePointer Uniform 63(buff) - 65: 64(ptr) Variable Uniform + 62(buff): TypeStruct 58(T) + 63: TypePointer Uniform 62(buff) + 64: 63(ptr) Variable Uniform 4(main): 2 Function None 3 5: Label 18(t): 9(ptr) Variable Function diff --git a/Test/hlsl.matpack-1.frag b/Test/hlsl.matpack-1.frag new file mode 100644 index 0000000000000000000000000000000000000000..5d02a3e4645bd081ff3b308779cc034360732141 --- /dev/null +++ b/Test/hlsl.matpack-1.frag @@ -0,0 +1,27 @@ +struct MyBuffer1 +{ + column_major float4x4 mat1; + row_major float4x4 mat2; + float4 vec1; + float foo; +}; + +struct MyBuffer2 +{ + row_major float4x4 mat1; + float4 vec1; +}; + +cbuffer Example +{ + MyBuffer1 g_MyBuffer1; + MyBuffer2 g_MyBuffer2; + column_major float4x4 mat1a; +}; + +float4 main() : SV_Target0 +{ + return mul(g_MyBuffer1.mat1, g_MyBuffer1.vec1) + + mul(g_MyBuffer2.mat1, g_MyBuffer2.vec1); +} + diff --git a/gtests/Hlsl.FromFile.cpp b/gtests/Hlsl.FromFile.cpp index 46d8cdd4bf434798d792778e520be11c3801efb0..27593248c655230afe1c7b36a21c72086afe4b58 100644 --- a/gtests/Hlsl.FromFile.cpp +++ b/gtests/Hlsl.FromFile.cpp @@ -201,6 +201,7 @@ INSTANTIATE_TEST_CASE_P( {"hlsl.namespace.frag", "main"}, {"hlsl.nonint-index.frag", "main"}, {"hlsl.matNx1.frag", "main"}, + {"hlsl.matpack-1.frag", "main"}, {"hlsl.matrixSwizzle.vert", "ShaderFunction"}, {"hlsl.memberFunCall.frag", "main"}, {"hlsl.mintypes.frag", "main"}, diff --git a/hlsl/hlslParseHelper.cpp b/hlsl/hlslParseHelper.cpp index ceda4051d94c9cb370f806ac2e342056e6c7d4e7..4f4d87a7b1049862847a1e9495ebaa9f6fa7a7b0 100755 --- a/hlsl/hlslParseHelper.cpp +++ b/hlsl/hlslParseHelper.cpp @@ -8010,17 +8010,17 @@ void HlslParseContext::declareBlock(const TSourceLoc& loc, TType& type, const TS case EvqBuffer: correctUniform(type.getQualifier()); if (it != ioTypeMap.end() && it->second.uniform) - type.setStruct(it->second.uniform); + memberType.setStruct(it->second.uniform); break; case EvqVaryingIn: correctInput(type.getQualifier()); if (it != ioTypeMap.end() && it->second.input) - type.setStruct(it->second.input); + memberType.setStruct(it->second.input); break; case EvqVaryingOut: correctOutput(type.getQualifier()); if (it != ioTypeMap.end() && it->second.output) - type.setStruct(it->second.output); + memberType.setStruct(it->second.output); break; default: break;