From bce070eba418c8a79f6affcd885564babbf8c9d3 Mon Sep 17 00:00:00 2001 From: quou Date: Sun, 5 Jan 2025 22:15:22 +1100 Subject: source level shader debugging --- sc/glslang | 2 +- sc/sc.cpp | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) (limited to 'sc') diff --git a/sc/glslang b/sc/glslang index 1062752..f754c85 160000 --- a/sc/glslang +++ b/sc/glslang @@ -1 +1 @@ -Subproject commit 1062752a891c95b2bfeed9e356562d88f9df84ac +Subproject commit f754c852a87988eb097a39480c65f704ceb46274 diff --git a/sc/sc.cpp b/sc/sc.cpp index 2bd1406..de39187 100644 --- a/sc/sc.cpp +++ b/sc/sc.cpp @@ -508,6 +508,7 @@ struct Desc { std::vector compile_shader( Desc& d, + const char* fname, const char* presrc, const char* src, const char* define, @@ -532,6 +533,9 @@ std::vector compile_shader( #ifdef DEBUG options.disableOptimizer = true; options.generateDebugInfo = true; + options.emitNonSemanticShaderDebugInfo = true; + options.emitNonSemanticShaderDebugSource = true; + options.stripDebugInfo = false; #else options.disableOptimizer = false; options.stripDebugInfo = true; @@ -541,6 +545,14 @@ std::vector compile_shader( shader.setEnvClient(glslang::EShClientVulkan, client_version); shader.setEnvTarget(glslang::EShTargetSpv, target_version); shader.setEntryPoint(d.entrypoints[stage].c_str()); +#ifdef DEBUG + shader.setDebugInfo(true); + shader.setSourceEntryPoint(d.entrypoints[stage].c_str()); + shader.setSourceFile(fname); + shader.addSourceText(src, strlen(src)); +#else + (void)fname; +#endif if (!shader.preprocess( GetDefaultResources(), glsl_version, @@ -599,6 +611,7 @@ void configure( } void compile_shaders( + const char* fname, std::vector* spv, const char* src, Desc& d @@ -612,6 +625,7 @@ void compile_shaders( configure(d, i, define, lang, ps); spv[i] = compile_shader( d, + fname, ps.c_str(), src, define, @@ -718,7 +732,7 @@ int main(int argc, const char** argv) { desc_src = get_desc(src); cdesc = parse_desc(dp_mem, desc_src.c_str()); desc.build(cdesc); - compile_shaders(spv, src, desc); + compile_shaders(argv[2], spv, src, desc); write_csh(argv[2], desc, spv); return 0; } -- cgit v1.2.3-54-g00ecf