From 81a5e2fa0c49b2545a45d42c79b4abb836fc3bfd Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Thu, 8 Nov 2018 18:49:52 +0100 Subject: [PATCH] [d3d11] Add helper to find exact mapping for depth-stencil formats This is necessary in situations when we need to get the Vulkan format that corresponds to the DXGI format rather than the remapped one. --- src/d3d11/d3d11_util.cpp | 20 ++++++++++++++++++++ src/d3d11/d3d11_util.h | 3 +++ 2 files changed, 23 insertions(+) diff --git a/src/d3d11/d3d11_util.cpp b/src/d3d11/d3d11_util.cpp index 6919ebdc..a3a2bf7e 100644 --- a/src/d3d11/d3d11_util.cpp +++ b/src/d3d11/d3d11_util.cpp @@ -157,4 +157,24 @@ namespace dxvk { return features; } + + VkFormat GetPackedDepthStencilFormat(DXGI_FORMAT Format) { + switch (Format) { + case DXGI_FORMAT_R24G8_TYPELESS: + case DXGI_FORMAT_R24_UNORM_X8_TYPELESS: + case DXGI_FORMAT_X24_TYPELESS_G8_UINT: + case DXGI_FORMAT_D24_UNORM_S8_UINT: + return VK_FORMAT_D24_UNORM_S8_UINT; + + case DXGI_FORMAT_R32G8X24_TYPELESS: + case DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS: + case DXGI_FORMAT_X32_TYPELESS_G8X24_UINT: + case DXGI_FORMAT_D32_FLOAT_S8X24_UINT: + return VK_FORMAT_D32_SFLOAT_S8_UINT; + + default: + return VK_FORMAT_UNDEFINED; + } + } + } \ No newline at end of file diff --git a/src/d3d11/d3d11_util.h b/src/d3d11/d3d11_util.h index 5a0360d4..a7c961fd 100644 --- a/src/d3d11/d3d11_util.h +++ b/src/d3d11/d3d11_util.h @@ -48,5 +48,8 @@ namespace dxvk { VkFormatFeatureFlags GetImageFormatFeatures( UINT BindFlags); + + VkFormat GetPackedDepthStencilFormat( + DXGI_FORMAT Format); } \ No newline at end of file