Merge pull request #1019 from KhronosGroup/fix-1018

Employ heuristics to figure out how to emit SSBO/UAV reflection names.
This commit is contained in:
Hans-Kristian Arntzen 2019-06-10 14:05:37 +02:00 committed by GitHub
commit 3e53273cc7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 809 additions and 9 deletions

View File

@ -0,0 +1,32 @@
{
"entryPoints" : [
{
"name" : "main",
"mode" : "comp"
}
],
"types" : {
"_5" : {
"name" : "SSBO0",
"members" : [
{
"name" : "a",
"type" : "vec4",
"array" : [
0
],
"offset" : 0
}
]
}
},
"ssbos" : [
{
"type" : "_5",
"name" : "SSBO0",
"block_size" : 0,
"set" : 0,
"binding" : 0
}
]
}

View File

@ -0,0 +1,52 @@
{
"entryPoints" : [
{
"name" : "main",
"mode" : "comp"
}
],
"types" : {
"_4" : {
"name" : "SSBO0",
"members" : [
{
"name" : "a",
"type" : "vec4",
"array" : [
0
],
"offset" : 0
}
]
},
"_6" : {
"name" : "SSBO1",
"members" : [
{
"name" : "b",
"type" : "vec4",
"array" : [
0
],
"offset" : 0
}
]
}
},
"ssbos" : [
{
"type" : "_4",
"name" : "SSBO0",
"block_size" : 0,
"set" : 0,
"binding" : 0
},
{
"type" : "_6",
"name" : "SSBO1",
"block_size" : 0,
"set" : 0,
"binding" : 1
}
]
}

View File

@ -0,0 +1,32 @@
{
"entryPoints" : [
{
"name" : "main",
"mode" : "comp"
}
],
"types" : {
"_4" : {
"name" : "UAV0",
"members" : [
{
"name" : "_data",
"type" : "vec4",
"array" : [
0
],
"offset" : 0
}
]
}
},
"ssbos" : [
{
"type" : "_4",
"name" : "UAV0",
"block_size" : 0,
"set" : 0,
"binding" : 0
}
]
}

View File

@ -0,0 +1,39 @@
{
"entryPoints" : [
{
"name" : "main",
"mode" : "comp"
}
],
"types" : {
"_4" : {
"name" : "UAV0",
"members" : [
{
"name" : "_data",
"type" : "vec4",
"array" : [
0
],
"offset" : 0
}
]
}
},
"ssbos" : [
{
"type" : "_4",
"name" : "UAV0",
"block_size" : 0,
"set" : 0,
"binding" : 0
},
{
"type" : "_4",
"name" : "UAV1",
"block_size" : 0,
"set" : 0,
"binding" : 1
}
]
}

View File

@ -0,0 +1,32 @@
{
"entryPoints" : [
{
"name" : "main",
"mode" : "comp"
}
],
"types" : {
"_5" : {
"name" : "SSBO0",
"members" : [
{
"name" : "a",
"type" : "vec4",
"array" : [
0
],
"offset" : 0
}
]
}
},
"ssbos" : [
{
"type" : "_5",
"name" : "SSBO0",
"block_size" : 0,
"set" : 0,
"binding" : 0
}
]
}

View File

@ -0,0 +1,52 @@
{
"entryPoints" : [
{
"name" : "main",
"mode" : "comp"
}
],
"types" : {
"_4" : {
"name" : "SSBO0",
"members" : [
{
"name" : "a",
"type" : "vec4",
"array" : [
0
],
"offset" : 0
}
]
},
"_6" : {
"name" : "SSBO1",
"members" : [
{
"name" : "b",
"type" : "vec4",
"array" : [
0
],
"offset" : 0
}
]
}
},
"ssbos" : [
{
"type" : "_4",
"name" : "SSBO0",
"block_size" : 0,
"set" : 0,
"binding" : 0
},
{
"type" : "_6",
"name" : "SSBO1",
"block_size" : 0,
"set" : 0,
"binding" : 1
}
]
}

View File

@ -0,0 +1,32 @@
{
"entryPoints" : [
{
"name" : "main",
"mode" : "comp"
}
],
"types" : {
"_4" : {
"name" : "UAV0",
"members" : [
{
"name" : "_data",
"type" : "vec4",
"array" : [
0
],
"offset" : 0
}
]
}
},
"ssbos" : [
{
"type" : "_4",
"name" : "UAV0",
"block_size" : 0,
"set" : 0,
"binding" : 0
}
]
}

View File

@ -0,0 +1,39 @@
{
"entryPoints" : [
{
"name" : "main",
"mode" : "comp"
}
],
"types" : {
"_4" : {
"name" : "UAV0",
"members" : [
{
"name" : "_data",
"type" : "vec4",
"array" : [
0
],
"offset" : 0
}
]
}
},
"ssbos" : [
{
"type" : "_4",
"name" : "UAV0",
"block_size" : 0,
"set" : 0,
"binding" : 0
},
{
"type" : "_4",
"name" : "UAV1",
"block_size" : 0,
"set" : 0,
"binding" : 1
}
]
}

View File

@ -0,0 +1,53 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 7
; Bound: 35
; Schema: 0
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %main "main" %gl_GlobalInvocationID %_
OpExecutionMode %main LocalSize 1 1 1
OpSource GLSL 450
OpName %main "main"
OpName %SSBO0 "SSBO0"
OpMemberName %SSBO0 0 "a"
OpName %_ ""
OpName %gl_GlobalInvocationID "gl_GlobalInvocationID"
OpDecorate %_runtimearr_v4float ArrayStride 16
OpMemberDecorate %SSBO0 0 Offset 0
OpDecorate %SSBO0 BufferBlock
OpDecorate %_ DescriptorSet 0
OpDecorate %_ Binding 0
OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId
OpDecorate %_runtimearr_v4float_0 ArrayStride 16
%void = OpTypeVoid
%3 = OpTypeFunction %void
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%_runtimearr_v4float = OpTypeRuntimeArray %v4float
%SSBO0 = OpTypeStruct %_runtimearr_v4float
%_ptr_Uniform_SSBO0 = OpTypePointer Uniform %SSBO0
%_ = OpVariable %_ptr_Uniform_SSBO0 Uniform
%int = OpTypeInt 32 1
%int_0 = OpConstant %int 0
%uint = OpTypeInt 32 0
%v3uint = OpTypeVector %uint 3
%_ptr_Input_v3uint = OpTypePointer Input %v3uint
%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3uint Input
%uint_0 = OpConstant %uint 0
%_ptr_Input_uint = OpTypePointer Input %uint
%float_1 = OpConstant %float 1
%23 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1
%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
%_runtimearr_v4float_0 = OpTypeRuntimeArray %v4float
%float_2 = OpConstant %float 2
%33 = OpConstantComposite %v4float %float_2 %float_2 %float_2 %float_2
%main = OpFunction %void None %3
%5 = OpLabel
%20 = OpAccessChain %_ptr_Input_uint %gl_GlobalInvocationID %uint_0
%21 = OpLoad %uint %20
%25 = OpAccessChain %_ptr_Uniform_v4float %_ %int_0 %21
OpStore %25 %23
OpReturn
OpFunctionEnd

View File

@ -0,0 +1,65 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 7
; Bound: 35
; Schema: 0
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %main "main" %gl_GlobalInvocationID
OpExecutionMode %main LocalSize 1 1 1
OpSource GLSL 450
OpName %main "main"
OpName %SSBO0 "SSBO0"
OpMemberName %SSBO0 0 "a"
OpName %_ ""
OpName %gl_GlobalInvocationID "gl_GlobalInvocationID"
OpName %SSBO1 "SSBO1"
OpMemberName %SSBO1 0 "b"
OpName %__0 ""
OpDecorate %_runtimearr_v4float ArrayStride 16
OpMemberDecorate %SSBO0 0 Offset 0
OpDecorate %SSBO0 BufferBlock
OpDecorate %_ DescriptorSet 0
OpDecorate %_ Binding 0
OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId
OpDecorate %_runtimearr_v4float_0 ArrayStride 16
OpMemberDecorate %SSBO1 0 Offset 0
OpDecorate %SSBO1 BufferBlock
OpDecorate %__0 DescriptorSet 0
OpDecorate %__0 Binding 1
%void = OpTypeVoid
%3 = OpTypeFunction %void
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%_runtimearr_v4float = OpTypeRuntimeArray %v4float
%SSBO0 = OpTypeStruct %_runtimearr_v4float
%_ptr_Uniform_SSBO0 = OpTypePointer Uniform %SSBO0
%_ = OpVariable %_ptr_Uniform_SSBO0 Uniform
%int = OpTypeInt 32 1
%int_0 = OpConstant %int 0
%uint = OpTypeInt 32 0
%v3uint = OpTypeVector %uint 3
%_ptr_Input_v3uint = OpTypePointer Input %v3uint
%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3uint Input
%uint_0 = OpConstant %uint 0
%_ptr_Input_uint = OpTypePointer Input %uint
%float_1 = OpConstant %float 1
%23 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1
%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
%_runtimearr_v4float_0 = OpTypeRuntimeArray %v4float
%SSBO1 = OpTypeStruct %_runtimearr_v4float_0
%_ptr_Uniform_SSBO1 = OpTypePointer Uniform %SSBO1
%__0 = OpVariable %_ptr_Uniform_SSBO1 Uniform
%float_2 = OpConstant %float 2
%33 = OpConstantComposite %v4float %float_2 %float_2 %float_2 %float_2
%main = OpFunction %void None %3
%5 = OpLabel
%20 = OpAccessChain %_ptr_Input_uint %gl_GlobalInvocationID %uint_0
%21 = OpLoad %uint %20
%25 = OpAccessChain %_ptr_Uniform_v4float %_ %int_0 %21
OpStore %25 %23
%34 = OpAccessChain %_ptr_Uniform_v4float %__0 %int_0 %21
OpStore %34 %33
OpReturn
OpFunctionEnd

View File

@ -0,0 +1,48 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 7
; Bound: 48
; Schema: 0
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %main "main" %threadId
OpExecutionMode %main LocalSize 1 1 1
OpSource HLSL 500
OpName %main "main"
OpName %UAV0 "UAV0"
OpMemberName %UAV0 0 "@data"
OpName %UAV0_0 "UAV0"
OpName %threadId "threadId"
OpDecorate %_runtimearr_v4float ArrayStride 16
OpMemberDecorate %UAV0 0 Offset 0
OpDecorate %UAV0 BufferBlock
OpDecorate %UAV0_0 DescriptorSet 0
OpDecorate %UAV0_0 Binding 0
OpDecorate %threadId BuiltIn GlobalInvocationId
%void = OpTypeVoid
%3 = OpTypeFunction %void
%int = OpTypeInt 32 1
%v3int = OpTypeVector %int 3
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%_runtimearr_v4float = OpTypeRuntimeArray %v4float
%UAV0 = OpTypeStruct %_runtimearr_v4float
%_ptr_Uniform_UAV0 = OpTypePointer Uniform %UAV0
%UAV0_0 = OpVariable %_ptr_Uniform_UAV0 Uniform
%int_0 = OpConstant %int 0
%float_1 = OpConstant %float 1
%26 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1
%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
%float_2 = OpConstant %float 2
%33 = OpConstantComposite %v4float %float_2 %float_2 %float_2 %float_2
%_ptr_Input_v3int = OpTypePointer Input %v3int
%threadId = OpVariable %_ptr_Input_v3int Input
%main = OpFunction %void None %3
%5 = OpLabel
%38 = OpLoad %v3int %threadId
%43 = OpCompositeExtract %int %38 0
%44 = OpAccessChain %_ptr_Uniform_v4float %UAV0_0 %int_0 %43
OpStore %44 %26
OpReturn
OpFunctionEnd

View File

@ -0,0 +1,54 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 7
; Bound: 48
; Schema: 0
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %main "main" %threadId
OpExecutionMode %main LocalSize 1 1 1
OpSource HLSL 500
OpName %main "main"
OpName %UAV0 "UAV0"
OpMemberName %UAV0 0 "@data"
OpName %UAV0_0 "UAV0"
OpName %UAV1 "UAV1"
OpName %threadId "threadId"
OpDecorate %_runtimearr_v4float ArrayStride 16
OpMemberDecorate %UAV0 0 Offset 0
OpDecorate %UAV0 BufferBlock
OpDecorate %UAV0_0 DescriptorSet 0
OpDecorate %UAV0_0 Binding 0
OpDecorate %UAV1 DescriptorSet 0
OpDecorate %UAV1 Binding 1
OpDecorate %threadId BuiltIn GlobalInvocationId
%void = OpTypeVoid
%3 = OpTypeFunction %void
%int = OpTypeInt 32 1
%v3int = OpTypeVector %int 3
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%_runtimearr_v4float = OpTypeRuntimeArray %v4float
%UAV0 = OpTypeStruct %_runtimearr_v4float
%_ptr_Uniform_UAV0 = OpTypePointer Uniform %UAV0
%UAV0_0 = OpVariable %_ptr_Uniform_UAV0 Uniform
%int_0 = OpConstant %int 0
%float_1 = OpConstant %float 1
%26 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1
%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
%UAV1 = OpVariable %_ptr_Uniform_UAV0 Uniform
%float_2 = OpConstant %float 2
%33 = OpConstantComposite %v4float %float_2 %float_2 %float_2 %float_2
%_ptr_Input_v3int = OpTypePointer Input %v3int
%threadId = OpVariable %_ptr_Input_v3int Input
%main = OpFunction %void None %3
%5 = OpLabel
%38 = OpLoad %v3int %threadId
%43 = OpCompositeExtract %int %38 0
%44 = OpAccessChain %_ptr_Uniform_v4float %UAV0_0 %int_0 %43
OpStore %44 %26
%47 = OpAccessChain %_ptr_Uniform_v4float %UAV1 %int_0 %43
OpStore %47 %33
OpReturn
OpFunctionEnd

View File

@ -0,0 +1,52 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 7
; Bound: 35
; Schema: 0
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %main "main" %gl_GlobalInvocationID %_
OpExecutionMode %main LocalSize 1 1 1
OpName %main "main"
OpName %SSBO0 "SSBO0"
OpMemberName %SSBO0 0 "a"
OpName %_ ""
OpName %gl_GlobalInvocationID "gl_GlobalInvocationID"
OpDecorate %_runtimearr_v4float ArrayStride 16
OpMemberDecorate %SSBO0 0 Offset 0
OpDecorate %SSBO0 BufferBlock
OpDecorate %_ DescriptorSet 0
OpDecorate %_ Binding 0
OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId
OpDecorate %_runtimearr_v4float_0 ArrayStride 16
%void = OpTypeVoid
%3 = OpTypeFunction %void
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%_runtimearr_v4float = OpTypeRuntimeArray %v4float
%SSBO0 = OpTypeStruct %_runtimearr_v4float
%_ptr_Uniform_SSBO0 = OpTypePointer Uniform %SSBO0
%_ = OpVariable %_ptr_Uniform_SSBO0 Uniform
%int = OpTypeInt 32 1
%int_0 = OpConstant %int 0
%uint = OpTypeInt 32 0
%v3uint = OpTypeVector %uint 3
%_ptr_Input_v3uint = OpTypePointer Input %v3uint
%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3uint Input
%uint_0 = OpConstant %uint 0
%_ptr_Input_uint = OpTypePointer Input %uint
%float_1 = OpConstant %float 1
%23 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1
%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
%_runtimearr_v4float_0 = OpTypeRuntimeArray %v4float
%float_2 = OpConstant %float 2
%33 = OpConstantComposite %v4float %float_2 %float_2 %float_2 %float_2
%main = OpFunction %void None %3
%5 = OpLabel
%20 = OpAccessChain %_ptr_Input_uint %gl_GlobalInvocationID %uint_0
%21 = OpLoad %uint %20
%25 = OpAccessChain %_ptr_Uniform_v4float %_ %int_0 %21
OpStore %25 %23
OpReturn
OpFunctionEnd

View File

@ -0,0 +1,64 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 7
; Bound: 35
; Schema: 0
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %main "main" %gl_GlobalInvocationID
OpExecutionMode %main LocalSize 1 1 1
OpName %main "main"
OpName %SSBO0 "SSBO0"
OpMemberName %SSBO0 0 "a"
OpName %_ ""
OpName %gl_GlobalInvocationID "gl_GlobalInvocationID"
OpName %SSBO1 "SSBO1"
OpMemberName %SSBO1 0 "b"
OpName %__0 ""
OpDecorate %_runtimearr_v4float ArrayStride 16
OpMemberDecorate %SSBO0 0 Offset 0
OpDecorate %SSBO0 BufferBlock
OpDecorate %_ DescriptorSet 0
OpDecorate %_ Binding 0
OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId
OpDecorate %_runtimearr_v4float_0 ArrayStride 16
OpMemberDecorate %SSBO1 0 Offset 0
OpDecorate %SSBO1 BufferBlock
OpDecorate %__0 DescriptorSet 0
OpDecorate %__0 Binding 1
%void = OpTypeVoid
%3 = OpTypeFunction %void
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%_runtimearr_v4float = OpTypeRuntimeArray %v4float
%SSBO0 = OpTypeStruct %_runtimearr_v4float
%_ptr_Uniform_SSBO0 = OpTypePointer Uniform %SSBO0
%_ = OpVariable %_ptr_Uniform_SSBO0 Uniform
%int = OpTypeInt 32 1
%int_0 = OpConstant %int 0
%uint = OpTypeInt 32 0
%v3uint = OpTypeVector %uint 3
%_ptr_Input_v3uint = OpTypePointer Input %v3uint
%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3uint Input
%uint_0 = OpConstant %uint 0
%_ptr_Input_uint = OpTypePointer Input %uint
%float_1 = OpConstant %float 1
%23 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1
%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
%_runtimearr_v4float_0 = OpTypeRuntimeArray %v4float
%SSBO1 = OpTypeStruct %_runtimearr_v4float_0
%_ptr_Uniform_SSBO1 = OpTypePointer Uniform %SSBO1
%__0 = OpVariable %_ptr_Uniform_SSBO1 Uniform
%float_2 = OpConstant %float 2
%33 = OpConstantComposite %v4float %float_2 %float_2 %float_2 %float_2
%main = OpFunction %void None %3
%5 = OpLabel
%20 = OpAccessChain %_ptr_Input_uint %gl_GlobalInvocationID %uint_0
%21 = OpLoad %uint %20
%25 = OpAccessChain %_ptr_Uniform_v4float %_ %int_0 %21
OpStore %25 %23
%34 = OpAccessChain %_ptr_Uniform_v4float %__0 %int_0 %21
OpStore %34 %33
OpReturn
OpFunctionEnd

View File

@ -0,0 +1,47 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 7
; Bound: 48
; Schema: 0
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %main "main" %threadId
OpExecutionMode %main LocalSize 1 1 1
OpName %main "main"
OpName %UAV0 "UAV0"
OpMemberName %UAV0 0 "@data"
OpName %UAV0_0 "UAV0"
OpName %threadId "threadId"
OpDecorate %_runtimearr_v4float ArrayStride 16
OpMemberDecorate %UAV0 0 Offset 0
OpDecorate %UAV0 BufferBlock
OpDecorate %UAV0_0 DescriptorSet 0
OpDecorate %UAV0_0 Binding 0
OpDecorate %threadId BuiltIn GlobalInvocationId
%void = OpTypeVoid
%3 = OpTypeFunction %void
%int = OpTypeInt 32 1
%v3int = OpTypeVector %int 3
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%_runtimearr_v4float = OpTypeRuntimeArray %v4float
%UAV0 = OpTypeStruct %_runtimearr_v4float
%_ptr_Uniform_UAV0 = OpTypePointer Uniform %UAV0
%UAV0_0 = OpVariable %_ptr_Uniform_UAV0 Uniform
%int_0 = OpConstant %int 0
%float_1 = OpConstant %float 1
%26 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1
%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
%float_2 = OpConstant %float 2
%33 = OpConstantComposite %v4float %float_2 %float_2 %float_2 %float_2
%_ptr_Input_v3int = OpTypePointer Input %v3int
%threadId = OpVariable %_ptr_Input_v3int Input
%main = OpFunction %void None %3
%5 = OpLabel
%38 = OpLoad %v3int %threadId
%43 = OpCompositeExtract %int %38 0
%44 = OpAccessChain %_ptr_Uniform_v4float %UAV0_0 %int_0 %43
OpStore %44 %26
OpReturn
OpFunctionEnd

View File

@ -0,0 +1,53 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 7
; Bound: 48
; Schema: 0
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %main "main" %threadId
OpExecutionMode %main LocalSize 1 1 1
OpName %main "main"
OpName %UAV0 "UAV0"
OpMemberName %UAV0 0 "@data"
OpName %UAV0_0 "UAV0"
OpName %UAV1 "UAV1"
OpName %threadId "threadId"
OpDecorate %_runtimearr_v4float ArrayStride 16
OpMemberDecorate %UAV0 0 Offset 0
OpDecorate %UAV0 BufferBlock
OpDecorate %UAV0_0 DescriptorSet 0
OpDecorate %UAV0_0 Binding 0
OpDecorate %UAV1 DescriptorSet 0
OpDecorate %UAV1 Binding 1
OpDecorate %threadId BuiltIn GlobalInvocationId
%void = OpTypeVoid
%3 = OpTypeFunction %void
%int = OpTypeInt 32 1
%v3int = OpTypeVector %int 3
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%_runtimearr_v4float = OpTypeRuntimeArray %v4float
%UAV0 = OpTypeStruct %_runtimearr_v4float
%_ptr_Uniform_UAV0 = OpTypePointer Uniform %UAV0
%UAV0_0 = OpVariable %_ptr_Uniform_UAV0 Uniform
%int_0 = OpConstant %int 0
%float_1 = OpConstant %float 1
%26 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1
%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
%UAV1 = OpVariable %_ptr_Uniform_UAV0 Uniform
%float_2 = OpConstant %float 2
%33 = OpConstantComposite %v4float %float_2 %float_2 %float_2 %float_2
%_ptr_Input_v3int = OpTypePointer Input %v3int
%threadId = OpVariable %_ptr_Input_v3int Input
%main = OpFunction %void None %3
%5 = OpLabel
%38 = OpLoad %v3int %threadId
%43 = OpCompositeExtract %int %38 0
%44 = OpAccessChain %_ptr_Uniform_v4float %UAV0_0 %int_0 %43
OpStore %44 %26
%47 = OpAccessChain %_ptr_Uniform_v4float %UAV1 %int_0 %43
OpStore %47 %33
OpReturn
OpFunctionEnd

View File

@ -755,6 +755,8 @@ ShaderResources Compiler::get_shader_resources(const unordered_set<uint32_t> *ac
{
ShaderResources res;
bool ssbo_instance_name = reflection_ssbo_instance_name_is_significant();
ir.for_each_typed_id<SPIRVariable>([&](uint32_t, const SPIRVariable &var) {
auto &type = this->get<SPIRType>(var.basetype);
@ -772,7 +774,7 @@ ShaderResources Compiler::get_shader_resources(const unordered_set<uint32_t> *ac
if (has_decoration(type.self, DecorationBlock))
{
res.stage_inputs.push_back(
{ var.self, var.basetype, type.self, get_remapped_declared_block_name(var.self) });
{ var.self, var.basetype, type.self, get_remapped_declared_block_name(var.self, false) });
}
else
res.stage_inputs.push_back({ var.self, var.basetype, type.self, get_name(var.self) });
@ -788,7 +790,7 @@ ShaderResources Compiler::get_shader_resources(const unordered_set<uint32_t> *ac
if (has_decoration(type.self, DecorationBlock))
{
res.stage_outputs.push_back(
{ var.self, var.basetype, type.self, get_remapped_declared_block_name(var.self) });
{ var.self, var.basetype, type.self, get_remapped_declared_block_name(var.self, false) });
}
else
res.stage_outputs.push_back({ var.self, var.basetype, type.self, get_name(var.self) });
@ -797,19 +799,19 @@ ShaderResources Compiler::get_shader_resources(const unordered_set<uint32_t> *ac
else if (type.storage == StorageClassUniform && has_decoration(type.self, DecorationBlock))
{
res.uniform_buffers.push_back(
{ var.self, var.basetype, type.self, get_remapped_declared_block_name(var.self) });
{ var.self, var.basetype, type.self, get_remapped_declared_block_name(var.self, false) });
}
// Old way to declare SSBOs.
else if (type.storage == StorageClassUniform && has_decoration(type.self, DecorationBufferBlock))
{
res.storage_buffers.push_back(
{ var.self, var.basetype, type.self, get_remapped_declared_block_name(var.self) });
{ var.self, var.basetype, type.self, get_remapped_declared_block_name(var.self, ssbo_instance_name) });
}
// Modern way to declare SSBOs.
else if (type.storage == StorageClassStorageBuffer)
{
res.storage_buffers.push_back(
{ var.self, var.basetype, type.self, get_remapped_declared_block_name(var.self) });
{ var.self, var.basetype, type.self, get_remapped_declared_block_name(var.self, ssbo_instance_name) });
}
// Push constant blocks
else if (type.storage == StorageClassPushConstant)
@ -4139,21 +4141,70 @@ const SmallVector<std::string> &Compiler::get_declared_extensions() const
}
std::string Compiler::get_remapped_declared_block_name(uint32_t id) const
{
return get_remapped_declared_block_name(id, false);
}
std::string Compiler::get_remapped_declared_block_name(uint32_t id, bool fallback_prefer_instance_name) const
{
auto itr = declared_block_names.find(id);
if (itr != end(declared_block_names))
{
return itr->second;
}
else
{
auto &var = get<SPIRVariable>(id);
auto &type = get<SPIRType>(var.basetype);
auto *type_meta = ir.find_meta(type.self);
auto *block_name = type_meta ? &type_meta->decoration.alias : nullptr;
return (!block_name || block_name->empty()) ? get_block_fallback_name(id) : *block_name;
if (fallback_prefer_instance_name)
{
return to_name(var.self);
}
else
{
auto &type = get<SPIRType>(var.basetype);
auto *type_meta = ir.find_meta(type.self);
auto *block_name = type_meta ? &type_meta->decoration.alias : nullptr;
return (!block_name || block_name->empty()) ? get_block_fallback_name(id) : *block_name;
}
}
}
bool Compiler::reflection_ssbo_instance_name_is_significant() const
{
if (ir.source.known)
{
// UAVs from HLSL source tend to be declared in a way where the type is reused
// but the instance name is significant, and that's the name we should report.
// For GLSL, SSBOs each have their own block type as that's how GLSL is written.
return ir.source.hlsl;
}
unordered_set<uint32_t> ssbo_type_ids;
bool aliased_ssbo_types = false;
// If we don't have any OpSource information, we need to perform some shaky heuristics.
ir.for_each_typed_id<SPIRVariable>([&](uint32_t, const SPIRVariable &var) {
auto &type = this->get<SPIRType>(var.basetype);
if (!type.pointer || var.storage == StorageClassFunction)
return;
bool ssbo = var.storage == StorageClassStorageBuffer ||
(var.storage == StorageClassUniform && has_decoration(type.self, DecorationBufferBlock));
if (ssbo)
{
if (ssbo_type_ids.count(type.self))
aliased_ssbo_types = true;
else
ssbo_type_ids.insert(type.self);
}
});
// If the block name is aliased, assume we have HLSL-style UAV declarations.
return aliased_ssbo_types;
}
bool Compiler::instruction_to_result_type(uint32_t &result_type, uint32_t &result_id, spv::Op op, const uint32_t *args,
uint32_t length)
{

View File

@ -976,6 +976,9 @@ protected:
bool type_is_block_like(const SPIRType &type) const;
bool type_is_opaque_value(const SPIRType &type) const;
bool reflection_ssbo_instance_name_is_significant() const;
std::string get_remapped_declared_block_name(uint32_t id, bool fallback_prefer_instance_name) const;
private:
// Used only to implement the old deprecated get_entry_point() interface.
const SPIREntryPoint &get_first_entry_point(const std::string &name) const;