nir: Add a lower_read_first_invocation option to lower_subgroups

Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25894>
This commit is contained in:
Faith Ekstrand
2023-10-23 10:33:14 -05:00
committed by Marge Bot
parent 3d027cca1e
commit 16664b74a2
2 changed files with 10 additions and 0 deletions
+1
View File
@@ -5528,6 +5528,7 @@ typedef struct nir_lower_subgroups_options {
bool lower_vote_trivial : 1;
bool lower_vote_eq : 1;
bool lower_first_invocation_to_ballot : 1;
bool lower_read_first_invocation : 1;
bool lower_subgroup_masks : 1;
bool lower_relative_shuffle : 1;
bool lower_shuffle_to_32bit : 1;
+9
View File
@@ -556,6 +556,12 @@ lower_first_invocation_to_ballot(nir_builder *b, nir_intrinsic_instr *intrin,
return nir_ballot_find_lsb(b, 32, nir_ballot(b, 4, 32, nir_imm_true(b)));
}
static nir_def *
lower_read_first_invocation(nir_builder *b, nir_intrinsic_instr *intrin)
{
return nir_read_invocation(b, intrin->src[0].ssa, nir_first_invocation(b));
}
static nir_def *
lower_read_invocation_to_cond(nir_builder *b, nir_intrinsic_instr *intrin)
{
@@ -616,6 +622,9 @@ lower_subgroups_instr(nir_builder *b, nir_instr *instr, void *_options)
case nir_intrinsic_read_first_invocation:
if (options->lower_to_scalar && intrin->num_components > 1)
return lower_subgroup_op_to_scalar(b, intrin);
if (options->lower_read_first_invocation)
return lower_read_first_invocation(b, intrin);
break;
case nir_intrinsic_load_subgroup_eq_mask: