From f6c6c04648f2177f1ddece65e8585cd7661c6a4b Mon Sep 17 00:00:00 2001 From: kd-11 Date: Sat, 15 Aug 2020 21:37:10 +0300 Subject: [PATCH] vk: Implement transport for D24S8_FLOAT data --- rpcs3/Emu/RSX/VK/VKCompute.h | 37 +++++++++++++++++++++++++++++----- rpcs3/Emu/RSX/VK/VKTexture.cpp | 34 ++++++++++++++++++++++++++++++- 2 files changed, 65 insertions(+), 6 deletions(-) diff --git a/rpcs3/Emu/RSX/VK/VKCompute.h b/rpcs3/Emu/RSX/VK/VKCompute.h index 6ab1515aa5..0d8bf03252 100644 --- a/rpcs3/Emu/RSX/VK/VKCompute.h +++ b/rpcs3/Emu/RSX/VK/VKCompute.h @@ -280,6 +280,8 @@ namespace vk "// Depth format conversions\n" "#define d24_to_f32(bits) floatBitsToUint(float(bits) / 16777215.f)\n" "#define f32_to_d24(bits) uint(uintBitsToFloat(bits) * 16777215.f)\n" + "#define d24f_to_f32(bits) (bits << 7)\n" + "#define f32_to_d24f(bits) (bits >> 7)\n" "#define d24x8_to_f32(bits) d24_to_f32(bits >> 8)\n" "#define d24x8_to_d24x8_swapped(bits) (bits & 0xFF00) | (bits & 0xFF0000) >> 16 | (bits & 0xFF) << 16\n" "#define f32_to_d24x8_swapped(bits) d24x8_to_d24x8_swapped(f32_to_d24(bits))\n" @@ -492,7 +494,7 @@ namespace vk } }; - template + template struct cs_gather_d32x8 : cs_interleave_task { cs_gather_d32x8() @@ -500,8 +502,20 @@ namespace vk work_kernel = " if (index >= block_length)\n" " return;\n" - "\n" - " depth = f32_to_d24(data[index + z_offset]);\n" + "\n"; + + if constexpr (!_DepthFloat) + { + work_kernel += + " depth = f32_to_d24(data[index + z_offset]);\n"; + } + else + { + work_kernel += + " depth = f32_to_d24f(data[index + z_offset]);\n"; + } + + work_kernel += " stencil_offset = (index / 4);\n" " stencil_shift = (index % 4) * 8;\n" " stencil = data[stencil_offset + s_offset];\n" @@ -542,6 +556,7 @@ namespace vk } }; + template struct cs_scatter_d32x8 : cs_interleave_task { cs_scatter_d32x8() @@ -550,8 +565,20 @@ namespace vk " if (index >= block_length)\n" " return;\n" "\n" - " value = data[index];\n" - " data[index + z_offset] = d24_to_f32(value >> 8);\n" + " value = data[index];\n"; + + if constexpr (!_DepthFloat) + { + work_kernel += + " data[index + z_offset] = d24_to_f32(value >> 8);\n"; + } + else + { + work_kernel += + " data[index + z_offset] = d24f_to_f32(value >> 8);\n"; + } + + work_kernel += " stencil_offset = (index / 4);\n" " stencil_shift = (index % 4) * 8;\n" " stencil = (value & 0xFF) << stencil_shift;\n" diff --git a/rpcs3/Emu/RSX/VK/VKTexture.cpp b/rpcs3/Emu/RSX/VK/VKTexture.cpp index b8f8d4e067..2225c5bc4d 100644 --- a/rpcs3/Emu/RSX/VK/VKTexture.cpp +++ b/rpcs3/Emu/RSX/VK/VKTexture.cpp @@ -78,6 +78,11 @@ namespace vk vkCmdCopyImageToBuffer(cmd, src->value, src->current_layout, dst->value, 1, ®ion); break; } + case VK_FORMAT_D32_SFLOAT: + { + fmt::throw_exception("Unsupported transfer (D16_FLOAT"); + break; + } case VK_FORMAT_D24_UNORM_S8_UINT: case VK_FORMAT_D32_SFLOAT_S8_UINT: { @@ -113,6 +118,11 @@ namespace vk { job = vk::get_compute_task>(); } + else if (auto dsv = dynamic_cast(src); + dsv && dsv->get_format_type() == rsx::format_type::depth_float) + { + job = vk::get_compute_task>(); + } else { job = vk::get_compute_task>(); @@ -124,6 +134,11 @@ namespace vk { job = vk::get_compute_task>(); } + else if (auto dsv = dynamic_cast(src); + dsv && dsv->get_format_type() == rsx::format_type::depth_float) + { + job = vk::get_compute_task>(); + } else { job = vk::get_compute_task>(); @@ -162,6 +177,11 @@ namespace vk vkCmdCopyBufferToImage(cmd, src->value, dst->value, dst->current_layout, 1, ®ion); break; } + case VK_FORMAT_D32_SFLOAT: + { + fmt::throw_exception("Unsupported transfer (D16_FLOAT"); + break; + } case VK_FORMAT_D24_UNORM_S8_UINT: case VK_FORMAT_D32_SFLOAT_S8_UINT: { @@ -191,9 +211,14 @@ namespace vk { job = vk::get_compute_task(); } + else if (auto dsv = dynamic_cast(dst); + dsv && dsv->get_format_type() == rsx::format_type::depth_float) + { + job = vk::get_compute_task>(); + } else { - job = vk::get_compute_task(); + job = vk::get_compute_task>(); } job->run(cmd, src, data_offset, packed_length, z_offset, s_offset); @@ -518,6 +543,13 @@ namespace vk stretch_image_typeless_unsafe(src, dst, typeless->value, src_rect, dst_rect, VK_IMAGE_ASPECT_DEPTH_BIT); break; } + case VK_FORMAT_D32_SFLOAT: + { + auto typeless = vk::get_typeless_helper(VK_FORMAT_R32_SFLOAT, typeless_w, typeless_h); + change_image_layout(cmd, typeless, VK_IMAGE_LAYOUT_GENERAL); + stretch_image_typeless_unsafe(src, dst, typeless->value, src_rect, dst_rect, VK_IMAGE_ASPECT_DEPTH_BIT); + break; + } case VK_FORMAT_D24_UNORM_S8_UINT: { const VkImageAspectFlags depth_stencil = VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT;