From 50029e13333bddfd49b14cd0cac0946c5381da15 Mon Sep 17 00:00:00 2001 From: Wunkolo Date: Fri, 11 Aug 2023 23:07:12 -0700 Subject: [PATCH] Avoid usage of D24-S8 format This support is not supported on `radv`. Vulkan mandates D16 only and a combination of Depth and Depth-Stencil types only. --- src/core/renderer_vk/vk_pica.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/core/renderer_vk/vk_pica.cpp b/src/core/renderer_vk/vk_pica.cpp index 8e72b51c..33aca623 100644 --- a/src/core/renderer_vk/vk_pica.cpp +++ b/src/core/renderer_vk/vk_pica.cpp @@ -14,10 +14,20 @@ namespace Vulkan { } vk::Format depthFormatToVulkan(PICA::DepthFmt depthFormat) { switch (depthFormat) { + // VK_FORMAT_D16_UNORM is mandated by the vulkan specification case PICA::DepthFmt::Depth16: return vk::Format::eD16Unorm; case PICA::DepthFmt::Unknown1: return vk::Format::eUndefined; - case PICA::DepthFmt::Depth24: return vk::Format::eX8D24UnormPack32; - case PICA::DepthFmt::Depth24Stencil8: return vk::Format::eD24UnormS8Uint; + // The GPU may _not_ support these formats natively + // Only one of: + // VK_FORMAT_X8_D24_UNORM_PACK32 and VK_FORMAT_D32_SFLOAT + // and one of: + // VK_FORMAT_D24_UNORM_S8_UINT and VK_FORMAT_D32_SFLOAT_S8_UINT + // will be supported + // TODO: Detect this! + // case PICA::DepthFmt::Depth24: return vk::Format::eX8D24UnormPack32; + // case PICA::DepthFmt::Depth24Stencil8: return vk::Format::eD24UnormS8Uint; + case PICA::DepthFmt::Depth24: return vk::Format::eD32Sfloat; + case PICA::DepthFmt::Depth24Stencil8: return vk::Format::eD32SfloatS8Uint; } return vk::Format::eUndefined; }