diff options
author | Eric Anholt <[email protected]> | 2014-10-24 15:03:04 +0100 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2014-10-24 18:04:26 +0100 |
commit | 52824811b9c0a9bb78a40fcb43af00b315f612d0 (patch) | |
tree | 2b324d8fc3a7037ac3ba57c5c25a4bfbe453b9e1 /src/gallium/drivers/vc4/vc4_program.c | |
parent | 5d32e263357e562779bfc0d2af712d4c7538a32b (diff) |
vc4: Allow dead code elimination of unused varyings.
total instructions in shared programs: 39022 -> 37341 (-4.31%)
instructions in affected programs: 26979 -> 25298 (-6.23%)
total uniforms in shared programs: 11242 -> 10523 (-6.40%)
uniforms in affected programs: 5836 -> 5117 (-12.32%)
Diffstat (limited to 'src/gallium/drivers/vc4/vc4_program.c')
-rw-r--r-- | src/gallium/drivers/vc4/vc4_program.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/gallium/drivers/vc4/vc4_program.c b/src/gallium/drivers/vc4/vc4_program.c index 01941f88428..0674e4fd01a 100644 --- a/src/gallium/drivers/vc4/vc4_program.c +++ b/src/gallium/drivers/vc4/vc4_program.c @@ -2018,6 +2018,18 @@ vc4_get_compiled_shader(struct vc4_context *vc4, enum qstage stage, shader->program_id = vc4->next_compiled_program_id++; if (stage == QSTAGE_FRAG) { + bool input_live[c->num_input_semantics]; + struct simple_node *node; + + memset(input_live, 0, sizeof(input_live)); + foreach(node, &c->instructions) { + struct qinst *inst = (struct qinst *)node; + for (int i = 0; i < qir_get_op_nsrc(inst->op); i++) { + if (inst->src[i].file == QFILE_VARY) + input_live[inst->src[i].index] = true; + } + } + shader->input_semantics = ralloc_array(shader, struct vc4_varying_semantic, c->num_input_semantics); @@ -2025,6 +2037,9 @@ vc4_get_compiled_shader(struct vc4_context *vc4, enum qstage stage, for (int i = 0; i < c->num_input_semantics; i++) { struct vc4_varying_semantic *sem = &c->input_semantics[i]; + if (!input_live[i]) + continue; + /* Skip non-VS-output inputs. */ if (sem->semantic == (uint8_t)~0) continue; |