vc4: Add support for turning constant uniforms into small immediates

Graphics / Mesa 3D Graphics Library / Mesa - Eric Anholt [anholt.net] - 17 December 2014 21:35 UTC

Small immediates have the downside of taking over the raddr B field, so you might have less chance to pack instructions together thanks to raddr B conflicts. However, it also reduces some register pressure since it lets you load 2 "uniform" values in one instruction (avoiding a previous load of the constant value to a register), and increases some pairing for the same reason.

total uniforms in shared programs: 16231 -> 13374 (-17.60%) uniforms in affected programs: 10280 -> 7423 (-27.79%) total instructions in shared programs: 40795 -> 41168 (0.91%) instructions in affected programs: 25551 -> 25924 (1.46%)

In a previous version of this patch I had a reduction in instruction count by forcing the other args alongside a SMALL_IMM to be in the A file or accumulators, but that increases register pressure and had a bug in handling FRAG_Z. In this patch is I just use raddr conflict resolution, which is more expensive. I think I'd rather tweak allocation to have some way to slightly prefer good choices for files in general, rather than risk failing to register allocate by forcing things into register classes.

e473fbe vc4: Add support for turning constant uniforms into small immediates.
src/gallium/drivers/vc4/Makefile.sources | 1 +
.../drivers/vc4/kernel/vc4_validate_shaders.c | 17 +++-
src/gallium/drivers/vc4/vc4_opt_algebraic.c | 26 +++--
src/gallium/drivers/vc4/vc4_opt_small_immediates.c | 105 ++++++++++++++++++++
src/gallium/drivers/vc4/vc4_qir.c | 13 ++-
src/gallium/drivers/vc4/vc4_qir.h | 7 ++
src/gallium/drivers/vc4/vc4_qpu.c | 104 +++++++++++++++----
src/gallium/drivers/vc4/vc4_qpu.h | 1 +
src/gallium/drivers/vc4/vc4_qpu_defines.h | 7 +-
src/gallium/drivers/vc4/vc4_qpu_disasm.c | 4 +-
src/gallium/drivers/vc4/vc4_qpu_emit.c | 35 +++++--
src/gallium/drivers/vc4/vc4_qpu_schedule.c | 8 +-
src/gallium/drivers/vc4/vc4_qpu_validate.c | 1 +
13 files changed, 283 insertions(+), 46 deletions(-)

Upstream: cgit.freedesktop.org


  • Share