diff --git a/3rdparty/glslang/SPIRV/GlslangToSpv.cpp b/3rdparty/glslang/SPIRV/GlslangToSpv.cpp index 138a2cd25..2899a741d 100755 --- a/3rdparty/glslang/SPIRV/GlslangToSpv.cpp +++ b/3rdparty/glslang/SPIRV/GlslangToSpv.cpp @@ -2822,7 +2822,7 @@ int TGlslangToSpvTraverser::getMatrixStride(const glslang::TType& matrixType, gl // 'currentOffset' should be passed in already initialized, ready to modify, and reflecting // the migration of data from nextOffset -> currentOffset. It should be -1 on the first call. // -1 means a non-forced member offset (no decoration needed). -void TGlslangToSpvTraverser::updateMemberOffset(const glslang::TType& /*structType*/, const glslang::TType& memberType, int& currentOffset, int& nextOffset, +void TGlslangToSpvTraverser::updateMemberOffset(const glslang::TType& structType, const glslang::TType& memberType, int& currentOffset, int& nextOffset, glslang::TLayoutPacking explicitLayout, glslang::TLayoutMatrix matrixLayout) { // this will get a positive value when deemed necessary @@ -2856,8 +2856,12 @@ void TGlslangToSpvTraverser::updateMemberOffset(const glslang::TType& /*structTy int memberAlignment = glslangIntermediate->getBaseAlignment(memberType, memberSize, dummyStride, explicitLayout == glslang::ElpStd140, matrixLayout == glslang::ElmRowMajor); // Adjust alignment for HLSL rules + // TODO: make this consistent in early phases of code: + // adjusting this late means inconsistencies with earlier code, which for reflection is an issue + // Until reflection is brought in sync with these adjustments, don't apply to $Global, + // which is the most likely to rely on reflection, and least likely to rely implicit layouts if (glslangIntermediate->usingHlslOFfsets() && - ! memberType.isArray() && memberType.isVector()) { + ! memberType.isArray() && memberType.isVector() && structType.getTypeName().compare("$Global") != 0) { int dummySize; int componentAlignment = glslangIntermediate->getBaseAlignmentScalar(memberType, dummySize); if (componentAlignment <= 4) diff --git a/3rdparty/glslang/StandAlone/StandAlone.cpp b/3rdparty/glslang/StandAlone/StandAlone.cpp index 1e2c8f734..1089432a3 100644 --- a/3rdparty/glslang/StandAlone/StandAlone.cpp +++ b/3rdparty/glslang/StandAlone/StandAlone.cpp @@ -176,7 +176,7 @@ public: fixLine(def); // The first "=" needs to turn into a space - int equal = def.find_first_of("="); + const size_t equal = def.find_first_of("="); if (equal != def.npos) def[equal] = ' '; @@ -197,7 +197,7 @@ protected: void fixLine(std::string& line) { // Can't go past a newline in the line - int end = line.find_first_of("\n"); + const size_t end = line.find_first_of("\n"); if (end != line.npos) line = line.substr(0, end); } diff --git a/3rdparty/glslang/Test/baseResults/hlsl.amend.frag.out b/3rdparty/glslang/Test/baseResults/hlsl.amend.frag.out index 7611af393..388d34680 100755 --- a/3rdparty/glslang/Test/baseResults/hlsl.amend.frag.out +++ b/3rdparty/glslang/Test/baseResults/hlsl.amend.frag.out @@ -184,9 +184,9 @@ gl_FragCoord origin is upper left Name 22 "" MemberDecorate 20($Global) 0 Offset 0 MemberDecorate 20($Global) 1 Offset 16 - MemberDecorate 20($Global) 2 Offset 20 - MemberDecorate 20($Global) 3 Offset 32 - MemberDecorate 20($Global) 4 Offset 36 + MemberDecorate 20($Global) 2 Offset 32 + MemberDecorate 20($Global) 3 Offset 44 + MemberDecorate 20($Global) 4 Offset 48 Decorate 20($Global) Block Decorate 22 DescriptorSet 0 2: TypeVoid diff --git a/3rdparty/glslang/Test/baseResults/hlsl.flattenOpaqueInit.vert.out b/3rdparty/glslang/Test/baseResults/hlsl.flattenOpaqueInit.vert.out new file mode 100755 index 000000000..774260fee --- /dev/null +++ b/3rdparty/glslang/Test/baseResults/hlsl.flattenOpaqueInit.vert.out @@ -0,0 +1,132 @@ +hlsl.flattenOpaqueInit.vert +Shader version: 500 +0:? Sequence +0:5 Function Definition: lookUp(struct-FxaaTex-p1-t211; ( temp 4-component vector of float) +0:5 Function Parameters: +0:? 'smpl' ( in sampler) +0:? 'tex' ( in texture2D) +0:? Sequence +0:6 Branch: Return with expression +0:6 texture ( temp 4-component vector of float) +0:6 Construct combined texture-sampler ( temp sampler2D) +0:? 'tex' ( in texture2D) +0:? 'smpl' ( in sampler) +0:? Constant: +0:? 0.300000 +0:? 0.400000 +0:10 Function Definition: @main( ( temp 4-component vector of float) +0:10 Function Parameters: +0:? Sequence +0:12 Branch: Return with expression +0:12 Function Call: lookUp(struct-FxaaTex-p1-t211; ( temp 4-component vector of float) +0:? 'g_tInputTexture_sampler' ( uniform sampler) +0:? 'g_tInputTexture' ( uniform texture2D) +0:10 Function Definition: main( ( temp void) +0:10 Function Parameters: +0:? Sequence +0:10 move second child to first child ( temp 4-component vector of float) +0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float) +0:10 Function Call: @main( ( temp 4-component vector of float) +0:? Linker Objects +0:? 'g_tInputTexture_sampler' ( uniform sampler) +0:? 'g_tInputTexture' ( uniform texture2D) +0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float) + + +Linked vertex stage: + + +Shader version: 500 +0:? Sequence +0:5 Function Definition: lookUp(struct-FxaaTex-p1-t211; ( temp 4-component vector of float) +0:5 Function Parameters: +0:? 'smpl' ( in sampler) +0:? 'tex' ( in texture2D) +0:? Sequence +0:6 Branch: Return with expression +0:6 texture ( temp 4-component vector of float) +0:6 Construct combined texture-sampler ( temp sampler2D) +0:? 'tex' ( in texture2D) +0:? 'smpl' ( in sampler) +0:? Constant: +0:? 0.300000 +0:? 0.400000 +0:10 Function Definition: @main( ( temp 4-component vector of float) +0:10 Function Parameters: +0:? Sequence +0:12 Branch: Return with expression +0:12 Function Call: lookUp(struct-FxaaTex-p1-t211; ( temp 4-component vector of float) +0:? 'g_tInputTexture_sampler' ( uniform sampler) +0:? 'g_tInputTexture' ( uniform texture2D) +0:10 Function Definition: main( ( temp void) +0:10 Function Parameters: +0:? Sequence +0:10 move second child to first child ( temp 4-component vector of float) +0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float) +0:10 Function Call: @main( ( temp 4-component vector of float) +0:? Linker Objects +0:? 'g_tInputTexture_sampler' ( uniform sampler) +0:? 'g_tInputTexture' ( uniform texture2D) +0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float) + +// Module Version 10000 +// Generated by (magic number): 80001 +// Id's are bound by 40 + + Capability Shader + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Vertex 4 "main" 38 + Source HLSL 500 + Name 4 "main" + Name 15 "lookUp(struct-FxaaTex-p1-t211;" + Name 13 "smpl" + Name 14 "tex" + Name 18 "@main(" + Name 32 "g_tInputTexture_sampler" + Name 33 "g_tInputTexture" + Name 38 "@entryPointOutput" + Decorate 32(g_tInputTexture_sampler) DescriptorSet 0 + Decorate 33(g_tInputTexture) DescriptorSet 0 + Decorate 38(@entryPointOutput) Location 0 + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeSampler + 7: TypePointer UniformConstant 6 + 8: TypeFloat 32 + 9: TypeImage 8(float) 2D sampled format:Unknown + 10: TypePointer UniformConstant 9 + 11: TypeVector 8(float) 4 + 12: TypeFunction 11(fvec4) 7(ptr) 10(ptr) + 17: TypeFunction 11(fvec4) + 22: TypeSampledImage 9 + 24: TypeVector 8(float) 2 + 25: 8(float) Constant 1050253722 + 26: 8(float) Constant 1053609165 + 27: 24(fvec2) ConstantComposite 25 26 + 28: 8(float) Constant 0 +32(g_tInputTexture_sampler): 7(ptr) Variable UniformConstant +33(g_tInputTexture): 10(ptr) Variable UniformConstant + 37: TypePointer Output 11(fvec4) +38(@entryPointOutput): 37(ptr) Variable Output + 4(main): 2 Function None 3 + 5: Label + 39: 11(fvec4) FunctionCall 18(@main() + Store 38(@entryPointOutput) 39 + Return + FunctionEnd +15(lookUp(struct-FxaaTex-p1-t211;): 11(fvec4) Function None 12 + 13(smpl): 7(ptr) FunctionParameter + 14(tex): 10(ptr) FunctionParameter + 16: Label + 20: 9 Load 14(tex) + 21: 6 Load 13(smpl) + 23: 22 SampledImage 20 21 + 29: 11(fvec4) ImageSampleExplicitLod 23 27 Lod 28 + ReturnValue 29 + FunctionEnd + 18(@main(): 11(fvec4) Function None 17 + 19: Label + 34: 11(fvec4) FunctionCall 15(lookUp(struct-FxaaTex-p1-t211;) 32(g_tInputTexture_sampler) 33(g_tInputTexture) + ReturnValue 34 + FunctionEnd diff --git a/3rdparty/glslang/Test/baseResults/hlsl.flattenOpaqueInitMix.vert.out b/3rdparty/glslang/Test/baseResults/hlsl.flattenOpaqueInitMix.vert.out new file mode 100755 index 000000000..3deaddd87 --- /dev/null +++ b/3rdparty/glslang/Test/baseResults/hlsl.flattenOpaqueInitMix.vert.out @@ -0,0 +1,159 @@ +hlsl.flattenOpaqueInitMix.vert +Shader version: 500 +0:? Sequence +0:5 Function Definition: lookUp(struct-FxaaTex-p1-t21-f11; ( temp 4-component vector of float) +0:5 Function Parameters: +0:? 'smpl' ( in sampler) +0:? 'tex' ( in texture2D) +0:? 'f' ( in float) +0:? Sequence +0:6 Branch: Return with expression +0:6 texture ( temp 4-component vector of float) +0:6 Construct combined texture-sampler ( temp sampler2D) +0:? 'tex' ( in texture2D) +0:? 'smpl' ( in sampler) +0:? Construct vec2 ( temp 2-component vector of float) +0:? 'f' ( in float) +0:? 'f' ( in float) +0:10 Function Definition: @main( ( temp 4-component vector of float) +0:10 Function Parameters: +0:? Sequence +0:11 Sequence +0:? Sequence +0:11 move second child to first child ( temp float) +0:? 'f' ( temp float) +0:11 Constant: +0:11 0.500000 +0:12 Branch: Return with expression +0:12 Function Call: lookUp(struct-FxaaTex-p1-t21-f11; ( temp 4-component vector of float) +0:? 'g_tInputTexture_sampler' ( uniform sampler) +0:? 'g_tInputTexture' ( uniform texture2D) +0:? 'f' ( temp float) +0:10 Function Definition: main( ( temp void) +0:10 Function Parameters: +0:? Sequence +0:10 move second child to first child ( temp 4-component vector of float) +0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float) +0:10 Function Call: @main( ( temp 4-component vector of float) +0:? Linker Objects +0:? 'g_tInputTexture_sampler' ( uniform sampler) +0:? 'g_tInputTexture' ( uniform texture2D) +0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float) + + +Linked vertex stage: + + +Shader version: 500 +0:? Sequence +0:5 Function Definition: lookUp(struct-FxaaTex-p1-t21-f11; ( temp 4-component vector of float) +0:5 Function Parameters: +0:? 'smpl' ( in sampler) +0:? 'tex' ( in texture2D) +0:? 'f' ( in float) +0:? Sequence +0:6 Branch: Return with expression +0:6 texture ( temp 4-component vector of float) +0:6 Construct combined texture-sampler ( temp sampler2D) +0:? 'tex' ( in texture2D) +0:? 'smpl' ( in sampler) +0:? Construct vec2 ( temp 2-component vector of float) +0:? 'f' ( in float) +0:? 'f' ( in float) +0:10 Function Definition: @main( ( temp 4-component vector of float) +0:10 Function Parameters: +0:? Sequence +0:11 Sequence +0:? Sequence +0:11 move second child to first child ( temp float) +0:? 'f' ( temp float) +0:11 Constant: +0:11 0.500000 +0:12 Branch: Return with expression +0:12 Function Call: lookUp(struct-FxaaTex-p1-t21-f11; ( temp 4-component vector of float) +0:? 'g_tInputTexture_sampler' ( uniform sampler) +0:? 'g_tInputTexture' ( uniform texture2D) +0:? 'f' ( temp float) +0:10 Function Definition: main( ( temp void) +0:10 Function Parameters: +0:? Sequence +0:10 move second child to first child ( temp 4-component vector of float) +0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float) +0:10 Function Call: @main( ( temp 4-component vector of float) +0:? Linker Objects +0:? 'g_tInputTexture_sampler' ( uniform sampler) +0:? 'g_tInputTexture' ( uniform texture2D) +0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float) + +// Module Version 10000 +// Generated by (magic number): 80001 +// Id's are bound by 46 + + Capability Shader + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Vertex 4 "main" 44 + Source HLSL 500 + Name 4 "main" + Name 17 "lookUp(struct-FxaaTex-p1-t21-f11;" + Name 14 "smpl" + Name 15 "tex" + Name 16 "f" + Name 20 "@main(" + Name 34 "f" + Name 36 "g_tInputTexture_sampler" + Name 37 "g_tInputTexture" + Name 38 "param" + Name 44 "@entryPointOutput" + Decorate 36(g_tInputTexture_sampler) DescriptorSet 0 + Decorate 37(g_tInputTexture) DescriptorSet 0 + Decorate 44(@entryPointOutput) Location 0 + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeSampler + 7: TypePointer UniformConstant 6 + 8: TypeFloat 32 + 9: TypeImage 8(float) 2D sampled format:Unknown + 10: TypePointer UniformConstant 9 + 11: TypePointer Function 8(float) + 12: TypeVector 8(float) 4 + 13: TypeFunction 12(fvec4) 7(ptr) 10(ptr) 11(ptr) + 19: TypeFunction 12(fvec4) + 24: TypeSampledImage 9 + 28: TypeVector 8(float) 2 + 30: 8(float) Constant 0 + 35: 8(float) Constant 1056964608 +36(g_tInputTexture_sampler): 7(ptr) Variable UniformConstant +37(g_tInputTexture): 10(ptr) Variable UniformConstant + 43: TypePointer Output 12(fvec4) +44(@entryPointOutput): 43(ptr) Variable Output + 4(main): 2 Function None 3 + 5: Label + 45: 12(fvec4) FunctionCall 20(@main() + Store 44(@entryPointOutput) 45 + Return + FunctionEnd +17(lookUp(struct-FxaaTex-p1-t21-f11;): 12(fvec4) Function None 13 + 14(smpl): 7(ptr) FunctionParameter + 15(tex): 10(ptr) FunctionParameter + 16(f): 11(ptr) FunctionParameter + 18: Label + 22: 9 Load 15(tex) + 23: 6 Load 14(smpl) + 25: 24 SampledImage 22 23 + 26: 8(float) Load 16(f) + 27: 8(float) Load 16(f) + 29: 28(fvec2) CompositeConstruct 26 27 + 31: 12(fvec4) ImageSampleExplicitLod 25 29 Lod 30 + ReturnValue 31 + FunctionEnd + 20(@main(): 12(fvec4) Function None 19 + 21: Label + 34(f): 11(ptr) Variable Function + 38(param): 11(ptr) Variable Function + Store 34(f) 35 + 39: 8(float) Load 34(f) + Store 38(param) 39 + 40: 12(fvec4) FunctionCall 17(lookUp(struct-FxaaTex-p1-t21-f11;) 36(g_tInputTexture_sampler) 37(g_tInputTexture) 38(param) + ReturnValue 40 + FunctionEnd diff --git a/3rdparty/glslang/Test/baseResults/hlsl.gatherRGBA.array.dx10.frag.out b/3rdparty/glslang/Test/baseResults/hlsl.gatherRGBA.array.dx10.frag.out index 03d03259f..675e17800 100644 --- a/3rdparty/glslang/Test/baseResults/hlsl.gatherRGBA.array.dx10.frag.out +++ b/3rdparty/glslang/Test/baseResults/hlsl.gatherRGBA.array.dx10.frag.out @@ -813,7 +813,7 @@ gl_FragCoord origin is upper left Decorate 20(g_sSamp) DescriptorSet 0 Decorate 20(g_sSamp) Binding 0 MemberDecorate 26($Global) 0 Offset 0 - MemberDecorate 26($Global) 1 Offset 4 + MemberDecorate 26($Global) 1 Offset 8 MemberDecorate 26($Global) 2 Offset 16 MemberDecorate 26($Global) 3 Offset 32 Decorate 26($Global) Block diff --git a/3rdparty/glslang/Test/baseResults/hlsl.gatherRGBA.basic.dx10.frag.out b/3rdparty/glslang/Test/baseResults/hlsl.gatherRGBA.basic.dx10.frag.out index c64a4e666..4d5da5215 100644 --- a/3rdparty/glslang/Test/baseResults/hlsl.gatherRGBA.basic.dx10.frag.out +++ b/3rdparty/glslang/Test/baseResults/hlsl.gatherRGBA.basic.dx10.frag.out @@ -824,7 +824,7 @@ gl_FragCoord origin is upper left Decorate 20(g_sSamp) DescriptorSet 0 Decorate 20(g_sSamp) Binding 0 MemberDecorate 26($Global) 0 Offset 0 - MemberDecorate 26($Global) 1 Offset 4 + MemberDecorate 26($Global) 1 Offset 8 MemberDecorate 26($Global) 2 Offset 16 MemberDecorate 26($Global) 3 Offset 32 Decorate 26($Global) Block diff --git a/3rdparty/glslang/Test/baseResults/hlsl.gatherRGBA.offset.dx10.frag.out b/3rdparty/glslang/Test/baseResults/hlsl.gatherRGBA.offset.dx10.frag.out index 6f6820515..a4fd588ae 100644 --- a/3rdparty/glslang/Test/baseResults/hlsl.gatherRGBA.offset.dx10.frag.out +++ b/3rdparty/glslang/Test/baseResults/hlsl.gatherRGBA.offset.dx10.frag.out @@ -1333,11 +1333,11 @@ gl_FragCoord origin is upper left Decorate 20(g_sSamp) DescriptorSet 0 Decorate 20(g_sSamp) Binding 0 MemberDecorate 30($Global) 0 Offset 0 - MemberDecorate 30($Global) 1 Offset 4 + MemberDecorate 30($Global) 1 Offset 8 MemberDecorate 30($Global) 2 Offset 16 MemberDecorate 30($Global) 3 Offset 32 MemberDecorate 30($Global) 4 Offset 48 - MemberDecorate 30($Global) 5 Offset 52 + MemberDecorate 30($Global) 5 Offset 56 MemberDecorate 30($Global) 6 Offset 64 MemberDecorate 30($Global) 7 Offset 80 Decorate 30($Global) Block diff --git a/3rdparty/glslang/Test/baseResults/hlsl.gatherRGBA.offsetarray.dx10.frag.out b/3rdparty/glslang/Test/baseResults/hlsl.gatherRGBA.offsetarray.dx10.frag.out index ef200d8a8..23d26cc8d 100644 --- a/3rdparty/glslang/Test/baseResults/hlsl.gatherRGBA.offsetarray.dx10.frag.out +++ b/3rdparty/glslang/Test/baseResults/hlsl.gatherRGBA.offsetarray.dx10.frag.out @@ -1322,11 +1322,11 @@ gl_FragCoord origin is upper left Decorate 20(g_sSamp) DescriptorSet 0 Decorate 20(g_sSamp) Binding 0 MemberDecorate 30($Global) 0 Offset 0 - MemberDecorate 30($Global) 1 Offset 4 + MemberDecorate 30($Global) 1 Offset 8 MemberDecorate 30($Global) 2 Offset 16 MemberDecorate 30($Global) 3 Offset 32 MemberDecorate 30($Global) 4 Offset 48 - MemberDecorate 30($Global) 5 Offset 52 + MemberDecorate 30($Global) 5 Offset 56 MemberDecorate 30($Global) 6 Offset 64 MemberDecorate 30($Global) 7 Offset 80 Decorate 30($Global) Block diff --git a/3rdparty/glslang/Test/baseResults/hlsl.gathercmpRGBA.offset.dx10.frag.out b/3rdparty/glslang/Test/baseResults/hlsl.gathercmpRGBA.offset.dx10.frag.out index cbbc259b8..0704ee0e0 100644 --- a/3rdparty/glslang/Test/baseResults/hlsl.gathercmpRGBA.offset.dx10.frag.out +++ b/3rdparty/glslang/Test/baseResults/hlsl.gathercmpRGBA.offset.dx10.frag.out @@ -506,7 +506,7 @@ gl_FragCoord origin is upper left Decorate 20(g_sSampCmp) DescriptorSet 0 Decorate 20(g_sSampCmp) Binding 0 MemberDecorate 27($Global) 0 Offset 0 - MemberDecorate 27($Global) 1 Offset 4 + MemberDecorate 27($Global) 1 Offset 8 MemberDecorate 27($Global) 2 Offset 16 MemberDecorate 27($Global) 3 Offset 32 Decorate 27($Global) Block diff --git a/3rdparty/glslang/Test/baseResults/hlsl.getdimensions.rw.dx10.frag.out b/3rdparty/glslang/Test/baseResults/hlsl.getdimensions.rw.dx10.frag.out index eb6a1b6b2..67b2f8f52 100644 --- a/3rdparty/glslang/Test/baseResults/hlsl.getdimensions.rw.dx10.frag.out +++ b/3rdparty/glslang/Test/baseResults/hlsl.getdimensions.rw.dx10.frag.out @@ -812,11 +812,11 @@ gl_FragCoord origin is upper left Decorate 225(g_sSamp) DescriptorSet 0 Decorate 225(g_sSamp) Binding 0 MemberDecorate 229($Global) 0 Offset 0 - MemberDecorate 229($Global) 1 Offset 4 + MemberDecorate 229($Global) 1 Offset 8 MemberDecorate 229($Global) 2 Offset 16 MemberDecorate 229($Global) 3 Offset 32 MemberDecorate 229($Global) 4 Offset 48 - MemberDecorate 229($Global) 5 Offset 52 + MemberDecorate 229($Global) 5 Offset 56 MemberDecorate 229($Global) 6 Offset 64 MemberDecorate 229($Global) 7 Offset 80 Decorate 229($Global) Block diff --git a/3rdparty/glslang/Test/baseResults/hlsl.global-const-init.frag.out b/3rdparty/glslang/Test/baseResults/hlsl.global-const-init.frag.out new file mode 100644 index 000000000..659ad53de --- /dev/null +++ b/3rdparty/glslang/Test/baseResults/hlsl.global-const-init.frag.out @@ -0,0 +1,178 @@ +hlsl.global-const-init.frag +Shader version: 500 +gl_FragCoord origin is upper left +0:? Sequence +0:6 Sequence +0:6 move second child to first child ( temp 4-component vector of float) +0:6 'bar' ( global 4-component vector of float) +0:6 foo: direct index for structure (layout( row_major std140) uniform 4-component vector of float) +0:6 'anon@0' (layout( row_major std140) uniform block{layout( row_major std140) uniform 4-component vector of float foo}) +0:6 Constant: +0:6 0 (const uint) +0:8 Sequence +0:8 move second child to first child ( temp 2-element array of 2-component vector of float) +0:8 'a1' ( global 2-element array of 2-component vector of float) +0:8 Construct vec2 ( temp 2-element array of 2-component vector of float) +0:8 Constant: +0:8 1.000000 +0:8 2.000000 +0:8 Construct vec2 ( temp 2-component vector of float) +0:8 direct index ( temp float) +0:8 foo: direct index for structure (layout( row_major std140) uniform 4-component vector of float) +0:8 'anon@0' (layout( row_major std140) uniform block{layout( row_major std140) uniform 4-component vector of float foo}) +0:8 Constant: +0:8 0 (const uint) +0:8 Constant: +0:8 0 (const int) +0:8 Constant: +0:8 4.000000 +0:12 Function Definition: @main( ( temp 4-component vector of float) +0:12 Function Parameters: +0:? Sequence +0:13 Branch: Return with expression +0:13 'bar' ( global 4-component vector of float) +0:12 Function Definition: main( ( temp void) +0:12 Function Parameters: +0:? Sequence +0:12 move second child to first child ( temp 4-component vector of float) +0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float) +0:12 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 4-component vector of float foo}) +0:? 'bar' ( global 4-component vector of float) +0:? 'a1' ( global 2-element array of 2-component vector of float) +0:? 'a2' ( const 2-element array of 2-component vector of float) +0:? 5.000000 +0:? 6.000000 +0:? 7.000000 +0:? 8.000000 +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:6 Sequence +0:6 move second child to first child ( temp 4-component vector of float) +0:6 'bar' ( global 4-component vector of float) +0:6 foo: direct index for structure (layout( row_major std140) uniform 4-component vector of float) +0:6 'anon@0' (layout( row_major std140) uniform block{layout( row_major std140) uniform 4-component vector of float foo}) +0:6 Constant: +0:6 0 (const uint) +0:8 Sequence +0:8 move second child to first child ( temp 2-element array of 2-component vector of float) +0:8 'a1' ( global 2-element array of 2-component vector of float) +0:8 Construct vec2 ( temp 2-element array of 2-component vector of float) +0:8 Constant: +0:8 1.000000 +0:8 2.000000 +0:8 Construct vec2 ( temp 2-component vector of float) +0:8 direct index ( temp float) +0:8 foo: direct index for structure (layout( row_major std140) uniform 4-component vector of float) +0:8 'anon@0' (layout( row_major std140) uniform block{layout( row_major std140) uniform 4-component vector of float foo}) +0:8 Constant: +0:8 0 (const uint) +0:8 Constant: +0:8 0 (const int) +0:8 Constant: +0:8 4.000000 +0:12 Function Definition: @main( ( temp 4-component vector of float) +0:12 Function Parameters: +0:? Sequence +0:13 Branch: Return with expression +0:13 'bar' ( global 4-component vector of float) +0:12 Function Definition: main( ( temp void) +0:12 Function Parameters: +0:? Sequence +0:12 move second child to first child ( temp 4-component vector of float) +0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float) +0:12 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 4-component vector of float foo}) +0:? 'bar' ( global 4-component vector of float) +0:? 'a1' ( global 2-element array of 2-component vector of float) +0:? 'a2' ( const 2-element array of 2-component vector of float) +0:? 5.000000 +0:? 6.000000 +0:? 7.000000 +0:? 8.000000 +0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float) + +// Module Version 10000 +// Generated by (magic number): 80001 +// Id's are bound by 50 + + Capability Shader + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Fragment 4 "main" 41 + ExecutionMode 4 OriginUpperLeft + Source HLSL 500 + Name 4 "main" + Name 9 "@main(" + Name 12 "bar" + Name 13 "CB" + MemberName 13(CB) 0 "foo" + Name 15 "" + Name 26 "a1" + Name 41 "@entryPointOutput" + MemberDecorate 13(CB) 0 Offset 0 + Decorate 13(CB) Block + Decorate 15 DescriptorSet 0 + Decorate 41(@entryPointOutput) Location 0 + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeFloat 32 + 7: TypeVector 6(float) 4 + 8: TypeFunction 7(fvec4) + 11: TypePointer Private 7(fvec4) + 12(bar): 11(ptr) Variable Private + 13(CB): TypeStruct 7(fvec4) + 14: TypePointer Uniform 13(CB) + 15: 14(ptr) Variable Uniform + 16: TypeInt 32 1 + 17: 16(int) Constant 0 + 18: TypePointer Uniform 7(fvec4) + 21: TypeVector 6(float) 2 + 22: TypeInt 32 0 + 23: 22(int) Constant 2 + 24: TypeArray 21(fvec2) 23 + 25: TypePointer Private 24 + 26(a1): 25(ptr) Variable Private + 27: 6(float) Constant 1065353216 + 28: 6(float) Constant 1073741824 + 29: 21(fvec2) ConstantComposite 27 28 + 30: 22(int) Constant 0 + 31: TypePointer Uniform 6(float) + 34: 6(float) Constant 1082130432 + 40: TypePointer Output 7(fvec4) +41(@entryPointOutput): 40(ptr) Variable Output + 43: 6(float) Constant 1084227584 + 44: 6(float) Constant 1086324736 + 45: 21(fvec2) ConstantComposite 43 44 + 46: 6(float) Constant 1088421888 + 47: 6(float) Constant 1090519040 + 48: 21(fvec2) ConstantComposite 46 47 + 49: 24 ConstantComposite 45 48 + 4(main): 2 Function None 3 + 5: Label + 19: 18(ptr) AccessChain 15 17 + 20: 7(fvec4) Load 19 + Store 12(bar) 20 + 32: 31(ptr) AccessChain 15 17 30 + 33: 6(float) Load 32 + 35: 21(fvec2) CompositeConstruct 33 34 + 36: 24 CompositeConstruct 29 35 + Store 26(a1) 36 + 42: 7(fvec4) FunctionCall 9(@main() + Store 41(@entryPointOutput) 42 + Return + FunctionEnd + 9(@main(): 7(fvec4) Function None 8 + 10: Label + 37: 7(fvec4) Load 12(bar) + ReturnValue 37 + FunctionEnd diff --git a/3rdparty/glslang/Test/baseResults/hlsl.implicitBool.frag.out b/3rdparty/glslang/Test/baseResults/hlsl.implicitBool.frag.out index 476769bf6..3eb559b4a 100755 --- a/3rdparty/glslang/Test/baseResults/hlsl.implicitBool.frag.out +++ b/3rdparty/glslang/Test/baseResults/hlsl.implicitBool.frag.out @@ -358,8 +358,8 @@ gl_FragCoord origin is upper left Name 138 "@entryPointOutput" MemberDecorate 16($Global) 0 Offset 0 MemberDecorate 16($Global) 1 Offset 4 - MemberDecorate 16($Global) 2 Offset 8 - MemberDecorate 16($Global) 3 Offset 12 + MemberDecorate 16($Global) 2 Offset 16 + MemberDecorate 16($Global) 3 Offset 32 Decorate 16($Global) Block Decorate 18 DescriptorSet 0 Decorate 138(@entryPointOutput) Location 0 diff --git a/3rdparty/glslang/Test/baseResults/hlsl.isfinite.frag.out b/3rdparty/glslang/Test/baseResults/hlsl.isfinite.frag.out index 3850be9e6..7eebb85f3 100644 --- a/3rdparty/glslang/Test/baseResults/hlsl.isfinite.frag.out +++ b/3rdparty/glslang/Test/baseResults/hlsl.isfinite.frag.out @@ -196,7 +196,7 @@ gl_FragCoord origin is upper left Name 65 "@finitetmp" Name 83 "@entryPointOutput" MemberDecorate 35($Global) 0 Offset 0 - MemberDecorate 35($Global) 1 Offset 4 + MemberDecorate 35($Global) 1 Offset 8 MemberDecorate 35($Global) 2 Offset 16 Decorate 35($Global) Block Decorate 37 DescriptorSet 0 diff --git a/3rdparty/glslang/Test/baseResults/hlsl.load.2dms.dx10.frag.out b/3rdparty/glslang/Test/baseResults/hlsl.load.2dms.dx10.frag.out index 712541ae6..251d56ed5 100644 --- a/3rdparty/glslang/Test/baseResults/hlsl.load.2dms.dx10.frag.out +++ b/3rdparty/glslang/Test/baseResults/hlsl.load.2dms.dx10.frag.out @@ -395,11 +395,11 @@ gl_FragCoord origin is upper left Name 129 "g_sSamp" Decorate 14(g_tTex2dmsf4) DescriptorSet 0 MemberDecorate 20($Global) 0 Offset 0 - MemberDecorate 20($Global) 1 Offset 4 + MemberDecorate 20($Global) 1 Offset 8 MemberDecorate 20($Global) 2 Offset 16 MemberDecorate 20($Global) 3 Offset 32 MemberDecorate 20($Global) 4 Offset 48 - MemberDecorate 20($Global) 5 Offset 52 + MemberDecorate 20($Global) 5 Offset 56 MemberDecorate 20($Global) 6 Offset 64 MemberDecorate 20($Global) 7 Offset 80 Decorate 20($Global) Block diff --git a/3rdparty/glslang/Test/baseResults/hlsl.load.array.dx10.frag.out b/3rdparty/glslang/Test/baseResults/hlsl.load.array.dx10.frag.out index dfd9a1560..78e2b2c36 100644 --- a/3rdparty/glslang/Test/baseResults/hlsl.load.array.dx10.frag.out +++ b/3rdparty/glslang/Test/baseResults/hlsl.load.array.dx10.frag.out @@ -440,11 +440,11 @@ gl_FragCoord origin is upper left Name 158 "g_tTexcdu4a" Decorate 14(g_tTex1df4a) DescriptorSet 0 MemberDecorate 20($Global) 0 Offset 0 - MemberDecorate 20($Global) 1 Offset 4 + MemberDecorate 20($Global) 1 Offset 8 MemberDecorate 20($Global) 2 Offset 16 MemberDecorate 20($Global) 3 Offset 32 MemberDecorate 20($Global) 4 Offset 48 - MemberDecorate 20($Global) 5 Offset 52 + MemberDecorate 20($Global) 5 Offset 56 MemberDecorate 20($Global) 6 Offset 64 MemberDecorate 20($Global) 7 Offset 80 Decorate 20($Global) Block diff --git a/3rdparty/glslang/Test/baseResults/hlsl.load.basic.dx10.frag.out b/3rdparty/glslang/Test/baseResults/hlsl.load.basic.dx10.frag.out index 53b94c1e0..0da4048ae 100644 --- a/3rdparty/glslang/Test/baseResults/hlsl.load.basic.dx10.frag.out +++ b/3rdparty/glslang/Test/baseResults/hlsl.load.basic.dx10.frag.out @@ -543,11 +543,11 @@ gl_FragCoord origin is upper left Decorate 14(g_tTex1df4) DescriptorSet 0 Decorate 14(g_tTex1df4) Binding 0 MemberDecorate 20($Global) 0 Offset 0 - MemberDecorate 20($Global) 1 Offset 4 + MemberDecorate 20($Global) 1 Offset 8 MemberDecorate 20($Global) 2 Offset 16 MemberDecorate 20($Global) 3 Offset 32 MemberDecorate 20($Global) 4 Offset 48 - MemberDecorate 20($Global) 5 Offset 52 + MemberDecorate 20($Global) 5 Offset 56 MemberDecorate 20($Global) 6 Offset 64 MemberDecorate 20($Global) 7 Offset 80 Decorate 20($Global) Block diff --git a/3rdparty/glslang/Test/baseResults/hlsl.load.basic.dx10.vert.out b/3rdparty/glslang/Test/baseResults/hlsl.load.basic.dx10.vert.out index 3893232b0..c3b7dc218 100644 --- a/3rdparty/glslang/Test/baseResults/hlsl.load.basic.dx10.vert.out +++ b/3rdparty/glslang/Test/baseResults/hlsl.load.basic.dx10.vert.out @@ -505,11 +505,11 @@ Shader version: 500 Decorate 14(g_tTex1df4) DescriptorSet 0 Decorate 14(g_tTex1df4) Binding 0 MemberDecorate 20($Global) 0 Offset 0 - MemberDecorate 20($Global) 1 Offset 4 + MemberDecorate 20($Global) 1 Offset 8 MemberDecorate 20($Global) 2 Offset 16 MemberDecorate 20($Global) 3 Offset 32 MemberDecorate 20($Global) 4 Offset 48 - MemberDecorate 20($Global) 5 Offset 52 + MemberDecorate 20($Global) 5 Offset 56 MemberDecorate 20($Global) 6 Offset 64 MemberDecorate 20($Global) 7 Offset 80 Decorate 20($Global) Block diff --git a/3rdparty/glslang/Test/baseResults/hlsl.load.buffer.dx10.frag.out b/3rdparty/glslang/Test/baseResults/hlsl.load.buffer.dx10.frag.out index 3512a99bd..e68e5f961 100644 --- a/3rdparty/glslang/Test/baseResults/hlsl.load.buffer.dx10.frag.out +++ b/3rdparty/glslang/Test/baseResults/hlsl.load.buffer.dx10.frag.out @@ -202,11 +202,11 @@ gl_FragCoord origin is upper left Name 71 "g_tTexbf4_test" Decorate 16(g_tTexbf4) DescriptorSet 0 MemberDecorate 22($Global) 0 Offset 0 - MemberDecorate 22($Global) 1 Offset 4 + MemberDecorate 22($Global) 1 Offset 8 MemberDecorate 22($Global) 2 Offset 16 MemberDecorate 22($Global) 3 Offset 32 MemberDecorate 22($Global) 4 Offset 48 - MemberDecorate 22($Global) 5 Offset 52 + MemberDecorate 22($Global) 5 Offset 56 MemberDecorate 22($Global) 6 Offset 64 MemberDecorate 22($Global) 7 Offset 80 Decorate 22($Global) Block diff --git a/3rdparty/glslang/Test/baseResults/hlsl.load.buffer.float.dx10.frag.out b/3rdparty/glslang/Test/baseResults/hlsl.load.buffer.float.dx10.frag.out index 5718b8189..ff686a316 100644 --- a/3rdparty/glslang/Test/baseResults/hlsl.load.buffer.float.dx10.frag.out +++ b/3rdparty/glslang/Test/baseResults/hlsl.load.buffer.float.dx10.frag.out @@ -208,11 +208,11 @@ gl_FragCoord origin is upper left Name 74 "g_tTexbfs_test" Decorate 16(g_tTexbfs) DescriptorSet 0 MemberDecorate 22($Global) 0 Offset 0 - MemberDecorate 22($Global) 1 Offset 4 + MemberDecorate 22($Global) 1 Offset 8 MemberDecorate 22($Global) 2 Offset 16 MemberDecorate 22($Global) 3 Offset 32 MemberDecorate 22($Global) 4 Offset 48 - MemberDecorate 22($Global) 5 Offset 52 + MemberDecorate 22($Global) 5 Offset 56 MemberDecorate 22($Global) 6 Offset 64 MemberDecorate 22($Global) 7 Offset 80 Decorate 22($Global) Block diff --git a/3rdparty/glslang/Test/baseResults/hlsl.load.offset.dx10.frag.out b/3rdparty/glslang/Test/baseResults/hlsl.load.offset.dx10.frag.out index 54b03dea3..473db6168 100644 --- a/3rdparty/glslang/Test/baseResults/hlsl.load.offset.dx10.frag.out +++ b/3rdparty/glslang/Test/baseResults/hlsl.load.offset.dx10.frag.out @@ -616,11 +616,11 @@ gl_FragCoord origin is upper left Decorate 14(g_tTex1df4) DescriptorSet 0 Decorate 14(g_tTex1df4) Binding 0 MemberDecorate 20($Global) 0 Offset 0 - MemberDecorate 20($Global) 1 Offset 4 + MemberDecorate 20($Global) 1 Offset 8 MemberDecorate 20($Global) 2 Offset 16 MemberDecorate 20($Global) 3 Offset 32 MemberDecorate 20($Global) 4 Offset 48 - MemberDecorate 20($Global) 5 Offset 52 + MemberDecorate 20($Global) 5 Offset 56 MemberDecorate 20($Global) 6 Offset 64 MemberDecorate 20($Global) 7 Offset 80 Decorate 20($Global) Block diff --git a/3rdparty/glslang/Test/baseResults/hlsl.load.offsetarray.dx10.frag.out b/3rdparty/glslang/Test/baseResults/hlsl.load.offsetarray.dx10.frag.out index fc2f09c79..4b6a09f02 100644 --- a/3rdparty/glslang/Test/baseResults/hlsl.load.offsetarray.dx10.frag.out +++ b/3rdparty/glslang/Test/baseResults/hlsl.load.offsetarray.dx10.frag.out @@ -489,11 +489,11 @@ gl_FragCoord origin is upper left Name 173 "g_tTexcdu4a" Decorate 14(g_tTex1df4a) DescriptorSet 0 MemberDecorate 20($Global) 0 Offset 0 - MemberDecorate 20($Global) 1 Offset 4 + MemberDecorate 20($Global) 1 Offset 8 MemberDecorate 20($Global) 2 Offset 16 MemberDecorate 20($Global) 3 Offset 32 MemberDecorate 20($Global) 4 Offset 48 - MemberDecorate 20($Global) 5 Offset 52 + MemberDecorate 20($Global) 5 Offset 56 MemberDecorate 20($Global) 6 Offset 64 MemberDecorate 20($Global) 7 Offset 80 Decorate 20($Global) Block diff --git a/3rdparty/glslang/Test/baseResults/hlsl.load.rwbuffer.dx10.frag.out b/3rdparty/glslang/Test/baseResults/hlsl.load.rwbuffer.dx10.frag.out index 048b5e64d..3e748cc2f 100644 --- a/3rdparty/glslang/Test/baseResults/hlsl.load.rwbuffer.dx10.frag.out +++ b/3rdparty/glslang/Test/baseResults/hlsl.load.rwbuffer.dx10.frag.out @@ -141,11 +141,11 @@ gl_FragCoord origin is upper left Name 54 "Color" Decorate 14(g_tBuffF) DescriptorSet 0 MemberDecorate 20($Global) 0 Offset 0 - MemberDecorate 20($Global) 1 Offset 4 + MemberDecorate 20($Global) 1 Offset 8 MemberDecorate 20($Global) 2 Offset 16 MemberDecorate 20($Global) 3 Offset 32 MemberDecorate 20($Global) 4 Offset 48 - MemberDecorate 20($Global) 5 Offset 52 + MemberDecorate 20($Global) 5 Offset 56 MemberDecorate 20($Global) 6 Offset 64 MemberDecorate 20($Global) 7 Offset 80 Decorate 20($Global) Block diff --git a/3rdparty/glslang/Test/baseResults/hlsl.load.rwtexture.array.dx10.frag.out b/3rdparty/glslang/Test/baseResults/hlsl.load.rwtexture.array.dx10.frag.out index a5c818d60..884ed8f66 100644 --- a/3rdparty/glslang/Test/baseResults/hlsl.load.rwtexture.array.dx10.frag.out +++ b/3rdparty/glslang/Test/baseResults/hlsl.load.rwtexture.array.dx10.frag.out @@ -253,11 +253,11 @@ gl_FragCoord origin is upper left Name 118 "g_tTex3du4" Decorate 14(g_tTex1df4a) DescriptorSet 0 MemberDecorate 20($Global) 0 Offset 0 - MemberDecorate 20($Global) 1 Offset 4 + MemberDecorate 20($Global) 1 Offset 8 MemberDecorate 20($Global) 2 Offset 16 MemberDecorate 20($Global) 3 Offset 32 MemberDecorate 20($Global) 4 Offset 48 - MemberDecorate 20($Global) 5 Offset 52 + MemberDecorate 20($Global) 5 Offset 56 MemberDecorate 20($Global) 6 Offset 64 MemberDecorate 20($Global) 7 Offset 80 Decorate 20($Global) Block diff --git a/3rdparty/glslang/Test/baseResults/hlsl.load.rwtexture.dx10.frag.out b/3rdparty/glslang/Test/baseResults/hlsl.load.rwtexture.dx10.frag.out index 6e3e5cee0..306186710 100644 --- a/3rdparty/glslang/Test/baseResults/hlsl.load.rwtexture.dx10.frag.out +++ b/3rdparty/glslang/Test/baseResults/hlsl.load.rwtexture.dx10.frag.out @@ -290,11 +290,11 @@ gl_FragCoord origin is upper left Decorate 14(g_tTex1df4) DescriptorSet 0 Decorate 14(g_tTex1df4) Binding 0 MemberDecorate 20($Global) 0 Offset 0 - MemberDecorate 20($Global) 1 Offset 4 + MemberDecorate 20($Global) 1 Offset 8 MemberDecorate 20($Global) 2 Offset 16 MemberDecorate 20($Global) 3 Offset 32 MemberDecorate 20($Global) 4 Offset 48 - MemberDecorate 20($Global) 5 Offset 52 + MemberDecorate 20($Global) 5 Offset 56 MemberDecorate 20($Global) 6 Offset 64 MemberDecorate 20($Global) 7 Offset 80 Decorate 20($Global) Block diff --git a/3rdparty/glslang/Test/baseResults/hlsl.rw.atomics.frag.out b/3rdparty/glslang/Test/baseResults/hlsl.rw.atomics.frag.out index 00301bebd..08369c0ec 100644 --- a/3rdparty/glslang/Test/baseResults/hlsl.rw.atomics.frag.out +++ b/3rdparty/glslang/Test/baseResults/hlsl.rw.atomics.frag.out @@ -3998,7 +3998,7 @@ gl_FragCoord origin is upper left Name 1146 "g_tBuffF" Decorate 15(g_tTex1di1) DescriptorSet 0 MemberDecorate 21($Global) 0 Offset 0 - MemberDecorate 21($Global) 1 Offset 4 + MemberDecorate 21($Global) 1 Offset 8 MemberDecorate 21($Global) 2 Offset 16 MemberDecorate 21($Global) 3 Offset 28 MemberDecorate 21($Global) 4 Offset 32 diff --git a/3rdparty/glslang/Test/baseResults/hlsl.rw.bracket.frag.out b/3rdparty/glslang/Test/baseResults/hlsl.rw.bracket.frag.out index fdb906aac..55264de91 100644 --- a/3rdparty/glslang/Test/baseResults/hlsl.rw.bracket.frag.out +++ b/3rdparty/glslang/Test/baseResults/hlsl.rw.bracket.frag.out @@ -1881,11 +1881,11 @@ gl_FragCoord origin is upper left Name 603 "g_tTex2di4a" Name 606 "g_tTex2du4a" MemberDecorate 63($Global) 0 Offset 0 - MemberDecorate 63($Global) 1 Offset 4 + MemberDecorate 63($Global) 1 Offset 8 MemberDecorate 63($Global) 2 Offset 16 MemberDecorate 63($Global) 3 Offset 32 MemberDecorate 63($Global) 4 Offset 48 - MemberDecorate 63($Global) 5 Offset 52 + MemberDecorate 63($Global) 5 Offset 56 MemberDecorate 63($Global) 6 Offset 64 MemberDecorate 63($Global) 7 Offset 80 MemberDecorate 63($Global) 8 Offset 96 diff --git a/3rdparty/glslang/Test/baseResults/hlsl.rw.scalar.bracket.frag.out b/3rdparty/glslang/Test/baseResults/hlsl.rw.scalar.bracket.frag.out index 38cfa8f24..e0e88d18c 100644 --- a/3rdparty/glslang/Test/baseResults/hlsl.rw.scalar.bracket.frag.out +++ b/3rdparty/glslang/Test/baseResults/hlsl.rw.scalar.bracket.frag.out @@ -1827,11 +1827,11 @@ gl_FragCoord origin is upper left Name 567 "g_tTex2di1a" Name 570 "g_tTex2du1a" MemberDecorate 59($Global) 0 Offset 0 - MemberDecorate 59($Global) 1 Offset 4 + MemberDecorate 59($Global) 1 Offset 8 MemberDecorate 59($Global) 2 Offset 16 MemberDecorate 59($Global) 3 Offset 32 MemberDecorate 59($Global) 4 Offset 48 - MemberDecorate 59($Global) 5 Offset 52 + MemberDecorate 59($Global) 5 Offset 56 MemberDecorate 59($Global) 6 Offset 64 MemberDecorate 59($Global) 7 Offset 80 MemberDecorate 59($Global) 8 Offset 96 diff --git a/3rdparty/glslang/Test/baseResults/hlsl.rw.vec2.bracket.frag.out b/3rdparty/glslang/Test/baseResults/hlsl.rw.vec2.bracket.frag.out index 151380acd..afcc52a57 100644 --- a/3rdparty/glslang/Test/baseResults/hlsl.rw.vec2.bracket.frag.out +++ b/3rdparty/glslang/Test/baseResults/hlsl.rw.vec2.bracket.frag.out @@ -1846,11 +1846,11 @@ gl_FragCoord origin is upper left Name 601 "g_tTex2di2a" Name 604 "g_tTex2du2a" MemberDecorate 64($Global) 0 Offset 0 - MemberDecorate 64($Global) 1 Offset 4 + MemberDecorate 64($Global) 1 Offset 8 MemberDecorate 64($Global) 2 Offset 16 MemberDecorate 64($Global) 3 Offset 32 MemberDecorate 64($Global) 4 Offset 48 - MemberDecorate 64($Global) 5 Offset 52 + MemberDecorate 64($Global) 5 Offset 56 MemberDecorate 64($Global) 6 Offset 64 MemberDecorate 64($Global) 7 Offset 80 MemberDecorate 64($Global) 8 Offset 96 diff --git a/3rdparty/glslang/Test/baseResults/hlsl.tx.bracket.frag.out b/3rdparty/glslang/Test/baseResults/hlsl.tx.bracket.frag.out index 0ea9c684d..12d5f178e 100644 --- a/3rdparty/glslang/Test/baseResults/hlsl.tx.bracket.frag.out +++ b/3rdparty/glslang/Test/baseResults/hlsl.tx.bracket.frag.out @@ -484,11 +484,11 @@ gl_FragCoord origin is upper left Name 184 "g_tTex2di4a" Name 187 "g_tTex2du4a" MemberDecorate 45($Global) 0 Offset 0 - MemberDecorate 45($Global) 1 Offset 4 + MemberDecorate 45($Global) 1 Offset 8 MemberDecorate 45($Global) 2 Offset 16 MemberDecorate 45($Global) 3 Offset 32 MemberDecorate 45($Global) 4 Offset 48 - MemberDecorate 45($Global) 5 Offset 52 + MemberDecorate 45($Global) 5 Offset 56 MemberDecorate 45($Global) 6 Offset 64 MemberDecorate 45($Global) 7 Offset 80 Decorate 45($Global) Block diff --git a/3rdparty/glslang/Test/baseResults/spv.noBuiltInLoc.vert.out b/3rdparty/glslang/Test/baseResults/spv.noBuiltInLoc.vert.out new file mode 100644 index 000000000..3d980bf0f --- /dev/null +++ b/3rdparty/glslang/Test/baseResults/spv.noBuiltInLoc.vert.out @@ -0,0 +1,51 @@ +spv.noBuiltInLoc.vert +// Module Version 10000 +// Generated by (magic number): 80001 +// Id's are bound by 23 + + Capability Shader + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Vertex 4 "main" 9 11 18 + Source GLSL 450 + Name 4 "main" + Name 9 "bar" + Name 11 "foo" + Name 16 "gl_PerVertex" + MemberName 16(gl_PerVertex) 0 "gl_Position" + MemberName 16(gl_PerVertex) 1 "gl_PointSize" + MemberName 16(gl_PerVertex) 2 "gl_ClipDistance" + MemberName 16(gl_PerVertex) 3 "gl_CullDistance" + Name 18 "" + Decorate 9(bar) Location 0 + Decorate 11(foo) Location 0 + MemberDecorate 16(gl_PerVertex) 0 BuiltIn Position + MemberDecorate 16(gl_PerVertex) 1 BuiltIn PointSize + MemberDecorate 16(gl_PerVertex) 2 BuiltIn ClipDistance + MemberDecorate 16(gl_PerVertex) 3 BuiltIn CullDistance + Decorate 16(gl_PerVertex) Block + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeFloat 32 + 7: TypeVector 6(float) 4 + 8: TypePointer Output 7(fvec4) + 9(bar): 8(ptr) Variable Output + 10: TypePointer Input 7(fvec4) + 11(foo): 10(ptr) Variable Input + 13: TypeInt 32 0 + 14: 13(int) Constant 1 + 15: TypeArray 6(float) 14 +16(gl_PerVertex): TypeStruct 7(fvec4) 6(float) 15 15 + 17: TypePointer Output 16(gl_PerVertex) + 18: 17(ptr) Variable Output + 19: TypeInt 32 1 + 20: 19(int) Constant 0 + 4(main): 2 Function None 3 + 5: Label + 12: 7(fvec4) Load 11(foo) + Store 9(bar) 12 + 21: 7(fvec4) Load 11(foo) + 22: 8(ptr) AccessChain 18 20 + Store 22 21 + Return + FunctionEnd diff --git a/3rdparty/glslang/Test/hlsl.flattenOpaqueInit.vert b/3rdparty/glslang/Test/hlsl.flattenOpaqueInit.vert new file mode 100644 index 000000000..5efb02edc --- /dev/null +++ b/3rdparty/glslang/Test/hlsl.flattenOpaqueInit.vert @@ -0,0 +1,13 @@ +struct FxaaTex { SamplerState smpl; Texture2D tex; }; +SamplerState g_tInputTexture_sampler; Texture2D g_tInputTexture; + +float4 lookUp(FxaaTex tex) +{ + return tex.tex.Sample(tex.smpl, float2(0.3, 0.4)); +} + +float4 main() : SV_TARGET0 +{ + FxaaTex tex = { g_tInputTexture_sampler, g_tInputTexture }; + return lookUp(tex); +} \ No newline at end of file diff --git a/3rdparty/glslang/Test/hlsl.flattenOpaqueInitMix.vert b/3rdparty/glslang/Test/hlsl.flattenOpaqueInitMix.vert new file mode 100644 index 000000000..2e712ee5b --- /dev/null +++ b/3rdparty/glslang/Test/hlsl.flattenOpaqueInitMix.vert @@ -0,0 +1,13 @@ +struct FxaaTex { SamplerState smpl; Texture2D tex; float f; }; +SamplerState g_tInputTexture_sampler; Texture2D g_tInputTexture; + +float4 lookUp(FxaaTex tex) +{ + return tex.tex.Sample(tex.smpl, float2(tex.f, tex.f)); +} + +float4 main() : SV_TARGET0 +{ + FxaaTex tex = { g_tInputTexture_sampler, g_tInputTexture, 0.5 }; + return lookUp(tex); +} \ No newline at end of file diff --git a/3rdparty/glslang/Test/hlsl.global-const-init.frag b/3rdparty/glslang/Test/hlsl.global-const-init.frag new file mode 100644 index 000000000..d8f36c966 --- /dev/null +++ b/3rdparty/glslang/Test/hlsl.global-const-init.frag @@ -0,0 +1,14 @@ + +cbuffer CB { + float4 foo; +}; + +static const float4 bar = foo; // test const (in the immutable sense) initializer from non-const. + +static const float2 a1[2] = { { 1, 2 }, { foo.x, 4 } }; // not entirely constant +static const float2 a2[2] = { { 5, 6 }, { 7, 8 } }; // entirely constant + +float4 main() : SV_Target0 +{ + return bar; +} diff --git a/3rdparty/glslang/Test/runtests b/3rdparty/glslang/Test/runtests index 29a208333..2a8542f49 100755 --- a/3rdparty/glslang/Test/runtests +++ b/3rdparty/glslang/Test/runtests @@ -103,6 +103,8 @@ diff -b $BASEDIR/hlsl.multiDescriptorSet.frag.out $TARGETDIR/hlsl.multiDescripto echo Testing SPV no location $EXE -V -C spv.noLocation.vert > $TARGETDIR/spv.noLocation.vert.out diff -b $BASEDIR/spv.noLocation.vert.out $TARGETDIR/spv.noLocation.vert.out || HASERROR=1 +$EXE -H --aml spv.noBuiltInLoc.vert > $TARGETDIR/spv.noBuiltInLoc.vert.out +diff -b $BASEDIR/spv.noBuiltInLoc.vert.out $TARGETDIR/spv.noBuiltInLoc.vert.out || HASERROR=1 # # Testing debug information diff --git a/3rdparty/glslang/Test/spv.noBuiltInLoc.vert b/3rdparty/glslang/Test/spv.noBuiltInLoc.vert new file mode 100644 index 000000000..e75489272 --- /dev/null +++ b/3rdparty/glslang/Test/spv.noBuiltInLoc.vert @@ -0,0 +1,13 @@ +#version 450 core + +layout(location = 0) +in vec4 foo; + +layout(location = 0) +out vec4 bar; + +void main() +{ + bar = foo; + gl_Position = foo; +} \ No newline at end of file diff --git a/3rdparty/glslang/glslang/MachineIndependent/ParseHelper.cpp b/3rdparty/glslang/glslang/MachineIndependent/ParseHelper.cpp index 46ddee860..1d56c1fa8 100644 --- a/3rdparty/glslang/glslang/MachineIndependent/ParseHelper.cpp +++ b/3rdparty/glslang/glslang/MachineIndependent/ParseHelper.cpp @@ -1386,7 +1386,6 @@ void TParseContext::builtInOpCheck(const TSourceLoc& loc, const TFunction& fnCan unaryArg = callNode.getAsUnaryNode()->getOperand(); arg0 = unaryArg; } - const TIntermSequence& aggArgs = *argp; // only valid when unaryArg is nullptr switch (callNode.getOp()) { case EOpTextureGather: @@ -1417,7 +1416,7 @@ void TParseContext::builtInOpCheck(const TSourceLoc& loc, const TFunction& fnCan profileRequires(loc, ~EEsProfile, 400, E_GL_ARB_texture_gather, feature); else profileRequires(loc, ~EEsProfile, 400, E_GL_ARB_gpu_shader5, feature); - if (! aggArgs[fnCandidate[0].type->getSampler().shadow ? 3 : 2]->getAsConstantUnion()) + if (! (*argp)[fnCandidate[0].type->getSampler().shadow ? 3 : 2]->getAsConstantUnion()) profileRequires(loc, EEsProfile, 0, Num_AEP_gpu_shader5, AEP_gpu_shader5, "non-constant offset argument"); if (! fnCandidate[0].type->getSampler().shadow) compArg = 3; @@ -1427,7 +1426,7 @@ void TParseContext::builtInOpCheck(const TSourceLoc& loc, const TFunction& fnCan if (! fnCandidate[0].type->getSampler().shadow) compArg = 3; // check for constant offsets - if (! aggArgs[fnCandidate[0].type->getSampler().shadow ? 3 : 2]->getAsConstantUnion()) + if (! (*argp)[fnCandidate[0].type->getSampler().shadow ? 3 : 2]->getAsConstantUnion()) error(loc, "must be a compile-time constant:", feature, "offsets argument"); break; default: @@ -1435,8 +1434,8 @@ void TParseContext::builtInOpCheck(const TSourceLoc& loc, const TFunction& fnCan } if (compArg > 0 && compArg < fnCandidate.getParamCount()) { - if (aggArgs[compArg]->getAsConstantUnion()) { - int value = aggArgs[compArg]->getAsConstantUnion()->getConstArray()[0].getIConst(); + if ((*argp)[compArg]->getAsConstantUnion()) { + int value = (*argp)[compArg]->getAsConstantUnion()->getConstArray()[0].getIConst(); if (value < 0 || value > 3) error(loc, "must be 0, 1, 2, or 3:", feature, "component argument"); } else @@ -1518,12 +1517,12 @@ void TParseContext::builtInOpCheck(const TSourceLoc& loc, const TFunction& fnCan } if (arg > 0) { - if (! aggArgs[arg]->getAsConstantUnion()) + if (! (*argp)[arg]->getAsConstantUnion()) error(loc, "argument must be compile-time constant", "texel offset", ""); else { - const TType& type = aggArgs[arg]->getAsTyped()->getType(); + const TType& type = (*argp)[arg]->getAsTyped()->getType(); for (int c = 0; c < type.getVectorSize(); ++c) { - int offset = aggArgs[arg]->getAsConstantUnion()->getConstArray()[c].getIConst(); + int offset = (*argp)[arg]->getAsConstantUnion()->getConstArray()[c].getIConst(); if (offset > resources.maxProgramTexelOffset || offset < resources.minProgramTexelOffset) error(loc, "value is out of range:", "texel offset", "[gl_MinProgramTexelOffset, gl_MaxProgramTexelOffset]"); } diff --git a/3rdparty/glslang/glslang/MachineIndependent/iomapper.cpp b/3rdparty/glslang/glslang/MachineIndependent/iomapper.cpp index 88c9bd605..ea5f16113 100644 --- a/3rdparty/glslang/glslang/MachineIndependent/iomapper.cpp +++ b/3rdparty/glslang/glslang/MachineIndependent/iomapper.cpp @@ -413,9 +413,22 @@ struct TDefaultIoResolverBase : public glslang::TIoMapResolver } int resolveInOutLocation(EShLanguage /*stage*/, const char* /*name*/, const TType& type, bool /*is_live*/) override { - if (!doAutoLocationMapping || type.getQualifier().hasLocation()) + // kick out of not doing this + if (!doAutoLocationMapping) return -1; + // no locations added if already present, or a built-in variable + if (type.getQualifier().hasLocation() || type.getQualifier().builtIn != EbvNone) + return -1; + + // no locations on blocks of built-in variables + if (type.isStruct()) { + if (type.getStruct()->size() < 1) + return -1; + if ((*type.getStruct())[0].type->getQualifier().builtIn != EbvNone) + return -1; + } + // Placeholder. // TODO: It would be nice to flesh this out using // intermediate->computeTypeLocationSize(type), or functions that call it like diff --git a/3rdparty/glslang/gtests/Hlsl.FromFile.cpp b/3rdparty/glslang/gtests/Hlsl.FromFile.cpp index d6fe367d7..21f606e64 100644 --- a/3rdparty/glslang/gtests/Hlsl.FromFile.cpp +++ b/3rdparty/glslang/gtests/Hlsl.FromFile.cpp @@ -122,6 +122,8 @@ INSTANTIATE_TEST_CASE_P( {"hlsl.float4.frag", "PixelShaderFunction"}, {"hlsl.flatten.return.frag", "main"}, {"hlsl.flattenOpaque.frag", "main"}, + {"hlsl.flattenOpaqueInit.vert", "main"}, + {"hlsl.flattenOpaqueInitMix.vert", "main"}, {"hlsl.forLoop.frag", "PixelShaderFunction"}, {"hlsl.gather.array.dx10.frag", "main"}, {"hlsl.gather.basic.dx10.frag", "main"}, @@ -137,6 +139,7 @@ INSTANTIATE_TEST_CASE_P( {"hlsl.getdimensions.rw.dx10.frag", "main"}, {"hlsl.getdimensions.dx10.vert", "main"}, {"hlsl.getsampleposition.dx10.frag", "main"}, + {"hlsl.global-const-init.frag", "main"}, {"hlsl.domain.1.tese", "main"}, {"hlsl.domain.2.tese", "main"}, {"hlsl.domain.3.tese", "main"}, diff --git a/3rdparty/glslang/hlsl/hlslGrammar.cpp b/3rdparty/glslang/hlsl/hlslGrammar.cpp index 95869e8d4..05c95d36a 100755 --- a/3rdparty/glslang/hlsl/hlslGrammar.cpp +++ b/3rdparty/glslang/hlsl/hlslGrammar.cpp @@ -2553,8 +2553,19 @@ bool HlslGrammar::acceptInitializer(TIntermTyped*& node) expected("assignment expression in initializer list"); return false; } + + const bool firstNode = (node == nullptr); + node = intermediate.growAggregate(node, expr, loc); + // If every sub-node in the list has qualifier EvqConst, the returned node becomes + // EvqConst. Otherwise, it becomes EvqTemporary. That doesn't happen with e.g. + // EvqIn or EvqPosition, since the collection isn't EvqPosition if all the members are. + if (firstNode && expr->getQualifier().storage == EvqConst) + node->getQualifier().storage = EvqConst; + else if (expr->getQualifier().storage != EvqConst) + node->getQualifier().storage = EvqTemporary; + // COMMA if (acceptTokenClass(EHTokComma)) { if (acceptTokenClass(EHTokRightBrace)) // allow trailing comma diff --git a/3rdparty/glslang/hlsl/hlslParseHelper.cpp b/3rdparty/glslang/hlsl/hlslParseHelper.cpp index a4960c544..6e12f8201 100755 --- a/3rdparty/glslang/hlsl/hlslParseHelper.cpp +++ b/3rdparty/glslang/hlsl/hlslParseHelper.cpp @@ -506,12 +506,14 @@ TIntermTyped* HlslParseContext::handleLvalue(const TSourceLoc& loc, const char* } // Deal with sampler aliasing: turning assignments into aliases +// Return a placeholder node for higher-level code that think assignments must +// generate code. TIntermTyped* HlslParseContext::handleSamplerLvalue(const TSourceLoc& loc, const char* op, TIntermTyped*& node) { // Can only alias an assignment: "s1 = s2" TIntermBinary* binary = node->getAsBinaryNode(); if (binary == nullptr || node->getAsOperator()->getOp() != EOpAssign || - binary->getLeft() ->getAsSymbolNode() == nullptr || + binary->getLeft()->getAsSymbolNode() == nullptr || binary->getRight()->getAsSymbolNode() == nullptr) { error(loc, "can't modify sampler", op, ""); return node; @@ -520,11 +522,25 @@ TIntermTyped* HlslParseContext::handleSamplerLvalue(const TSourceLoc& loc, const if (controlFlowNestingLevel > 0) warn(loc, "sampler or image aliased under control flow; consumption must be in same path", op, ""); + TIntermTyped* set = setOpaqueLvalue(binary->getLeft(), binary->getRight()); + if (set == nullptr) + warn(loc, "could not create alias for sampler", op, ""); + else + node = set; + + return node; +} + +// Do an opaque assignment that needs to turn into an alias. +// Return nullptr if it can't be done, otherwise return a placeholder +// node for higher-level code that think assignments must generate code. +TIntermTyped* HlslParseContext::setOpaqueLvalue(TIntermTyped* leftTyped, TIntermTyped* rightTyped) +{ // Best is if we are aliasing a flattened struct member "S.s1 = s2", // in which case we want to update the flattening information with the alias, // making everything else work seamlessly. - TIntermSymbol* left = binary->getLeft()->getAsSymbolNode(); - TIntermSymbol* right = binary->getRight()->getAsSymbolNode(); + TIntermSymbol* left = leftTyped->getAsSymbolNode(); + TIntermSymbol* right = rightTyped->getAsSymbolNode(); for (auto fit = flattenMap.begin(); fit != flattenMap.end(); ++fit) { for (auto mit = fit->second.members.begin(); mit != fit->second.members.end(); ++mit) { if ((*mit)->getUniqueId() == left->getId()) { @@ -533,15 +549,12 @@ TIntermTyped* HlslParseContext::handleSamplerLvalue(const TSourceLoc& loc, const (*mit)->setUniqueId(right->getId()); // replace node (rest of compiler expects either an error or code to generate) // with pointless access - node = binary->getRight(); - return node; + return right; } } } - warn(loc, "could not create alias for sampler", op, ""); - - return node; + return nullptr; } void HlslParseContext::handlePragma(const TSourceLoc& loc, const TVector& tokens) @@ -2412,6 +2425,34 @@ TIntermAggregate* HlslParseContext::assignClipCullDistance(const TSourceLoc& loc return assignList; } +// For a declaration with an initializer, where the initialized symbol is flattened, +// and possibly contains opaque values, such that the initializer should never exist +// as emitted code, because even creating the initializer would write opaques. +// +// Decompose this into individual member-wise assignments, which themselves are +// expected to then not exist for opaque types, because they will turn into aliases. +// +// Return a node that contains the non-aliased assignments that must continue to exist. +TIntermAggregate* HlslParseContext::flattenedInit(const TSourceLoc& loc, TIntermSymbol* symbol, const TIntermAggregate& initializer) +{ + TIntermAggregate* initList = nullptr; + // synthesize an access to each member, and then an assignment to it + const TTypeList& typeList = *symbol->getType().getStruct(); + for (int member = 0; member < (int)typeList.size(); ++member) { + TIntermTyped* memberInitializer = initializer.getSequence()[member]->getAsTyped(); + TIntermTyped* flattenedMember = flattenAccess(symbol, member); + if (flattenedMember->getType().containsOpaque()) + setOpaqueLvalue(flattenedMember, memberInitializer); + else + initList = intermediate.growAggregate(initList, handleAssign(loc, EOpAssign, flattenedMember, + memberInitializer)); + } + + if (initList) + initList->setOperator(EOpSequence); + return initList; +} + // Some simple source assignments need to be flattened to a sequence // of AST assignments. Catch these and flatten, otherwise, pass through // to intermediate.addAssign(). @@ -2449,7 +2490,7 @@ TIntermTyped* HlslParseContext::handleAssign(const TSourceLoc& loc, TOperator op // A temporary to store the right node's value, so we don't keep indirecting into it // if it's not a simple symbol. - TVariable* rhsTempVar = nullptr; + TVariable* rhsTempVar = nullptr; // If the RHS is a simple symbol node, we'll copy it for each member. TIntermSymbol* cloneSymNode = nullptr; @@ -7165,6 +7206,21 @@ TIntermNode* HlslParseContext::declareVariable(const TSourceLoc& loc, const TStr if (voidErrorCheck(loc, identifier, type.getBasicType())) return nullptr; + // Global consts with initializers that are non-const act like EvqGlobal in HLSL. + // This test is implicitly recursive, because initializers propagate constness + // up the aggregate node tree during creation. E.g, for: + // { { 1, 2 }, { 3, 4 } } + // the initializer list is marked EvqConst at the top node, and remains so here. However: + // { 1, { myvar, 2 }, 3 } + // is not a const intializer, and still becomes EvqGlobal here. + + const bool nonConstInitializer = (initializer != nullptr && initializer->getQualifier().storage != EvqConst); + + if (type.getQualifier().storage == EvqConst && symbolTable.atGlobalLevel() && nonConstInitializer) { + // Force to global + type.getQualifier().storage = EvqGlobal; + } + // make const and initialization consistent fixConstInit(loc, identifier, type, initializer); @@ -7207,34 +7263,22 @@ TIntermNode* HlslParseContext::declareVariable(const TSourceLoc& loc, const TStr error(loc, "cannot change the type of", "redeclaration", symbol->getName().c_str()); } - if (flattenVar) - flatten(loc, *symbol->getAsVariable()); - if (symbol == nullptr) return nullptr; + if (flattenVar) + flatten(loc, *symbol->getAsVariable()); + + if (initializer == nullptr) + return nullptr; + // Deal with initializer - TIntermNode* initNode = nullptr; - if (symbol && initializer) { -/* - * BK - - * uniform SamplerState s_texNormalSampler : register(s1); - * uniform Texture2D s_texNormalTexture : register(t1); - * static BgfxSampler2D s_texNormal = { s_texNormalSampler, s_texNormalTexture }; - * - if (flattenVar) - error(loc, "flattened array with initializer list unsupported", identifier.c_str(), ""); -*/ - - TVariable* variable = symbol->getAsVariable(); - if (variable == nullptr) { - error(loc, "initializer requires a variable, not a member", identifier.c_str(), ""); - return nullptr; - } - initNode = executeInitializer(loc, initializer, variable); + TVariable* variable = symbol->getAsVariable(); + if (variable == nullptr) { + error(loc, "initializer requires a variable, not a member", identifier.c_str(), ""); + return nullptr; } - - return initNode; + return executeInitializer(loc, initializer, variable, flattenVar); } // Pick up global defaults from the provide global defaults into dst. @@ -7300,7 +7344,7 @@ TVariable* HlslParseContext::declareNonArray(const TSourceLoc& loc, const TStrin // Returning nullptr just means there is no code to execute to handle the // initializer, which will, for example, be the case for constant initializers. // -TIntermNode* HlslParseContext::executeInitializer(const TSourceLoc& loc, TIntermTyped* initializer, TVariable* variable) +TIntermNode* HlslParseContext::executeInitializer(const TSourceLoc& loc, TIntermTyped* initializer, TVariable* variable, bool flattened) { // // Identifier must be of type constant, a global, or a temporary, and @@ -7321,6 +7365,7 @@ TIntermNode* HlslParseContext::executeInitializer(const TSourceLoc& loc, TInterm TType skeletalType; skeletalType.shallowCopy(variable->getType()); skeletalType.getQualifier().makeTemporary(); + TIntermAggregate* initializerList = nullptr; if (initializer->getAsAggregate() && initializer->getAsAggregate()->getOp() == EOpNull) initializer = convertInitializerList(loc, skeletalType, initializer, nullptr); if (initializer == nullptr) { @@ -7352,11 +7397,6 @@ TIntermNode* HlslParseContext::executeInitializer(const TSourceLoc& loc, TInterm variable->getWritableType().getQualifier().storage = EvqTemporary; return nullptr; } - if (qualifier == EvqConst && symbolTable.atGlobalLevel() && initializer->getType().getQualifier().storage != EvqConst) { - error(loc, "global const initializers must be constant", "=", "'%s'", variable->getType().getCompleteString().c_str()); - variable->getWritableType().getQualifier().storage = EvqTemporary; - return nullptr; - } // Const variables require a constant initializer if (qualifier == EvqConst) { @@ -7385,11 +7425,20 @@ TIntermNode* HlslParseContext::executeInitializer(const TSourceLoc& loc, TInterm // normal assigning of a value to a variable... specializationCheck(loc, initializer->getType(), "initializer"); TIntermSymbol* intermSymbol = intermediate.addSymbol(*variable, loc); - TIntermNode* initNode = handleAssign(loc, EOpAssign, intermSymbol, initializer); - if (initNode == nullptr) - assignError(loc, "=", intermSymbol->getCompleteString(), initializer->getCompleteString()); - return initNode; + // If we are flattening, it could be due to setting opaques, which must be handled + // as aliases, and the 'initializer' node cannot actually be emitted, because it + // itself stores the result of the constructor, and we can't store to opaques. + // handleAssign() will emit the initializer. + TIntermNode* initNode = nullptr; + if (flattened && intermSymbol->getType().containsOpaque()) + return flattenedInit(loc, intermSymbol, *initializer->getAsAggregate()); + else { + initNode = handleAssign(loc, EOpAssign, intermSymbol, initializer); + if (initNode == nullptr) + assignError(loc, "=", intermSymbol->getCompleteString(), initializer->getCompleteString()); + return initNode; + } } return nullptr; diff --git a/3rdparty/glslang/hlsl/hlslParseHelper.h b/3rdparty/glslang/hlsl/hlslParseHelper.h index 713e8303e..2d507c38a 100755 --- a/3rdparty/glslang/hlsl/hlslParseHelper.h +++ b/3rdparty/glslang/hlsl/hlslParseHelper.h @@ -87,6 +87,7 @@ public: void remapNonEntryPointIO(TFunction& function); TIntermNode* handleReturnValue(const TSourceLoc&, TIntermTyped*); void handleFunctionArgument(TFunction*, TIntermTyped*& arguments, TIntermTyped* newArg); + TIntermAggregate* flattenedInit(const TSourceLoc&, TIntermSymbol*, const TIntermAggregate&); TIntermTyped* handleAssign(const TSourceLoc&, TOperator, TIntermTyped* left, TIntermTyped* right); TIntermTyped* handleAssignToMatrixSwizzle(const TSourceLoc&, TOperator, TIntermTyped* left, TIntermTyped* right); TIntermTyped* handleFunctionCall(const TSourceLoc&, TFunction*, TIntermTyped*); @@ -191,6 +192,7 @@ public: // Apply L-value conversions. E.g, turning a write to a RWTexture into an ImageStore. TIntermTyped* handleLvalue(const TSourceLoc&, const char* op, TIntermTyped*& node); TIntermTyped* handleSamplerLvalue(const TSourceLoc&, const char* op, TIntermTyped*& node); + TIntermTyped* setOpaqueLvalue(TIntermTyped* left, TIntermTyped* right); bool lValueErrorCheck(const TSourceLoc&, const char* op, TIntermTyped*) override; TLayoutFormat getLayoutFromTxType(const TSourceLoc&, const TType&); @@ -231,7 +233,7 @@ protected: 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); + TIntermNode* executeInitializer(const TSourceLoc&, TIntermTyped* initializer, TVariable* variable, bool flattened); TIntermTyped* convertInitializerList(const TSourceLoc&, const TType&, TIntermTyped* initializer, TIntermTyped* scalarInit); bool isScalarConstructor(const TIntermNode*); TOperator mapAtomicOp(const TSourceLoc& loc, TOperator op, bool isImage);