kk: Add support for VK_EXT_depth_clip_control.

Uses dynamic lowering pass pulled from asahi.

Reviewed-by: Aitor Camacho <aitor@lunarg.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41088>
This commit is contained in:
squidbus 2026-04-22 14:46:40 -07:00 committed by Marge Bot
parent a41f0e62bb
commit f13bec7934
6 changed files with 16 additions and 1 deletions

View file

@ -620,7 +620,7 @@ Khronos extensions that are not part of any Vulkan version:
VK_EXT_depth_bias_control DONE (anv, hk, lvp, nvk, panvk, radv, vn)
VK_EXT_depth_clamp_control DONE (anv, hasvk, nvk, panvk, radv, tu, vn)
VK_EXT_depth_clamp_zero_one DONE (anv, nvk, panvk, pvr, radv, tu, v3dv/vc7+, vn)
VK_EXT_depth_clip_control DONE (anv, hasvk, hk, lvp, nvk, panvk, radv, tu, v3dv, vn)
VK_EXT_depth_clip_control DONE (anv, hasvk, hk, kk, lvp, nvk, panvk, radv, tu, v3dv, vn)
VK_EXT_depth_clip_enable DONE (anv, hasvk, hk, lvp, nvk, panvk, pvr, radv, tu, v3dv/vc7+, vn)
VK_EXT_depth_range_unrestricted DONE (anv/gen20+, nvk, radv, lvp, vn)
VK_EXT_descriptor_buffer DONE (anv, lvp, nvk, radv, tu)

View file

@ -37,6 +37,7 @@ struct kk_root_descriptor_table {
uint64_t attrib_base[KK_MAX_ATTRIBS];
uint32_t attrib_clamps[KK_MAX_ATTRIBS];
float blend_constant[4];
float clip_z_coeff;
uint32_t draw_id;
} draw;
struct {

View file

@ -742,6 +742,12 @@ kk_flush_dynamic_state(struct kk_cmd_buffer *cmd)
IS_DIRTY(VP_SCISSOR_COUNT) || IS_DIRTY(VP_SCISSORS)))
kk_flush_vp_state(cmd);
if (IS_DIRTY(VP_DEPTH_CLIP_NEGATIVE_ONE_TO_ONE)) {
desc->root.draw.clip_z_coeff =
dyn->vp.depth_clip_negative_one_to_one ? 0.5f : 0.0f;
desc->root_dirty = true;
}
if (IS_DIRTY(RS_FRONT_FACE)) {
mtl_set_front_face_winding(
enc, vk_front_face_to_mtl_winding(

View file

@ -407,6 +407,9 @@ try_lower_intrin(nir_builder *b, nir_intrinsic_instr *intrin,
case nir_intrinsic_load_blend_const_color_rgba:
return lower_sysval_to_root_table(b, intrin, draw.blend_constant);
case nir_intrinsic_load_clip_z_coeff:
return lower_sysval_to_root_table(b, intrin, draw.clip_z_coeff);
case nir_intrinsic_load_push_constant:
return lower_load_push_constant(b, intrin, ctx);

View file

@ -135,6 +135,7 @@ kk_get_device_extensions(const struct kk_instance *instance,
.KHR_workgroup_memory_explicit_layout = true,
.EXT_calibrated_timestamps = true,
.EXT_depth_clip_control = true,
.EXT_external_memory_metal = true,
.EXT_image_2d_view_of_3d = true,
.EXT_load_store_op_none = true,
@ -303,6 +304,9 @@ kk_get_device_features(
.formatA4R4G4B4 = true,
.formatA4B4G4R4 = true,
/* VK_EXT_depth_clip_control */
.depthClipControl = true,
/* EXT_image_2d_view_of_3d */
.image2DViewOf3D = true,
.sampler2DViewOf3D = true,

View file

@ -323,6 +323,7 @@ kk_lower_vs(nir_shader *nir, const struct vk_graphics_pipeline_state *state)
nir_shader_intrinsics_pass(nir, msl_nir_vs_remove_point_size_write,
nir_metadata_control_flow, NULL);
NIR_PASS(_, nir, nir_lower_clip_halfz_dynamic);
NIR_PASS(_, nir, msl_nir_vs_io_types);
}