Repository navigation
Runtime: order repeated Vulkan buffer transfer copies - #4475
pmilewsskiedu-gif wants to merge 1 commit into
Conversation
Kam471
left a comment
There was a problem hiding this comment.
Built d3d12_buffer_copy_order_test and vk_command_replay_test at 4757ab51 and ran them on Windows 11: d3d12_buffer_copy_order_test -> exit 0, "native WARP: consecutive overlapping CopyBufferRegion writes, 0 byte mismatches"; ctest -R 'buffer_copy_order|vk_command_replay' -> 2/2 passed. No blocking issue.
Flyander
left a comment
There was a problem hiding this comment.
Reviewed 4757ab5: prepare stores one buffer-copy region on the corresponding command and emit inserts the transfer write-to-read/write dependency before each CopyBufferRegion replay. The synthetic replay checks the later overlapping write wins with zero validation errors; native WARP confirms D3D12 ordering.
|
Tested 4757ab5 on Windows 11 (MSVC BuildTools 2022, Ninja, RelWithDebInfo, -j 4), one GPU at a time, device line confirmed: AMD Radeon RDNA2 iGPU (driver 26.10.1) and NVIDIA RTX 5080 (driver 616.92). AI-assisted. |
|
Tested
One note, not a blocker: the barrier is emitted before every buffer-copy batch, including the first, and it is a global No game data. AI-assisted. |
|
Separate timing check for disjoint copies, where the new dependency is also emitted. Windows 11 28000.3501, RTX 4070 Ti SUPER / 617.14,
All readbacks passed. The differences were small relative to run-to-run variation, so this check found no clear slowdown for this upload workload. It covers disjoint transfers; the overlap validation is covered by the other reports. No Vulkan validation layer in this timing run. Synthetic bytes only. AI-assisted (Codex). |
|
FAIL to merge, verified: git merge-tree conflicts in runtime/CMakeLists.txt and runtime/test/vk_command_replay_test.cpp from main's round-43 churn, so a rebase is needed. The substance holds: the fix hunk in vulkan_replay.h auto-merges clean, and on current main the buffer-copy emit path really does lack the transfer-to-transfer barrier while the analogous UAV-clear path beside it already has one — the gap is real, so this wants a rebase rather than closing. The C++/WARP side cannot be built or run here, so the ordering fix stands with the pending checks and the Windows test. Checks pending. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only review). |
Claimed before production edits on coordination #4421: #4421 (comment)
Production correctness
On main
03b09a086592a197db64d91655c6e65c30764d96, Vulkan replay directly emitsvkCmdCopyBufferfor successive D3D12CopyBufferRegion/ resource-buffer copies to the same destination without a transfer write dependency. Unlikecopy_layout's repeated image copy path, overlapping Vulkan transfer writes remain unordered for synchronization validation despite D3D12 allowing multiple writes while the buffer remains COPY_DEST. This patch inserts a transfer WRITE->READ|WRITE pipeline memory dependency before the buffer-copy execution branch, covering prior transfer-produced sources as well as same-destination writes. No resource lifecycle, API recording, shader or aliasing changes.Original-main RED / patched GREEN, identical test
A new Part J of
runtime/test/vk_command_replay_test.cppissues two synthetic 4096-byte buffer copies to identical destination offsets (0x11 first, 0x22 last) in one real Leonida command list, replays using Vulkan backend on actual RTX 4060 Ti withLEONIDA_VK_VALIDATION=1, reads back all final bytes and requires zero synchronization VUIDs. Detached original-main test-only worktreeLeonidaBufferCopyWawBaseline20261122retains unchanged production source at03b09a08; SHA-256 of regression source in baseline equals patched79661FF7E2B2A0DDE7B6F12896114F19BD2845EF870AC66023FBB05E8A7BF30E.vkCmdCopyBuffer(): WRITE_AFTER_WRITE hazard, 1 sync validation error in Part J, executable exit 1; preceding Parts A–I remain green.VkMemoryBarrieralso synchronizes final GPU→host readback.d3d12_buffer_copy_order_testmakes two unbarriered CopyBufferRegion writes to a DEFAULT/COPY_DEST buffer, transitions only before readback, and checks 4096 bytes of 0x22; native WARP Close/queue/fence/readback pass, 0 mismatches, exit 0.command_list,vk_command_replay,vk_predicated_copy,vk_sync_validation,d3d12_buffer_copy_order,replay_copy_offset6/6 PASS (3.06s).vk_command_replayand native WARPd3d12_buffer_copy_ordereach 10/10 consecutive repetitions PASS (2.61s combined).git diff --checkclean.Limits / checklist
Raw Vulkan sync VUID proves the identified hazard; no game executable, authentic boot, framerate or proprietary resources tested. No full CTest suite or non-NVIDIA Vulkan device recheck yet. Separate from #4253 footprint-buffer support, #655/#770 placed-buffer ownership and earlier copy PRs. Base
03b09a08, head commit4757ab515b12a4ffbec2a1e6fd83f375d1d3ed95. Please review, do not self-merge.