Repository navigation
d3d12: SYNC_COPY waits for the CLEAR stage too, so WriteBufferImmediate is ordered (D3D-838) - #8187
kykifox1337-source wants to merge 1 commit into
Conversation
An enhanced barrier's D3D12_BARRIER_SYNC_COPY mapped to VK_PIPELINE_STAGE_2_COPY_BIT only. Two D3D12 copy-scope commands are not Vulkan copies: WriteBufferImmediate is recorded as vkCmdUpdateBuffer and ResolveQueryData's never-written queries as vkCmdFillBuffer, and synchronization2 runs both in the CLEAR stage. A SYNC_COPY barrier after either therefore did not order it, and a copy after the barrier could read the word before the write landed. vulkan_sync now maps SYNC_COPY to COPY | CLEAR. vk_command_replay_test part K records WriteBufferImmediate, a SYNC_COPY -> SYNC_COPY buffer barrier and a CopyBufferRegion of the written word; under LEONIDA_VK_VALIDATION=1 it is a read-after-write hazard without this change. d3d12_state_map_test and docs/d3d12_vulkan.md follow the new mapping. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Tested
|
|
Tested
AI-assisted. |
|
Full
No game files used. AI-assisted (Claude Code). |
…ers of each mode Review of ItsNotRexed#8457: a DEFAULT-mode WriteBufferImmediate followed by an enhanced SYNC_COPY barrier is not ordered. Replay records the write as vkCmdUpdateBuffer, which synchronization2 runs in the CLEAR stage, while SYNC_COPY maps to COPY only. ItsNotRexed#8187 adds CLEAR to that mapping, which orders the DIRECT and COMPUTE queues. The COPY queue's stage mask (queue_stages_copy) drops CLEAR again, so OPTIONS3 now answers DIRECT | BUNDLE | COMPUTE (0x7). Advertising COPY is deferred to a follow-up after that mask is fixed. 0x7 is a subset of the native answer on the same adapter (0x7f on an RTX 5070 Ti, driver 610.74) and of WARP's 0xF. The new replay_write_immediate_barriers_test (no GPU) mocks the barrier and update functions: - DEFAULT adds no barrier, MARKER_IN waits for every earlier command (ALL_COMMANDS -> TRANSFER, no access) and MARKER_OUT for them and their writes (MEMORY_WRITE -> TRANSFER_WRITE). This is what the written values cannot show: swapping the two marker modes fails it. - On the DIRECT queue (no mask) and under queue_stages_compute, a DEFAULT write, a SYNC_COPY buffer barrier and a copy record the update, then a barrier holding its CLEAR stage and transfer write, then the copy. This part fails until ItsNotRexed#8187 is merged. d3d12_write_immediate_queues_test expects 0x7 and still runs a COPY list's writes as replay coverage, without the cap. Its copy-then-MARKER_OUT checks are gone: both are transfer commands, so they showed no ordering. AI-assisted (Claude Code). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Independent check of Setup: Windows 11, MSVC 2022 Build Tools ( The PR's own test,
My own check (a scratch mock, not part of the PR) of the
It records the Vulkan calls in order, on the DIRECT queue (no stage mask) and under
The other resolve paths don't depend on this change, from reading the code. Ended queries use Scope note, not a defect here: this PR's tests run with No game files. AI-assisted (Claude Code). |
Claimed in the coordination issue as: D3D-838 (#7913 (comment))
Depends on: #7342, #4475 (text conflicts only: both edit the same
main()line ofruntime/test/vk_command_replay_test.cpp, and #7342 adds its ownpart_k; whichever lands second renames its part)What and why
An enhanced barrier's
D3D12_BARRIER_SYNC_COPYmapped toVK_PIPELINE_STAGE_2_COPY_BITonly (vulkan_sync,runtime/src/vulkan_replay.h). Two D3D12 copy-scope commands are not Vulkan copies:WriteBufferImmediateis recorded asvkCmdUpdateBuffer, and a DEFAULT-mode write gets no barrier of its own (replay leaves it to the application's barriers);ResolveQueryDatafills never-written queries withvkCmdFillBuffer.Synchronization2 runs both in the
CLEARstage, notCOPY, so aSYNC_COPYbarrier after either did not order it, and a copy after the barrier could read the word before the write landed. The legacy-state path already covers this (COPY_DESTmaps toCOPY | TRANSFER).vulkan_sync:SYNC_COPY→COPY | CLEAR. Every access a copy barrier names stays valid in that mask (TRANSFER_WRITEis allowed inCLEAR;TRANSFER_READkeepsCOPY).vk_command_replay_testpart K:WriteBufferImmediateinto one buffer, aSYNC_COPY → SYNC_COPYbuffer barrier (COPY_DEST → COPY_SOURCE), thenCopyBufferRegionof the written word into another buffer. It checks the copied value and, underLEONIDA_VK_VALIDATION=1, that synchronization validation reports nothing.d3d12_state_map_test: the two expectations that includedSYNC_COPY, plus a direct check of the new mapping.docs/d3d12_vulkan.md: one sentence on the mapping where the enhanced barriers are described.Tested
Windows 10, NVIDIA GeForce RTX 2070 SUPER, driver 610.88 (Vulkan 1.4.341), MSVC 14.44 (VS 2022 Build Tools 17.14), Ninja
RelWithDebInfo, Vulkan SDK 1.4.363.0 validation layer with synchronization validation.d3d12_state_map_test: pass.vk_command_replay_testwithLEONIDA_VK_VALIDATION=1: parts A–K pass, 0 validation errors (part D's 360 sync/access pairs included, so the wider stage mask is valid on every barrier kind).vulkan_replay.hchange, part K fails with 1 validation error (the read-after-write hazard), so the test catches the bug.scripts/check_no_game_data.pyon the four files: pass.ctestrun on this machine is still going; I'll add its result as a comment.No game files used.
AI-assisted: yes (Claude Code)
Checklist
docs/design.md, with how it was confirmed. (Not applicable: no translator change.)🤖 Generated with Claude Code