From 17e5ea118e3feb5555a512be5fe5b673d0ed62d2 Mon Sep 17 00:00:00 2001 From: "duncan.hopkins" Date: Wed, 27 Nov 2024 15:25:25 +0000 Subject: [PATCH] zink: Avoid optimalDeviceAccess on MoltenVK when creating depth taregts. MoltenVK fails to create a depth format target if `optimalDeviceAccess`, `info.have_EXT_host_image_copy` and `VK_IMAGE_USAGE_HOST_TRANSFER_BIT_EXT` are in used. The specification seems to claim it is not needed if `hic.identicalMemoryLayout` is set, so for a MoltenVK build unset optimalDeviceAccess. Part-of: --- src/gallium/drivers/zink/zink_resource.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/gallium/drivers/zink/zink_resource.c b/src/gallium/drivers/zink/zink_resource.c index 0e38ebfce43..5f2b3342983 100644 --- a/src/gallium/drivers/zink/zink_resource.c +++ b/src/gallium/drivers/zink/zink_resource.c @@ -367,6 +367,12 @@ check_ici(struct zink_screen *screen, VkImageCreateInfo *ici, uint64_t modifier) image_props = props2.imageFormatProperties; if (screen->info.have_EXT_host_image_copy && ici->usage & VK_IMAGE_USAGE_HOST_TRANSFER_BIT_EXT) optimalDeviceAccess = hic.optimalDeviceAccess; +#if defined(MVK_VERSION) + // MoltenVK cannot allocate a depth buffer with VK_IMAGE_USAGE_HOST_TRANSFER_BIT_EXT + // As hic.identicalMemoryLayout is set, it is not needed? + if (screen->info.have_EXT_host_image_copy && ici->usage & VK_IMAGE_USAGE_HOST_TRANSFER_BIT_EXT && hic.identicalMemoryLayout) + optimalDeviceAccess = false; +#endif } else ret = VKSCR(GetPhysicalDeviceImageFormatProperties)(screen->pdev, ici->format, ici->imageType, ici->tiling, ici->usage, ici->flags, &image_props);