From 721666e52a7e95b5bc1a7bcfc9cb6b8d43f2c97f Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Mon, 16 Dec 2019 10:43:18 -0600 Subject: [PATCH] anv,nir: Lower quad_broadcast with dynamic index in NIR This is required for the subgroupBroadcastDynamicId feature that was added in Vulkan 1.2. Reviewed-by: Caio Marcelo de Oliveira Filho --- src/compiler/nir/nir.h | 1 + src/compiler/nir/nir_lower_subgroups.c | 5 ++++- src/intel/compiler/brw_nir.c | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index a8e4184f1d5..0ac3f45ccec 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -3839,6 +3839,7 @@ typedef struct nir_lower_subgroups_options { bool lower_shuffle:1; bool lower_shuffle_to_32bit:1; bool lower_quad:1; + bool lower_quad_broadcast_dynamic:1; } nir_lower_subgroups_options; bool nir_lower_subgroups(nir_shader *shader, diff --git a/src/compiler/nir/nir_lower_subgroups.c b/src/compiler/nir/nir_lower_subgroups.c index 249d5e446bd..4462c708ec8 100644 --- a/src/compiler/nir/nir_lower_subgroups.c +++ b/src/compiler/nir/nir_lower_subgroups.c @@ -473,7 +473,10 @@ lower_subgroups_instr(nir_builder *b, nir_instr *instr, void *_options) case nir_intrinsic_quad_swap_horizontal: case nir_intrinsic_quad_swap_vertical: case nir_intrinsic_quad_swap_diagonal: - if (options->lower_quad) + if (options->lower_quad || + (options->lower_quad_broadcast_dynamic && + intrin->intrinsic == nir_intrinsic_quad_broadcast && + !nir_src_is_const(intrin->src[1]))) return lower_shuffle(b, intrin, options->lower_to_scalar, false); else if (options->lower_to_scalar && intrin->num_components > 1) return lower_subgroup_op_to_scalar(b, intrin, false); diff --git a/src/intel/compiler/brw_nir.c b/src/intel/compiler/brw_nir.c index 9db35ea160e..e29398db7f6 100644 --- a/src/intel/compiler/brw_nir.c +++ b/src/intel/compiler/brw_nir.c @@ -713,6 +713,7 @@ brw_preprocess_nir(const struct brw_compiler *compiler, nir_shader *nir, .lower_to_scalar = true, .lower_vote_trivial = !is_scalar, .lower_shuffle = true, + .lower_quad_broadcast_dynamic = true, }; OPT(nir_lower_subgroups, &subgroups_options); -- 2.30.2