From 6d7be3694fbaae525b2f4463630c35bed487cd5b Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Thu, 13 Jul 2017 12:10:08 -0700 Subject: Add support for dumping intermediates for debugging. Calling: spSetDumpIntermedites(compileRequest, true); will set up a mode where Slang tries to dump every intermediate HLSL, GLSL, DXBC, SPIR-V, etc. file it generates. If SPIR-V or DXBC is requested then we also dump assembly of those. Right now the files are all named as `slang-.`, and get dropped in whatever the working directory is, but I'm open to ideas on how to improve that. Note: this change introduces a new binary interface to `glslang`, so pulling it requires an updated `glslang.dll`. --- source/slang/compiler.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'source/slang/compiler.h') diff --git a/source/slang/compiler.h b/source/slang/compiler.h index 2b440ad85..a7d104b5f 100644 --- a/source/slang/compiler.h +++ b/source/slang/compiler.h @@ -207,6 +207,9 @@ namespace Slang // Compile flags to be shared by all translation units SlangCompileFlags compileFlags = 0; + // Should we dump intermediate results along the way, for debugging? + bool shouldDumpIntermediates = false; + // Output stuff DiagnosticSink mSink; String mDiagnosticOutput; @@ -277,6 +280,17 @@ namespace Slang void generateOutput( CompileRequest* compileRequest); + + // Helper to dump intermediate output when debugging + void maybeDumpIntermediate( + CompileRequest* compileRequest, + void const* data, + size_t size, + CodeGenTarget target); + void maybeDumpIntermediate( + CompileRequest* compileRequest, + char const* text, + CodeGenTarget target); } #endif \ No newline at end of file -- cgit v1.2.3