r300: lower undefs to zero
authorPavel Ondračka <pavel.ondracka@gmail.com>
Fri, 23 Jun 2023 12:30:44 +0000 (14:30 +0200)
committerMarge Bot <emma+marge@anholt.net>
Wed, 5 Jul 2023 18:34:37 +0000 (18:34 +0000)
They will get translated to read from random register otherwise, which is
not problematic per se, but they will not be regalloced and if the
initial register index was too high, we can fail the shader compilation
because we think we run out of registers.

Almost no effect with shader-db on RV530:
total instructions in shared programs: 130707 -> 130705 (<.01%)
instructions in affected programs: 1012 -> 1010 (-0.20%)
helped: 2
HURT: 1

Reviewed-by: Filip Gawin <filip.gawin@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23927>

src/gallium/drivers/r300/compiler/r300_nir.c

index 127ff6b..2e8e5da 100644 (file)
@@ -96,6 +96,8 @@ r300_optimize_nir(struct nir_shader *s, struct pipe_screen *screen)
       NIR_PASS(progress, s, nir_opt_trivial_continues);
       NIR_PASS(progress, s, nir_opt_vectorize, r300_should_vectorize_instr, NULL);
       NIR_PASS(progress, s, nir_opt_undef);
+      if(!progress)
+         NIR_PASS(progress, s, nir_lower_undef_to_zero);
       NIR_PASS(progress, s, nir_opt_loop_unroll);
 
       /* Try to fold addressing math into ubo_vec4's base to avoid load_consts