From 621fab2ad9b7d35f6f4863a94a97572af375b6e1 Mon Sep 17 00:00:00 2001 From: kd-11 Date: Wed, 15 Jan 2020 19:49:25 +0300 Subject: [PATCH] vk: Fix D32S8 interpolation by using integer interpolation instead of floating point - Interpolating floats is not the same as interpolating their bits! Use integer format to interpolate linearly for D32F formats instead of using R32F as intermediary --- rpcs3/Emu/RSX/VK/VKTexture.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rpcs3/Emu/RSX/VK/VKTexture.cpp b/rpcs3/Emu/RSX/VK/VKTexture.cpp index 7f86f39ff1..588b2e014d 100644 --- a/rpcs3/Emu/RSX/VK/VKTexture.cpp +++ b/rpcs3/Emu/RSX/VK/VKTexture.cpp @@ -517,7 +517,10 @@ namespace vk // Since the typeless transfer itself violates spec, the only way to make it work is to use a D32S8 intermediate // Copy from src->intermediate then intermediate->dst for each aspect separately - auto typeless_depth = vk::get_typeless_helper(VK_FORMAT_R32_SFLOAT, typeless_w, typeless_h); + // NOTE: While it may seem intuitive to use R32_SFLOAT as the carrier for the depth aspect, this does not work properly + // Floating point interpolation is non-linear from a bit-by-bit perspective and generates undesirable effects + + auto typeless_depth = vk::get_typeless_helper(VK_FORMAT_B8G8R8A8_UNORM, typeless_w, typeless_h); auto typeless_stencil = vk::get_typeless_helper(VK_FORMAT_R8_UNORM, typeless_w, typeless_h); change_image_layout(cmd, typeless_depth, VK_IMAGE_LAYOUT_GENERAL); change_image_layout(cmd, typeless_stencil, VK_IMAGE_LAYOUT_GENERAL);