Skip to content

Commit

Permalink
Enable debug information for Vulkan shaders (bkaradzic#3193)
Browse files Browse the repository at this point in the history
* Enable debug information for Vulkan shaders

* Enable debug information for Metal shaders
  • Loading branch information
Arcnor authored and jay3d committed Dec 7, 2023
1 parent 40b3ef8 commit c43d90b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
5 changes: 4 additions & 1 deletion docs/tools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,12 @@ Options:
--varyingdef <file path> A varying.def.sc's file path.
--verbose Be verbose.

(DX9 and DX11 only):
(Vulkan, DirectX and Metal):

--debug Debug information.

(DirectX only):

--disasm Disassemble a compiled shader.
-O <level> Set optimization level.
Can be 0–3.
Expand Down
7 changes: 6 additions & 1 deletion tools/shaderc/shaderc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1054,10 +1054,15 @@ namespace bgfx
" --verbose Be verbose.\n"

"\n"
"(DX9 and DX11 only):\n"
"(Vulkan, DirectX and Metal):\n"

"\n"
" --debug Debug information.\n"

"\n"
"(DirectX only):\n"

"\n"
" --disasm Disassemble compiled shader.\n"
" -O <level> Set optimization level. Can be 0 to 3.\n"
" --Werror Treat warnings as errors.\n"
Expand Down
6 changes: 5 additions & 1 deletion tools/shaderc/shaderc_metal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ namespace bgfx { namespace metal
| EShMsgReadHlsl
| EShMsgVulkanRules
| EShMsgSpvRules
| EShMsgDebugInfo
);

shader->setEntryPoint("main");
Expand Down Expand Up @@ -495,7 +496,10 @@ namespace bgfx { namespace metal
std::vector<uint32_t> spirv;

glslang::SpvOptions options;
options.disableOptimizer = false;
options.disableOptimizer = _options.debugInformation;
options.generateDebugInfo = _options.debugInformation;
options.emitNonSemanticShaderDebugInfo = _options.debugInformation;
options.emitNonSemanticShaderDebugSource = _options.debugInformation;

glslang::GlslangToSpv(*intermediate, spirv, &options);

Expand Down
6 changes: 5 additions & 1 deletion tools/shaderc/shaderc_spirv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ namespace bgfx { namespace spirv
| EShMsgReadHlsl
| EShMsgVulkanRules
| EShMsgSpvRules
| EShMsgDebugInfo
);

shader->setEntryPoint("main");
Expand Down Expand Up @@ -705,7 +706,10 @@ namespace bgfx { namespace spirv
std::vector<uint32_t> spirv;

glslang::SpvOptions options;
options.disableOptimizer = false;
options.disableOptimizer = _options.debugInformation;
options.generateDebugInfo = _options.debugInformation;
options.emitNonSemanticShaderDebugInfo = _options.debugInformation;
options.emitNonSemanticShaderDebugSource = _options.debugInformation;

glslang::GlslangToSpv(*intermediate, spirv, &options);

Expand Down

0 comments on commit c43d90b

Please sign in to comment.