diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp index c222ccb74..b3f7df78b 100644 --- a/SPIRV/GlslangToSpv.cpp +++ b/SPIRV/GlslangToSpv.cpp @@ -2812,8 +2812,9 @@ 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) - builder.addCapability(spv::CapabilityStorageBuffer8BitAccess); + } else if (storageClass == spv::StorageClassStorageBuffer) { + builder.addExtension(spv::E_SPV_KHR_8bit_storage); + builder.addCapability(spv::CapabilityStorageBuffer8BitAccess); } } diff --git a/Test/baseResults/spv.1.3.8bitstorage-ssbo.vert.out b/Test/baseResults/spv.1.3.8bitstorage-ssbo.vert.out new file mode 100644 index 000000000..878aa1a2e --- /dev/null +++ b/Test/baseResults/spv.1.3.8bitstorage-ssbo.vert.out @@ -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 diff --git a/Test/baseResults/spv.1.3.8bitstorage-ubo.vert.out b/Test/baseResults/spv.1.3.8bitstorage-ubo.vert.out new file mode 100644 index 000000000..54b497ff3 --- /dev/null +++ b/Test/baseResults/spv.1.3.8bitstorage-ubo.vert.out @@ -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 diff --git a/Test/baseResults/spv.8bitstorage-int.frag.out b/Test/baseResults/spv.8bitstorage-int.frag.out index 55a8b3bd7..96cb2ae5d 100644 --- a/Test/baseResults/spv.8bitstorage-int.frag.out +++ b/Test/baseResults/spv.8bitstorage-int.frag.out @@ -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" diff --git a/Test/baseResults/spv.8bitstorage-ssbo.vert.out b/Test/baseResults/spv.8bitstorage-ssbo.vert.out new file mode 100644 index 000000000..1e2337836 --- /dev/null +++ b/Test/baseResults/spv.8bitstorage-ssbo.vert.out @@ -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 diff --git a/Test/baseResults/spv.8bitstorage-ubo.vert.out b/Test/baseResults/spv.8bitstorage-ubo.vert.out new file mode 100644 index 000000000..a6a05cfb5 --- /dev/null +++ b/Test/baseResults/spv.8bitstorage-ubo.vert.out @@ -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 diff --git a/Test/baseResults/spv.8bitstorage-uint.frag.out b/Test/baseResults/spv.8bitstorage-uint.frag.out index 461cec4f3..415bada43 100644 --- a/Test/baseResults/spv.8bitstorage-uint.frag.out +++ b/Test/baseResults/spv.8bitstorage-uint.frag.out @@ -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" diff --git a/Test/baseResults/spv.debugInfo.1.1.frag.out b/Test/baseResults/spv.debugInfo.1.1.frag.out index 7ba005225..f9c8578ca 100644 --- a/Test/baseResults/spv.debugInfo.1.1.frag.out +++ b/Test/baseResults/spv.debugInfo.1.1.frag.out @@ -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 diff --git a/Test/baseResults/spv.subgroup.geom.out b/Test/baseResults/spv.subgroup.geom.out index 8f134c712..a68343af6 100644 --- a/Test/baseResults/spv.subgroup.geom.out +++ b/Test/baseResults/spv.subgroup.geom.out @@ -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) diff --git a/Test/baseResults/spv.subgroup.tesc.out b/Test/baseResults/spv.subgroup.tesc.out index 2a7a96325..4e362e2dd 100644 --- a/Test/baseResults/spv.subgroup.tesc.out +++ b/Test/baseResults/spv.subgroup.tesc.out @@ -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) diff --git a/Test/baseResults/spv.subgroup.tese.out b/Test/baseResults/spv.subgroup.tese.out index 68c8076b1..e09f558d5 100644 --- a/Test/baseResults/spv.subgroup.tese.out +++ b/Test/baseResults/spv.subgroup.tese.out @@ -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) diff --git a/Test/baseResults/spv.subgroup.vert.out b/Test/baseResults/spv.subgroup.vert.out index e4e778491..2fbc92ba2 100644 --- a/Test/baseResults/spv.subgroup.vert.out +++ b/Test/baseResults/spv.subgroup.vert.out @@ -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) diff --git a/Test/baseResults/spv.subgroupArithmetic.comp.out b/Test/baseResults/spv.subgroupArithmetic.comp.out index c38d4d0ae..f4e251a0c 100644 --- a/Test/baseResults/spv.subgroupArithmetic.comp.out +++ b/Test/baseResults/spv.subgroupArithmetic.comp.out @@ -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 diff --git a/Test/baseResults/spv.subgroupBallot.comp.out b/Test/baseResults/spv.subgroupBallot.comp.out index 7b24337be..23a59132a 100644 --- a/Test/baseResults/spv.subgroupBallot.comp.out +++ b/Test/baseResults/spv.subgroupBallot.comp.out @@ -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 diff --git a/Test/baseResults/spv.subgroupBasic.comp.out b/Test/baseResults/spv.subgroupBasic.comp.out index 647712fd3..641534d5b 100644 --- a/Test/baseResults/spv.subgroupBasic.comp.out +++ b/Test/baseResults/spv.subgroupBasic.comp.out @@ -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 diff --git a/Test/baseResults/spv.subgroupClustered.comp.out b/Test/baseResults/spv.subgroupClustered.comp.out index 0c5c0c4d6..150eb8aa4 100644 --- a/Test/baseResults/spv.subgroupClustered.comp.out +++ b/Test/baseResults/spv.subgroupClustered.comp.out @@ -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 diff --git a/Test/baseResults/spv.subgroupPartitioned.comp.out b/Test/baseResults/spv.subgroupPartitioned.comp.out index f65d9962c..e967df4a2 100644 --- a/Test/baseResults/spv.subgroupPartitioned.comp.out +++ b/Test/baseResults/spv.subgroupPartitioned.comp.out @@ -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 diff --git a/Test/baseResults/spv.subgroupQuad.comp.out b/Test/baseResults/spv.subgroupQuad.comp.out index 0299fc9ab..435c490f4 100644 --- a/Test/baseResults/spv.subgroupQuad.comp.out +++ b/Test/baseResults/spv.subgroupQuad.comp.out @@ -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 diff --git a/Test/baseResults/spv.subgroupShuffle.comp.out b/Test/baseResults/spv.subgroupShuffle.comp.out index 2f5e4aa58..991c6fa77 100644 --- a/Test/baseResults/spv.subgroupShuffle.comp.out +++ b/Test/baseResults/spv.subgroupShuffle.comp.out @@ -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 diff --git a/Test/baseResults/spv.subgroupShuffleRelative.comp.out b/Test/baseResults/spv.subgroupShuffleRelative.comp.out index 757d4cab3..3aad7605b 100644 --- a/Test/baseResults/spv.subgroupShuffleRelative.comp.out +++ b/Test/baseResults/spv.subgroupShuffleRelative.comp.out @@ -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 diff --git a/Test/baseResults/spv.subgroupVote.comp.out b/Test/baseResults/spv.subgroupVote.comp.out index 89213da1a..4fdbb0be0 100644 --- a/Test/baseResults/spv.subgroupVote.comp.out +++ b/Test/baseResults/spv.subgroupVote.comp.out @@ -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 diff --git a/Test/spv.1.3.8bitstorage-ssbo.vert b/Test/spv.1.3.8bitstorage-ssbo.vert new file mode 100644 index 000000000..61ba7bf15 --- /dev/null +++ b/Test/spv.1.3.8bitstorage-ssbo.vert @@ -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])); +} diff --git a/Test/spv.1.3.8bitstorage-ubo.vert b/Test/spv.1.3.8bitstorage-ubo.vert new file mode 100644 index 000000000..5c49a2434 --- /dev/null +++ b/Test/spv.1.3.8bitstorage-ubo.vert @@ -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])); +} diff --git a/Test/spv.8bitstorage-ssbo.vert b/Test/spv.8bitstorage-ssbo.vert new file mode 100644 index 000000000..61ba7bf15 --- /dev/null +++ b/Test/spv.8bitstorage-ssbo.vert @@ -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])); +} diff --git a/Test/spv.8bitstorage-ubo.vert b/Test/spv.8bitstorage-ubo.vert new file mode 100644 index 000000000..5c49a2434 --- /dev/null +++ b/Test/spv.8bitstorage-ubo.vert @@ -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])); +} diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp index 4c2d69fd9..190f3fc56 100755 --- a/glslang/MachineIndependent/ParseHelper.cpp +++ b/glslang/MachineIndependent/ParseHelper.cpp @@ -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(); diff --git a/gtests/Spv.FromFile.cpp b/gtests/Spv.FromFile.cpp index 815839143..e4b43d4d4 100644 --- a/gtests/Spv.FromFile.cpp +++ b/gtests/Spv.FromFile.cpp @@ -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({ + "spv.1.3.8bitstorage-ubo.vert", + "spv.1.3.8bitstorage-ssbo.vert", "spv.deviceGroup.frag", "spv.drawParams.vert", "spv.int8.frag",