Fix function call line number for calls spanning multiple lines.

This commit is contained in:
Qingyuan Zheng 2024-07-02 08:11:11 +00:00 committed by arcady-lunarg
parent 85262fb20e
commit 704107fda3
4 changed files with 191 additions and 0 deletions

View File

@ -6444,6 +6444,9 @@ spv::Id TGlslangToSpvTraverser::handleUserFunctionCall(const glslang::TIntermAgg
}
}
// Reset source location to the function call location after argument evaluation
builder.setDebugSourceLocation(node->getLoc().line, node->getLoc().getFilename());
// 2. Allocate space for anything needing a copy, and if it's "in" or "inout"
// copy the original into that space.
//

View File

@ -0,0 +1,162 @@
spv.debuginfo.multiline.glsl.frag
// Module Version 10000
// Generated by (magic number): 8000b
// Id's are bound by 105
Capability Shader
Extension "SPV_KHR_non_semantic_info"
1: ExtInstImport "NonSemantic.Shader.DebugInfo.100"
3: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 14 "main" 73 79
ExecutionMode 14 OriginUpperLeft
2: String "spv.debuginfo.multiline.glsl.frag"
8: String "uint"
17: String "float"
29: String "add"
32: 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
#version 460
in float inx;
out float outx;
float add(float x, float y, float z) {
return
x
+
y
+
z
;
}
void main() {
outx
=
add(
inx+1,
inx+2,
inx+3
)
;
}"
38: String "x"
44: String "y"
47: String "z"
49: String "main"
75: String "outx"
81: String "inx"
Name 14 "main"
Name 27 "add(f1;f1;f1;"
Name 24 "x"
Name 25 "y"
Name 26 "z"
Name 73 "outx"
Name 79 "inx"
Name 97 "param"
Name 100 "param"
Name 101 "param"
Decorate 73(outx) Location 0
Decorate 79(inx) Location 0
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 1(NonSemantic.Shader.DebugInfo.100) 2(DebugTypeBasic) 8 10 11 12
13: 7(int) Constant 3
6: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 8(DebugTypeFunction) 13 4
16: TypeFloat 32
18: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 2(DebugTypeBasic) 17 10 13 12
19: TypePointer Function 16(float)
20: 7(int) Constant 7
21: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 3(DebugTypePointer) 18 20 12
22: TypeFunction 16(float) 19(ptr) 19(ptr) 19(ptr)
23: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 8(DebugTypeFunction) 13 18 18 18 18
31: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 35(DebugSource) 2 32
34: 7(int) Constant 1
35: 7(int) Constant 4
36: 7(int) Constant 2
33: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 1(DebugCompilationUnit) 34 35 31 36
30: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 20(DebugFunction) 29 23 31 11 12 33 29 13 11
37: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 26(DebugLocalVariable) 38 18 31 11 12 30 35 34
40: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 31(DebugExpression)
43: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 26(DebugLocalVariable) 44 18 31 11 12 30 35 36
46: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 26(DebugLocalVariable) 47 18 31 11 12 30 35 13
51: 7(int) Constant 16
50: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 20(DebugFunction) 49 6 31 51 12 33 49 13 51
55: 7(int) Constant 8
58: 7(int) Constant 10
62: 7(int) Constant 12
71: TypePointer Output 16(float)
72: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 3(DebugTypePointer) 18 13 12
73(outx): 71(ptr) Variable Output
76: 7(int) Constant 17
74: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 18(DebugGlobalVariable) 75 18 31 76 12 33 75 73(outx) 55
77: TypePointer Input 16(float)
78: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 3(DebugTypePointer) 18 34 12
79(inx): 77(ptr) Variable Input
82: 7(int) Constant 20
80: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 18(DebugGlobalVariable) 81 18 31 82 12 33 81 79(inx) 55
85: 16(float) Constant 1065353216
89: 7(int) Constant 21
90: 16(float) Constant 1073741824
94: 7(int) Constant 22
95: 16(float) Constant 1077936128
99: 7(int) Constant 23
104: 7(int) Constant 18
14(main): 4 Function None 5
15: Label
97(param): 19(ptr) Variable Function
100(param): 19(ptr) Variable Function
101(param): 19(ptr) Variable Function
69: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 50
70: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 31 51 51 12 12
68: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 101(DebugFunctionDefinition) 50 14(main)
84: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 31 82 82 12 12
83: 16(float) Load 79(inx)
86: 16(float) FAdd 83 85
88: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 31 89 89 12 12
87: 16(float) Load 79(inx)
91: 16(float) FAdd 87 90
93: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 31 94 94 12 12
92: 16(float) Load 79(inx)
96: 16(float) FAdd 92 95
98: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 31 99 99 12 12
Store 97(param) 86
Store 100(param) 91
Store 101(param) 96
102: 16(float) FunctionCall 27(add(f1;f1;f1;) 97(param) 100(param) 101(param)
103: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 31 104 104 12 12
Store 73(outx) 102
Return
FunctionEnd
27(add(f1;f1;f1;): 16(float) Function None 22
24(x): 19(ptr) FunctionParameter
25(y): 19(ptr) FunctionParameter
26(z): 19(ptr) FunctionParameter
28: Label
41: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 30
42: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 31 11 11 12 12
39: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 28(DebugDeclare) 37 24(x) 40
45: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 28(DebugDeclare) 43 25(y) 40
48: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 28(DebugDeclare) 46 26(z) 40
52: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 101(DebugFunctionDefinition) 30 27(add(f1;f1;f1;)
54: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 31 55 55 12 12
53: 16(float) Load 24(x)
57: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 31 58 58 12 12
56: 16(float) Load 25(y)
59: 16(float) FAdd 53 56
61: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 31 62 62 12 12
60: 16(float) Load 26(z)
63: 16(float) FAdd 59 60
64: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 31 20 20 12 12
ReturnValue 63
FunctionEnd

View File

@ -0,0 +1,25 @@
#version 460
in float inx;
out float outx;
float add(float x, float y, float z) {
return
x
+
y
+
z
;
}
void main() {
outx
=
add(
inx+1,
inx+2,
inx+3
)
;
}

View File

@ -954,6 +954,7 @@ INSTANTIATE_TEST_SUITE_P(
"spv.debuginfo.scalar_types.glsl.frag",
"spv.debuginfo.rt_types.glsl.rgen",
"spv.debuginfo.include.glsl.frag",
"spv.debuginfo.multiline.glsl.frag",
})),
FileNameAsCustomTestSuffix
);