summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2018-12-20 07:45:58 -0800
committerEric Anholt <[email protected]>2018-12-30 08:03:51 -0800
commit696f63f1b472acd5efe32910c714469728fb5162 (patch)
treed8b7fc00b6f64a8c1e47f42a848a16f8438b5afc
parent87b251a94082fbc386a65670b1748daa7b44c00f (diff)
v3d: Hook up some shader-db output to GL_ARB_debug_output.
This allows the original shader-db project's run.c runner to parse things easily, and is probably a good thing to have for GL_ARB_debug_output in general. I formatted it more like Intel's so I can mostly reuse their report script.
-rw-r--r--src/broadcom/compiler/nir_to_vir.c2
-rw-r--r--src/broadcom/compiler/v3d_compiler.h14
-rw-r--r--src/broadcom/compiler/vir.c29
-rw-r--r--src/gallium/drivers/v3d/v3d_program.c12
4 files changed, 55 insertions, 2 deletions
diff --git a/src/broadcom/compiler/nir_to_vir.c b/src/broadcom/compiler/nir_to_vir.c
index ada0dd69921..b6dd188778a 100644
--- a/src/broadcom/compiler/nir_to_vir.c
+++ b/src/broadcom/compiler/nir_to_vir.c
@@ -1895,6 +1895,8 @@ ntq_emit_loop(struct v3d_compile *c, nir_loop *loop)
c->loop_break_block = save_loop_break_block;
c->loop_cont_block = save_loop_cont_block;
+
+ c->loops++;
}
static void
diff --git a/src/broadcom/compiler/v3d_compiler.h b/src/broadcom/compiler/v3d_compiler.h
index ec5fd87083c..2d9167a27a0 100644
--- a/src/broadcom/compiler/v3d_compiler.h
+++ b/src/broadcom/compiler/v3d_compiler.h
@@ -457,6 +457,10 @@ struct v3d_compile {
struct exec_list *cf_node_list;
const struct v3d_compiler *compiler;
+ void (*debug_output)(const char *msg,
+ void *debug_output_data);
+ void *debug_output_data;
+
/**
* Mapping from nir_register * or nir_ssa_def * to array of struct
* qreg for the values.
@@ -529,8 +533,8 @@ struct v3d_compile {
* space needs to be available in the spill BO per thread per QPU.
*/
uint32_t spill_size;
- /* Shader-db stats for register spilling. */
- uint32_t spills, fills;
+ /* Shader-db stats */
+ uint32_t spills, fills, loops;
/**
* Register spilling's per-thread base address, shared between each
* spill/fill's addressing calculations.
@@ -706,6 +710,9 @@ uint64_t *v3d_compile_vs(const struct v3d_compiler *compiler,
struct v3d_vs_key *key,
struct v3d_vs_prog_data *prog_data,
nir_shader *s,
+ void (*debug_output)(const char *msg,
+ void *debug_output_data),
+ void *debug_output_data,
int program_id, int variant_id,
uint32_t *final_assembly_size);
@@ -713,6 +720,9 @@ uint64_t *v3d_compile_fs(const struct v3d_compiler *compiler,
struct v3d_fs_key *key,
struct v3d_fs_prog_data *prog_data,
nir_shader *s,
+ void (*debug_output)(const char *msg,
+ void *debug_output_data),
+ void *debug_output_data,
int program_id, int variant_id,
uint32_t *final_assembly_size);
diff --git a/src/broadcom/compiler/vir.c b/src/broadcom/compiler/vir.c
index 9bec5e54e13..8880a282045 100644
--- a/src/broadcom/compiler/vir.c
+++ b/src/broadcom/compiler/vir.c
@@ -558,6 +558,9 @@ static struct v3d_compile *
vir_compile_init(const struct v3d_compiler *compiler,
struct v3d_key *key,
nir_shader *s,
+ void (*debug_output)(const char *msg,
+ void *debug_output_data),
+ void *debug_output_data,
int program_id, int variant_id)
{
struct v3d_compile *c = rzalloc(NULL, struct v3d_compile);
@@ -568,6 +571,8 @@ vir_compile_init(const struct v3d_compiler *compiler,
c->program_id = program_id;
c->variant_id = variant_id;
c->threads = 4;
+ c->debug_output = debug_output;
+ c->debug_output_data = debug_output_data;
s = nir_shader_clone(c, s);
c->s = s;
@@ -702,6 +707,22 @@ v3d_return_qpu_insts(struct v3d_compile *c, uint32_t *final_assembly_size)
memcpy(qpu_insts, c->qpu_insts, *final_assembly_size);
+ char *shaderdb;
+ int ret = asprintf(&shaderdb,
+ "%s shader: %d inst, %d threads, %d loops, "
+ "%d uniforms, %d:%d spills:fills",
+ vir_get_stage_name(c),
+ c->qpu_inst_count,
+ c->threads,
+ c->loops,
+ c->num_uniforms,
+ c->spills,
+ c->fills);
+ if (ret >= 0) {
+ c->debug_output(shaderdb, c->debug_output_data);
+ free(shaderdb);
+ }
+
vir_compile_destroy(c);
return qpu_insts;
@@ -711,10 +732,14 @@ uint64_t *v3d_compile_vs(const struct v3d_compiler *compiler,
struct v3d_vs_key *key,
struct v3d_vs_prog_data *prog_data,
nir_shader *s,
+ void (*debug_output)(const char *msg,
+ void *debug_output_data),
+ void *debug_output_data,
int program_id, int variant_id,
uint32_t *final_assembly_size)
{
struct v3d_compile *c = vir_compile_init(compiler, &key->base, s,
+ debug_output, debug_output_data,
program_id, variant_id);
c->vs_key = key;
@@ -874,10 +899,14 @@ uint64_t *v3d_compile_fs(const struct v3d_compiler *compiler,
struct v3d_fs_key *key,
struct v3d_fs_prog_data *prog_data,
nir_shader *s,
+ void (*debug_output)(const char *msg,
+ void *debug_output_data),
+ void *debug_output_data,
int program_id, int variant_id,
uint32_t *final_assembly_size)
{
struct v3d_compile *c = vir_compile_init(compiler, &key->base, s,
+ debug_output, debug_output_data,
program_id, variant_id);
c->fs_key = key;
diff --git a/src/gallium/drivers/v3d/v3d_program.c b/src/gallium/drivers/v3d/v3d_program.c
index d6350682936..759fac117f2 100644
--- a/src/gallium/drivers/v3d/v3d_program.c
+++ b/src/gallium/drivers/v3d/v3d_program.c
@@ -307,6 +307,14 @@ v3d_shader_state_create(struct pipe_context *pctx,
return so;
}
+static void
+v3d_shader_debug_output(const char *message, void *data)
+{
+ struct v3d_context *v3d = data;
+
+ pipe_debug_message(&v3d->debug, SHADER_INFO, "%s", message);
+}
+
static struct v3d_compiled_shader *
v3d_get_compiled_shader(struct v3d_context *v3d, struct v3d_key *key)
{
@@ -343,6 +351,8 @@ v3d_get_compiled_shader(struct v3d_context *v3d, struct v3d_key *key)
qpu_insts = v3d_compile_vs(v3d->screen->compiler,
(struct v3d_vs_key *)key,
shader->prog_data.vs, s,
+ v3d_shader_debug_output,
+ v3d,
program_id, variant_id,
&shader_size);
break;
@@ -352,6 +362,8 @@ v3d_get_compiled_shader(struct v3d_context *v3d, struct v3d_key *key)
qpu_insts = v3d_compile_fs(v3d->screen->compiler,
(struct v3d_fs_key *)key,
shader->prog_data.fs, s,
+ v3d_shader_debug_output,
+ v3d,
program_id, variant_id,
&shader_size);
break;