nir: implement the GLSL equivalent of if simplication in nir_opt_if

Graphics / Mesa 3D Graphics Library / Mesa - Samuel Pitoiset [gmail.com] - 4 June 2018 10:41 EDT

This pass turns:

if (cond) { } else { do_work(); }

into:

if (!cond) { do_work(); } else { }

Here's the vkpipeline-db stats (from affected shaders) on Polaris10:

Totals from affected shaders: SGPRS: 17272 -> 17296 (0.14 %)
VGPRS: 18712 -> 18740 (0.15 %) Spilled SGPRs: 1179 -> 1142 (-3.14 %) Code Size: 1503364 -> 1515176 (0.79 %) bytes Max Waves: 916 -> 911 (-0.55 %)

This pass only affects Serious Sam 2017 (Vulkan) on my side. The stats are not really good for now. Some shaders look quite dumb but this will be improved with further NIR passes, like ifs combination.

e3e929f8c3 nir: implement the GLSL equivalent of if simplication in nir_opt_if
src/compiler/nir/nir_opt_if.c | 97 ++++++++++++++++++++++++++++++++++++++++---
1 file changed, 92 insertions(+), 5 deletions(-)

Upstream: cgit.freedesktop.org


  • Share