diff options
author | Rhys Perry <pendingchaos02@gmail.com> | 2021-01-13 15:50:52 +0000 |
---|---|---|
committer | Marge Bot <eric+marge@anholt.net> | 2021-06-21 15:13:05 +0000 |
commit | ea68d4a676260d9c45dfbe0cb8de8e40869b5523 (patch) | |
tree | 49afcbe4060c74c269cbefa2e275f973ce7d6a5e /src/compiler | |
parent | 7144f338025e1f4db4d01cf79e1d9bda218fea0d (diff) |
nir/propagate_invariant: add invariant_prim option
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11035>
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/nir/nir.h | 2 | ||||
-rw-r--r-- | src/compiler/nir/nir_propagate_invariant.c | 26 |
2 files changed, 26 insertions, 2 deletions
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 47a88fdb6d3..66aad033447 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -4317,7 +4317,7 @@ void nir_inline_uniforms(nir_shader *shader, unsigned num_uniforms, const uint32_t *uniform_values, const uint16_t *uniform_dw_offsets); -bool nir_propagate_invariant(nir_shader *shader); +bool nir_propagate_invariant(nir_shader *shader, bool invariant_prim); void nir_lower_var_copy_instr(nir_intrinsic_instr *copy, nir_shader *shader); void nir_lower_deref_copy_instr(struct nir_builder *b, diff --git a/src/compiler/nir/nir_propagate_invariant.c b/src/compiler/nir/nir_propagate_invariant.c index afe0098158b..c5664bf701b 100644 --- a/src/compiler/nir/nir_propagate_invariant.c +++ b/src/compiler/nir/nir_propagate_invariant.c @@ -188,12 +188,36 @@ propagate_invariant_impl(nir_function_impl *impl, struct set *invariants) return progress; } +/* If invariant_prim=true, this pass considers all geometry-affecting + * outputs as invariant. Doing this works around a common class of application + * bugs appearing as flickering. + */ bool -nir_propagate_invariant(nir_shader *shader) +nir_propagate_invariant(nir_shader *shader, bool invariant_prim) { /* Hash set of invariant things */ struct set *invariants = _mesa_pointer_set_create(NULL); + if (shader->info.stage != MESA_SHADER_FRAGMENT && invariant_prim) { + nir_foreach_shader_out_variable(var, shader) { + switch (var->data.location) { + case VARYING_SLOT_POS: + case VARYING_SLOT_PSIZ: + case VARYING_SLOT_CLIP_DIST0: + case VARYING_SLOT_CLIP_DIST1: + case VARYING_SLOT_CULL_DIST0: + case VARYING_SLOT_CULL_DIST1: + case VARYING_SLOT_TESS_LEVEL_OUTER: + case VARYING_SLOT_TESS_LEVEL_INNER: + if (!var->data.invariant) + _mesa_set_add(invariants, var); + break; + default: + break; + } + } + } + bool progress = false; nir_foreach_function(function, shader) { if (function->impl && propagate_invariant_impl(function->impl, invariants)) |