From bea21177f27e9889e2d39e1c50720651671a2516 Mon Sep 17 00:00:00 2001 From: Aitor Camacho Date: Tue, 4 Nov 2025 10:08:48 +0900 Subject: [PATCH] kk: Ignore depth clear value if load op is not clear This is required otherwise Metal validation will report an error. Acked-By: Arcady Goldmints-Orlov Part-of: --- src/kosmickrisp/vulkan/kk_cmd_draw.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/kosmickrisp/vulkan/kk_cmd_draw.c b/src/kosmickrisp/vulkan/kk_cmd_draw.c index b66d992e8e7..868fd14e0f0 100644 --- a/src/kosmickrisp/vulkan/kk_cmd_draw.c +++ b/src/kosmickrisp/vulkan/kk_cmd_draw.c @@ -304,9 +304,15 @@ kk_CmdBeginRendering(VkCommandBuffer commandBuffer, kk_fill_common_attachment_description( attachment_descriptor, render->depth_att.iview, pRenderingInfo->pDepthAttachment, force_attachment_load); - mtl_render_pass_attachment_descriptor_set_clear_depth( - attachment_descriptor, - pRenderingInfo->pDepthAttachment->clearValue.depthStencil.depth); + + /* clearValue.depthStencil.depth could have invalid values such as NaN + * which will trigger a Metal validation error. Ensure we only use this + * value if the attachment is actually cleared. */ + if (pRenderingInfo->pDepthAttachment->loadOp == + VK_ATTACHMENT_LOAD_OP_CLEAR) + mtl_render_pass_attachment_descriptor_set_clear_depth( + attachment_descriptor, + pRenderingInfo->pDepthAttachment->clearValue.depthStencil.depth); } if (render->stencil_att.iview) { const struct kk_image_view *iview = render->stencil_att.iview;