From 0fe2a4a69286dce232e889a1c2a4410ef149833f Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Tue, 4 Apr 2023 14:36:45 +0200 Subject: [PATCH] Vulkan: Enable Step-by-Step Debugging in Renderdoc. This PR adds debug information inside the spir-v assembly to enable step-by-step debugging of Shaders using renderdoc. The debugging information can be fairly large so are only generated when used with the `--debug-gpu-renderdoc` feature. During debugging shader optimizations are turned off. --- source/blender/gpu/vulkan/vk_shader.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/blender/gpu/vulkan/vk_shader.cc b/source/blender/gpu/vulkan/vk_shader.cc index 3a181e51d20..a4165095c84 100644 --- a/source/blender/gpu/vulkan/vk_shader.cc +++ b/source/blender/gpu/vulkan/vk_shader.cc @@ -15,6 +15,8 @@ #include "BLI_string_utils.h" #include "BLI_vector.hh" +#include "BKE_global.h" + using namespace blender::gpu::shader; extern "C" char datatoc_glsl_shader_defines_glsl[]; @@ -523,6 +525,10 @@ Vector VKShader::compile_glsl_to_spirv(Span sources, shaderc::Compiler &compiler = backend.get_shaderc_compiler(); shaderc::CompileOptions options; options.SetOptimizationLevel(shaderc_optimization_level_performance); + if (G.debug & G_DEBUG_GPU_RENDERDOC) { + options.SetOptimizationLevel(shaderc_optimization_level_zero); + options.SetGenerateDebugInfo(); + } shaderc::SpvCompilationResult module = compiler.CompileGlslToSpv( combined_sources, stage, name, options); -- 2.30.2