Commit b3805904 by Ben Clayton

SpirvShaderDebugger: Add flag for printing opcodes

The `PRINT_EACH_PROCESSED_INSTRUCTION` preprocessor flag can control printing of each instruction before they are processed. This is exceptionally helpful when debugging the debugger (or anything else to do with SpirvShader). Bug: b/145351270 Change-Id: Iddfbedbfc86487d71f6980b2f3fb74f7f13e972f Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/40093Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Tested-by: 's avatarBen Clayton <bclayton@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
parent 8842c8f4
......@@ -14,6 +14,9 @@
#include "SpirvShader.hpp"
// If enabled, each instruction will be printed before processing.
#define PRINT_EACH_PROCESSED_INSTRUCTION 0
#ifdef ENABLE_VK_DEBUGGER
# include "Vulkan/Debug/Context.hpp"
......@@ -598,6 +601,17 @@ void SpirvShader::dbgEndEmit(EmitState *state) const
void SpirvShader::dbgBeginEmitInstruction(InsnIterator insn, EmitState *state) const
{
# if PRINT_EACH_PROCESSED_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_PROCESSED_INSTRUCTION
auto dbg = impl.debugger;
if(!dbg) { return; }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment