nir/lower_indirect_derefs: Add a threshold

Instead of always lowering everything, we add a threshold such that if
the total indirected array size (AoA size) is above that threshold, it
won't lower.  It's assumed that the driver will sort things out somehow
by, for instance, lowering to scratch.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5909>
This commit is contained in:
Jason Ekstrand
2020-07-14 13:55:19 -05:00
committed by Marge Bot
parent c897cd0278
commit 38a83a3048
7 changed files with 30 additions and 17 deletions

View File

@@ -763,7 +763,7 @@ brw_preprocess_nir(const struct brw_compiler *compiler, nir_shader *nir,
nir_variable_mode indirect_mask =
brw_nir_no_indirect_mask(compiler, nir->info.stage);
OPT(nir_lower_indirect_derefs, indirect_mask);
OPT(nir_lower_indirect_derefs, indirect_mask, UINT32_MAX);
/* Lower array derefs of vectors for SSBO and UBO loads. For both UBOs and
* SSBOs, our back-end is capable of loading an entire vec4 at a time and
@@ -813,9 +813,11 @@ brw_nir_link_shaders(const struct brw_compiler *compiler,
* varyings we have demoted here.
*/
NIR_PASS_V(producer, nir_lower_indirect_derefs,
brw_nir_no_indirect_mask(compiler, producer->info.stage));
brw_nir_no_indirect_mask(compiler, producer->info.stage),
UINT32_MAX);
NIR_PASS_V(consumer, nir_lower_indirect_derefs,
brw_nir_no_indirect_mask(compiler, consumer->info.stage));
brw_nir_no_indirect_mask(compiler, consumer->info.stage),
UINT32_MAX);
brw_nir_optimize(producer, compiler, p_is_scalar, false);
brw_nir_optimize(consumer, compiler, c_is_scalar, false);