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.
This commit is contained in:
Eric Anholt
2018-12-20 07:45:58 -08:00
parent 87b251a940
commit 696f63f1b4
4 changed files with 55 additions and 2 deletions

View File

@@ -1895,6 +1895,8 @@ ntq_emit_loop(struct v3d_compile *c, nir_loop *loop)
c->loop_break_block = save_loop_break_block; c->loop_break_block = save_loop_break_block;
c->loop_cont_block = save_loop_cont_block; c->loop_cont_block = save_loop_cont_block;
c->loops++;
} }
static void static void

View File

@@ -457,6 +457,10 @@ struct v3d_compile {
struct exec_list *cf_node_list; struct exec_list *cf_node_list;
const struct v3d_compiler *compiler; 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 * Mapping from nir_register * or nir_ssa_def * to array of struct
* qreg for the values. * qreg for the values.
@@ -529,8 +533,8 @@ struct v3d_compile {
* space needs to be available in the spill BO per thread per QPU. * space needs to be available in the spill BO per thread per QPU.
*/ */
uint32_t spill_size; uint32_t spill_size;
/* Shader-db stats for register spilling. */ /* Shader-db stats */
uint32_t spills, fills; uint32_t spills, fills, loops;
/** /**
* Register spilling's per-thread base address, shared between each * Register spilling's per-thread base address, shared between each
* spill/fill's addressing calculations. * 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_key *key,
struct v3d_vs_prog_data *prog_data, struct v3d_vs_prog_data *prog_data,
nir_shader *s, nir_shader *s,
void (*debug_output)(const char *msg,
void *debug_output_data),
void *debug_output_data,
int program_id, int variant_id, int program_id, int variant_id,
uint32_t *final_assembly_size); 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_key *key,
struct v3d_fs_prog_data *prog_data, struct v3d_fs_prog_data *prog_data,
nir_shader *s, nir_shader *s,
void (*debug_output)(const char *msg,
void *debug_output_data),
void *debug_output_data,
int program_id, int variant_id, int program_id, int variant_id,
uint32_t *final_assembly_size); uint32_t *final_assembly_size);

View File

@@ -558,6 +558,9 @@ static struct v3d_compile *
vir_compile_init(const struct v3d_compiler *compiler, vir_compile_init(const struct v3d_compiler *compiler,
struct v3d_key *key, struct v3d_key *key,
nir_shader *s, nir_shader *s,
void (*debug_output)(const char *msg,
void *debug_output_data),
void *debug_output_data,
int program_id, int variant_id) int program_id, int variant_id)
{ {
struct v3d_compile *c = rzalloc(NULL, struct v3d_compile); 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->program_id = program_id;
c->variant_id = variant_id; c->variant_id = variant_id;
c->threads = 4; c->threads = 4;
c->debug_output = debug_output;
c->debug_output_data = debug_output_data;
s = nir_shader_clone(c, s); s = nir_shader_clone(c, s);
c->s = 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); 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); vir_compile_destroy(c);
return qpu_insts; 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_key *key,
struct v3d_vs_prog_data *prog_data, struct v3d_vs_prog_data *prog_data,
nir_shader *s, nir_shader *s,
void (*debug_output)(const char *msg,
void *debug_output_data),
void *debug_output_data,
int program_id, int variant_id, int program_id, int variant_id,
uint32_t *final_assembly_size) uint32_t *final_assembly_size)
{ {
struct v3d_compile *c = vir_compile_init(compiler, &key->base, s, struct v3d_compile *c = vir_compile_init(compiler, &key->base, s,
debug_output, debug_output_data,
program_id, variant_id); program_id, variant_id);
c->vs_key = key; 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_key *key,
struct v3d_fs_prog_data *prog_data, struct v3d_fs_prog_data *prog_data,
nir_shader *s, nir_shader *s,
void (*debug_output)(const char *msg,
void *debug_output_data),
void *debug_output_data,
int program_id, int variant_id, int program_id, int variant_id,
uint32_t *final_assembly_size) uint32_t *final_assembly_size)
{ {
struct v3d_compile *c = vir_compile_init(compiler, &key->base, s, struct v3d_compile *c = vir_compile_init(compiler, &key->base, s,
debug_output, debug_output_data,
program_id, variant_id); program_id, variant_id);
c->fs_key = key; c->fs_key = key;

View File

@@ -307,6 +307,14 @@ v3d_shader_state_create(struct pipe_context *pctx,
return so; 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 * static struct v3d_compiled_shader *
v3d_get_compiled_shader(struct v3d_context *v3d, struct v3d_key *key) 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, qpu_insts = v3d_compile_vs(v3d->screen->compiler,
(struct v3d_vs_key *)key, (struct v3d_vs_key *)key,
shader->prog_data.vs, s, shader->prog_data.vs, s,
v3d_shader_debug_output,
v3d,
program_id, variant_id, program_id, variant_id,
&shader_size); &shader_size);
break; 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, qpu_insts = v3d_compile_fs(v3d->screen->compiler,
(struct v3d_fs_key *)key, (struct v3d_fs_key *)key,
shader->prog_data.fs, s, shader->prog_data.fs, s,
v3d_shader_debug_output,
v3d,
program_id, variant_id, program_id, variant_id,
&shader_size); &shader_size);
break; break;