vc4: Add debug output to match shaderdb info to program dumps.

I'm going to be using VC4_DEBUG=shaderdb,norast to do shaderdb stats, but
when debugging regressions, I want to match shaderdb output to shader
disassembly.
This commit is contained in:
Eric Anholt 2014-10-22 18:02:18 +01:00
parent 14bdcc6ff9
commit 5d32e26335
4 changed files with 29 additions and 7 deletions

View File

@ -79,6 +79,10 @@ struct vc4_shader_uniform_info {
};
struct vc4_uncompiled_shader {
/** A name for this program, so you can track it in shader-db output. */
uint32_t program_id;
/** How many variants of this program were compiled, for shader-db. */
uint32_t compiled_variant_count;
struct pipe_shader_state base;
const struct tgsi_token *twoside_tokens;
};
@ -183,6 +187,7 @@ struct vc4_context {
struct primconvert_context *primconvert;
struct util_hash_table *fs_cache, *vs_cache;
uint32_t next_uncompiled_program_id;
uint64_t next_compiled_program_id;
struct ra_regs *regs;

View File

@ -1827,6 +1827,8 @@ vc4_shader_tgsi_to_qir(struct vc4_context *vc4, enum qstage stage,
c->stage = stage;
c->shader_state = &key->shader_state->base;
c->program_id = key->shader_state->program_id;
c->variant_id = key->shader_state->compiled_variant_count++;
c->key = key;
switch (stage) {
@ -1874,7 +1876,9 @@ vc4_shader_tgsi_to_qir(struct vc4_context *vc4, enum qstage stage,
assert(ret == TGSI_PARSE_OK);
if (vc4_debug & VC4_DEBUG_TGSI) {
fprintf(stderr, "TGSI:\n");
fprintf(stderr, "%s prog %d/%d TGSI:\n",
qir_get_stage_name(c->stage),
c->program_id, c->variant_id);
tgsi_dump(tokens, 0);
}
@ -1918,17 +1922,23 @@ vc4_shader_tgsi_to_qir(struct vc4_context *vc4, enum qstage stage,
qir_optimize(c);
if (vc4_debug & VC4_DEBUG_QIR) {
fprintf(stderr, "QIR:\n");
fprintf(stderr, "%s prog %d/%d QIR:\n",
qir_get_stage_name(c->stage),
c->program_id, c->variant_id);
qir_dump(c);
}
qir_reorder_uniforms(c);
vc4_generate_code(vc4, c);
if (vc4_debug & VC4_DEBUG_SHADERDB) {
fprintf(stderr, "SHADER-DB: %s: %d instructions\n",
qir_get_stage_name(c->stage), c->qpu_inst_count);
fprintf(stderr, "SHADER-DB: %s: %d uniforms\n",
qir_get_stage_name(c->stage), c->num_uniforms);
fprintf(stderr, "SHADER-DB: %s prog %d/%d: %d instructions\n",
qir_get_stage_name(c->stage),
c->program_id, c->variant_id,
c->qpu_inst_count);
fprintf(stderr, "SHADER-DB: %s prog %d/%d: %d uniforms\n",
qir_get_stage_name(c->stage),
c->program_id, c->variant_id,
c->num_uniforms);
}
return c;
@ -1938,6 +1948,7 @@ static void *
vc4_shader_state_create(struct pipe_context *pctx,
const struct pipe_shader_state *cso)
{
struct vc4_context *vc4 = vc4_context(pctx);
struct vc4_uncompiled_shader *so = CALLOC_STRUCT(vc4_uncompiled_shader);
if (!so)
return NULL;
@ -1961,6 +1972,7 @@ vc4_shader_state_create(struct pipe_context *pctx,
so->base.tokens = tgsi_transform_lowering(&lowering_config, cso->tokens, &info);
if (!so->base.tokens)
so->base.tokens = tgsi_dup_tokens(cso->tokens);
so->program_id = vc4->next_uncompiled_program_id++;
return so;
}

View File

@ -289,6 +289,9 @@ struct vc4_compile {
uint32_t qpu_inst_count;
uint32_t qpu_inst_size;
uint32_t num_inputs;
uint32_t program_id;
uint32_t variant_id;
};
struct vc4_compile *qir_compile_init(void);

View File

@ -30,7 +30,9 @@
static void
vc4_dump_program(struct vc4_compile *c)
{
fprintf(stderr, "%s:\n", qir_get_stage_name(c->stage));
fprintf(stderr, "%s prog %d/%d QPU:\n",
qir_get_stage_name(c->stage),
c->program_id, c->variant_id);
for (int i = 0; i < c->qpu_inst_count; i++) {
fprintf(stderr, "0x%016"PRIx64" ", c->qpu_insts[i]);