lavapipe: Implement KHR_shader_quad_control

Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33628>
This commit is contained in:
Konstantin Seurer
2025-01-30 21:37:15 +01:00
committed by Marge Bot
parent f49ef38701
commit 94c8a0e820
3 changed files with 18 additions and 4 deletions
+13 -4
View File
@@ -352,6 +352,15 @@ mask_vec_with_helpers(struct lp_build_nir_soa_context *bld)
bld->uint_bld.type, -1);
}
static LLVMValueRef
group_op_mask_vec(struct lp_build_nir_soa_context *bld)
{
if (bld->shader->info.fs.require_full_quads)
return mask_vec_with_helpers(bld);
return mask_vec(bld);
}
static bool
lp_exec_mask_is_nz(struct lp_build_nir_soa_context *bld)
{
@@ -2154,7 +2163,7 @@ static void emit_vote(struct lp_build_nir_soa_context *bld, LLVMValueRef src,
struct gallivm_state * gallivm = bld->base.gallivm;
LLVMBuilderRef builder = gallivm->builder;
uint32_t bit_size = nir_src_bit_size(instr->src[0]);
LLVMValueRef exec_mask = mask_vec(bld);
LLVMValueRef exec_mask = group_op_mask_vec(bld);
struct lp_build_loop_state loop_state;
LLVMValueRef outer_cond = LLVMBuildICmp(builder, LLVMIntNE, exec_mask, bld->uint_bld.zero, "");
@@ -2225,7 +2234,7 @@ static void emit_ballot(struct lp_build_nir_soa_context *bld, LLVMValueRef src,
{
struct gallivm_state * gallivm = bld->base.gallivm;
LLVMBuilderRef builder = gallivm->builder;
LLVMValueRef exec_mask = mask_vec(bld);
LLVMValueRef exec_mask = group_op_mask_vec(bld);
struct lp_build_loop_state loop_state;
src = LLVMBuildSExt(builder, src, bld->int_bld.vec_type, "");
src = LLVMBuildAnd(builder, src, exec_mask, "");
@@ -2249,7 +2258,7 @@ static void emit_elect(struct lp_build_nir_soa_context *bld, LLVMValueRef result
{
struct gallivm_state *gallivm = bld->base.gallivm;
LLVMBuilderRef builder = gallivm->builder;
LLVMValueRef exec_mask = mask_vec(bld);
LLVMValueRef exec_mask = group_op_mask_vec(bld);
struct lp_build_loop_state loop_state;
LLVMValueRef idx_store = lp_build_alloca(gallivm, bld->int_bld.elem_type, "");
@@ -2289,7 +2298,7 @@ static void emit_reduce(struct lp_build_nir_soa_context *bld, LLVMValueRef src,
LLVMBuilderRef builder = gallivm->builder;
uint32_t bit_size = nir_src_bit_size(instr->src[0]);
/* can't use llvm reduction intrinsics because of exec_mask */
LLVMValueRef exec_mask = mask_vec(bld);
LLVMValueRef exec_mask = group_op_mask_vec(bld);
nir_op reduction_op = nir_intrinsic_reduction_op(instr);
uint32_t cluster_size = 0;
@@ -176,6 +176,7 @@ static const struct vk_device_extension_table lvp_device_extensions_supported =
.KHR_shader_integer_dot_product = true,
.KHR_shader_maximal_reconvergence = true,
.KHR_shader_non_semantic_info = true,
.KHR_shader_quad_control = true,
.KHR_shader_relaxed_extended_instruction = true,
.KHR_shader_subgroup_extended_types = true,
.KHR_shader_subgroup_rotate = true,
@@ -759,6 +760,9 @@ lvp_get_features(const struct lvp_physical_device *pdevice,
/* VK_KHR_compute_shader_derivatives */
.computeDerivativeGroupQuads = true,
.computeDerivativeGroupLinear = true,
/* VK_KHR_shader_quad_control */
.shaderQuadControl = true,
};
}
@@ -359,6 +359,7 @@ lvp_shader_lower(struct lvp_device *pdevice, nir_shader *nir, struct lvp_pipelin
struct nir_lower_subgroups_options subgroup_opts = {0};
subgroup_opts.lower_quad = true;
subgroup_opts.lower_quad_vote = true;
subgroup_opts.ballot_components = 1;
subgroup_opts.ballot_bit_size = 32;
subgroup_opts.lower_inverse_ballot = true;