Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emit correct name in debug info for scalar types #3323

Merged
merged 1 commit into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions SPIRV/SpvBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -859,11 +859,19 @@ Id Builder::makeBoolDebugType(int const size)

Id Builder::makeIntegerDebugType(int const width, bool const hasSign)
{
const char* typeName = nullptr;
switch (width) {
case 8: typeName = hasSign ? "int8_t" : "uint8_t"; break;
case 16: typeName = hasSign ? "int16_t" : "uint16_t"; break;
case 64: typeName = hasSign ? "int64_t" : "uint64_t"; break;
default: typeName = hasSign ? "int" : "uint";
}
auto nameId = getStringId(typeName);
// try to find it
Instruction* type;
for (int t = 0; t < (int)groupedDebugTypes[NonSemanticShaderDebugInfo100DebugTypeBasic].size(); ++t) {
type = groupedDebugTypes[NonSemanticShaderDebugInfo100DebugTypeBasic][t];
if (type->getIdOperand(0) == (hasSign ? getStringId("int") : getStringId("uint")) &&
if (type->getIdOperand(0) == nameId &&
type->getIdOperand(1) == static_cast<unsigned int>(width) &&
type->getIdOperand(2) == (hasSign ? NonSemanticShaderDebugInfo100Signed : NonSemanticShaderDebugInfo100Unsigned))
return type->getResultId();
Expand All @@ -873,11 +881,7 @@ Id Builder::makeIntegerDebugType(int const width, bool const hasSign)
type = new Instruction(getUniqueId(), makeVoidType(), OpExtInst);
type->addIdOperand(nonSemanticShaderDebugInfo);
type->addImmediateOperand(NonSemanticShaderDebugInfo100DebugTypeBasic);
if(hasSign == true) {
type->addIdOperand(getStringId("int")); // name id
} else {
type->addIdOperand(getStringId("uint")); // name id
}
type->addIdOperand(nameId); // name id
type->addIdOperand(makeUintConstant(width)); // size id
if(hasSign == true) {
type->addIdOperand(makeUintConstant(NonSemanticShaderDebugInfo100Signed)); // encoding id
Expand All @@ -895,11 +899,18 @@ Id Builder::makeIntegerDebugType(int const width, bool const hasSign)

Id Builder::makeFloatDebugType(int const width)
{
const char* typeName = nullptr;
switch (width) {
case 16: typeName = "float16_t"; break;
case 64: typeName = "double"; break;
default: typeName = "float"; break;
}
auto nameId = getStringId(typeName);
// try to find it
Instruction* type;
for (int t = 0; t < (int)groupedDebugTypes[NonSemanticShaderDebugInfo100DebugTypeBasic].size(); ++t) {
type = groupedDebugTypes[NonSemanticShaderDebugInfo100DebugTypeBasic][t];
if (type->getIdOperand(0) == getStringId("float") &&
if (type->getIdOperand(0) == nameId &&
type->getIdOperand(1) == static_cast<unsigned int>(width) &&
type->getIdOperand(2) == NonSemanticShaderDebugInfo100Float)
return type->getResultId();
Expand All @@ -909,7 +920,7 @@ Id Builder::makeFloatDebugType(int const width)
type = new Instruction(getUniqueId(), makeVoidType(), OpExtInst);
type->addIdOperand(nonSemanticShaderDebugInfo);
type->addImmediateOperand(NonSemanticShaderDebugInfo100DebugTypeBasic);
type->addIdOperand(getStringId("float")); // name id
type->addIdOperand(nameId); // name id
type->addIdOperand(makeUintConstant(width)); // size id
type->addIdOperand(makeUintConstant(NonSemanticShaderDebugInfo100Float)); // encoding id
type->addIdOperand(makeUintConstant(NonSemanticShaderDebugInfo100None)); // flags id
Expand Down
4 changes: 2 additions & 2 deletions Test/baseResults/spv.debuginfo.const_params.glsl.comp.out
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ spv.debuginfo.const_params.glsl.comp
EntryPoint GLCompute 14 "main"
ExecutionMode 14 LocalSize 1 1 1
1: String ""
9: String "uint"
8: String "uint"
15: String "main"
18: String "// OpModuleProcessed auto-map-locations
// OpModuleProcessed auto-map-bindings
Expand Down Expand Up @@ -39,7 +39,7 @@ spv.debuginfo.const_params.glsl.comp
10: 7(int) Constant 32
11: 7(int) Constant 6
12: 7(int) Constant 0
8: 4 ExtInst 2(NonSemantic.Shader.DebugInfo.100) 2(DebugTypeBasic) 9 10 11 12
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
Expand Down
10 changes: 5 additions & 5 deletions Test/baseResults/spv.debuginfo.glsl.comp.out
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ spv.debuginfo.glsl.comp
EntryPoint GLCompute 14 "main" 124
ExecutionMode 14 LocalSize 10 10 1
1: String ""
9: String "uint"
8: String "uint"
15: String "main"
18: String "// OpModuleProcessed auto-map-locations
// OpModuleProcessed auto-map-bindings
Expand Down Expand Up @@ -164,7 +164,7 @@ spv.debuginfo.glsl.comp
10: 7(int) Constant 32
11: 7(int) Constant 6
12: 7(int) Constant 0
8: 4 ExtInst 2(NonSemantic.Shader.DebugInfo.100) 2(DebugTypeBasic) 9 10 11 12
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
Expand Down Expand Up @@ -220,15 +220,15 @@ spv.debuginfo.glsl.comp
101: TypePointer Uniform 24(float)
115: 7(int) Constant 74
116: TypeVector 7(int) 3
117: 4 ExtInst 2(NonSemantic.Shader.DebugInfo.100) 6(DebugTypeVector) 8 13
117: 4 ExtInst 2(NonSemantic.Shader.DebugInfo.100) 6(DebugTypeVector) 9 13
118: TypePointer Function 116(ivec3)
120: 4 ExtInst 2(NonSemantic.Shader.DebugInfo.100) 26(DebugLocalVariable) 121 117 17 115 12 16 21
123: TypePointer Input 116(ivec3)
124(gl_GlobalInvocationID): 123(ptr) Variable Input
125: 4 ExtInst 2(NonSemantic.Shader.DebugInfo.100) 18(DebugGlobalVariable) 126 117 17 115 12 19 126 124(gl_GlobalInvocationID) 78
129: 7(int) Constant 76
130: TypePointer Function 7(int)
132: 4 ExtInst 2(NonSemantic.Shader.DebugInfo.100) 26(DebugLocalVariable) 133 8 17 129 12 16 21
132: 4 ExtInst 2(NonSemantic.Shader.DebugInfo.100) 26(DebugLocalVariable) 133 9 17 129 12 16 21
137: 69(int) Constant 10
138: TypePointer Uniform 69(int)
147: 7(int) Constant 77
Expand Down Expand Up @@ -330,7 +330,7 @@ spv.debuginfo.glsl.comp
670: 7(int) Constant 144
671(PushConsts): TypeStruct 7(int)
674: 7(int) Constant 63
672: 4 ExtInst 2(NonSemantic.Shader.DebugInfo.100) 11(DebugTypeMember) 673 8 17 674 89 12 12 13
672: 4 ExtInst 2(NonSemantic.Shader.DebugInfo.100) 11(DebugTypeMember) 673 9 17 674 89 12 12 13
675: 4 ExtInst 2(NonSemantic.Shader.DebugInfo.100) 10(DebugTypeComposite) 676 20 17 670 12 19 676 12 13 672
677: TypePointer PushConstant 671(PushConsts)
678(pushConsts): 677(ptr) Variable PushConstant
Expand Down
4 changes: 2 additions & 2 deletions Test/baseResults/spv.debuginfo.glsl.frag.out
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ spv.debuginfo.glsl.frag
EntryPoint Fragment 14 "main" 478 533
ExecutionMode 14 OriginUpperLeft
1: String ""
9: String "uint"
8: String "uint"
15: String "main"
18: String "// OpModuleProcessed auto-map-locations
// OpModuleProcessed auto-map-bindings
Expand Down Expand Up @@ -187,7 +187,7 @@ spv.debuginfo.glsl.frag
10: 7(int) Constant 32
11: 7(int) Constant 6
12: 7(int) Constant 0
8: 4 ExtInst 2(NonSemantic.Shader.DebugInfo.100) 2(DebugTypeBasic) 9 10 11 12
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
Expand Down
4 changes: 2 additions & 2 deletions Test/baseResults/spv.debuginfo.glsl.geom.out
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ spv.debuginfo.glsl.geom
ExecutionMode 14 OutputTriangleStrip
ExecutionMode 14 OutputVertices 3
1: String ""
9: String "uint"
8: String "uint"
15: String "main"
18: String "// OpModuleProcessed auto-map-locations
// OpModuleProcessed auto-map-bindings
Expand Down Expand Up @@ -123,7 +123,7 @@ spv.debuginfo.glsl.geom
10: 7(int) Constant 32
11: 7(int) Constant 6
12: 7(int) Constant 0
8: 4 ExtInst 2(NonSemantic.Shader.DebugInfo.100) 2(DebugTypeBasic) 9 10 11 12
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
Expand Down
4 changes: 2 additions & 2 deletions Test/baseResults/spv.debuginfo.glsl.tesc.out
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ spv.debuginfo.glsl.tesc
EntryPoint TessellationControl 14 "main" 249 253 279 370 383 498 512 519 533
ExecutionMode 14 OutputVertices 4
1: String ""
9: String "uint"
8: String "uint"
15: String "main"
18: String "// OpModuleProcessed auto-map-locations
// OpModuleProcessed auto-map-bindings
Expand Down Expand Up @@ -153,7 +153,7 @@ spv.debuginfo.glsl.tesc
10: 7(int) Constant 32
11: 7(int) Constant 6
12: 7(int) Constant 0
8: 4 ExtInst 2(NonSemantic.Shader.DebugInfo.100) 2(DebugTypeBasic) 9 10 11 12
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
Expand Down
4 changes: 2 additions & 2 deletions Test/baseResults/spv.debuginfo.glsl.tese.out
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ spv.debuginfo.glsl.tese
ExecutionMode 14 SpacingEqual
ExecutionMode 14 VertexOrderCw
1: String ""
9: String "uint"
8: String "uint"
15: String "main"
18: String "// OpModuleProcessed auto-map-locations
// OpModuleProcessed auto-map-bindings
Expand Down Expand Up @@ -141,7 +141,7 @@ spv.debuginfo.glsl.tese
10: 7(int) Constant 32
11: 7(int) Constant 6
12: 7(int) Constant 0
8: 4 ExtInst 2(NonSemantic.Shader.DebugInfo.100) 2(DebugTypeBasic) 9 10 11 12
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
Expand Down
4 changes: 2 additions & 2 deletions Test/baseResults/spv.debuginfo.glsl.vert.out
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ spv.debuginfo.glsl.vert
MemoryModel Logical GLSL450
EntryPoint Vertex 14 "main" 34 39 45 51 59 75 289 307 312 337 353 370 409 418
1: String ""
9: String "uint"
8: String "uint"
15: String "main"
18: String "// OpModuleProcessed auto-map-locations
// OpModuleProcessed auto-map-bindings
Expand Down Expand Up @@ -127,7 +127,7 @@ spv.debuginfo.glsl.vert
10: 7(int) Constant 32
11: 7(int) Constant 6
12: 7(int) Constant 0
8: 4 ExtInst 2(NonSemantic.Shader.DebugInfo.100) 2(DebugTypeBasic) 9 10 11 12
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
Expand Down
Loading