Decorate accesschain operand for nonuniform UBO loads

This is conservative and still also decorates the loaded value.
This commit is contained in:
Jeff Bolz 2020-03-09 11:31:15 -05:00
parent 39ffdaf2ab
commit b57af2f5ad
9 changed files with 110 additions and 3 deletions

View File

@ -2731,7 +2731,13 @@ Id Builder::accessChainLoad(Decoration precision, Decoration nonUniform, Id resu
} }
// load through the access chain // 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); setPrecision(id, precision);
addDecoration(id, nonUniform); addDecoration(id, nonUniform);
} }

View File

@ -40,6 +40,7 @@ spv.RayGenShaderArray.rgen
Decorate 60(accNV1) DescriptorSet 0 Decorate 60(accNV1) DescriptorSet 0
Decorate 60(accNV1) Binding 1 Decorate 60(accNV1) Binding 1
Decorate 75 DecorationNonUniformEXT Decorate 75 DecorationNonUniformEXT
Decorate 76 DecorationNonUniformEXT
Decorate 77 DecorationNonUniformEXT Decorate 77 DecorationNonUniformEXT
Decorate 88(payload) Location 0 Decorate 88(payload) Location 0
2: TypeVoid 2: TypeVoid

View File

@ -59,16 +59,20 @@ spv.nonuniform.frag
Name 203 "S" Name 203 "S"
MemberName 203(S) 0 "a" MemberName 203(S) 0 "a"
Name 205 "s" Name 205 "s"
Decorate 9(nupi) DecorationNonUniformEXT
Decorate 13 DecorationNonUniformEXT Decorate 13 DecorationNonUniformEXT
Decorate 17(nu_li) DecorationNonUniformEXT Decorate 17(nu_li) DecorationNonUniformEXT
Decorate 17(nu_li) DecorationNonUniformEXT
Decorate 19 DecorationNonUniformEXT Decorate 19 DecorationNonUniformEXT
Decorate 24 DecorationNonUniformEXT Decorate 24 DecorationNonUniformEXT
Decorate 28 DecorationNonUniformEXT Decorate 28 DecorationNonUniformEXT
Decorate 29 DecorationNonUniformEXT Decorate 29 DecorationNonUniformEXT
Decorate 35(nu_inv4) Location 0 Decorate 35(nu_inv4) Location 0
Decorate 35(nu_inv4) DecorationNonUniformEXT Decorate 35(nu_inv4) DecorationNonUniformEXT
Decorate 39 DecorationNonUniformEXT
Decorate 40 DecorationNonUniformEXT Decorate 40 DecorationNonUniformEXT
Decorate 41(nu_gf) DecorationNonUniformEXT Decorate 41(nu_gf) DecorationNonUniformEXT
Decorate 41(nu_gf) DecorationNonUniformEXT
Decorate 42 DecorationNonUniformEXT Decorate 42 DecorationNonUniformEXT
Decorate 43 DecorationNonUniformEXT Decorate 43 DecorationNonUniformEXT
Decorate 47(inputAttachmentDyn) DescriptorSet 0 Decorate 47(inputAttachmentDyn) DescriptorSet 0
@ -85,47 +89,71 @@ spv.nonuniform.frag
Decorate 92(nu_ii) Flat Decorate 92(nu_ii) Flat
Decorate 92(nu_ii) Location 1 Decorate 92(nu_ii) Location 1
Decorate 92(nu_ii) DecorationNonUniformEXT Decorate 92(nu_ii) DecorationNonUniformEXT
Decorate 92(nu_ii) DecorationNonUniformEXT
Decorate 93 DecorationNonUniformEXT Decorate 93 DecorationNonUniformEXT
Decorate 95 DecorationNonUniformEXT
Decorate 96 DecorationNonUniformEXT Decorate 96 DecorationNonUniformEXT
MemberDecorate 99(bname) 0 Offset 0 MemberDecorate 99(bname) 0 Offset 0
Decorate 99(bname) BufferBlock Decorate 99(bname) BufferBlock
Decorate 102(storageBuffer) DescriptorSet 0 Decorate 102(storageBuffer) DescriptorSet 0
Decorate 102(storageBuffer) Binding 4 Decorate 102(storageBuffer) Binding 4
Decorate 92(nu_ii) DecorationNonUniformEXT
Decorate 103 DecorationNonUniformEXT Decorate 103 DecorationNonUniformEXT
Decorate 104 DecorationNonUniformEXT
Decorate 105 DecorationNonUniformEXT Decorate 105 DecorationNonUniformEXT
Decorate 112(sampledImage) DescriptorSet 0 Decorate 112(sampledImage) DescriptorSet 0
Decorate 112(sampledImage) Binding 5 Decorate 112(sampledImage) Binding 5
Decorate 92(nu_ii) DecorationNonUniformEXT
Decorate 113 DecorationNonUniformEXT Decorate 113 DecorationNonUniformEXT
Decorate 115 DecorationNonUniformEXT
Decorate 116 DecorationNonUniformEXT Decorate 116 DecorationNonUniformEXT
Decorate 127(storageImage) DescriptorSet 0 Decorate 127(storageImage) DescriptorSet 0
Decorate 127(storageImage) Binding 6 Decorate 127(storageImage) Binding 6
Decorate 92(nu_ii) DecorationNonUniformEXT
Decorate 128 DecorationNonUniformEXT Decorate 128 DecorationNonUniformEXT
Decorate 130 DecorationNonUniformEXT
Decorate 131 DecorationNonUniformEXT Decorate 131 DecorationNonUniformEXT
Decorate 139(inputAttachment) DescriptorSet 0 Decorate 139(inputAttachment) DescriptorSet 0
Decorate 139(inputAttachment) Binding 7 Decorate 139(inputAttachment) Binding 7
Decorate 139(inputAttachment) InputAttachmentIndex 1 Decorate 139(inputAttachment) InputAttachmentIndex 1
Decorate 92(nu_ii) DecorationNonUniformEXT
Decorate 140 DecorationNonUniformEXT Decorate 140 DecorationNonUniformEXT
Decorate 141 DecorationNonUniformEXT
Decorate 142 DecorationNonUniformEXT Decorate 142 DecorationNonUniformEXT
Decorate 149(uniformTexelBuffer) DescriptorSet 0 Decorate 149(uniformTexelBuffer) DescriptorSet 0
Decorate 149(uniformTexelBuffer) Binding 8 Decorate 149(uniformTexelBuffer) Binding 8
Decorate 92(nu_ii) DecorationNonUniformEXT
Decorate 150 DecorationNonUniformEXT Decorate 150 DecorationNonUniformEXT
Decorate 151 DecorationNonUniformEXT
Decorate 152 DecorationNonUniformEXT Decorate 152 DecorationNonUniformEXT
Decorate 160(storageTexelBuffer) DescriptorSet 0 Decorate 160(storageTexelBuffer) DescriptorSet 0
Decorate 160(storageTexelBuffer) Binding 9 Decorate 160(storageTexelBuffer) Binding 9
Decorate 92(nu_ii) DecorationNonUniformEXT
Decorate 161 DecorationNonUniformEXT Decorate 161 DecorationNonUniformEXT
Decorate 162 DecorationNonUniformEXT
Decorate 163 DecorationNonUniformEXT Decorate 163 DecorationNonUniformEXT
Decorate 170(v) DecorationNonUniformEXT Decorate 170(v) DecorationNonUniformEXT
Decorate 172 DecorationNonUniformEXT
Decorate 173 DecorationNonUniformEXT Decorate 173 DecorationNonUniformEXT
Decorate 174 DecorationNonUniformEXT
Decorate 175 DecorationNonUniformEXT Decorate 175 DecorationNonUniformEXT
Decorate 179 DecorationNonUniformEXT
Decorate 180 DecorationNonUniformEXT Decorate 180 DecorationNonUniformEXT
Decorate 181 DecorationNonUniformEXT
Decorate 182 DecorationNonUniformEXT Decorate 182 DecorationNonUniformEXT
Decorate 92(nu_ii) DecorationNonUniformEXT
Decorate 186 DecorationNonUniformEXT Decorate 186 DecorationNonUniformEXT
Decorate 187 DecorationNonUniformEXT
Decorate 188 DecorationNonUniformEXT Decorate 188 DecorationNonUniformEXT
Decorate 189 DecorationNonUniformEXT
Decorate 190 DecorationNonUniformEXT Decorate 190 DecorationNonUniformEXT
Decorate 195(m) DecorationNonUniformEXT Decorate 195(m) DecorationNonUniformEXT
Decorate 196 DecorationNonUniformEXT
Decorate 197 DecorationNonUniformEXT Decorate 197 DecorationNonUniformEXT
Decorate 205(s) DecorationNonUniformEXT Decorate 205(s) DecorationNonUniformEXT
Decorate 206 DecorationNonUniformEXT
Decorate 207 DecorationNonUniformEXT Decorate 207 DecorationNonUniformEXT
Decorate 208 DecorationNonUniformEXT
Decorate 209 DecorationNonUniformEXT Decorate 209 DecorationNonUniformEXT
2: TypeVoid 2: TypeVoid
3: TypeFunction 2 3: TypeFunction 2

View File

@ -25,6 +25,7 @@ spv.nonuniform2.frag
Decorate 16(rIndex) Flat Decorate 16(rIndex) Flat
Decorate 16(rIndex) Location 3 Decorate 16(rIndex) Location 3
Decorate 18 DecorationNonUniformEXT Decorate 18 DecorationNonUniformEXT
Decorate 20 DecorationNonUniformEXT
Decorate 21 DecorationNonUniformEXT Decorate 21 DecorationNonUniformEXT
2: TypeVoid 2: TypeVoid
3: TypeFunction 2 3: TypeFunction 2

View File

@ -1,5 +1,4 @@
spv.nonuniform3.frag spv.nonuniform3.frag
Validation failed
// Module Version 10000 // Module Version 10000
// Generated by (magic number): 80008 // Generated by (magic number): 80008
// Id's are bound by 32 // Id's are bound by 32

View File

@ -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

15
Test/spv.nonuniform5.frag Normal file
View File

@ -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;
}

View File

@ -358,6 +358,7 @@ INSTANTIATE_TEST_CASE_P(
"spv.nonuniform2.frag", "spv.nonuniform2.frag",
"spv.nonuniform3.frag", "spv.nonuniform3.frag",
"spv.nonuniform4.frag", "spv.nonuniform4.frag",
"spv.nonuniform5.frag",
"spv.noWorkgroup.comp", "spv.noWorkgroup.comp",
"spv.offsets.frag", "spv.offsets.frag",
"spv.Operations.frag", "spv.Operations.frag",

View File

@ -5,7 +5,7 @@
"site" : "github", "site" : "github",
"subrepo" : "KhronosGroup/SPIRV-Tools", "subrepo" : "KhronosGroup/SPIRV-Tools",
"subdir" : "External/spirv-tools", "subdir" : "External/spirv-tools",
"commit" : "79f8caf9154a0328a87424354bd10ab69e811185" "commit" : "dd3d91691f1e1dc4c0f42818756cf5e165c8918c"
}, },
{ {
"name" : "spirv-tools/external/spirv-headers", "name" : "spirv-tools/external/spirv-headers",