ShaderCompiler: Attach source text to SPIR-V for debuggers like RenderDoc

This commit is contained in:
OatmealDome
2021-08-04 21:45:38 -04:00
parent 942545b7fc
commit d453390c48
2 changed files with 18 additions and 4 deletions

View File

@ -196,7 +196,21 @@ static std::optional<SPIRVCodeVector> CompileShaderToSPV(EShLanguage stage,
SPIRVCodeVector out_code;
spv::SpvBuildLogger logger;
glslang::GlslangToSpv(*intermediate, out_code, &logger);
glslang::SpvOptions options;
if (g_ActiveConfig.bEnableValidationLayer)
{
// Attach the source code to the SPIR-V for tools like RenderDoc.
intermediate->addSourceText(pass_source_code, pass_source_code_length);
options.generateDebugInfo = true;
options.disableOptimizer = true;
options.optimizeSize = false;
options.disassemble = false;
options.validate = true;
}
glslang::GlslangToSpv(*intermediate, out_code, &logger, &options);
// Write out messages
// Temporary: skip if it contains "Warning, version 450 is not yet complete; most version-specific