glsl: Optimize "if (cond) discard;" to a conditional discard

Graphics / Mesa 3D Graphics Library / Mesa - Kenneth Graunke [whitecape.org] - 24 February 2015 17:24 UTC

st_glsl_to_tgsi and ir_to_mesa have handled conditional discards for a long time; the previous patch added that capability to i965.

i965 (Haswell) shader-db stats:

Without NIR: total instructions in shared programs: 5792133 -> 5776360 (-0.27%) instructions in affected programs: 737585 -> 721812 (-2.14%) helped: 6300 HURT: 68 GAINED: 2

With NIR: total instructions in shared programs: 5787538 -> 5769569 (-0.31%) instructions in affected programs: 767843 -> 749874 (-2.34%) helped: 6522 HURT: 35 GAINED: 6

30f51f1 glsl: Optimize "if (cond) discard;" to a conditional discard.
src/glsl/Makefile.sources | 1 +
src/glsl/glsl_parser_extras.cpp | 1 +
src/glsl/ir_optimization.h | 1 +
src/glsl/opt_conditional_discard.cpp | 81 ++++++++++++++++++++++++++++++++++
4 files changed, 84 insertions(+)

Upstream: cgit.freedesktop.org


  • Share