diff --git a/src/kosmickrisp/compiler/msl_nir_lower_common.c b/src/kosmickrisp/compiler/msl_nir_lower_common.c index 34e0f264bcb..2df0fc366ef 100644 --- a/src/kosmickrisp/compiler/msl_nir_lower_common.c +++ b/src/kosmickrisp/compiler/msl_nir_lower_common.c @@ -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); +} \ No newline at end of file diff --git a/src/kosmickrisp/compiler/nir_to_msl.h b/src/kosmickrisp/compiler/nir_to_msl.h index 0a4d50109ed..02abf58f66e 100644 --- a/src/kosmickrisp/compiler/nir_to_msl.h +++ b/src/kosmickrisp/compiler/nir_to_msl.h @@ -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); diff --git a/src/kosmickrisp/vulkan/kk_physical_device.c b/src/kosmickrisp/vulkan/kk_physical_device.c index c659dd04e6e..a1e1038d194 100644 --- a/src/kosmickrisp/vulkan/kk_physical_device.c +++ b/src/kosmickrisp/vulkan/kk_physical_device.c @@ -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, diff --git a/src/kosmickrisp/vulkan/kk_shader.c b/src/kosmickrisp/vulkan/kk_shader.c index a720f548aff..eae36b8d83a 100644 --- a/src/kosmickrisp/vulkan/kk_shader.c +++ b/src/kosmickrisp/vulkan/kk_shader.c @@ -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);