diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2022-02-23 18:29:42 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-02-23 15:29:42 -0800 |
| commit | 97ee917b5be4544db0f29eeb095eb55e360619c6 (patch) | |
| tree | 4898b49beed9a280870712a8e56a8e8d4d4fe3ae | |
| parent | 393d5beb1e0e71e6f2a384c9ab19b717f389a056 (diff) | |
Add SPIR-V debug information via GLSLANG (#2142)
* #include an absolute path didn't work - because paths were taken to always be relative.
* Switch on generateDebugInfo on glslang i s any debug level is set.
* Take copy of SpvOptions.
Co-authored-by: Theresa Foley <10618364+tangent-vector@users.noreply.github.com>
| -rw-r--r-- | source/slang-glslang/slang-glslang.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/source/slang-glslang/slang-glslang.cpp b/source/slang-glslang/slang-glslang.cpp index 6cb6db995..0a9f2ec3b 100644 --- a/source/slang-glslang/slang-glslang.cpp +++ b/source/slang-glslang/slang-glslang.cpp @@ -619,6 +619,19 @@ static int glslang_compileGLSLToSPIRV(const glslang_CompileRequest_1_1& request) } } + // Options for compilation of glsl to Spv + + // spvOptions ctors with default options (this it the same as passing nullptr to GlslangToSpv) + glslang::SpvOptions spvOptions; + + const SlangDebugInfoLevel debugLevel = (SlangDebugInfoLevel)request.debugInfoType; + + // Enable generation of debug info, if any debug level other than none is requested + if (debugLevel != SLANG_DEBUG_INFO_LEVEL_NONE) + { + spvOptions.generateDebugInfo = true; + } + for(int stage = 0; stage < EShLangCount; ++stage) { auto stageIntermediate = program->getIntermediate((EShLanguage)stage); @@ -628,7 +641,10 @@ static int glslang_compileGLSLToSPIRV(const glslang_CompileRequest_1_1& request) std::vector<unsigned int> spirv; spv::SpvBuildLogger logger; - glslang::GlslangToSpv(*stageIntermediate, spirv, &logger); + // Copy options to make sure spvOptions not altered + glslang::SpvOptions copySpvOptions(spvOptions); + + glslang::GlslangToSpv(*stageIntermediate, spirv, &logger, ©SpvOptions); int optErrorCount = 0; |
