summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/vc4/vc4_program.c
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2015-02-20 00:31:51 -0800
committerEric Anholt <[email protected]>2015-04-01 10:57:01 -0700
commit26261bca2137eb1ca57e53f4efb95bcb3f1419df (patch)
tree785171eaca9f7c4d82555f70ebeed6c177462ced /src/gallium/drivers/vc4/vc4_program.c
parent73e2d4837d7e4611f31532ab0ccc14369341e0cb (diff)
vc4: Add shader-db dumping of NIR instruction count.
I was previously using temporary disables of VC4 optimization to show the benefits of improved NIR optimization, but this can get me quick and dirty numbers for NIR-only improvements without having to add hacks to disable VC4's code (disabling of which might hide ways that the NIR changes would hurt actual VC4 codegen).
Diffstat (limited to 'src/gallium/drivers/vc4/vc4_program.c')
-rw-r--r--src/gallium/drivers/vc4/vc4_program.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/gallium/drivers/vc4/vc4_program.c b/src/gallium/drivers/vc4/vc4_program.c
index 1b87fe417d8..5ed2165b014 100644
--- a/src/gallium/drivers/vc4/vc4_program.c
+++ b/src/gallium/drivers/vc4/vc4_program.c
@@ -1994,6 +1994,28 @@ static const nir_shader_compiler_options nir_options = {
.lower_negate = true,
};
+static bool
+count_nir_instrs_in_block(nir_block *block, void *state)
+{
+ int *count = (int *) state;
+ nir_foreach_instr(block, instr) {
+ *count = *count + 1;
+ }
+ return true;
+}
+
+static int
+count_nir_instrs(nir_shader *nir)
+{
+ int count = 0;
+ nir_foreach_overload(nir, overload) {
+ if (!overload->impl)
+ continue;
+ nir_foreach_block(overload->impl, count_nir_instrs_in_block, &count);
+ }
+ return count;
+}
+
static struct vc4_compile *
vc4_shader_ntq(struct vc4_context *vc4, enum qstage stage,
struct vc4_key *key)
@@ -2064,6 +2086,13 @@ vc4_shader_ntq(struct vc4_context *vc4, enum qstage stage,
nir_convert_from_ssa(c->s);
+ if (vc4_debug & VC4_DEBUG_SHADERDB) {
+ fprintf(stderr, "SHADER-DB: %s prog %d/%d: %d NIR instructions\n",
+ qir_get_stage_name(c->stage),
+ c->program_id, c->variant_id,
+ count_nir_instrs(c->s));
+ }
+
if (vc4_debug & VC4_DEBUG_NIR) {
fprintf(stderr, "%s prog %d/%d NIR:\n",
qir_get_stage_name(c->stage),