radeonsi: eliminate trivial constant VS outputs

Graphics / Mesa 3D Graphics Library / Mesa - Marek Olšák [amd.com] - 19 October 2016 15:21 UTC

These constant value VS PARAM exports:- 0,0,0,0- 0,0,0,1- 1,1,1,0- 1,1,1,1 can be loaded into PS inputs using the DEFAULT_VAL field, and the VS exports can be removed from the IR to save export & parameter memory.

After LLVM optimizations, analyze the IR to see which exports are equal to the ones listed above (or undef) and remove them if they are.

Targeted use cases:- All DX9 eON ports always clear 10 VS outputs to 0.0 even if most of them are unused by PS (such as Witcher 2 below).- VS output arrays with unused elements that the GLSL compiler can't eliminate (such as Batman below).

The shader-db deltas are quite interesting: (not from upstream si-report.py, it won't be upstreamed)

PERCENTAGE DELTAS Shaders PARAM exports (affected only) batman_arkham_origins 589 -67.17 % bioshock-infinite 1769 -0.47 % dirt-showdown 548 -2.68 % dota2 1747 -3.36 % f1-2015 776 -4.94 % left_4_dead_2 1762 -0.07 % metro_2033_redux 2670 -0.43 % portal 474 -0.22 % talos_principle 324 -3.63 % warsow 176 -2.20 % witcher2 1040 -73.78 %

All affected 991 -65.37 % ... 9681 -> 3353

Total 26725 -10.82 % ... 58490 -> 52162

v2: treat Undef as both 0 and 1

3ec9975 radeonsi: eliminate trivial constant VS outputs
src/gallium/drivers/radeonsi/si_shader.c | 160 +++++++++++++++++++++++
src/gallium/drivers/radeonsi/si_shader.h | 11 ++
src/gallium/drivers/radeonsi/si_state_shaders.c | 17 ++-
3 files changed, 186 insertions(+), 2 deletions(-)

Upstream: cgit.freedesktop.org


  • Share