Skip to content

Commit c2ebbbd

Browse files
kylehiebelarcady-lunarg
authored andcommitted
Unconditionally emit debug source for include files when using non-semantic debug info + test
1 parent aa8e19e commit c2ebbbd

5 files changed

Lines changed: 100 additions & 0 deletions

File tree

SPIRV/SpvBuilder.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,6 +1381,14 @@ Id Builder::makeDebugCompilationUnit() {
13811381
module.mapInstruction(sourceInst);
13821382
nonSemanticShaderCompilationUnitId = resultId;
13831383

1384+
// In the case of non-semantic shader debug info, preserve source text for every include
1385+
// even if no debug scope or line record ends up referencing that file.
1386+
if (emitNonSemanticShaderDebugSource) {
1387+
for (const auto& includeFile : includeFiles) {
1388+
makeDebugSource(includeFile.first);
1389+
}
1390+
}
1391+
13841392
// We can reasonably assume that makeDebugCompilationUnit will be called before any of
13851393
// debug-scope stack. Function scopes and lexical scopes will occur afterward.
13861394
assert(currentDebugScopeId.empty());
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
spv.debuginfo.macro.include.glsl.frag
2+
// Module Version 10000
3+
// Generated by (magic number): 8000b
4+
// Id's are bound by 52
5+
6+
Capability Shader
7+
Extension "SPV_KHR_non_semantic_info"
8+
1: ExtInstImport "NonSemantic.Shader.DebugInfo.100"
9+
4: ExtInstImport "GLSL.std.450"
10+
MemoryModel Logical GLSL450
11+
EntryPoint Fragment 15 "main" 35
12+
ExecutionMode 15 OriginUpperLeft
13+
2: String "spv.debuginfo.macro.include.glsl.frag"
14+
3: String "spv.debuginfo.macro.include.glsl.h"
15+
9: String "uint"
16+
17: String "main"
17+
20: String "#version 450
18+
#extension GL_GOOGLE_include_directive : require
19+
#include "spv.debuginfo.macro.include.glsl.h"
20+
21+
layout(location = 0) out vec4 fragColor;
22+
23+
void main()
24+
{
25+
fragColor = INCLUDED_COLOR;
26+
}
27+
"
28+
27: String "#define INCLUDED_COLOR vec4(0.25, 0.5, 0.75, 1.0)
29+
"
30+
29: String "float"
31+
37: String "fragColor"
32+
SourceExtension "GL_GOOGLE_cpp_style_line_directive"
33+
SourceExtension "GL_GOOGLE_include_directive"
34+
Name 15 "main"
35+
Name 35 "fragColor"
36+
Decorate 35(fragColor) Location 0
37+
5: TypeVoid
38+
6: TypeFunction 5
39+
8: TypeInt 32 0
40+
11: 8(int) Constant 32
41+
12: 8(int) Constant 6
42+
13: 8(int) Constant 0
43+
10: 5 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 2(DebugTypeBasic) 9 11 12 13
44+
14: 8(int) Constant 3
45+
7: 5 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 8(DebugTypeFunction) 14 5
46+
19: 5 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 35(DebugSource) 2 20
47+
21: 8(int) Constant 7
48+
23: 8(int) Constant 1
49+
24: 8(int) Constant 4
50+
25: 8(int) Constant 2
51+
22: 5 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 1(DebugCompilationUnit) 23 24 19 25
52+
26: 5 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 35(DebugSource) 3 27
53+
18: 5 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 20(DebugFunction) 17 7 19 21 13 22 17 14 21
54+
28: TypeFloat 32
55+
30: 5 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 2(DebugTypeBasic) 29 11 14 13
56+
31: TypeVector 28(float) 4
57+
32: 5 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 6(DebugTypeVector) 30 24
58+
33: TypePointer Output 31(fvec4)
59+
34: 5 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 3(DebugTypePointer) 32 14 13
60+
35(fragColor): 33(ptr) Variable Output
61+
38: 8(int) Constant 5
62+
39: 8(int) Constant 8
63+
36: 5 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 18(DebugGlobalVariable) 37 32 19 38 13 22 37 35(fragColor) 39
64+
43: 28(float) Constant 1048576000
65+
44: 28(float) Constant 1056964608
66+
45: 28(float) Constant 1061158912
67+
46: 28(float) Constant 1065353216
68+
47: 31(fvec4) ConstantComposite 43 44 45 46
69+
49: 8(int) Constant 9
70+
51: 8(int) Constant 10
71+
15(main): 5 Function None 6
72+
16: Label
73+
41: 5 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 18
74+
42: 5 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 19 21 21 13 13
75+
40: 5 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 101(DebugFunctionDefinition) 18 15(main)
76+
48: 5 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 19 49 49 13 13
77+
Store 35(fragColor) 47
78+
50: 5 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 19 51 51 13 13
79+
Return
80+
FunctionEnd
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#version 450
2+
#extension GL_GOOGLE_include_directive : require
3+
#include "spv.debuginfo.macro.include.glsl.h"
4+
5+
layout(location = 0) out vec4 fragColor;
6+
7+
void main()
8+
{
9+
fragColor = INCLUDED_COLOR;
10+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#define INCLUDED_COLOR vec4(0.25, 0.5, 0.75, 1.0)

gtests/Spv.FromFile.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,6 +1144,7 @@ INSTANTIATE_TEST_SUITE_P(
11441144
"spv.debuginfo.const_params.glsl.comp",
11451145
"spv.debuginfo.scalar_types.glsl.frag",
11461146
"spv.debuginfo.include.glsl.frag",
1147+
"spv.debuginfo.macro.include.glsl.frag",
11471148
"spv.debuginfo.multiline.glsl.frag",
11481149
"spv.debuginfo.implicit_br.glsl.frag",
11491150
"spv.debuginfo.non_ascii.glsl.frag",

0 commit comments

Comments
 (0)