spirv: don't emit invalid debuginfo for buffer references

Currently no debug info is emitted for buffer reference types, which
resulted in the SPIR-V backend code asserting when trying to emit the
debug info for struct member that had such a type. Instead, the code now
skips such struct members. Full debug info for buffer references may
require forward references in the debug info instructions, which is
currently prohibited by the spec.
This commit is contained in:
Arcady Goldmints-Orlov 2023-10-12 13:42:32 -04:00 committed by arcady-lunarg
parent 48f9ed8b08
commit 0504953b35
4 changed files with 219 additions and 1 deletions

View File

@ -1029,6 +1029,9 @@ Id Builder::makeCompositeDebugType(std::vector<Id> const& memberTypes, char cons
for(auto const memberType : memberTypes) { for(auto const memberType : memberTypes) {
assert(debugTypeLocs.find(memberType) != debugTypeLocs.end()); assert(debugTypeLocs.find(memberType) != debugTypeLocs.end());
// There _should_ be debug types for all the member types but currently buffer references
// do not have member debug info generated.
if (debugId[memberType])
memberDebugTypes.emplace_back(makeMemberDebugType(memberType, debugTypeLocs[memberType])); memberDebugTypes.emplace_back(makeMemberDebugType(memberType, debugTypeLocs[memberType]));
// TODO: Need to rethink this method of passing location information. // TODO: Need to rethink this method of passing location information.

View File

@ -0,0 +1,186 @@
spv.debuginfo.bufferref.glsl.frag
// Module Version 10000
// Generated by (magic number): 8000b
// Id's are bound by 131
Capability Shader
Capability PhysicalStorageBufferAddressesEXT
Extension "SPV_KHR_non_semantic_info"
Extension "SPV_KHR_physical_storage_buffer"
Extension "SPV_KHR_storage_buffer_storage_class"
2: ExtInstImport "NonSemantic.Shader.DebugInfo.100"
3: ExtInstImport "GLSL.std.450"
MemoryModel PhysicalStorageBuffer64EXT GLSL450
EntryPoint Fragment 14 "main" 69 122
ExecutionMode 14 OriginUpperLeft
1: String ""
8: String "uint"
15: String "main"
18: String "// OpModuleProcessed auto-map-locations
// OpModuleProcessed auto-map-bindings
// OpModuleProcessed client vulkan100
// OpModuleProcessed target-env vulkan1.0
// OpModuleProcessed keep-uncalled
// OpModuleProcessed entry-point main
#line 1
"
31: String "Mesh"
33: String "float"
39: String "data"
43: String "MeshVertexPositions"
47: String "meshData"
59: String "PerPass_meshes"
63: String "perPass_meshes"
65: String "int"
71: String "tri_idx0"
86: String "vertex_pos0"
124: String "out_fragColor"
SourceExtension "GL_EXT_buffer_reference"
Name 14 "main"
Name 29 "Mesh"
MemberName 29(Mesh) 0 "positions"
Name 37 "MeshVertexPositions"
MemberName 37(MeshVertexPositions) 0 "data"
Name 45 "meshData"
Name 50 "Mesh"
MemberName 50(Mesh) 0 "positions"
Name 54 "PerPass_meshes"
MemberName 54(PerPass_meshes) 0 "data"
Name 61 "perPass_meshes"
Name 69 "tri_idx0"
Name 84 "vertex_pos0"
Name 122 "out_fragColor"
Decorate 35 ArrayStride 4
MemberDecorate 37(MeshVertexPositions) 0 Offset 0
Decorate 37(MeshVertexPositions) Block
MemberDecorate 50(Mesh) 0 Offset 0
Decorate 52 ArrayStride 8
MemberDecorate 54(PerPass_meshes) 0 NonWritable
MemberDecorate 54(PerPass_meshes) 0 Offset 0
Decorate 54(PerPass_meshes) Block
Decorate 61(perPass_meshes) DescriptorSet 0
Decorate 61(perPass_meshes) Binding 0
Decorate 69(tri_idx0) Flat
Decorate 69(tri_idx0) Location 0
Decorate 122(out_fragColor) Location 0
Decorate 45(meshData) DecorationAliasedPointerEXT
4: TypeVoid
5: TypeFunction 4
7: TypeInt 32 0
10: 7(int) Constant 32
11: 7(int) Constant 6
12: 7(int) Constant 0
9: 4 ExtInst 2(NonSemantic.Shader.DebugInfo.100) 2(DebugTypeBasic) 8 10 11 12
13: 7(int) Constant 3
6: 4 ExtInst 2(NonSemantic.Shader.DebugInfo.100) 8(DebugTypeFunction) 13 4
17: 4 ExtInst 2(NonSemantic.Shader.DebugInfo.100) 35(DebugSource) 1 18
20: 7(int) Constant 1
21: 7(int) Constant 4
22: 7(int) Constant 2
19: 4 ExtInst 2(NonSemantic.Shader.DebugInfo.100) 1(DebugCompilationUnit) 20 21 17 22
16: 4 ExtInst 2(NonSemantic.Shader.DebugInfo.100) 20(DebugFunction) 15 6 17 12 12 19 15 13 12
27: 7(int) Constant 21
TypeForwardPointer 28 PhysicalStorageBufferEXT
29(Mesh): TypeStruct 28
30: 4 ExtInst 2(NonSemantic.Shader.DebugInfo.100) 10(DebugTypeComposite) 31 20 17 27 12 19 31 12 13
32: TypeFloat 32
34: 4 ExtInst 2(NonSemantic.Shader.DebugInfo.100) 2(DebugTypeBasic) 33 10 13 12
35: TypeRuntimeArray 32(float)
36: 4 ExtInst 2(NonSemantic.Shader.DebugInfo.100) 5(DebugTypeArray) 34 12
37(MeshVertexPositions): TypeStruct 35
40: 7(int) Constant 5
41: 7(int) Constant 9
38: 4 ExtInst 2(NonSemantic.Shader.DebugInfo.100) 11(DebugTypeMember) 39 36 17 40 41 12 12 13
42: 4 ExtInst 2(NonSemantic.Shader.DebugInfo.100) 10(DebugTypeComposite) 43 20 17 27 12 19 43 12 13 38
28: TypePointer PhysicalStorageBufferEXT 37(MeshVertexPositions)
44: TypePointer Function 29(Mesh)
46: 4 ExtInst 2(NonSemantic.Shader.DebugInfo.100) 26(DebugLocalVariable) 47 30 17 27 12 16 21
49: 4 ExtInst 2(NonSemantic.Shader.DebugInfo.100) 31(DebugExpression)
50(Mesh): TypeStruct 28(ptr)
51: 4 ExtInst 2(NonSemantic.Shader.DebugInfo.100) 10(DebugTypeComposite) 31 20 17 27 12 19 31 12 13
52: TypeRuntimeArray 50(Mesh)
53: 4 ExtInst 2(NonSemantic.Shader.DebugInfo.100) 5(DebugTypeArray) 51 12
54(PerPass_meshes): TypeStruct 52
56: 7(int) Constant 13
57: 7(int) Constant 8
55: 4 ExtInst 2(NonSemantic.Shader.DebugInfo.100) 11(DebugTypeMember) 39 53 17 56 57 12 12 13
58: 4 ExtInst 2(NonSemantic.Shader.DebugInfo.100) 10(DebugTypeComposite) 59 20 17 27 12 19 59 12 13 55
60: TypePointer StorageBuffer 54(PerPass_meshes)
61(perPass_meshes): 60(ptr) Variable StorageBuffer
62: 4 ExtInst 2(NonSemantic.Shader.DebugInfo.100) 18(DebugGlobalVariable) 63 58 17 27 12 19 63 61(perPass_meshes) 57
64: TypeInt 32 1
66: 4 ExtInst 2(NonSemantic.Shader.DebugInfo.100) 2(DebugTypeBasic) 65 10 21 12
67: 64(int) Constant 0
68: TypePointer Input 7(int)
69(tri_idx0): 68(ptr) Variable Input
70: 4 ExtInst 2(NonSemantic.Shader.DebugInfo.100) 18(DebugGlobalVariable) 71 9 17 27 12 19 71 69(tri_idx0) 57
73: TypePointer StorageBuffer 50(Mesh)
77: TypePointer Function 28(ptr)
80: 7(int) Constant 23
81: TypeVector 32(float) 3
82: 4 ExtInst 2(NonSemantic.Shader.DebugInfo.100) 6(DebugTypeVector) 34 13
83: TypePointer Function 81(fvec3)
85: 4 ExtInst 2(NonSemantic.Shader.DebugInfo.100) 26(DebugLocalVariable) 86 82 17 80 12 16 21
89: 7(int) Constant 25
95: TypePointer PhysicalStorageBufferEXT 32(float)
99: 7(int) Constant 24
118: 7(int) Constant 27
119: TypeVector 32(float) 4
120: 4 ExtInst 2(NonSemantic.Shader.DebugInfo.100) 6(DebugTypeVector) 34 21
121: TypePointer Output 119(fvec4)
122(out_fragColor): 121(ptr) Variable Output
123: 4 ExtInst 2(NonSemantic.Shader.DebugInfo.100) 18(DebugGlobalVariable) 124 120 17 118 12 19 124 122(out_fragColor) 57
126: 32(float) Constant 1065353216
Line 1 20 11
14(main): 4 Function None 5
23: Label
45(meshData): 44(ptr) Variable Function
84(vertex_pos0): 83(ptr) Variable Function
24: 4 ExtInst 2(NonSemantic.Shader.DebugInfo.100) 101(DebugFunctionDefinition) 16 14(main)
25: 4 ExtInst 2(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 16
26: 4 ExtInst 2(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 17 27 27 12 12
48: 4 ExtInst 2(NonSemantic.Shader.DebugInfo.100) 28(DebugDeclare) 46 45(meshData) 49
72: 7(int) Load 69(tri_idx0)
74: 73(ptr) AccessChain 61(perPass_meshes) 67 72
75: 50(Mesh) Load 74
76: 28(ptr) CompositeExtract 75 0
78: 77(ptr) AccessChain 45(meshData) 67
Store 78 76
79: 4 ExtInst 2(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 17 80 80 12 12
87: 4 ExtInst 2(NonSemantic.Shader.DebugInfo.100) 28(DebugDeclare) 85 84(vertex_pos0) 49
88: 4 ExtInst 2(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 17 89 89 12 12
90: 4 ExtInst 2(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 17 80 80 12 12
91: 77(ptr) AccessChain 45(meshData) 67
92: 28(ptr) Load 91
93: 7(int) Load 69(tri_idx0)
94: 7(int) IMul 13 93
96: 95(ptr) AccessChain 92 67 94
97: 32(float) Load 96 Aligned 4
98: 4 ExtInst 2(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 17 99 99 12 12
100: 77(ptr) AccessChain 45(meshData) 67
101: 28(ptr) Load 100
102: 7(int) Load 69(tri_idx0)
103: 7(int) IMul 13 102
104: 7(int) IAdd 103 20
105: 95(ptr) AccessChain 101 67 104
106: 32(float) Load 105 Aligned 4
107: 4 ExtInst 2(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 17 89 89 12 12
108: 77(ptr) AccessChain 45(meshData) 67
109: 28(ptr) Load 108
110: 7(int) Load 69(tri_idx0)
111: 7(int) IMul 13 110
112: 7(int) IAdd 111 22
113: 95(ptr) AccessChain 109 67 112
114: 32(float) Load 113 Aligned 4
115: 81(fvec3) CompositeConstruct 97 106 114
116: 4 ExtInst 2(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 17 80 80 12 12
Store 84(vertex_pos0) 115
117: 4 ExtInst 2(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 17 118 118 12 12
125: 81(fvec3) Load 84(vertex_pos0)
127: 32(float) CompositeExtract 125 0
128: 32(float) CompositeExtract 125 1
129: 32(float) CompositeExtract 125 2
130: 119(fvec4) CompositeConstruct 127 128 129 126
Store 122(out_fragColor) 130
Return
FunctionEnd

View File

@ -0,0 +1,28 @@
#version 450 core
#extension GL_EXT_buffer_reference : enable
layout(buffer_reference, std430) buffer MeshVertexPositions {
float data[];
};
struct Mesh {
MeshVertexPositions positions;
};
layout(set = 0, binding = 0) readonly buffer PerPass_meshes {
Mesh data[];
} perPass_meshes;
layout(location = 0) out vec4 out_fragColor;
layout(location = 0) in flat uint tri_idx0;
void main() {
Mesh meshData = perPass_meshes.data[tri_idx0];
vec3 vertex_pos0 = vec3(meshData.positions.data[3 * tri_idx0],
meshData.positions.data[3 * tri_idx0 + 1],
meshData.positions.data[3 * tri_idx0 + 2]);
out_fragColor = vec4(vertex_pos0, 1.0);
}

View File

@ -931,6 +931,7 @@ INSTANTIATE_TEST_SUITE_P(
"spv.debuginfo.glsl.geom", "spv.debuginfo.glsl.geom",
"spv.debuginfo.glsl.tesc", "spv.debuginfo.glsl.tesc",
"spv.debuginfo.glsl.tese", "spv.debuginfo.glsl.tese",
"spv.debuginfo.bufferref.glsl.frag",
"spv.debuginfo.const_params.glsl.comp", "spv.debuginfo.const_params.glsl.comp",
"spv.debuginfo.scalar_types.glsl.frag", "spv.debuginfo.scalar_types.glsl.frag",
})), })),