Fix 8-bit storage nearly always using the

UniformAndStorageBuffer8BitAccess capability.

When using the 8-bit storage extension it basically always used the
`UniformAndStorageBuffer8BitAccess` capability, even in cases where it
wasn't required. For instance if we are targeting Vulkan 1.1 (SPIR-V 1.3
or higher), and we are only using 8-bit types in an SSBO, we only need
the `StorageBuffer8BitAccess` capability.

I fixed this by enabling storage buffer use in Vulkan 1.1 / SPIR-V 1.3
or higher, and then changing the logic to match.

I also added some tests that will output different capabilities when run
on Vulkan 1.0 and 1.1, thus they are added twice to the test list (one
for each version).

Fixes #1539
This commit is contained in:
Neil Henning 2018-10-23 15:02:29 +01:00
parent a08f465d53
commit b6b01f067b
27 changed files with 404 additions and 112 deletions

View File

@ -2812,7 +2812,8 @@ spv::Id TGlslangToSpvTraverser::createSpvVariable(const glslang::TIntermSymbol*
} else if (storageClass == spv::StorageClassUniform) {
builder.addExtension(spv::E_SPV_KHR_8bit_storage);
builder.addCapability(spv::CapabilityUniformAndStorageBuffer8BitAccess);
if (node->getType().getQualifier().storage == glslang::EvqBuffer)
} else if (storageClass == spv::StorageClassStorageBuffer) {
builder.addExtension(spv::E_SPV_KHR_8bit_storage);
builder.addCapability(spv::CapabilityStorageBuffer8BitAccess);
}
}

View File

@ -0,0 +1,56 @@
spv.1.3.8bitstorage-ssbo.vert
// Module Version 10300
// Generated by (magic number): 80007
// Id's are bound by 28
Capability Shader
Capability CapabilityStorageBuffer8BitAccess
Extension "SPV_KHR_8bit_storage"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Vertex 4 "main" 9 18
Source GLSL 450
SourceExtension "GL_EXT_shader_8bit_storage"
Name 4 "main"
Name 9 "color"
Name 12 "Vertices"
MemberName 12(Vertices) 0 "vertices"
Name 14 ""
Name 18 "gl_VertexIndex"
Decorate 9(color) Location 0
Decorate 11 ArrayStride 1
MemberDecorate 12(Vertices) 0 NonWritable
MemberDecorate 12(Vertices) 0 Offset 0
Decorate 12(Vertices) Block
Decorate 14 DescriptorSet 0
Decorate 14 Binding 0
Decorate 18(gl_VertexIndex) BuiltIn VertexIndex
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
7: TypeVector 6(float) 4
8: TypePointer Output 7(fvec4)
9(color): 8(ptr) Variable Output
10: TypeInt 8 0
11: TypeRuntimeArray 10(int8_t)
12(Vertices): TypeStruct 11
13: TypePointer StorageBuffer 12(Vertices)
14: 13(ptr) Variable StorageBuffer
15: TypeInt 32 1
16: 15(int) Constant 0
17: TypePointer Input 15(int)
18(gl_VertexIndex): 17(ptr) Variable Input
20: TypePointer StorageBuffer 10(int8_t)
23: TypeInt 32 0
4(main): 2 Function None 3
5: Label
19: 15(int) Load 18(gl_VertexIndex)
21: 20(ptr) AccessChain 14 16 19
22: 10(int8_t) Load 21
24: 23(int) UConvert 22
25: 15(int) Bitcast 24
26: 6(float) ConvertSToF 25
27: 7(fvec4) CompositeConstruct 26 26 26 26
Store 9(color) 27
Return
FunctionEnd

View File

@ -0,0 +1,56 @@
spv.1.3.8bitstorage-ubo.vert
// Module Version 10300
// Generated by (magic number): 80007
// Id's are bound by 29
Capability Shader
Capability CapabilityUniformAndStorageBuffer8BitAccess
Extension "SPV_KHR_8bit_storage"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Vertex 4 "main" 9 20
Source GLSL 450
SourceExtension "GL_EXT_shader_8bit_storage"
Name 4 "main"
Name 9 "color"
Name 14 "Vertices"
MemberName 14(Vertices) 0 "vertices"
Name 16 ""
Name 20 "gl_VertexIndex"
Decorate 9(color) Location 0
Decorate 13 ArrayStride 16
MemberDecorate 14(Vertices) 0 Offset 0
Decorate 14(Vertices) Block
Decorate 16 DescriptorSet 0
Decorate 16 Binding 0
Decorate 20(gl_VertexIndex) BuiltIn VertexIndex
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
7: TypeVector 6(float) 4
8: TypePointer Output 7(fvec4)
9(color): 8(ptr) Variable Output
10: TypeInt 8 0
11: TypeInt 32 0
12: 11(int) Constant 512
13: TypeArray 10(int8_t) 12
14(Vertices): TypeStruct 13
15: TypePointer Uniform 14(Vertices)
16: 15(ptr) Variable Uniform
17: TypeInt 32 1
18: 17(int) Constant 0
19: TypePointer Input 17(int)
20(gl_VertexIndex): 19(ptr) Variable Input
22: TypePointer Uniform 10(int8_t)
4(main): 2 Function None 3
5: Label
21: 17(int) Load 20(gl_VertexIndex)
23: 22(ptr) AccessChain 16 18 21
24: 10(int8_t) Load 23
25: 11(int) UConvert 24
26: 17(int) Bitcast 25
27: 6(float) ConvertSToF 26
28: 7(fvec4) CompositeConstruct 27 27 27 27
Store 9(color) 28
Return
FunctionEnd

View File

@ -4,7 +4,6 @@ spv.8bitstorage-int.frag
// Id's are bound by 171
Capability Shader
Capability CapabilityStorageBuffer8BitAccess
Capability CapabilityUniformAndStorageBuffer8BitAccess
Extension "SPV_KHR_8bit_storage"
1: ExtInstImport "GLSL.std.450"

View File

@ -0,0 +1,56 @@
spv.8bitstorage-ssbo.vert
// Module Version 10000
// Generated by (magic number): 80007
// Id's are bound by 28
Capability Shader
Capability CapabilityUniformAndStorageBuffer8BitAccess
Extension "SPV_KHR_8bit_storage"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Vertex 4 "main" 9 18
Source GLSL 450
SourceExtension "GL_EXT_shader_8bit_storage"
Name 4 "main"
Name 9 "color"
Name 12 "Vertices"
MemberName 12(Vertices) 0 "vertices"
Name 14 ""
Name 18 "gl_VertexIndex"
Decorate 9(color) Location 0
Decorate 11 ArrayStride 1
MemberDecorate 12(Vertices) 0 NonWritable
MemberDecorate 12(Vertices) 0 Offset 0
Decorate 12(Vertices) BufferBlock
Decorate 14 DescriptorSet 0
Decorate 14 Binding 0
Decorate 18(gl_VertexIndex) BuiltIn VertexIndex
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
7: TypeVector 6(float) 4
8: TypePointer Output 7(fvec4)
9(color): 8(ptr) Variable Output
10: TypeInt 8 0
11: TypeRuntimeArray 10(int8_t)
12(Vertices): TypeStruct 11
13: TypePointer Uniform 12(Vertices)
14: 13(ptr) Variable Uniform
15: TypeInt 32 1
16: 15(int) Constant 0
17: TypePointer Input 15(int)
18(gl_VertexIndex): 17(ptr) Variable Input
20: TypePointer Uniform 10(int8_t)
23: TypeInt 32 0
4(main): 2 Function None 3
5: Label
19: 15(int) Load 18(gl_VertexIndex)
21: 20(ptr) AccessChain 14 16 19
22: 10(int8_t) Load 21
24: 23(int) UConvert 22
25: 15(int) Bitcast 24
26: 6(float) ConvertSToF 25
27: 7(fvec4) CompositeConstruct 26 26 26 26
Store 9(color) 27
Return
FunctionEnd

View File

@ -0,0 +1,56 @@
spv.8bitstorage-ubo.vert
// Module Version 10000
// Generated by (magic number): 80007
// Id's are bound by 29
Capability Shader
Capability CapabilityUniformAndStorageBuffer8BitAccess
Extension "SPV_KHR_8bit_storage"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Vertex 4 "main" 9 20
Source GLSL 450
SourceExtension "GL_EXT_shader_8bit_storage"
Name 4 "main"
Name 9 "color"
Name 14 "Vertices"
MemberName 14(Vertices) 0 "vertices"
Name 16 ""
Name 20 "gl_VertexIndex"
Decorate 9(color) Location 0
Decorate 13 ArrayStride 16
MemberDecorate 14(Vertices) 0 Offset 0
Decorate 14(Vertices) Block
Decorate 16 DescriptorSet 0
Decorate 16 Binding 0
Decorate 20(gl_VertexIndex) BuiltIn VertexIndex
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
7: TypeVector 6(float) 4
8: TypePointer Output 7(fvec4)
9(color): 8(ptr) Variable Output
10: TypeInt 8 0
11: TypeInt 32 0
12: 11(int) Constant 512
13: TypeArray 10(int8_t) 12
14(Vertices): TypeStruct 13
15: TypePointer Uniform 14(Vertices)
16: 15(ptr) Variable Uniform
17: TypeInt 32 1
18: 17(int) Constant 0
19: TypePointer Input 17(int)
20(gl_VertexIndex): 19(ptr) Variable Input
22: TypePointer Uniform 10(int8_t)
4(main): 2 Function None 3
5: Label
21: 17(int) Load 20(gl_VertexIndex)
23: 22(ptr) AccessChain 16 18 21
24: 10(int8_t) Load 23
25: 11(int) UConvert 24
26: 17(int) Bitcast 25
27: 6(float) ConvertSToF 26
28: 7(fvec4) CompositeConstruct 27 27 27 27
Store 9(color) 28
Return
FunctionEnd

View File

@ -4,7 +4,6 @@ spv.8bitstorage-uint.frag
// Id's are bound by 173
Capability Shader
Capability CapabilityStorageBuffer8BitAccess
Capability CapabilityUniformAndStorageBuffer8BitAccess
Extension "SPV_KHR_8bit_storage"
1: ExtInstImport "GLSL.std.450"

View File

@ -88,6 +88,7 @@ void main()
ModuleProcessed "suppress-warnings"
ModuleProcessed "hlsl-offsets"
ModuleProcessed "entry-point main"
ModuleProcessed "use-storage-buffer"
Decorate 24(inv) Location 0
Decorate 52(outv) Location 0
MemberDecorate 53(S) 0 Offset 0

View File

@ -23,7 +23,7 @@ spv.subgroup.geom
Name 20 "gl_SubgroupInvocationID"
Decorate 8 ArrayStride 16
MemberDecorate 9(Output) 0 Offset 0
Decorate 9(Output) BufferBlock
Decorate 9(Output) Block
Decorate 11 DescriptorSet 0
Decorate 11 Binding 0
Decorate 15(gl_PrimitiveIDIn) BuiltIn PrimitiveId
@ -39,8 +39,8 @@ spv.subgroup.geom
7: TypeVector 6(int) 4
8: TypeRuntimeArray 7(ivec4)
9(Output): TypeStruct 8
10: TypePointer Uniform 9(Output)
11: 10(ptr) Variable Uniform
10: TypePointer StorageBuffer 9(Output)
11: 10(ptr) Variable StorageBuffer
12: TypeInt 32 1
13: 12(int) Constant 0
14: TypePointer Input 12(int)
@ -49,7 +49,7 @@ spv.subgroup.geom
18(gl_SubgroupSize): 17(ptr) Variable Input
20(gl_SubgroupInvocationID): 17(ptr) Variable Input
22: 6(int) Constant 0
24: TypePointer Uniform 7(ivec4)
24: TypePointer StorageBuffer 7(ivec4)
4(main): 2 Function None 3
5: Label
16: 12(int) Load 15(gl_PrimitiveIDIn)

View File

@ -20,7 +20,7 @@ spv.subgroup.tesc
Name 20 "gl_SubgroupInvocationID"
Decorate 8 ArrayStride 16
MemberDecorate 9(Output) 0 Offset 0
Decorate 9(Output) BufferBlock
Decorate 9(Output) Block
Decorate 11 DescriptorSet 0
Decorate 11 Binding 0
Decorate 15(gl_PrimitiveID) BuiltIn PrimitiveId
@ -36,8 +36,8 @@ spv.subgroup.tesc
7: TypeVector 6(int) 4
8: TypeRuntimeArray 7(ivec4)
9(Output): TypeStruct 8
10: TypePointer Uniform 9(Output)
11: 10(ptr) Variable Uniform
10: TypePointer StorageBuffer 9(Output)
11: 10(ptr) Variable StorageBuffer
12: TypeInt 32 1
13: 12(int) Constant 0
14: TypePointer Input 12(int)
@ -46,7 +46,7 @@ spv.subgroup.tesc
18(gl_SubgroupSize): 17(ptr) Variable Input
20(gl_SubgroupInvocationID): 17(ptr) Variable Input
22: 6(int) Constant 0
24: TypePointer Uniform 7(ivec4)
24: TypePointer StorageBuffer 7(ivec4)
4(main): 2 Function None 3
5: Label
16: 12(int) Load 15(gl_PrimitiveID)

View File

@ -22,7 +22,7 @@ spv.subgroup.tese
Name 20 "gl_SubgroupInvocationID"
Decorate 8 ArrayStride 16
MemberDecorate 9(Output) 0 Offset 0
Decorate 9(Output) BufferBlock
Decorate 9(Output) Block
Decorate 11 DescriptorSet 0
Decorate 11 Binding 0
Decorate 15(gl_PrimitiveID) BuiltIn PrimitiveId
@ -38,8 +38,8 @@ spv.subgroup.tese
7: TypeVector 6(int) 4
8: TypeRuntimeArray 7(ivec4)
9(Output): TypeStruct 8
10: TypePointer Uniform 9(Output)
11: 10(ptr) Variable Uniform
10: TypePointer StorageBuffer 9(Output)
11: 10(ptr) Variable StorageBuffer
12: TypeInt 32 1
13: 12(int) Constant 0
14: TypePointer Input 12(int)
@ -48,7 +48,7 @@ spv.subgroup.tese
18(gl_SubgroupSize): 17(ptr) Variable Input
20(gl_SubgroupInvocationID): 17(ptr) Variable Input
22: 6(int) Constant 0
24: TypePointer Uniform 7(ivec4)
24: TypePointer StorageBuffer 7(ivec4)
4(main): 2 Function None 3
5: Label
16: 12(int) Load 15(gl_PrimitiveID)

View File

@ -19,7 +19,7 @@ spv.subgroup.vert
Name 20 "gl_SubgroupInvocationID"
Decorate 8 ArrayStride 16
MemberDecorate 9(Output) 0 Offset 0
Decorate 9(Output) BufferBlock
Decorate 9(Output) Block
Decorate 11 DescriptorSet 0
Decorate 11 Binding 0
Decorate 15(gl_VertexIndex) BuiltIn VertexIndex
@ -35,8 +35,8 @@ spv.subgroup.vert
7: TypeVector 6(int) 4
8: TypeRuntimeArray 7(ivec4)
9(Output): TypeStruct 8
10: TypePointer Uniform 9(Output)
11: 10(ptr) Variable Uniform
10: TypePointer StorageBuffer 9(Output)
11: 10(ptr) Variable StorageBuffer
12: TypeInt 32 1
13: 12(int) Constant 0
14: TypePointer Input 12(int)
@ -45,7 +45,7 @@ spv.subgroup.vert
18(gl_SubgroupSize): 17(ptr) Variable Input
20(gl_SubgroupInvocationID): 17(ptr) Variable Input
22: 6(int) Constant 0
24: TypePointer Uniform 7(ivec4)
24: TypePointer StorageBuffer 7(ivec4)
4(main): 2 Function None 3
5: Label
16: 12(int) Load 15(gl_VertexIndex)

View File

@ -36,7 +36,7 @@ spv.subgroupArithmetic.comp
MemberDecorate 24(Buffers) 1 Offset 16
MemberDecorate 24(Buffers) 2 Offset 32
MemberDecorate 24(Buffers) 3 Offset 64
Decorate 24(Buffers) BufferBlock
Decorate 24(Buffers) Block
Decorate 27(data) DescriptorSet 0
Decorate 27(data) Binding 0
Decorate 2084 BuiltIn WorkgroupSize
@ -57,29 +57,29 @@ spv.subgroupArithmetic.comp
23: TypeVector 22(float64_t) 4
24(Buffers): TypeStruct 18(fvec4) 20(ivec4) 21(ivec4) 23(f64vec4)
25: TypeArray 24(Buffers) 15
26: TypePointer Uniform 25
27(data): 26(ptr) Variable Uniform
26: TypePointer StorageBuffer 25
27(data): 26(ptr) Variable StorageBuffer
29: 19(int) Constant 0
30: 6(int) Constant 0
31: TypePointer Uniform 17(float)
31: TypePointer StorageBuffer 17(float)
34: 6(int) Constant 3
38: 19(int) Constant 1
39: TypeVector 17(float) 2
40: TypePointer Uniform 18(fvec4)
40: TypePointer StorageBuffer 18(fvec4)
49: 19(int) Constant 2
50: TypeVector 17(float) 3
59: 19(int) Constant 3
65: TypePointer Uniform 19(int)
65: TypePointer StorageBuffer 19(int)
71: TypeVector 19(int) 2
72: TypePointer Uniform 20(ivec4)
72: TypePointer StorageBuffer 20(ivec4)
81: TypeVector 19(int) 3
95: TypePointer Uniform 6(int)
95: TypePointer StorageBuffer 6(int)
101: TypeVector 6(int) 2
102: TypePointer Uniform 21(ivec4)
102: TypePointer StorageBuffer 21(ivec4)
111: TypeVector 6(int) 3
125: TypePointer Uniform 22(float64_t)
125: TypePointer StorageBuffer 22(float64_t)
131: TypeVector 22(float64_t) 2
132: TypePointer Uniform 23(f64vec4)
132: TypePointer StorageBuffer 23(f64vec4)
141: TypeVector 22(float64_t) 3
521: TypeBool
530: 71(ivec2) ConstantComposite 29 29

View File

@ -48,7 +48,7 @@ spv.subgroupBallot.comp
MemberDecorate 46(Buffers) 1 Offset 16
MemberDecorate 46(Buffers) 2 Offset 32
MemberDecorate 46(Buffers) 3 Offset 64
Decorate 46(Buffers) BufferBlock
Decorate 46(Buffers) Block
Decorate 49(data) DescriptorSet 0
Decorate 49(data) Binding 0
Decorate 416 BuiltIn WorkgroupSize
@ -79,31 +79,31 @@ spv.subgroupBallot.comp
45: TypeVector 44(float64_t) 4
46(Buffers): TypeStruct 41(fvec4) 43(ivec4) 17(ivec4) 45(f64vec4)
47: TypeArray 46(Buffers) 15
48: TypePointer Uniform 47
49(data): 48(ptr) Variable Uniform
48: TypePointer StorageBuffer 47
49(data): 48(ptr) Variable StorageBuffer
51: 42(int) Constant 2
54: 6(int) Constant 0
55: TypePointer Uniform 6(int)
55: TypePointer StorageBuffer 6(int)
60: 42(int) Constant 1
61: 42(int) Constant 0
64: 6(int) Constant 1
72: 6(int) Constant 2
83: TypeVector 36(bool) 4
88: TypePointer Uniform 17(ivec4)
96: TypePointer Uniform 40(float)
88: TypePointer StorageBuffer 17(ivec4)
96: TypePointer StorageBuffer 40(float)
103: TypeVector 40(float) 2
104: TypePointer Uniform 41(fvec4)
104: TypePointer StorageBuffer 41(fvec4)
114: TypeVector 40(float) 3
124: 42(int) Constant 3
131: TypePointer Uniform 42(int)
131: TypePointer StorageBuffer 42(int)
138: TypeVector 42(int) 2
139: TypePointer Uniform 43(ivec4)
139: TypePointer StorageBuffer 43(ivec4)
149: TypeVector 42(int) 3
171: TypeVector 6(int) 2
181: TypeVector 6(int) 3
197: TypePointer Uniform 44(float64_t)
197: TypePointer StorageBuffer 44(float64_t)
204: TypeVector 44(float64_t) 2
205: TypePointer Uniform 45(f64vec4)
205: TypePointer StorageBuffer 45(f64vec4)
215: TypeVector 44(float64_t) 3
242: 138(ivec2) ConstantComposite 61 61
243: TypeVector 36(bool) 2

View File

@ -21,7 +21,7 @@ spv.subgroupBasic.comp
Name 25 "gl_SubgroupID"
Decorate 7 ArrayStride 4
MemberDecorate 8(Buffer) 0 Offset 0
Decorate 8(Buffer) BufferBlock
Decorate 8(Buffer) Block
Decorate 10(data) DescriptorSet 0
Decorate 10(data) Binding 0
Decorate 14(gl_SubgroupSize) RelaxedPrecision
@ -38,14 +38,14 @@ spv.subgroupBasic.comp
6: TypeInt 32 1
7: TypeRuntimeArray 6(int)
8(Buffer): TypeStruct 7
9: TypePointer Uniform 8(Buffer)
10(data): 9(ptr) Variable Uniform
9: TypePointer StorageBuffer 8(Buffer)
10(data): 9(ptr) Variable StorageBuffer
11: 6(int) Constant 0
12: TypeInt 32 0
13: TypePointer Input 12(int)
14(gl_SubgroupSize): 13(ptr) Variable Input
16: 6(int) Constant 1
17: TypePointer Uniform 6(int)
17: TypePointer StorageBuffer 6(int)
19(gl_SubgroupInvocationID): 13(ptr) Variable Input
22(gl_NumSubgroups): 13(ptr) Variable Input
25(gl_SubgroupID): 13(ptr) Variable Input

View File

@ -36,7 +36,7 @@ spv.subgroupClustered.comp
MemberDecorate 24(Buffers) 1 Offset 16
MemberDecorate 24(Buffers) 2 Offset 32
MemberDecorate 24(Buffers) 3 Offset 64
Decorate 24(Buffers) BufferBlock
Decorate 24(Buffers) Block
Decorate 27(data) DescriptorSet 0
Decorate 27(data) Binding 0
Decorate 736 BuiltIn WorkgroupSize
@ -57,30 +57,30 @@ spv.subgroupClustered.comp
23: TypeVector 22(float64_t) 4
24(Buffers): TypeStruct 18(fvec4) 20(ivec4) 21(ivec4) 23(f64vec4)
25: TypeArray 24(Buffers) 15
26: TypePointer Uniform 25
27(data): 26(ptr) Variable Uniform
26: TypePointer StorageBuffer 25
27(data): 26(ptr) Variable StorageBuffer
29: 19(int) Constant 0
30: 6(int) Constant 0
31: TypePointer Uniform 17(float)
31: TypePointer StorageBuffer 17(float)
34: 6(int) Constant 1
35: 6(int) Constant 3
39: 19(int) Constant 1
40: TypeVector 17(float) 2
41: TypePointer Uniform 18(fvec4)
41: TypePointer StorageBuffer 18(fvec4)
50: 19(int) Constant 2
51: TypeVector 17(float) 3
60: 19(int) Constant 3
66: TypePointer Uniform 19(int)
66: TypePointer StorageBuffer 19(int)
72: TypeVector 19(int) 2
73: TypePointer Uniform 20(ivec4)
73: TypePointer StorageBuffer 20(ivec4)
82: TypeVector 19(int) 3
96: TypePointer Uniform 6(int)
96: TypePointer StorageBuffer 6(int)
102: TypeVector 6(int) 2
103: TypePointer Uniform 21(ivec4)
103: TypePointer StorageBuffer 21(ivec4)
112: TypeVector 6(int) 3
126: TypePointer Uniform 22(float64_t)
126: TypePointer StorageBuffer 22(float64_t)
132: TypeVector 22(float64_t) 2
133: TypePointer Uniform 23(f64vec4)
133: TypePointer StorageBuffer 23(f64vec4)
142: TypeVector 22(float64_t) 3
522: TypeBool
531: 72(ivec2) ConstantComposite 29 29

View File

@ -42,7 +42,7 @@ error: Opcode GroupNonUniformFAdd requires one of these capabilities: GroupNonUn
MemberDecorate 28(Buffers) 1 Offset 16
MemberDecorate 28(Buffers) 2 Offset 32
MemberDecorate 28(Buffers) 3 Offset 64
Decorate 28(Buffers) BufferBlock
Decorate 28(Buffers) Block
Decorate 31(data) DescriptorSet 0
Decorate 31(data) Binding 0
Decorate 2505 BuiltIn WorkgroupSize
@ -64,28 +64,28 @@ error: Opcode GroupNonUniformFAdd requires one of these capabilities: GroupNonUn
27: TypeVector 26(float64_t) 4
28(Buffers): TypeStruct 23(fvec4) 25(ivec4) 17(ivec4) 27(f64vec4)
29: TypeArray 28(Buffers) 15
30: TypePointer Uniform 29
31(data): 30(ptr) Variable Uniform
30: TypePointer StorageBuffer 29
31(data): 30(ptr) Variable StorageBuffer
33: 24(int) Constant 2
34: 24(int) Constant 0
35: 6(int) Constant 0
36: TypePointer Uniform 22(float)
40: TypePointer Uniform 17(ivec4)
36: TypePointer StorageBuffer 22(float)
40: TypePointer StorageBuffer 17(ivec4)
43: TypeVector 22(float) 2
44: TypePointer Uniform 23(fvec4)
44: TypePointer StorageBuffer 23(fvec4)
51: TypeVector 22(float) 3
63: 24(int) Constant 1
64: TypePointer Uniform 24(int)
64: TypePointer StorageBuffer 24(int)
70: TypeVector 24(int) 2
71: TypePointer Uniform 25(ivec4)
71: TypePointer StorageBuffer 25(ivec4)
78: TypeVector 24(int) 3
90: TypePointer Uniform 6(int)
90: TypePointer StorageBuffer 6(int)
96: TypeVector 6(int) 2
103: TypeVector 6(int) 3
115: 24(int) Constant 3
116: TypePointer Uniform 26(float64_t)
116: TypePointer StorageBuffer 26(float64_t)
122: TypeVector 26(float64_t) 2
123: TypePointer Uniform 27(f64vec4)
123: TypePointer StorageBuffer 27(f64vec4)
130: TypeVector 26(float64_t) 3
144: TypeBool
152: TypeVector 144(bool) 2

View File

@ -36,7 +36,7 @@ spv.subgroupQuad.comp
MemberDecorate 24(Buffers) 1 Offset 16
MemberDecorate 24(Buffers) 2 Offset 32
MemberDecorate 24(Buffers) 3 Offset 64
Decorate 24(Buffers) BufferBlock
Decorate 24(Buffers) Block
Decorate 27(data) DescriptorSet 0
Decorate 27(data) Binding 0
Decorate 615 BuiltIn WorkgroupSize
@ -57,30 +57,30 @@ spv.subgroupQuad.comp
23: TypeVector 22(float64_t) 4
24(Buffers): TypeStruct 18(fvec4) 20(ivec4) 21(ivec4) 23(f64vec4)
25: TypeArray 24(Buffers) 15
26: TypePointer Uniform 25
27(data): 26(ptr) Variable Uniform
26: TypePointer StorageBuffer 25
27(data): 26(ptr) Variable StorageBuffer
29: 19(int) Constant 0
30: 6(int) Constant 0
31: TypePointer Uniform 17(float)
31: TypePointer StorageBuffer 17(float)
34: 6(int) Constant 1
35: 6(int) Constant 3
39: 19(int) Constant 1
40: TypeVector 17(float) 2
41: TypePointer Uniform 18(fvec4)
41: TypePointer StorageBuffer 18(fvec4)
50: 19(int) Constant 2
51: TypeVector 17(float) 3
60: 19(int) Constant 3
66: TypePointer Uniform 19(int)
66: TypePointer StorageBuffer 19(int)
72: TypeVector 19(int) 2
73: TypePointer Uniform 20(ivec4)
73: TypePointer StorageBuffer 20(ivec4)
82: TypeVector 19(int) 3
96: TypePointer Uniform 6(int)
96: TypePointer StorageBuffer 6(int)
102: TypeVector 6(int) 2
103: TypePointer Uniform 21(ivec4)
103: TypePointer StorageBuffer 21(ivec4)
112: TypeVector 6(int) 3
126: TypePointer Uniform 22(float64_t)
126: TypePointer StorageBuffer 22(float64_t)
132: TypeVector 22(float64_t) 2
133: TypePointer Uniform 23(f64vec4)
133: TypePointer StorageBuffer 23(f64vec4)
142: TypeVector 22(float64_t) 3
158: TypeBool
167: 72(ivec2) ConstantComposite 29 29

View File

@ -36,7 +36,7 @@ spv.subgroupShuffle.comp
MemberDecorate 24(Buffers) 1 Offset 16
MemberDecorate 24(Buffers) 2 Offset 32
MemberDecorate 24(Buffers) 3 Offset 64
Decorate 24(Buffers) BufferBlock
Decorate 24(Buffers) Block
Decorate 27(data) DescriptorSet 0
Decorate 27(data) Binding 0
Decorate 378 BuiltIn WorkgroupSize
@ -57,29 +57,29 @@ spv.subgroupShuffle.comp
23: TypeVector 22(float64_t) 4
24(Buffers): TypeStruct 18(fvec4) 20(ivec4) 21(ivec4) 23(f64vec4)
25: TypeArray 24(Buffers) 15
26: TypePointer Uniform 25
27(data): 26(ptr) Variable Uniform
26: TypePointer StorageBuffer 25
27(data): 26(ptr) Variable StorageBuffer
29: 19(int) Constant 0
30: 6(int) Constant 0
31: TypePointer Uniform 17(float)
31: TypePointer StorageBuffer 17(float)
35: 6(int) Constant 3
39: 19(int) Constant 1
40: TypeVector 17(float) 2
41: TypePointer Uniform 18(fvec4)
41: TypePointer StorageBuffer 18(fvec4)
51: 19(int) Constant 2
52: TypeVector 17(float) 3
62: 19(int) Constant 3
69: TypePointer Uniform 19(int)
69: TypePointer StorageBuffer 19(int)
76: TypeVector 19(int) 2
77: TypePointer Uniform 20(ivec4)
77: TypePointer StorageBuffer 20(ivec4)
87: TypeVector 19(int) 3
103: TypePointer Uniform 6(int)
103: TypePointer StorageBuffer 6(int)
110: TypeVector 6(int) 2
111: TypePointer Uniform 21(ivec4)
111: TypePointer StorageBuffer 21(ivec4)
121: TypeVector 6(int) 3
137: TypePointer Uniform 22(float64_t)
137: TypePointer StorageBuffer 22(float64_t)
144: TypeVector 22(float64_t) 2
145: TypePointer Uniform 23(f64vec4)
145: TypePointer StorageBuffer 23(f64vec4)
155: TypeVector 22(float64_t) 3
173: TypeBool
183: 76(ivec2) ConstantComposite 29 29

View File

@ -36,7 +36,7 @@ spv.subgroupShuffleRelative.comp
MemberDecorate 24(Buffers) 1 Offset 16
MemberDecorate 24(Buffers) 2 Offset 32
MemberDecorate 24(Buffers) 3 Offset 64
Decorate 24(Buffers) BufferBlock
Decorate 24(Buffers) Block
Decorate 27(data) DescriptorSet 0
Decorate 27(data) Binding 0
Decorate 378 BuiltIn WorkgroupSize
@ -57,29 +57,29 @@ spv.subgroupShuffleRelative.comp
23: TypeVector 22(float64_t) 4
24(Buffers): TypeStruct 18(fvec4) 20(ivec4) 21(ivec4) 23(f64vec4)
25: TypeArray 24(Buffers) 15
26: TypePointer Uniform 25
27(data): 26(ptr) Variable Uniform
26: TypePointer StorageBuffer 25
27(data): 26(ptr) Variable StorageBuffer
29: 19(int) Constant 0
30: 6(int) Constant 0
31: TypePointer Uniform 17(float)
31: TypePointer StorageBuffer 17(float)
35: 6(int) Constant 3
39: 19(int) Constant 1
40: TypeVector 17(float) 2
41: TypePointer Uniform 18(fvec4)
41: TypePointer StorageBuffer 18(fvec4)
51: 19(int) Constant 2
52: TypeVector 17(float) 3
62: 19(int) Constant 3
69: TypePointer Uniform 19(int)
69: TypePointer StorageBuffer 19(int)
76: TypeVector 19(int) 2
77: TypePointer Uniform 20(ivec4)
77: TypePointer StorageBuffer 20(ivec4)
87: TypeVector 19(int) 3
103: TypePointer Uniform 6(int)
103: TypePointer StorageBuffer 6(int)
110: TypeVector 6(int) 2
111: TypePointer Uniform 21(ivec4)
111: TypePointer StorageBuffer 21(ivec4)
121: TypeVector 6(int) 3
137: TypePointer Uniform 22(float64_t)
137: TypePointer StorageBuffer 22(float64_t)
144: TypeVector 22(float64_t) 2
145: TypePointer Uniform 23(f64vec4)
145: TypePointer StorageBuffer 23(f64vec4)
155: TypeVector 22(float64_t) 3
173: TypeBool
183: 76(ivec2) ConstantComposite 29 29

View File

@ -38,7 +38,7 @@ spv.subgroupVote.comp
MemberDecorate 24(Buffers) 2 Offset 32
MemberDecorate 24(Buffers) 3 Offset 64
MemberDecorate 24(Buffers) 4 Offset 96
Decorate 24(Buffers) BufferBlock
Decorate 24(Buffers) Block
Decorate 27(data) DescriptorSet 0
Decorate 27(data) Binding 0
Decorate 215 BuiltIn WorkgroupSize
@ -59,31 +59,31 @@ spv.subgroupVote.comp
23: TypeVector 22(float64_t) 4
24(Buffers): TypeStruct 18(fvec4) 20(ivec4) 21(ivec4) 23(f64vec4) 19(int)
25: TypeArray 24(Buffers) 15
26: TypePointer Uniform 25
27(data): 26(ptr) Variable Uniform
26: TypePointer StorageBuffer 25
27(data): 26(ptr) Variable StorageBuffer
29: 19(int) Constant 4
30: TypePointer Uniform 19(int)
30: TypePointer StorageBuffer 19(int)
33: 19(int) Constant 0
34: TypeBool
36: 6(int) Constant 3
41: 6(int) Constant 0
42: TypePointer Uniform 17(float)
42: TypePointer StorageBuffer 17(float)
46: 19(int) Constant 1
50: TypeVector 17(float) 2
51: TypePointer Uniform 18(fvec4)
51: TypePointer StorageBuffer 18(fvec4)
59: 19(int) Constant 2
60: TypeVector 17(float) 3
68: 19(int) Constant 3
81: TypeVector 19(int) 2
82: TypePointer Uniform 20(ivec4)
82: TypePointer StorageBuffer 20(ivec4)
90: TypeVector 19(int) 3
104: TypePointer Uniform 6(int)
104: TypePointer StorageBuffer 6(int)
111: TypeVector 6(int) 2
112: TypePointer Uniform 21(ivec4)
112: TypePointer StorageBuffer 21(ivec4)
120: TypeVector 6(int) 3
142: TypePointer Uniform 22(float64_t)
142: TypePointer StorageBuffer 22(float64_t)
149: TypeVector 22(float64_t) 2
150: TypePointer Uniform 23(f64vec4)
150: TypePointer StorageBuffer 23(f64vec4)
158: TypeVector 22(float64_t) 3
182: 81(ivec2) ConstantComposite 33 33
183: TypeVector 34(bool) 2

View File

@ -0,0 +1,15 @@
#version 450
#extension GL_EXT_shader_8bit_storage: require
layout(binding = 0) readonly buffer Vertices
{
uint8_t vertices[];
};
layout(location = 0) out vec4 color;
void main()
{
color = vec4(int(vertices[gl_VertexIndex]));
}

View File

@ -0,0 +1,15 @@
#version 450
#extension GL_EXT_shader_8bit_storage: require
layout(binding = 0) readonly uniform Vertices
{
uint8_t vertices[512];
};
layout(location = 0) out vec4 color;
void main()
{
color = vec4(int(vertices[gl_VertexIndex]));
}

View File

@ -0,0 +1,15 @@
#version 450
#extension GL_EXT_shader_8bit_storage: require
layout(binding = 0) readonly buffer Vertices
{
uint8_t vertices[];
};
layout(location = 0) out vec4 color;
void main()
{
color = vec4(int(vertices[gl_VertexIndex]));
}

View File

@ -0,0 +1,15 @@
#version 450
#extension GL_EXT_shader_8bit_storage: require
layout(binding = 0) readonly uniform Vertices
{
uint8_t vertices[512];
};
layout(location = 0) out vec4 color;
void main()
{
color = vec4(int(vertices[gl_VertexIndex]));
}

View File

@ -76,6 +76,10 @@ TParseContext::TParseContext(TSymbolTable& symbolTable, TIntermediate& interm, b
globalBufferDefaults.layoutMatrix = ElmColumnMajor;
globalBufferDefaults.layoutPacking = spvVersion.spv != 0 ? ElpStd430 : ElpShared;
// use storage buffer on SPIR-V 1.3 and up
if (spvVersion.spv >= EShTargetSpv_1_3)
intermediate.setUseStorageBuffer();
globalInputDefaults.clear();
globalOutputDefaults.clear();

View File

@ -241,6 +241,8 @@ INSTANTIATE_TEST_CASE_P(
"spv.8bitstorage_Error-int.frag",
"spv.8bitstorage-uint.frag",
"spv.8bitstorage_Error-uint.frag",
"spv.8bitstorage-ubo.vert",
"spv.8bitstorage-ssbo.vert",
"spv.accessChain.frag",
"spv.aggOps.frag",
"spv.always-discard.frag",
@ -365,6 +367,8 @@ INSTANTIATE_TEST_CASE_P(
INSTANTIATE_TEST_CASE_P(
Glsl, CompileVulkan1_1ToSpirvTest,
::testing::ValuesIn(std::vector<std::string>({
"spv.1.3.8bitstorage-ubo.vert",
"spv.1.3.8bitstorage-ssbo.vert",
"spv.deviceGroup.frag",
"spv.drawParams.vert",
"spv.int8.frag",