diff options
author | Tomeu Vizoso <[email protected]> | 2020-04-30 09:29:10 +0200 |
---|---|---|
committer | Tomeu Vizoso <[email protected]> | 2020-05-01 16:52:16 +0200 |
commit | 07b31f3437ef60779f0fea83425521da3b7441f9 (patch) | |
tree | 5473870996d3ed83e10c6f0cd9fb4408505e4fab /src/panfrost | |
parent | 9c7d30fb4a0ca1625d16dffb3ff2359331783fe6 (diff) |
pan/bi: Print shaders only if BIFROST_MESA_DEBUG=shaders
Similar to how it's done in the Midgard compiler.
Signed-off-by: Tomeu Vizoso <[email protected]>
Reviewed-by: Alyssa Rosenzweig <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4832>
Diffstat (limited to 'src/panfrost')
-rw-r--r-- | src/panfrost/bifrost/bifrost.h | 5 | ||||
-rw-r--r-- | src/panfrost/bifrost/bifrost_compile.c | 33 |
2 files changed, 34 insertions, 4 deletions
diff --git a/src/panfrost/bifrost/bifrost.h b/src/panfrost/bifrost/bifrost.h index ad2b2ac01b7..3e8e0229e9d 100644 --- a/src/panfrost/bifrost/bifrost.h +++ b/src/panfrost/bifrost/bifrost.h @@ -29,6 +29,11 @@ #include <stdint.h> #include <stdbool.h> +#define BIFROST_DBG_MSGS 0x0001 +#define BIFROST_DBG_SHADERS 0x0002 + +extern int bifrost_debug; + enum bifrost_clause_type { BIFROST_CLAUSE_NONE = 0, BIFROST_CLAUSE_LOAD_VARY = 1, diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c index d3d89df1d63..a76ac2d0a0c 100644 --- a/src/panfrost/bifrost/bifrost_compile.c +++ b/src/panfrost/bifrost/bifrost_compile.c @@ -28,6 +28,7 @@ #include "compiler/glsl/glsl_to_nir.h" #include "compiler/nir_types.h" #include "compiler/nir/nir_builder.h" +#include "util/u_debug.h" #include "disassemble.h" #include "bifrost_compile.h" @@ -36,6 +37,21 @@ #include "bi_quirks.h" #include "bi_print.h" +static const struct debug_named_value debug_options[] = { + {"msgs", BIFROST_DBG_MSGS, "Print debug messages"}, + {"shaders", BIFROST_DBG_SHADERS, "Dump shaders in NIR and MIR"}, + DEBUG_NAMED_VALUE_END +}; + +DEBUG_GET_ONCE_FLAGS_OPTION(bifrost_debug, "BIFROST_MESA_DEBUG", debug_options, 0) + +int bifrost_debug = 0; + +#define DBG(fmt, ...) \ + do { if (bifrost_debug & BIFROST_DBG_MSGS) \ + fprintf(stderr, "%s:%d: "fmt, \ + __FUNCTION__, __LINE__, ##__VA_ARGS__); } while (0) + static bi_block *emit_cf_list(bi_context *ctx, struct exec_list *list); static bi_instruction *bi_emit_branch(bi_context *ctx); static void bi_schedule_barrier(bi_context *ctx); @@ -1051,6 +1067,8 @@ bi_optimize_nir(nir_shader *nir) void bifrost_compile_shader_nir(nir_shader *nir, panfrost_program *program, unsigned product_id) { + bifrost_debug = debug_get_option_bifrost_debug(); + bi_context *ctx = rzalloc(NULL, bi_context); ctx->nir = nir; ctx->stage = nir->info.stage; @@ -1077,7 +1095,10 @@ bifrost_compile_shader_nir(nir_shader *nir, panfrost_program *program, unsigned NIR_PASS_V(nir, nir_lower_mediump_outputs); bi_optimize_nir(nir); - nir_print_shader(nir, stdout); + + if (bifrost_debug & BIFROST_DBG_SHADERS) { + nir_print_shader(nir, stdout); + } panfrost_nir_assign_sysvals(&ctx->sysvals, nir); program->sysval_count = ctx->sysvals.sysval_count; @@ -1109,12 +1130,16 @@ bifrost_compile_shader_nir(nir_shader *nir, panfrost_program *program, unsigned } } while(progress); - bi_print_shader(ctx, stdout); + if (bifrost_debug & BIFROST_DBG_SHADERS) + bi_print_shader(ctx, stdout); bi_schedule(ctx); bi_register_allocate(ctx); - bi_print_shader(ctx, stdout); + if (bifrost_debug & BIFROST_DBG_SHADERS) + bi_print_shader(ctx, stdout); bi_pack(ctx, &program->compiled); - disassemble_bifrost(stdout, program->compiled.data, program->compiled.size, true); + + if (bifrost_debug & BIFROST_DBG_SHADERS) + disassemble_bifrost(stdout, program->compiled.data, program->compiled.size, true); ralloc_free(ctx); } |