Skip to content
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
22 changes: 17 additions & 5 deletions SPIRV/GlslangToSpv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1679,20 +1679,32 @@ TGlslangToSpvTraverser::TGlslangToSpvTraverser(unsigned int spvVersion,
}
builder.setDebugMainSourceFile(glslangIntermediate->getSourceFile());

// Set the source shader's text. If for SPV version 1.0, include
// Set the source shader's text
std::string text;

// If for SPV version 1.0, include
// a preamble in comments stating the OpModuleProcessed instructions.
// Otherwise, emit those as actual instructions.
std::string text;
//
// ...Except when using ShaderDebugInfo we DON'T want these as it will mess up the line
// number, instead the user has opt'ed in for ShaderDebugInfo instead, so they will want
// to parse those instead
// https://github.com/KhronosGroup/glslang/issues/3863
const bool add_comments =
glslangIntermediate->getSpv().spv < glslang::EShTargetSpv_1_1 && !options.emitNonSemanticShaderDebugSource;

const std::vector<std::string>& processes = glslangIntermediate->getProcesses();
for (int p = 0; p < (int)processes.size(); ++p) {
if (glslangIntermediate->getSpv().spv < glslang::EShTargetSpv_1_1) {
if (add_comments) {
text.append("// OpModuleProcessed ");
text.append(processes[p]);
text.append("\n");
} else
} else if (glslangIntermediate->getSpv().spv >= glslang::EShTargetSpv_1_1) {
// OpModuleProcessed added in SPIR-V 1.1
builder.addModuleProcessed(processes[p]);
}
}
if (glslangIntermediate->getSpv().spv < glslang::EShTargetSpv_1_1 && (int)processes.size() > 0)
if (add_comments && (int)processes.size() > 0)
text.append("#line 1\n");
text.append(glslangIntermediate->getSourceText());
builder.setSourceText(text);
Expand Down
9 changes: 1 addition & 8 deletions Test/baseResults/spv.debuginfo.bufferref.glsl.frag.out
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,7 @@ spv.debuginfo.bufferref.glsl.frag
2: String "spv.debuginfo.bufferref.glsl.frag"
8: String "uint"
16: String "main"
19: 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 450 core
19: String "#version 450 core
#extension GL_EXT_buffer_reference : enable

layout(buffer_reference, std430) buffer MeshVertexPositions {
Expand Down
9 changes: 1 addition & 8 deletions Test/baseResults/spv.debuginfo.const_params.glsl.comp.out
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,7 @@ spv.debuginfo.const_params.glsl.comp
8: String "uint"
17: String "float"
35: String "function"
38: 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 450
38: String "#version 450

void function(
const float f,
Expand Down
9 changes: 1 addition & 8 deletions Test/baseResults/spv.debuginfo.const_variables.glsl.frag.out
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,7 @@ spv.debuginfo.const_variables.glsl.frag
2: String "spv.debuginfo.const_variables.glsl.frag"
8: String "uint"
16: String "main"
19: 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
19: String "#version 460

const vec4 constGlobal = vec4(1.0, 0.0, 0.0, 1.0);

Expand Down
25 changes: 10 additions & 15 deletions Test/baseResults/spv.debuginfo.continued.glsl.vert.out
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,7 @@ spv.debuginfo.continued.glsl.vert
2: String "spv.debuginfo.continued.glsl.vert"
8: String "uint"
16: String "main"
19: 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
19: String "#version 460

// This is filler text to cause the source length to exceed the maximum length of DebugSource and require the use of DebugSourceContinued.
// This is filler text to cause the source length to exceed the maximum length of DebugSource and require the use of DebugSourceContinued.
Expand Down Expand Up @@ -1904,10 +1897,10 @@ spv.debuginfo.continued.glsl.vert
// This is filler text to cause the source length to exceed the maximum length of DebugSource and require the use of DebugSourceContinued.
// This is filler text to cause the source length to exceed the maximum length of DebugSource and require the use of DebugSourceContinued.
// This is filler text to cause the source length to exceed the maximum length of DebugSource and require the use of DebugSourceContinued.
// This is filler text to cause the source length to exceed the maximum length of DebugSource and require the use of DebugSourceCont"
20: String "inued.
// This is filler text to cause the source length to exceed the maximum length of DebugSource and require the use of DebugSourceContinued.
// This is filler text to cause the source length to exceed the maximum length of DebugSource and require the use of DebugSourceContinued.
// This is filler text to cause the source length to exceed the maximum length of DebugSource "
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add another copy of the filler comment to the test file to maintain the structure of the test with two DebugSourceContinueds?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

think I got it as best as it will get

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's fine, I just wanted the same number of instructions in the SPIR-V result.

20: String "and require the use of DebugSourceContinued.
// This is filler text to cause the source length to exceed the maximum length of DebugSource and require the use of DebugSourceContinued.
// This is filler text to cause the source length to exceed the maximum length of DebugSource and require the use of DebugSourceContinued.
// This is filler text to cause the source length to exceed the maximum length of DebugSource and require the use of DebugSourceContinued.
Expand Down Expand Up @@ -3791,8 +3784,10 @@ spv.debuginfo.continued.glsl.vert
// This is filler text to cause the source length to exceed the maximum length of DebugSource and require the use of DebugSourceContinued.
// This is filler text to cause the source length to exceed the maximum length of DebugSource and require the use of DebugSourceContinued.
// This is filler text to cause the source length to exceed the maximum length of DebugSource and require the use of DebugSourceContinued.
// This is filler text to cause the source length to exceed the maximum length of DebugSource and req"
22: String "uire the use of DebugSourceContinued.
// This is filler text to cause the source length to exceed the maximum length of DebugSource and require the use of DebugSourceContinued.
// This is filler text to cause the source length to exceed the maximum length of DebugSource and require the use of DebugSourceContinued.
// This is filler text to cause the source length to exceed the"
22: String " maximum length of DebugSource and require the use of DebugSourceContinued.

void main()
{
Expand Down Expand Up @@ -3831,7 +3826,7 @@ void main()
18: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 35(DebugSource) 2 19
21: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 102(DebugSourceContinued) 20
23: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 102(DebugSourceContinued) 22
24: 7(int) Constant 3774
24: 7(int) Constant 3776
26: 7(int) Constant 1
27: 7(int) Constant 4
28: 7(int) Constant 2
Expand All @@ -3852,7 +3847,7 @@ void main()
46: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 11(DebugTypeMember) 47 38 18 26 48 12 12 13
51: 7(int) Constant 85
49: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 11(DebugTypeMember) 50 38 18 26 51 12 12 13
54: 7(int) Constant 3776
54: 7(int) Constant 3778
52: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 10(DebugTypeComposite) 53 26 18 54 12 25 53 12 13 40 43 46 49
55: TypePointer Output 39(gl_PerVertex)
56: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 3(DebugTypePointer) 52 13 12
Expand All @@ -3866,7 +3861,7 @@ void main()
66: 35(fvec4) ConstantComposite 65 65 65 65
67: TypePointer Output 35(fvec4)
68: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 3(DebugTypePointer) 36 13 12
72: 7(int) Constant 3777
72: 7(int) Constant 3779
14(main): 4 Function None 5
15: Label
30: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 17
Expand Down
9 changes: 1 addition & 8 deletions Test/baseResults/spv.debuginfo.declaration.glsl.frag.out
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,7 @@ spv.debuginfo.declaration.glsl.frag
2: String "spv.debuginfo.declaration.glsl.frag"
8: String "uint"
16: String "main"
19: 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
19: String "#version 460

uniform UBO {
int x;
Expand Down
9 changes: 1 addition & 8 deletions Test/baseResults/spv.debuginfo.glsl.comp.out
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,7 @@ spv.debuginfo.glsl.comp
8: String "uint"
17: String "float"
33: String "springForce"
36: 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
/*
36: String "/*
The MIT License (MIT)

Copyright (c) 2022 Sascha Willems
Expand Down
9 changes: 1 addition & 8 deletions Test/baseResults/spv.debuginfo.glsl.frag.out
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,7 @@ spv.debuginfo.glsl.frag
8: String "uint"
17: String "float"
39: String "textureProj"
42: 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
/*
42: String "/*
The MIT License (MIT)

Copyright (c) 2022 Sascha Willems
Expand Down
9 changes: 1 addition & 8 deletions Test/baseResults/spv.debuginfo.glsl.geom.out
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,7 @@ spv.debuginfo.glsl.geom
2: String "spv.debuginfo.glsl.geom"
8: String "uint"
16: String "main"
19: 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
/*
19: String "/*
The MIT License (MIT)

Copyright (c) 2022 Sascha Willems
Expand Down
9 changes: 1 addition & 8 deletions Test/baseResults/spv.debuginfo.glsl.tesc.out
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,7 @@ spv.debuginfo.glsl.tesc
8: String "uint"
17: String "float"
31: String "screenSpaceTessFactor"
34: 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
/*
34: String "/*
The MIT License (MIT)

Copyright (c) 2022 Sascha Willems
Expand Down
9 changes: 1 addition & 8 deletions Test/baseResults/spv.debuginfo.glsl.tese.out
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,7 @@ spv.debuginfo.glsl.tese
2: String "spv.debuginfo.glsl.tese"
8: String "uint"
16: String "main"
19: 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
/*
19: String "/*
The MIT License (MIT)

Copyright (c) 2022 Sascha Willems
Expand Down
9 changes: 1 addition & 8 deletions Test/baseResults/spv.debuginfo.glsl.vert.out
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,7 @@ spv.debuginfo.glsl.vert
2: String "spv.debuginfo.glsl.vert"
8: String "uint"
16: String "main"
19: 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
/*
19: String "/*
The MIT License (MIT)

Copyright (c) 2022 Sascha Willems
Expand Down
10 changes: 1 addition & 9 deletions Test/baseResults/spv.debuginfo.hlsl.comp.out
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,7 @@ spv.debuginfo.hlsl.comp
9: String "float"
12: String "uint"
32: String "springForce"
35: String "// OpModuleProcessed auto-map-locations
// OpModuleProcessed auto-map-bindings
// OpModuleProcessed entry-point main
// OpModuleProcessed client vulkan100
// OpModuleProcessed target-env vulkan1.0
// OpModuleProcessed keep-uncalled
// OpModuleProcessed hlsl-offsets
#line 1
/*
35: String "/*
The MIT License (MIT)

Copyright (c) 2022 Google LLC
Expand Down
10 changes: 1 addition & 9 deletions Test/baseResults/spv.debuginfo.hlsl.frag.out
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,7 @@ spv.debuginfo.hlsl.frag
9: String "float"
12: String "uint"
38: String "textureProj"
41: String "// OpModuleProcessed auto-map-locations
// OpModuleProcessed auto-map-bindings
// OpModuleProcessed entry-point main
// OpModuleProcessed client vulkan100
// OpModuleProcessed target-env vulkan1.0
// OpModuleProcessed keep-uncalled
// OpModuleProcessed hlsl-offsets
#line 1
/*
41: String "/*
The MIT License (MIT)

Copyright (c) 2022 Google LLC
Expand Down
10 changes: 1 addition & 9 deletions Test/baseResults/spv.debuginfo.hlsl.geom.out
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,7 @@ spv.debuginfo.hlsl.geom
9: String "float"
12: String "uint"
25: String "Pos"
27: String "// OpModuleProcessed auto-map-locations
// OpModuleProcessed auto-map-bindings
// OpModuleProcessed entry-point main
// OpModuleProcessed client vulkan100
// OpModuleProcessed target-env vulkan1.0
// OpModuleProcessed keep-uncalled
// OpModuleProcessed hlsl-offsets
#line 1
/*
27: String "/*
The MIT License (MIT)

Copyright (c) 2022 Google LLC
Expand Down
10 changes: 1 addition & 9 deletions Test/baseResults/spv.debuginfo.hlsl.tesc.out
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,7 @@ WARNING: spv.debuginfo.hlsl.tesc:158: '' : attribute does not apply to entry poi
9: String "float"
12: String "uint"
30: String "screenSpaceTessFactor"
33: String "// OpModuleProcessed auto-map-locations
// OpModuleProcessed auto-map-bindings
// OpModuleProcessed entry-point main
// OpModuleProcessed client vulkan100
// OpModuleProcessed target-env vulkan1.0
// OpModuleProcessed keep-uncalled
// OpModuleProcessed hlsl-offsets
#line 1
/*
33: String "/*
The MIT License (MIT)

Copyright (c) 2022 Google LLC
Expand Down
10 changes: 1 addition & 9 deletions Test/baseResults/spv.debuginfo.hlsl.tese.out
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,7 @@ spv.debuginfo.hlsl.tese
9: String "float"
12: String "uint"
26: String "TessLevelOuter"
28: String "// OpModuleProcessed auto-map-locations
// OpModuleProcessed auto-map-bindings
// OpModuleProcessed entry-point main
// OpModuleProcessed client vulkan100
// OpModuleProcessed target-env vulkan1.0
// OpModuleProcessed keep-uncalled
// OpModuleProcessed hlsl-offsets
#line 1
/*
28: String "/*
The MIT License (MIT)

Copyright (c) 2022 Google LLC
Expand Down
10 changes: 1 addition & 9 deletions Test/baseResults/spv.debuginfo.hlsl.vert.out
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,7 @@ spv.debuginfo.hlsl.vert
12: String "uint"
24: String "int"
29: String "Pos"
31: String "// OpModuleProcessed auto-map-locations
// OpModuleProcessed auto-map-bindings
// OpModuleProcessed entry-point main
// OpModuleProcessed client vulkan100
// OpModuleProcessed target-env vulkan1.0
// OpModuleProcessed keep-uncalled
// OpModuleProcessed hlsl-offsets
#line 1
/*
31: String "/*
The MIT License (MIT)

Copyright (c) 2022 Google LLC
Expand Down
9 changes: 1 addition & 8 deletions Test/baseResults/spv.debuginfo.implicit_br.glsl.frag.out
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,7 @@ spv.debuginfo.implicit_br.glsl.frag
2: String "spv.debuginfo.implicit_br.glsl.frag"
8: String "uint"
18: String "test_if"
21: 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
21: String "#version 460

out int outx;
int counter = 0;
Expand Down
Loading