Mesa (master): nir/lower_subgroups: pass options struct to lower_shuffle

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Jul 13 14:40:50 UTC 2020


Module: Mesa
Branch: master
Commit: 9c317cb2787db09be103dde5eee86b4709ebe6ba
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=9c317cb2787db09be103dde5eee86b4709ebe6ba

Author: Rhys Perry <pendingchaos02 at gmail.com>
Date:   Mon Jul  6 17:59:08 2020 +0100

nir/lower_subgroups: pass options struct to lower_shuffle

Signed-off-by: Rhys Perry <pendingchaos02 at gmail.com>
Reviewed-by: Daniel Schürmann <daniel at schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5695>

---

 src/compiler/nir/nir_lower_subgroups.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/compiler/nir/nir_lower_subgroups.c b/src/compiler/nir/nir_lower_subgroups.c
index 2a7361b7472..5244d916fd9 100644
--- a/src/compiler/nir/nir_lower_subgroups.c
+++ b/src/compiler/nir/nir_lower_subgroups.c
@@ -224,21 +224,25 @@ lower_vote_eq_to_ballot(nir_builder *b, nir_intrinsic_instr *intrin,
 
 static nir_ssa_def *
 lower_shuffle(nir_builder *b, nir_intrinsic_instr *intrin,
-              bool lower_to_scalar, bool lower_to_32bit)
+              const nir_lower_subgroups_options *options)
 {
    nir_ssa_def *index = nir_load_subgroup_invocation(b);
+   bool is_shuffle = false;
    switch (intrin->intrinsic) {
    case nir_intrinsic_shuffle_xor:
       assert(intrin->src[1].is_ssa);
       index = nir_ixor(b, index, intrin->src[1].ssa);
+      is_shuffle = true;
       break;
    case nir_intrinsic_shuffle_up:
       assert(intrin->src[1].is_ssa);
       index = nir_isub(b, index, intrin->src[1].ssa);
+      is_shuffle = true;
       break;
    case nir_intrinsic_shuffle_down:
       assert(intrin->src[1].is_ssa);
       index = nir_iadd(b, index, intrin->src[1].ssa);
+      is_shuffle = true;
       break;
    case nir_intrinsic_quad_broadcast:
       assert(intrin->src[1].is_ssa);
@@ -276,7 +280,8 @@ lower_shuffle(nir_builder *b, nir_intrinsic_instr *intrin,
                      intrin->dest.ssa.num_components,
                      intrin->dest.ssa.bit_size, NULL);
 
-   if (lower_to_scalar && shuffle->num_components > 1) {
+   bool lower_to_32bit = options->lower_shuffle_to_32bit && is_shuffle;
+   if (options->lower_to_scalar && shuffle->num_components > 1) {
       return lower_subgroup_op_to_scalar(b, shuffle, lower_to_32bit);
    } else if (lower_to_32bit && shuffle->src[0].ssa->bit_size == 64) {
       return lower_subgroup_op_to_32bit(b, shuffle);
@@ -306,7 +311,7 @@ lower_dynamic_quad_broadcast(nir_builder *b, nir_intrinsic_instr *intrin,
                              const nir_lower_subgroups_options *options)
 {
    if (!options->lower_quad_broadcast_dynamic_to_const)
-      return lower_shuffle(b, intrin, options->lower_to_scalar, false);
+      return lower_shuffle(b, intrin, options);
 
    nir_ssa_def *dst = NULL;
 
@@ -523,12 +528,11 @@ lower_subgroups_instr(nir_builder *b, nir_instr *instr, void *_options)
       else if (options->lower_shuffle_to_32bit && intrin->src[0].ssa->bit_size == 64)
          return lower_subgroup_op_to_32bit(b, intrin);
       break;
-
    case nir_intrinsic_shuffle_xor:
    case nir_intrinsic_shuffle_up:
    case nir_intrinsic_shuffle_down:
       if (options->lower_shuffle)
-         return lower_shuffle(b, intrin, options->lower_to_scalar, options->lower_shuffle_to_32bit);
+         return lower_shuffle(b, intrin, options);
       else if (options->lower_to_scalar && intrin->num_components > 1)
          return lower_subgroup_op_to_scalar(b, intrin, options->lower_shuffle_to_32bit);
       else if (options->lower_shuffle_to_32bit && intrin->src[0].ssa->bit_size == 64)



More information about the mesa-commit mailing list