diff --git a/SPIRV/SpvBuilder.cpp b/SPIRV/SpvBuilder.cpp index 6982205d0..b3b95224b 100644 --- a/SPIRV/SpvBuilder.cpp +++ b/SPIRV/SpvBuilder.cpp @@ -2731,7 +2731,13 @@ Id Builder::accessChainLoad(Decoration precision, Decoration nonUniform, Id resu } // load through the access chain - id = createLoad(collapseAccessChain(), memoryAccess, scope, alignment); + id = collapseAccessChain(); + // Apply nonuniform both to the access chain and the loaded value. + // Buffer accesses need the access chain decorated, and this is where + // loaded image types get decorated. TODO: This should maybe move to + // createImageTextureFunctionCall. + addDecoration(id, nonUniform); + id = createLoad(id, memoryAccess, scope, alignment); setPrecision(id, precision); addDecoration(id, nonUniform); } diff --git a/Test/baseResults/spv.RayGenShaderArray.rgen.out b/Test/baseResults/spv.RayGenShaderArray.rgen.out index e9143049d..7a024ecf7 100644 --- a/Test/baseResults/spv.RayGenShaderArray.rgen.out +++ b/Test/baseResults/spv.RayGenShaderArray.rgen.out @@ -40,6 +40,7 @@ spv.RayGenShaderArray.rgen Decorate 60(accNV1) DescriptorSet 0 Decorate 60(accNV1) Binding 1 Decorate 75 DecorationNonUniformEXT + Decorate 76 DecorationNonUniformEXT Decorate 77 DecorationNonUniformEXT Decorate 88(payload) Location 0 2: TypeVoid diff --git a/Test/baseResults/spv.nonuniform.frag.out b/Test/baseResults/spv.nonuniform.frag.out index 32b64662a..6b7d4073b 100644 --- a/Test/baseResults/spv.nonuniform.frag.out +++ b/Test/baseResults/spv.nonuniform.frag.out @@ -59,16 +59,20 @@ spv.nonuniform.frag Name 203 "S" MemberName 203(S) 0 "a" Name 205 "s" + Decorate 9(nupi) DecorationNonUniformEXT Decorate 13 DecorationNonUniformEXT Decorate 17(nu_li) DecorationNonUniformEXT + Decorate 17(nu_li) DecorationNonUniformEXT Decorate 19 DecorationNonUniformEXT Decorate 24 DecorationNonUniformEXT Decorate 28 DecorationNonUniformEXT Decorate 29 DecorationNonUniformEXT Decorate 35(nu_inv4) Location 0 Decorate 35(nu_inv4) DecorationNonUniformEXT + Decorate 39 DecorationNonUniformEXT Decorate 40 DecorationNonUniformEXT Decorate 41(nu_gf) DecorationNonUniformEXT + Decorate 41(nu_gf) DecorationNonUniformEXT Decorate 42 DecorationNonUniformEXT Decorate 43 DecorationNonUniformEXT Decorate 47(inputAttachmentDyn) DescriptorSet 0 @@ -85,47 +89,71 @@ spv.nonuniform.frag Decorate 92(nu_ii) Flat Decorate 92(nu_ii) Location 1 Decorate 92(nu_ii) DecorationNonUniformEXT + Decorate 92(nu_ii) DecorationNonUniformEXT Decorate 93 DecorationNonUniformEXT + Decorate 95 DecorationNonUniformEXT Decorate 96 DecorationNonUniformEXT MemberDecorate 99(bname) 0 Offset 0 Decorate 99(bname) BufferBlock Decorate 102(storageBuffer) DescriptorSet 0 Decorate 102(storageBuffer) Binding 4 + Decorate 92(nu_ii) DecorationNonUniformEXT Decorate 103 DecorationNonUniformEXT + Decorate 104 DecorationNonUniformEXT Decorate 105 DecorationNonUniformEXT Decorate 112(sampledImage) DescriptorSet 0 Decorate 112(sampledImage) Binding 5 + Decorate 92(nu_ii) DecorationNonUniformEXT Decorate 113 DecorationNonUniformEXT + Decorate 115 DecorationNonUniformEXT Decorate 116 DecorationNonUniformEXT Decorate 127(storageImage) DescriptorSet 0 Decorate 127(storageImage) Binding 6 + Decorate 92(nu_ii) DecorationNonUniformEXT Decorate 128 DecorationNonUniformEXT + Decorate 130 DecorationNonUniformEXT Decorate 131 DecorationNonUniformEXT Decorate 139(inputAttachment) DescriptorSet 0 Decorate 139(inputAttachment) Binding 7 Decorate 139(inputAttachment) InputAttachmentIndex 1 + Decorate 92(nu_ii) DecorationNonUniformEXT Decorate 140 DecorationNonUniformEXT + Decorate 141 DecorationNonUniformEXT Decorate 142 DecorationNonUniformEXT Decorate 149(uniformTexelBuffer) DescriptorSet 0 Decorate 149(uniformTexelBuffer) Binding 8 + Decorate 92(nu_ii) DecorationNonUniformEXT Decorate 150 DecorationNonUniformEXT + Decorate 151 DecorationNonUniformEXT Decorate 152 DecorationNonUniformEXT Decorate 160(storageTexelBuffer) DescriptorSet 0 Decorate 160(storageTexelBuffer) Binding 9 + Decorate 92(nu_ii) DecorationNonUniformEXT Decorate 161 DecorationNonUniformEXT + Decorate 162 DecorationNonUniformEXT Decorate 163 DecorationNonUniformEXT Decorate 170(v) DecorationNonUniformEXT + Decorate 172 DecorationNonUniformEXT Decorate 173 DecorationNonUniformEXT + Decorate 174 DecorationNonUniformEXT Decorate 175 DecorationNonUniformEXT + Decorate 179 DecorationNonUniformEXT Decorate 180 DecorationNonUniformEXT + Decorate 181 DecorationNonUniformEXT Decorate 182 DecorationNonUniformEXT + Decorate 92(nu_ii) DecorationNonUniformEXT Decorate 186 DecorationNonUniformEXT + Decorate 187 DecorationNonUniformEXT Decorate 188 DecorationNonUniformEXT + Decorate 189 DecorationNonUniformEXT Decorate 190 DecorationNonUniformEXT Decorate 195(m) DecorationNonUniformEXT + Decorate 196 DecorationNonUniformEXT Decorate 197 DecorationNonUniformEXT Decorate 205(s) DecorationNonUniformEXT + Decorate 206 DecorationNonUniformEXT Decorate 207 DecorationNonUniformEXT + Decorate 208 DecorationNonUniformEXT Decorate 209 DecorationNonUniformEXT 2: TypeVoid 3: TypeFunction 2 diff --git a/Test/baseResults/spv.nonuniform2.frag.out b/Test/baseResults/spv.nonuniform2.frag.out index db24f4177..759f4c4ea 100644 --- a/Test/baseResults/spv.nonuniform2.frag.out +++ b/Test/baseResults/spv.nonuniform2.frag.out @@ -25,6 +25,7 @@ spv.nonuniform2.frag Decorate 16(rIndex) Flat Decorate 16(rIndex) Location 3 Decorate 18 DecorationNonUniformEXT + Decorate 20 DecorationNonUniformEXT Decorate 21 DecorationNonUniformEXT 2: TypeVoid 3: TypeFunction 2 diff --git a/Test/baseResults/spv.nonuniform3.frag.out b/Test/baseResults/spv.nonuniform3.frag.out index 1e95b3e8f..93142619c 100644 --- a/Test/baseResults/spv.nonuniform3.frag.out +++ b/Test/baseResults/spv.nonuniform3.frag.out @@ -1,5 +1,4 @@ spv.nonuniform3.frag -Validation failed // Module Version 10000 // Generated by (magic number): 80008 // Id's are bound by 32 diff --git a/Test/baseResults/spv.nonuniform5.frag.out b/Test/baseResults/spv.nonuniform5.frag.out new file mode 100644 index 000000000..8ce131a84 --- /dev/null +++ b/Test/baseResults/spv.nonuniform5.frag.out @@ -0,0 +1,56 @@ +spv.nonuniform5.frag +// Module Version 10000 +// Generated by (magic number): 80008 +// Id's are bound by 23 + + Capability Shader + Capability ShaderNonUniformEXT + Capability RuntimeDescriptorArrayEXT + Capability UniformBufferArrayNonUniformIndexingEXT + Extension "SPV_EXT_descriptor_indexing" + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Fragment 4 "main" 9 16 + ExecutionMode 4 OriginUpperLeft + Source GLSL 450 + SourceExtension "GL_EXT_nonuniform_qualifier" + Name 4 "main" + Name 9 "FragColor" + Name 10 "UBO" + MemberName 10(UBO) 0 "v" + Name 13 "ubos" + Name 16 "Index" + Decorate 9(FragColor) Location 0 + MemberDecorate 10(UBO) 0 Offset 0 + Decorate 10(UBO) Block + Decorate 13(ubos) DescriptorSet 0 + Decorate 13(ubos) Binding 0 + Decorate 16(Index) Flat + Decorate 16(Index) Location 0 + Decorate 18 DecorationNonUniformEXT + Decorate 21 DecorationNonUniformEXT + Decorate 22 DecorationNonUniformEXT + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeFloat 32 + 7: TypeVector 6(float) 4 + 8: TypePointer Output 7(fvec4) + 9(FragColor): 8(ptr) Variable Output + 10(UBO): TypeStruct 7(fvec4) + 11: TypeRuntimeArray 10(UBO) + 12: TypePointer Uniform 11 + 13(ubos): 12(ptr) Variable Uniform + 14: TypeInt 32 1 + 15: TypePointer Input 14(int) + 16(Index): 15(ptr) Variable Input + 19: 14(int) Constant 0 + 20: TypePointer Uniform 7(fvec4) + 4(main): 2 Function None 3 + 5: Label + 17: 14(int) Load 16(Index) + 18: 14(int) CopyObject 17 + 21: 20(ptr) AccessChain 13(ubos) 18 19 + 22: 7(fvec4) Load 21 + Store 9(FragColor) 22 + Return + FunctionEnd diff --git a/Test/spv.nonuniform5.frag b/Test/spv.nonuniform5.frag new file mode 100644 index 000000000..ef7077953 --- /dev/null +++ b/Test/spv.nonuniform5.frag @@ -0,0 +1,15 @@ +#version 450 +#extension GL_EXT_nonuniform_qualifier : require + +layout(location = 0) flat in int Index; +layout(location = 0) out vec4 FragColor; + +layout(set = 0, binding = 0) uniform UBO +{ + vec4 v; +} ubos[]; + +void main() +{ + FragColor = ubos[nonuniformEXT(Index)].v; +} diff --git a/gtests/Spv.FromFile.cpp b/gtests/Spv.FromFile.cpp index dafff6213..110313e9f 100644 --- a/gtests/Spv.FromFile.cpp +++ b/gtests/Spv.FromFile.cpp @@ -358,6 +358,7 @@ INSTANTIATE_TEST_CASE_P( "spv.nonuniform2.frag", "spv.nonuniform3.frag", "spv.nonuniform4.frag", + "spv.nonuniform5.frag", "spv.noWorkgroup.comp", "spv.offsets.frag", "spv.Operations.frag", diff --git a/known_good.json b/known_good.json index 8c0a4436e..1f108db82 100644 --- a/known_good.json +++ b/known_good.json @@ -5,7 +5,7 @@ "site" : "github", "subrepo" : "KhronosGroup/SPIRV-Tools", "subdir" : "External/spirv-tools", - "commit" : "79f8caf9154a0328a87424354bd10ab69e811185" + "commit" : "dd3d91691f1e1dc4c0f42818756cf5e165c8918c" }, { "name" : "spirv-tools/external/spirv-headers",