From d83f0c1c0427140406439555471e5efef9a51c74 Mon Sep 17 00:00:00 2001 From: Emma Anholt Date: Sun, 27 Jun 2021 13:47:51 -0700 Subject: [PATCH] i915g: Enable dumping of fragment shaders under I915_DEBUG=fs. Probably the most common thing I want to debug in this driver, and we didn't have a good option for it. Part-of: --- src/gallium/drivers/i915/i915_debug.c | 1 + src/gallium/drivers/i915/i915_debug.h | 1 + src/gallium/drivers/i915/i915_debug_fp.c | 1 - src/gallium/drivers/i915/i915_fpc_translate.c | 27 ++++++++++++++----- 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/gallium/drivers/i915/i915_debug.c b/src/gallium/drivers/i915/i915_debug.c index e2d271e0480..47d0f3cf55f 100644 --- a/src/gallium/drivers/i915/i915_debug.c +++ b/src/gallium/drivers/i915/i915_debug.c @@ -42,6 +42,7 @@ static const struct debug_named_value i915_debug_options[] = { {"flush", DBG_FLUSH, "Flushing information"}, {"texture", DBG_TEXTURE, "Texture information"}, {"constants", DBG_CONSTANTS, "Constant buffers"}, + {"fs", DBG_FS, "Dump fragment shaders"}, DEBUG_NAMED_VALUE_END}; unsigned i915_debug = 0; diff --git a/src/gallium/drivers/i915/i915_debug.h b/src/gallium/drivers/i915/i915_debug.h index 30b0f9c979a..8195832aed7 100644 --- a/src/gallium/drivers/i915/i915_debug.h +++ b/src/gallium/drivers/i915/i915_debug.h @@ -44,6 +44,7 @@ struct i915_winsys_batchbuffer; #define DBG_FLUSH 0x8 #define DBG_TEXTURE 0x10 #define DBG_CONSTANTS 0x20 +#define DBG_FS 0x40 extern unsigned i915_debug; diff --git a/src/gallium/drivers/i915/i915_debug_fp.c b/src/gallium/drivers/i915/i915_debug_fp.c index 628db703cbc..fcada721390 100644 --- a/src/gallium/drivers/i915/i915_debug_fp.c +++ b/src/gallium/drivers/i915/i915_debug_fp.c @@ -277,5 +277,4 @@ i915_disassemble_program(const unsigned *program, unsigned sz) } mesa_logi("\t\tEND"); - mesa_logi("\t\t"); } diff --git a/src/gallium/drivers/i915/i915_fpc_translate.c b/src/gallium/drivers/i915/i915_fpc_translate.c index 1fc5ab1786f..5bfbbc88b26 100644 --- a/src/gallium/drivers/i915/i915_fpc_translate.c +++ b/src/gallium/drivers/i915/i915_fpc_translate.c @@ -28,6 +28,7 @@ #include #include "i915_context.h" +#include "i915_debug.h" #include "i915_debug_private.h" #include "i915_fpc.h" #include "i915_reg.h" @@ -35,6 +36,7 @@ #include "pipe/p_shader_tokens.h" #include "tgsi/tgsi_dump.h" #include "tgsi/tgsi_parse.h" +#include "util/log.h" #include "util/u_math.h" #include "util/u_memory.h" #include "util/u_string.h" @@ -1046,9 +1048,10 @@ i915_translate_fragment_program(struct i915_context *i915, const struct tgsi_token *tokens = fs->state.tokens; struct i915_token_list *i_tokens; -#if 0 - tgsi_dump(tokens, 0); -#endif + if (I915_DBG_ON(DBG_FS)) { + mesa_logi("TGSI fragment shader:"); + tgsi_dump(tokens, 0); + } /* hw doesn't seem to like empty frag programs, even when the depth write * fixup gets emitted below - may that one is fishy, too? */ @@ -1067,8 +1070,18 @@ i915_translate_fragment_program(struct i915_context *i915, i915_fini_compile(i915, p); i915_optimize_free(i_tokens); -#if 0 - /* XXX: The disasm wants the concatenation of the decl and program. */ - i915_disassemble_program(fs->program, fs->program_len); -#endif + if (I915_DBG_ON(DBG_FS)) { + mesa_logi("i915 fragment shader with %d constants%s", fs->num_constants, + fs->num_constants ? ":" : ""); + + for (int i = 0; i < I915_MAX_CONSTANT; i++) { + if (fs->constant_flags[i] && + fs->constant_flags[i] != I915_CONSTFLAG_USER) { + mesa_logi("\t\tC[%d] = { %f, %f, %f, %f }", i, fs->constants[i][0], + fs->constants[i][1], fs->constants[i][2], + fs->constants[i][3]); + } + } + i915_disassemble_program(fs->program, fs->program_len); + } }