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 <tomeu.vizoso@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4832>
This commit is contained in:
Tomeu Vizoso 2020-04-30 09:29:10 +02:00
parent 9c7d30fb4a
commit 07b31f3437
2 changed files with 34 additions and 4 deletions

View file

@ -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,

View file

@ -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);
}