summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2014-10-22 18:02:18 +0100
committerEric Anholt <[email protected]>2014-10-24 18:04:26 +0100
commit5d32e263357e562779bfc0d2af712d4c7538a32b (patch)
treed324188b178eda0f85c4b293a6aed364cc612244 /src/gallium
parent14bdcc6ff98664552216acfdb7e35d0b128003ef (diff)
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.
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/drivers/vc4/vc4_context.h5
-rw-r--r--src/gallium/drivers/vc4/vc4_program.c24
-rw-r--r--src/gallium/drivers/vc4/vc4_qir.h3
-rw-r--r--src/gallium/drivers/vc4/vc4_qpu_emit.c4
4 files changed, 29 insertions, 7 deletions
diff --git a/src/gallium/drivers/vc4/vc4_context.h b/src/gallium/drivers/vc4/vc4_context.h
index 45dfa020551..d0b280a3b6d 100644
--- a/src/gallium/drivers/vc4/vc4_context.h
+++ b/src/gallium/drivers/vc4/vc4_context.h
@@ -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;
diff --git a/src/gallium/drivers/vc4/vc4_program.c b/src/gallium/drivers/vc4/vc4_program.c
index c6d9fb31603..01941f88428 100644
--- a/src/gallium/drivers/vc4/vc4_program.c
+++ b/src/gallium/drivers/vc4/vc4_program.c
@@ -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;
}
diff --git a/src/gallium/drivers/vc4/vc4_qir.h b/src/gallium/drivers/vc4/vc4_qir.h
index b95dbc33d51..c2f83a7e923 100644
--- a/src/gallium/drivers/vc4/vc4_qir.h
+++ b/src/gallium/drivers/vc4/vc4_qir.h
@@ -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);
diff --git a/src/gallium/drivers/vc4/vc4_qpu_emit.c b/src/gallium/drivers/vc4/vc4_qpu_emit.c
index 99e634eb493..1d9bff39fe0 100644
--- a/src/gallium/drivers/vc4/vc4_qpu_emit.c
+++ b/src/gallium/drivers/vc4/vc4_qpu_emit.c
@@ -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]);