From faccbe8e0c14303750c49bd4abf4ac1f392ba14c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20Wei=C3=9F?= <45500341+Poohl@users.noreply.github.com> Date: Fri, 14 Nov 2025 16:04:28 +0100 Subject: [PATCH 1/2] debuggable shaders in when compiled in debug --- Graphics/ShaderTools/src/GLSLangUtils.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Graphics/ShaderTools/src/GLSLangUtils.cpp b/Graphics/ShaderTools/src/GLSLangUtils.cpp index fb4431dec..6f0f92645 100644 --- a/Graphics/ShaderTools/src/GLSLangUtils.cpp +++ b/Graphics/ShaderTools/src/GLSLangUtils.cpp @@ -266,6 +266,9 @@ std::vector CompileShaderInternal(::glslang::TShader& Sh Shader.setAutoMapBindings(true); Shader.setAutoMapLocations(true); TBuiltInResource Resources = InitResources(); +#ifdef DILIGENT_DEBUG + messages = static_cast(static_cast(messages) | static_cast(EShMessages::EShMsgDebugInfo)); +#endif bool ParseResult = pIncluder != nullptr ? Shader.parse(&Resources, 100, shProfile, false, false, messages, *pIncluder) : @@ -288,8 +291,17 @@ std::vector CompileShaderInternal(::glslang::TShader& Sh if (AssignBindings) Program.mapIO(); + ::glslang::SpvOptions spvOptions; +#ifdef DILIGENT_DEBUG + spvOptions.generateDebugInfo = true; +#if DILIGENT_NO_HLSL + // will be stripped anyway with HLSL support anyway + spvOptions.emitNonSemanticShaderDebugInfo = true; + spvOptions.emitNonSemanticShaderDebugSource = true; +#endif +#endif std::vector spirv; - ::glslang::GlslangToSpv(*Program.getIntermediate(Shader.getStage()), spirv); + ::glslang::GlslangToSpv(*Program.getIntermediate(Shader.getStage()), spirv, &spvOptions); return spirv; } From 4ce0c898c177441740b00f3d08528097cbe3f519 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20Wei=C3=9F?= <45500341+Poohl@users.noreply.github.com> Date: Tue, 18 Nov 2025 17:18:52 +0100 Subject: [PATCH 2/2] Formatting --- Graphics/ShaderTools/src/GLSLangUtils.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Graphics/ShaderTools/src/GLSLangUtils.cpp b/Graphics/ShaderTools/src/GLSLangUtils.cpp index 6f0f92645..2d85633d6 100644 --- a/Graphics/ShaderTools/src/GLSLangUtils.cpp +++ b/Graphics/ShaderTools/src/GLSLangUtils.cpp @@ -82,7 +82,7 @@ EShLanguage ShaderTypeToShLanguage(SHADER_TYPE ShaderType) static_assert(SHADER_TYPE_LAST == 0x4000, "Please handle the new shader type in the switch below"); switch (ShaderType) { - // clang-format off + // clang-format off case SHADER_TYPE_VERTEX: return EShLangVertex; case SHADER_TYPE_HULL: return EShLangTessControl; case SHADER_TYPE_DOMAIN: return EShLangTessEvaluation; @@ -294,11 +294,11 @@ std::vector CompileShaderInternal(::glslang::TShader& Sh ::glslang::SpvOptions spvOptions; #ifdef DILIGENT_DEBUG spvOptions.generateDebugInfo = true; -#if DILIGENT_NO_HLSL +# if DILIGENT_NO_HLSL // will be stripped anyway with HLSL support anyway - spvOptions.emitNonSemanticShaderDebugInfo = true; + spvOptions.emitNonSemanticShaderDebugInfo = true; spvOptions.emitNonSemanticShaderDebugSource = true; -#endif +# endif #endif std::vector spirv; ::glslang::GlslangToSpv(*Program.getIntermediate(Shader.getStage()), spirv, &spvOptions); @@ -421,7 +421,7 @@ spv_target_env SpirvVersionToSpvTargetEnv(SpirvVersion Version) static_assert(static_cast(SpirvVersion::Count) == 6, "Did you add a new member to SpirvVersion? You may need to handle it here."); switch (Version) { - // clang-format off + // clang-format off case SpirvVersion::Vk100: return SPV_ENV_VULKAN_1_0; case SpirvVersion::Vk110: return SPV_ENV_VULKAN_1_1; case SpirvVersion::Vk110_Spirv14: return SPV_ENV_VULKAN_1_1_SPIRV_1_4;