SpirvShaderDebugger: Add PRINT_EACH_DEFINED_DBG_INSTRUCTION Prints each debug instruction as it is defined. Yet another tool in debugging the debugger. Also rename `PRINT_EACH_PROCESSED_INSTRUCTION` to `PRINT_EACH_EMITTED_INSTRUCTION` as that's really what it meant. Bug: b/148401179 Change-Id: I9ddf90eab1919deefb5f4557756364478f06375a Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/48430 Tested-by: Ben Clayton <bclayton@google.com> Kokoro-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/Pipeline/SpirvShaderDebugger.cpp b/src/Pipeline/SpirvShaderDebugger.cpp index ea2adc8..1608bc5 100644 --- a/src/Pipeline/SpirvShaderDebugger.cpp +++ b/src/Pipeline/SpirvShaderDebugger.cpp
@@ -14,8 +14,10 @@ #include "SpirvShader.hpp" -// If enabled, each instruction will be printed before processing. -#define PRINT_EACH_PROCESSED_INSTRUCTION 0 +// If enabled, each instruction will be printed before defining. +#define PRINT_EACH_DEFINED_DBG_INSTRUCTION 0 +// If enabled, each instruction will be printed before emitting. +#define PRINT_EACH_EMITTED_INSTRUCTION 0 // If enabled, each instruction will be printed before executing. #define PRINT_EACH_EXECUTED_INSTRUCTION 0 // If enabled, debugger variables will contain debug information (addresses, @@ -2048,7 +2050,7 @@ void SpirvShader::dbgBeginEmitInstruction(InsnIterator insn, EmitState *state) const { -# if PRINT_EACH_PROCESSED_INSTRUCTION +# if PRINT_EACH_EMITTED_INSTRUCTION { auto instruction = spvtools::spvInstructionBinaryToText( SPV_ENV_VULKAN_1_1, @@ -2059,7 +2061,7 @@ SPV_BINARY_TO_TEXT_OPTION_NO_HEADER); printf("%s\n", instruction.c_str()); } -# endif // PRINT_EACH_PROCESSED_INSTRUCTION +# endif // PRINT_EACH_EMITTED_INSTRUCTION # if PRINT_EACH_EXECUTED_INSTRUCTION { @@ -2162,6 +2164,19 @@ void SpirvShader::DefineOpenCLDebugInfo100(const InsnIterator &insn) { +# if PRINT_EACH_DEFINED_DBG_INSTRUCTION + { + auto instruction = spvtools::spvInstructionBinaryToText( + SPV_ENV_VULKAN_1_1, + insn.wordPointer(0), + insn.wordCount(), + insns.data(), + insns.size(), + SPV_BINARY_TO_TEXT_OPTION_NO_HEADER); + printf("%s\n", instruction.c_str()); + } +# endif // PRINT_EACH_DEFINED_DBG_INSTRUCTION + auto dbg = impl.debugger; if(!dbg) { return; }