From 8b070c36ec38388724ebf95f449b9eb1f0944fc7 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Mon, 6 May 2024 22:31:14 -0400 Subject: [PATCH] nir/lower_subgroups: add filter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit this will be useful for AGX, which has many reductions (but not all) in hardware with the logic too backend-specific to encode with bitflags. Signed-off-by: Alyssa Rosenzweig Reviewed-by: Daniel Schürmann Part-of: --- src/compiler/nir/nir.h | 6 ++++++ src/compiler/nir/nir_lower_subgroups.c | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 29c5d78a9df..62deb064c85 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -5796,6 +5796,12 @@ bool nir_lower_is_helper_invocation(nir_shader *shader); bool nir_lower_single_sampled(nir_shader *shader); typedef struct nir_lower_subgroups_options { + /* In addition to the boolean lowering options below, this optional callback + * will filter instructions for lowering if non-NULL. The data passed will be + * this options struct itself. + */ + nir_instr_filter_cb filter; + uint8_t subgroup_size; uint8_t ballot_bit_size; uint8_t ballot_components; diff --git a/src/compiler/nir/nir_lower_subgroups.c b/src/compiler/nir/nir_lower_subgroups.c index 2982f7f2e3a..585e69185c0 100644 --- a/src/compiler/nir/nir_lower_subgroups.c +++ b/src/compiler/nir/nir_lower_subgroups.c @@ -1090,8 +1090,8 @@ bool nir_lower_subgroups(nir_shader *shader, const nir_lower_subgroups_options *options) { - return nir_shader_lower_instructions(shader, - lower_subgroups_filter, + void *filter = options->filter ? options->filter : lower_subgroups_filter; + return nir_shader_lower_instructions(shader, filter, lower_subgroups_instr, (void *)options); }