kk: enable shaderStencilExport

This requires a small new NIR pass to force the stencil output to be unsigned.

Reviewed-by: Aitor Camacho <aitor@lunarg.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38067>
This commit is contained in:
Arcady Goldmints-Orlov 2025-10-22 19:39:28 -04:00 committed by Arcady Goldmints-Orlov
parent d3424de889
commit 53de36895c
4 changed files with 32 additions and 0 deletions

View file

@ -253,3 +253,31 @@ msl_nir_layer_id_type(nir_shader *nir)
return nir_shader_intrinsics_pass(nir, msl_layer_id_uint, nir_metadata_all,
NULL);
}
static bool
stencil_type(nir_builder *b, nir_intrinsic_instr *intr, void *data)
{
if (intr->intrinsic == nir_intrinsic_store_output &&
nir_intrinsic_io_semantics(intr).location == FRAG_RESULT_STENCIL) {
nir_alu_type type = nir_intrinsic_src_type(intr);
nir_intrinsic_set_src_type(
intr, nir_type_uint | nir_alu_type_get_type_size(type));
return true;
}
if (intr->intrinsic == nir_intrinsic_load_output &&
nir_intrinsic_io_semantics(intr).location == FRAG_RESULT_STENCIL) {
nir_alu_type type = nir_intrinsic_dest_type(intr);
nir_intrinsic_set_dest_type(
intr, nir_type_uint | nir_alu_type_get_type_size(type));
return true;
}
return false;
}
bool
msl_nir_fix_stencil_type(nir_shader *nir)
{
assert(nir->info.stage == MESA_SHADER_FRAGMENT);
return nir_shader_intrinsics_pass(nir, stencil_type, nir_metadata_all, NULL);
}

View file

@ -54,3 +54,4 @@ bool msl_ensure_depth_write(nir_shader *nir);
bool msl_ensure_vertex_position_output(nir_shader *nir);
bool msl_nir_sample_mask_type(nir_shader *nir);
bool msl_nir_layer_id_type(nir_shader *nir);
bool msl_nir_fix_stencil_type(nir_shader *nir);

View file

@ -107,6 +107,7 @@ kk_get_device_extensions(const struct kk_instance *instance,
.EXT_pipeline_creation_feedback = true,
.EXT_private_data = true,
.EXT_shader_demote_to_helper_invocation = true,
.EXT_shader_stencil_export = true,
.EXT_subgroup_size_control = true,
.EXT_texel_buffer_alignment = false,
.EXT_texture_compression_astc_hdr = false,

View file

@ -407,6 +407,8 @@ kk_lower_fs(nir_shader *nir, const struct vk_graphics_pipeline_state *state)
/* Metal's sample mask is uint. */
NIR_PASS(_, nir, msl_nir_sample_mask_type);
NIR_PASS(_, nir, msl_nir_fix_stencil_type);
if (state->ms && state->ms->rasterization_samples &&
state->ms->sample_mask != UINT16_MAX)
NIR_PASS(_, nir, msl_lower_static_sample_mask, state->ms->sample_mask);