From 00eaf39c0150175b931edf91a6d97470123bc95a Mon Sep 17 00:00:00 2001 From: kd-11 Date: Fri, 8 Jun 2018 13:53:45 +0300 Subject: [PATCH] vk: RADV support for depth scaling and transfer --- rpcs3/Emu/RSX/VK/VKTexture.cpp | 35 ++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/rpcs3/Emu/RSX/VK/VKTexture.cpp b/rpcs3/Emu/RSX/VK/VKTexture.cpp index de89466d91..0e80511d27 100644 --- a/rpcs3/Emu/RSX/VK/VKTexture.cpp +++ b/rpcs3/Emu/RSX/VK/VKTexture.cpp @@ -161,23 +161,26 @@ namespace vk // Drivers are not very accepting of aspect COLOR -> aspect DEPTH or aspect STENCIL separately // However, this works okay for D24S8 (nvidia-only format) - // To work around the problem we use the non-existent DEPTH/STENCIL/DEPTH_STENCIL aspect of the color texture instead - VkImageAspectFlags typeless_aspect = VK_IMAGE_ASPECT_COLOR_BIT; - if (transfer_flags == VK_IMAGE_ASPECT_DEPTH_BIT || transfer_flags == VK_IMAGE_ASPECT_STENCIL_BIT) + // To work around the problem we use the non-existent DEPTH/STENCIL aspect of the color texture instead (AMD only) + VkImageAspectFlags typeless_aspect; + const bool single_aspect = (transfer_flags == VK_IMAGE_ASPECT_DEPTH_BIT || transfer_flags == VK_IMAGE_ASPECT_STENCIL_BIT); + + switch (vk::get_driver_vendor()) { - // NOTE: This path is only taken for VK_FORMAT_D32_SFLOAT_S8_UINT as there is no 36-bit format available - // On Nvidia, the default format is VK_FORMAT_D24_UNORM_S8_UINT which does not require this workaround - switch (vk::get_driver_vendor()) - { - case driver_vendor::AMD: - // Quirks: This workaround allows proper transfer of stencil data - case driver_vendor::NVIDIA: - // Quirks: This workaround allows only transfer of depth data, stencil is ignored - typeless_aspect = aspect; - break; - default: - break; - } + case driver_vendor::AMD: + // This workaround allows proper transfer of stencil data + typeless_aspect = aspect; + break; + case driver_vendor::NVIDIA: + // This workaround allows only transfer of depth data, stencil is ignored (D32S8 only) + // However, transfer from r32 to d24s8 in color->depth_stencil works + typeless_aspect = (single_aspect)? aspect : VK_IMAGE_ASPECT_COLOR_BIT; + break; + case driver_vendor::RADV: + // This workaround allows only transfer of depth data, stencil is ignored (D32S8 only) + default: + typeless_aspect = VK_IMAGE_ASPECT_COLOR_BIT; + break; } //1. Copy unscaled to typeless surface