From 97ee917b5be4544db0f29eeb095eb55e360619c6 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Wed, 23 Feb 2022 18:29:42 -0500 Subject: 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> --- source/slang-glslang/slang-glslang.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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 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; -- cgit v1.2.3