nir: lower is/load_helper to zero if no helper lanes are needed

If there are no helper invocations required during the
execution of the shader, we can assume that there also
are no helper invocations active.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9058>
This commit is contained in:
Daniel Schürmann 2021-02-15 16:13:39 +01:00 committed by Marge Bot
parent b689a65316
commit 2e6c9e54f1

View file

@ -62,8 +62,15 @@ nir_lower_demote_to_discard_instr(nir_builder *b, nir_instr *instr, void *data)
intrin->intrinsic = nir_intrinsic_discard_if;
return true;
case nir_intrinsic_is_helper_invocation:
intrin->intrinsic = nir_intrinsic_load_helper_invocation;
case nir_intrinsic_load_helper_invocation: {
/* If the shader doesn't need helper invocations,
* we can assume there are none */
b->cursor = nir_before_instr(instr);
nir_ssa_def *zero = nir_imm_false(b);
nir_ssa_def_rewrite_uses_ssa(&intrin->dest.ssa, zero);
nir_instr_remove_v(instr);
return true;
}
default:
return false;
}