Repository navigation
runtime: order consecutive buffer copies on the same queue (RT-STREAM-TRANSFER-BARRIER) - #1099
Conversation
…-TRANSFER-BARRIER) Vulkan transfer writes can overlap a later read or write when D3D12 submits plain buffer copies in sequence. Emit the transfer memory dependency from natterman12's #354 (GPL-3.0) before every plain buffer copy. Allow an explicit rollback for comparison, and record the access masks in the synthetic replay fixture. The base failed both copy-ordering assertions. The child passed both replay fixtures, and the rollback control observed no ordering barrier. AI-assisted (Codex and Claude Code agents). Co-authored-by: Plaaasma <47513553+Plaaasma@users.noreply.github.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Native Windows check, AI-assisted (Claude Code). Windows 11, i9-13900K, 64 GB, RTX 4070 Ti 12 GB (NVIDIA 630.20), MSVC 2022 (VS 17 generator, Release), Vulkan. Head
Cross-check: the PR's test built against the base's 1 passed, 0 failed. |
abnalstlll-byte
left a comment
There was a problem hiding this comment.
Audited and verified. Emits TRANSFER_WRITE -> TRANSFER_READ | TRANSFER_WRITE transfer barrier before �kCmdCopyBuffer in
untime/src/vulkan_replay.h, matching D3D12's implicit queue ordering on back-to-back buffer copies. Configurable via LEONIDA_ORDER_BUFFER_COPIES. Tests in
untime/test/replay_copy_offset_test.cpp pass cleanly. Approved.
abnalstlll-byte
left a comment
There was a problem hiding this comment.
Clean-Room Audit — PR #1099 (RT-STREAM-TRANSFER-BARRIER)
Well-scoped transfer ordering barrier (TRANSFER_WRITE -> TRANSFER_READ | TRANSFER_WRITE) before queue buffer copies in vulkan_replay.h, preserving LEONIDA_ORDER_BUFFER_COPIES=0 escape hatch and adding regression tests in replay_copy_offset_test.cpp. 0 game data.
Verdict: APPROVED
|
AMD run (the gap the description lists): RX 9070 XT (RDNA4, GFX1201), AMD proprietary Windows driver 26.11.2 (LLPC, Vulkan 1.4.359), Windows 11, MSVC 2022 RelWithDebInfo. Head |
|
Recommendation: [MERGE] Reasoning: Emits a transfer-stage memory barrier between back-to-back buffer copies on the same queue, fixing a real RAW/WAW hazard in the Vulkan replay, with a rollback switch and a test that fails on the base header. Verified on NVIDIA (Plaaasma, including a negative control) and AMD RX 9070 XT (iFeyz). Synchronization changes affect every title copy, so the rollback switch is useful. CI (label, change-scope, no-game-data and the Runtime jobs) is still queued awaiting maintainer workflow approval, so nothing has run in CI yet; GitHub reports no merge conflict with Impact level: 5/10 |
|
GPU verification (AI-assisted, overnight worker w4; independent run, not the author's). Head tested: ddcffa6 on this machine's two GPUs. AMD Radeon iGPU (gfx1035, RDNA2, driver 24.10.24, Vulkan 1.3.280) — env:
NVIDIA RTX 4070 SUPER — env:
Verdict: no regressions found on either GPU; barrier ordering holds under validation on the AMD iGPU. LGTM from this hardware. |
|
Independent GPU verification at Added a synthetic chained-copy/readback probe covering intra-list and same-batch cross-list dependencies on both direct and copy queues.
This confirms actual GPU data corruption from the missing dependency, beyond the command-recording assertions. All ten cases pass with the fix enabled. No blocking issues found. AI-assisted testing. |
|
Merging. Why merged: RT-STREAM-TRANSFER-BARRIER: a transfer-write → transfer-read/write barrier goes before every vkCmdCopyBuffer, so back-to-back streamed copies are ordered. moffington measured SyncVal at 10 errors on the base and 0 on the head. Plaaasma (4070 Ti), iFeyz (RX 9070 XT) and whoalin1 (gfx1035) passed it. LEONIDA_ORDER_BUFFER_COPIES=0 turns it off (documented in docs/d3d12_vulkan.md). Why it's good: replay_, vk_bc_zero_init, vk_queue and d3d12_close_parity: 16/16 both plain and under validation. A negative control on the cumulative build checked that the test really catches a missing barrier: with the barrier on, Tested on Windows 11 / RTX 4070 SUPER (NVIDIA 621.24), VS 2022 + Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0. Merged alone onto main 0f98d19, its ctests pass both plain and with LEONIDA_VK_VALIDATION=1. Cumulative with the rest of this batch on main 507029d: the repo-consistency set gives 578 passed / 5 skipped / 0 failed, compileall is clean, and full ctest is 317/318 with the usual 11 skips; the only failure is main's pre-existing d3d12_depth_resolve. All d3d12_* tests under validation: 119/120 with 0 VUIDs. The semantic suite has only the known environment-only failure. git merge-tree against current main 9c5e706: no conflicts. Security read of the three-dot diff: no binaries, game data, downloads, network calls or CI changes. AI-assisted (Claude Code, Claude Opus 5.5). |
…984 LAYOUT_UNDEFINED, Wave-21b CMake & leonida-ce 525c44e1 ReadFile fast-path - ProjectLeonida/mandy#1100 (RT-PLACED-IMAGE-DEFER): unify Resource deferred memory binding onto leonida::DeferredImageBinding (deduping duplicate flags/mutex), add LEONIDA_PLACED_IMAGE_DEFER=0 rollback, defer placed depth/UAV/RT attachments + cpu_copy bind + race-free memory_flags(), preserve MemoryPriority, add check_placed_target_backing test & docs/d3d12_vulkan.md note. - ProjectLeonida/mandy#1099 (RT-STREAM-TRANSFER-BARRIER): deduped against existing ultimate CopyBuffer/CopyResource transfer barriers; add LEONIDA_ORDER_BUFFER_COPIES=0 opt-out toggle, --expect-unordered test mode, and docs/d3d12_vulkan.md note. - ProjectLeonida/mandy#1097 (SHADER-BUFFER-BOUNDS): use OobSelect::structured_with_offset for structured buffer SRVs in d3d12_vulkan_device.cpp, add cross-record GPU readbacks in d3d12_compute_test.cpp + cs_user_data.comp (and align Xbox slot-17 CBV expectations with wave18b vector-row encoding). - ProjectLeonida/mandy#1096 (RT-STARTUP-TRACE): add VirtualQuery memory region metadata on access violations in startup_trace.h & startup_trace_test.cpp. - ProjectLeonida/mandy#1023 & #1007: update docs/directstorage.md (measured factory IID & slot 8) and docs/d3d12_vulkan.md (device slot 62 5-arg arity & slot 76 FFX-only note). - Wave-21b deferred CMake: add loader TIMEOUT 180 (Reforge#169) and tiny_game_ga / run_tiny_game_ga_tls (ubiq#947 Patch 2). - ProjectLeonida/mandy#984 (self-contained Windows-native port): accept enhanced TextureBarrier into LAYOUT_UNDEFINED without violating VUID-VkImageMemoryBarrier2-newLayout-01198 (command_list.h, vulkan_replay.h, command_list_test, replay_texture_barrier_test, d3d12_close_parity_test). - IAmNotSiob/leonida-ce 525c44e1 (GPL-3.0, deduped): wire optional xmem::commit_physical_range_fn hook into file_system.cpp ReadFile ERROR_NOACCESS retry path to commit large console buffers without per-page VEH faults while keeping zero-cost fast path and touch_pages fallback. - DesignWithTommy/Neonbridge eaf7e7e0: audited and skipped (ultimate has no refresh read-back byte/time cap skipping Bink R8/R8G8 planes).
|
Tested ddcffa6 on NVIDIA GeForce RTX 4060 (Ada), driver 617.42, Windows 11 Pro build 26200, native Windows: pass. Built at this head with
AI-assisted (Claude Code ran the build and tests). No game files. |
Claimed in the coordination issue as: RT-STREAM-TRANSFER-BARRIER (claim).
Part of the split of #984 into small pull requests.
Depends on: none
Overlaps: #354 (closed without merging) supplies the transfer dependency. This child credits that contribution, adds the rollback switch and tests the emitted commands.
What and why
A D3D12 queue can submit overlapping buffer copies back to back. Without a Vulkan memory dependency, a later copy can read or overwrite bytes before the earlier transfer write finishes. Emit a transfer-stage memory barrier before each plain buffer copy, including the first one in a list. A preceding list on the same queue can have written those bytes. Real Vulkan contexts provide the barrier entry point. The existing query mock also exercises a context that omits it. Set
LEONIDA_ORDER_BUFFER_COPIES=0to restore the old behavior.Tested
Cross-built with clang-cl 23 and the xwin SDK. Ran the command-recording fixtures under Proton Experimental (Wine 11) on CachyOS Linux 7.3, Ryzen 5 5600X, 16 GB.
GPUs tested: none. The fixtures record Vulkan commands and check the stage and access masks. Native Windows, AMD, Intel and a game boot were not tested.
AI-assisted: yes
Checklist
🤖 Generated with Claude Code