diff options
| author | ItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com> | 2026-11-21 22:09:18 -0500 |
|---|---|---|
| committer | ItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com> | 2026-11-21 22:09:18 -0500 |
| commit | 6badcb87a3ab59bf2c08eecfd20ef5bc547fa6aa (patch) | |
| tree | a857814a3ce2b44faf18df7db9981c14e96c81b8 /runtime | |
| parent | 947405993459f51a093dd1a77fb4ae31c44fae8a (diff) | |
| parent | 5ec780c3e7c279310c667a9dc05ba54e6f1284a8 (diff) | |
Merge pull request #782 from ismailchaka1
Diffstat (limited to 'runtime')
| -rw-r--r-- | runtime/src/vulkan_replay.h | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/runtime/src/vulkan_replay.h b/runtime/src/vulkan_replay.h index 1ca907171..7cee9ef75 100644 --- a/runtime/src/vulkan_replay.h +++ b/runtime/src/vulkan_replay.h | |||
| @@ -1087,10 +1087,25 @@ inline VkImageLayout copy_layout(const ReplayFunctions& vk, VkCommandBuffer comm | |||
| 1087 | const VkImageLayout target = image_layout(resource, wanted); | 1087 | const VkImageLayout target = image_layout(resource, wanted); |
| 1088 | auto pieces = current(tracker, id, range, target); | 1088 | auto pieces = current(tracker, id, range, target); |
| 1089 | initialize(vk, command_buffer, resource, id, pieces, target, tracker); | 1089 | initialize(vk, command_buffer, resource, id, pieces, target, tracker); |
| 1090 | if (pieces.size() == 1 && (pieces[0].layout == target || pieces[0].layout == VK_IMAGE_LAYOUT_GENERAL)) | 1090 | // D3D12 orders back-to-back copies and resolves on a resource that stays in COPY_DEST or COPY_SOURCE without a |
| 1091 | // barrier from the application; Vulkan does not. A piece already in the transfer layout gets no layout | ||
| 1092 | // transition, so an earlier transfer write to it is ordered here instead (write-after-write and read-after-write, | ||
| 1093 | // which synchronization validation reports otherwise). | ||
| 1094 | const auto after_transfer_writes = [&] { | ||
| 1095 | memory_barrier(vk, command_buffer, VK_ACCESS_TRANSFER_WRITE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, access, | ||
| 1096 | VK_PIPELINE_STAGE_TRANSFER_BIT); | ||
| 1097 | }; | ||
| 1098 | if (pieces.size() == 1 && (pieces[0].layout == target || pieces[0].layout == VK_IMAGE_LAYOUT_GENERAL)) { | ||
| 1099 | after_transfer_writes(); | ||
| 1091 | return pieces[0].layout; | 1100 | return pieces[0].layout; |
| 1101 | } | ||
| 1102 | bool ordered = false; | ||
| 1092 | for (const auto& piece : pieces) { | 1103 | for (const auto& piece : pieces) { |
| 1093 | if (piece.layout == target) continue; | 1104 | if (piece.layout == target) { |
| 1105 | if (!ordered) after_transfer_writes(); | ||
| 1106 | ordered = true; | ||
| 1107 | continue; | ||
| 1108 | } | ||
| 1094 | image_barrier(vk, command_buffer, resource, piece.range, piece.layout, target, | 1109 | image_barrier(vk, command_buffer, resource, piece.range, piece.layout, target, |
| 1095 | VK_ACCESS_MEMORY_WRITE_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, access, | 1110 | VK_ACCESS_MEMORY_WRITE_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, access, |
| 1096 | VK_PIPELINE_STAGE_TRANSFER_BIT); | 1111 | VK_PIPELINE_STAGE_TRANSFER_BIT); |