Skip to content

Commit faccbe8

Browse files
committed
debuggable shaders in when compiled in debug
1 parent 1c3ac22 commit faccbe8

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

Graphics/ShaderTools/src/GLSLangUtils.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,9 @@ std::vector<unsigned int> CompileShaderInternal(::glslang::TShader& Sh
266266
Shader.setAutoMapBindings(true);
267267
Shader.setAutoMapLocations(true);
268268
TBuiltInResource Resources = InitResources();
269+
#ifdef DILIGENT_DEBUG
270+
messages = static_cast<EShMessages>(static_cast<unsigned>(messages) | static_cast<unsigned>(EShMessages::EShMsgDebugInfo));
271+
#endif
269272

270273
bool ParseResult = pIncluder != nullptr ?
271274
Shader.parse(&Resources, 100, shProfile, false, false, messages, *pIncluder) :
@@ -288,8 +291,17 @@ std::vector<unsigned int> CompileShaderInternal(::glslang::TShader& Sh
288291
if (AssignBindings)
289292
Program.mapIO();
290293

294+
::glslang::SpvOptions spvOptions;
295+
#ifdef DILIGENT_DEBUG
296+
spvOptions.generateDebugInfo = true;
297+
#if DILIGENT_NO_HLSL
298+
// will be stripped anyway with HLSL support anyway
299+
spvOptions.emitNonSemanticShaderDebugInfo = true;
300+
spvOptions.emitNonSemanticShaderDebugSource = true;
301+
#endif
302+
#endif
291303
std::vector<unsigned int> spirv;
292-
::glslang::GlslangToSpv(*Program.getIntermediate(Shader.getStage()), spirv);
304+
::glslang::GlslangToSpv(*Program.getIntermediate(Shader.getStage()), spirv, &spvOptions);
293305

294306
return spirv;
295307
}

0 commit comments

Comments
 (0)