Repository navigation
vulkan_replay: order back-to-back buffer copies, as image copies already are (VK-BUFCOPY-ORDER) - #354
Closed
natterman12 wants to merge 1 commit into
Closed
natterman12 wants to merge 1 commit into
natterman12 wants to merge 1 commit into
Conversation
…ady are D3D12 runs consecutive copies on a buffer that stays in COPY_DEST or COPY_SOURCE in order, with no barrier from the application, in one list or across lists on a queue. Vulkan orders nothing without a barrier. The replay emitted that barrier for image copies (copy_layout) but not for a plain buffer-to-buffer copy, so two copies into the same buffer raced as far as Vulkan is concerned: synchronization validation reports WRITE_AFTER_WRITE on vk_queue's backlog case, ten times on an RTX 3080 Ti. A plain buffer copy now gets a memory barrier from earlier transfer writes to its transfer reads and writes. replay_copy_offset checks the barrier ahead of one copy and ahead of each of two back-to-back copies into the same buffer. replay_query_edges' fake Vulkan table gains the barrier entry point the replay now calls. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Draft
2 tasks done
|
Independent verification on Linux with an RTX 4070 Ti (620.70.06). I reproduced the ten write-after-write errors in the 256-submit backlog case. With natterman12's buffer-copy barrier applied, that case passed. On transfer-only family 1, a copy followed by vkCmdUpdateBuffer or vkCmdFillBuffer also needed the copy-queue stage-filter correction in the PR 314 report. I added a preparation check for the new barrier callback so a plain buffer copy reports unsupported when the callback is missing. Seven focused tests passed after applying both series to a clean base. In the full integrated Linux suite, 71 tests passed and the unconfigured shader-corpus test skipped. Patch and reproduction commands. |
QemmHD
pushed a commit
that referenced
this pull request
Nov 25, 2026
…-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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Claimed in the coordination issue as: VK-BUFCOPY-ORDER (#14)
What and why
D3D12 runs consecutive copies on a buffer in order with no barrier from the application: the buffer stays in
COPY_DEST/COPY_SOURCE, and that holds within one list and across lists on a queue. Vulkan orders nothing unless a barrier says so.The replay already handles this for images.
copy_layoutsays: "D3D12 orders back-to-back copies and resolves on a resource that stays in COPY_DEST or COPY_SOURCE without a barrier from the application; Vulkan does not", and emits a memory barrier after earlier transfer writes. The plain buffer-to-buffer copy had no such barrier, so two copies into the same buffer are unordered as far as Vulkan is concerned.Synchronization validation reports it. On
maind478a92 withLEONIDA_VK_VALIDATION=1,vk_queuefails with ten of these from its backlog case (the same 16 MiB copy submitted repeatedly):The change is one barrier ahead of a plain buffer copy: earlier
TRANSFER_WRITEat the transfer stage, to this copy'sTRANSFER_READ | TRANSFER_WRITEat the transfer stage, through the existingdetail::memory_barrier(so it is restricted to the queue's stages like the others). It covers the read side too: a copy that reads what the copy before it wrote.Cost: one transfer-to-transfer memory barrier per buffer copy, the same price image copies already pay.
Tests
replay_copy_offset_test(GPU-free, fake Vulkan): its barrier callback now records whether a transfer-write barrier came before eachvkCmdCopyBuffer. It checks that for a singleCopyResource, and for two overlappingCopyBufferRegioncalls into the same buffer, where each copy needs its own barrier. Both checks fail without the change.replay_query_edges_test: its fake Vulkan table setcopy_bufferbut nopipeline_barrier, so it crashed on the new call. It gets a no-op entry; nothing it asserts changes.Tested
Windows 11 10.0.26300.9974, NVIDIA GeForce RTX 3080 Ti, driver 621.24, Vulkan SDK 1.4.363.0 (validation layer from the SDK), MSVC 19.44.35230. No game files. Everything recompiled for the "after" numbers.
maind478a92)vk_queue,LEONIDA_VK_VALIDATION=1WRITE_AFTER_WRITEvalidation errors: 0,vk_queue_test: OKreplay_copy_offsetctest,LEONIDA_VK_VALIDATION=1The five that remain fail the same way without this change:
d3d12_vulkan_device(#262 / #238),d3d12_execute_indirect_validation(#337 / #306),d3d12_depth_resolve(#66), and two that only fail under validation and that I am reporting separately in #14 rather than fixing here:d3d12_clear(VUID-VkClearDepthStencilValue-depth-00022) andd3d12_mesh(VUID-vkCmdDrawMeshTasksEXT-pipelineStatistics-07076).Not tested: other GPUs, Linux, and the full suite without validation on this branch (the validation run executes the same tests).
AI-assisted: yes (Claude Code)
Checklist
docs/design.md, with how it was confirmed. (not applicable: no translator change)🤖 Generated with Claude Code