diff options
| author | aslan2142 <jan.trencansky@protonmail.com> | 2026-11-25 17:19:44 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-11-25 17:19:44 +0100 |
| commit | 9e7720c9e764211e0021aa23907d2d3ecd58963f (patch) | |
| tree | d1831cd6c3ec00eeaaa6c35e336339b9d57675a8 /runtime/src | |
| parent | b0f3d3998f0401eb7df8ddbb7a303d1e6bee9fb8 (diff) | |
| parent | daf31b820b5b9fe5d7d119836657bff1f8fd1ea0 (diff) | |
Merge pull request #1893 from OreoFR/rt-depth-format-copy-staged
replay: copies between depth formats that differ go through transfer scratch (RT-DEPTH-FORMAT-COPY-STAGED)
Diffstat (limited to 'runtime/src')
| -rw-r--r-- | runtime/src/vulkan_replay.h | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/runtime/src/vulkan_replay.h b/runtime/src/vulkan_replay.h index 725cd3487..359fabff0 100644 --- a/runtime/src/vulkan_replay.h +++ b/runtime/src/vulkan_replay.h | |||
| @@ -548,6 +548,27 @@ inline bool a8_mixed_backing(VkFormat a, VkFormat b) { | |||
| 548 | #endif | 548 | #endif |
| 549 | } | 549 | } |
| 550 | 550 | ||
| 551 | // Two depth formats whose depth aspect has the same encoding but which are not the same VkFormat: D32_SFLOAT and | ||
| 552 | // D32_SFLOAT_S8_UINT, D16_UNORM and D16_UNORM_S8_UINT, X8_D24_UNORM_PACK32 and D24_UNORM_S8_UINT. D3D12 copies the | ||
| 553 | // depth plane between them; Vulkan's vkCmdCopyImage requires depth/stencil formats to match exactly | ||
| 554 | // (VUID-vkCmdCopyImage-srcImage-01548), and an NVIDIA driver handed D32_SFLOAT_S8_UINT -> D32_SFLOAT writes past the | ||
| 555 | // end of the D32 image (the world-start WRITE_INVALID). The replay stages these through a buffer, where the depth | ||
| 556 | // aspect has the same texel layout on both sides. | ||
| 557 | inline bool depth_format_pair(VkFormat a, VkFormat b) { | ||
| 558 | const auto encoding = [](VkFormat format) -> int { | ||
| 559 | switch (format) { | ||
| 560 | case VK_FORMAT_D32_SFLOAT: | ||
| 561 | case VK_FORMAT_D32_SFLOAT_S8_UINT: return 32; | ||
| 562 | case VK_FORMAT_X8_D24_UNORM_PACK32: | ||
| 563 | case VK_FORMAT_D24_UNORM_S8_UINT: return 24; | ||
| 564 | case VK_FORMAT_D16_UNORM: | ||
| 565 | case VK_FORMAT_D16_UNORM_S8_UINT: return 16; | ||
| 566 | default: return 0; | ||
| 567 | } | ||
| 568 | }; | ||
| 569 | return a != b && encoding(a) && encoding(a) == encoding(b); | ||
| 570 | } | ||
| 571 | |||
| 551 | inline bool depth_colour_pair(const ResourceBinding& a, const ResourceBinding& b) { | 572 | inline bool depth_colour_pair(const ResourceBinding& a, const ResourceBinding& b) { |
| 552 | const auto family = [](VkFormat format) -> int { | 573 | const auto family = [](VkFormat format) -> int { |
| 553 | switch (format) { | 574 | switch (format) { |
| @@ -3629,7 +3650,8 @@ ReplayResult prepare(const CommandList& list, Resolve&& resolve, const ReplayFun | |||
| 3629 | } | 3650 | } |
| 3630 | if (result == ReplayResult::success && !p.image_copies.empty() && | 3651 | if (result == ReplayResult::success && !p.image_copies.empty() && |
| 3631 | (p.image_copies[0].srcSubresource.aspectMask != p.image_copies[0].dstSubresource.aspectMask || | 3652 | (p.image_copies[0].srcSubresource.aspectMask != p.image_copies[0].dstSubresource.aspectMask || |
| 3632 | a8_mixed_backing(p.source.format, p.binding.format))) { | 3653 | a8_mixed_backing(p.source.format, p.binding.format) || |
| 3654 | depth_format_pair(p.source.format, p.binding.format))) { | ||
| 3633 | // Depth <-> colour: vkCmdCopyImage cannot mix aspects, so each region goes image -> scratch -> image, | 3655 | // Depth <-> colour: vkCmdCopyImage cannot mix aspects, so each region goes image -> scratch -> image, |
| 3634 | // tightly packed. Depth aspects want 4-byte buffer offsets; 16 covers every texel size here. The two | 3656 | // tightly packed. Depth aspects want 4-byte buffer offsets; 16 covers every texel size here. The two |
| 3635 | // backings of A8_UNORM take the same route: one byte per texel on both sides, but Vulkan does not | 3657 | // backings of A8_UNORM take the same route: one byte per texel on both sides, but Vulkan does not |