vulkan: every submission starts with a full memory barrier, as an ExecuteCommandLists boundary (VK-SUBMIT-BARRIER) #470
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!470
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/470/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Kokonotcu on GitHub · 2026-11-24 05:55 UTC · original
Kokonotcu:pr/submission-barrier→main· +71 −0 · 2 files · 2 commits · merged 2026-11-24 16:25 UTCClaim: VK-SUBMIT-BARRIER (#14).
What was wrong: D3D12 ends every
ExecuteCommandListswith its work done and its writes visible to the next submission on the queue. Implicit state decay relies on it, and a list may touch memory an earlier submission wrote without any barrier (two submissions copying into one buffer, say). Vulkan orders submissions on a queue only by their barriers, and nothing in aVulkanQueue's command buffer ordered it after the previous one. Synchronization validation reports it invk_queue_test's back-to-back copies into one buffer: WRITE_AFTER_WRITE between submissions, 10 errors, the test fails underLEONIDA_VK_VALIDATION=1.What changed:
execute_nowrecords anALL_COMMANDS -> ALL_COMMANDSmemory barrier (MEMORY_WRITE -> MEMORY_READ | MEMORY_WRITE) right aftervkBeginCommandBuffer. The second commit skips it on a context withoutvkCmdPipelineBarrier:replay_query_edges_test's mocked context has none, and the first commit alone crashed that test.Cost: one global memory barrier per submitted command buffer. Execution order between submissions is unchanged; the barrier only makes writes visible.
Tests:
vk_queue_test4b counts the command buffers begun and those whose first barrier is this one, over two submissions each on the direct and the copy queue: 4 of 4 (0 before).Tested on Windows 10, i7-11800H, RTX 3080 Laptop (NVIDIA driver), on
main8f481cf16, withLEONIDA_VK_VALIDATION=1:vk_queuepasses with 0 validation errors,replay_query_edgespasses. On our cumulative branch the GPU tests (^(d3d12_|vk_)) under validation pass with this in place.🤖 Generated with Claude Code
@kawaii-shakal on GitHub · 2026-11-24 10:31 UTC · original
Independent check on Windows with Khronos synchronization validation: this PR removes the
vk_queuehazardsmainreports.LEONIDA_VK_VALIDATION=1 vk_queue_test.exe(RelWithDebInfo, MSVC 19.50, Vulkan SDK 1.4.363.0), NVIDIA GeForce RTX 5070 Ti, driver 617.42, Windows 11 Pro 26300:main21625bca8WRITE_AFTER_WRITE: avkCmdCopyBufferwrites a VkBuffer another submission'svkCmdCopyBufferon the same queue wrote, with nothing between the submissions (the layer stops at the duplicate limit of 10)line 394: d.validation_errors() == 09f9a50340Without validation both pass (backlog: 256 submits, 62 command buffers allocated, cap 64). The head was built as it is, on its own base
8f481cf; GitHub reports the PR mergeable withmain. I did not run the rest of the suite on the PR head or measure the cost of the extra barrier.AI-assisted.
@Timon360SB on GitHub · 2026-11-24 12:51 UTC · original
Independent verification — Turing and Blackwell
Baseline (exact merge base):
8f481cf16f261c7f37458aeb45e8f4e19994146dPR head:
9f9a503406c581320bcd84d5a73dc77ae9626107Test environment
Synchronization validation was enabled.
Three independent test runs per revision on each GPU.
CTest results
36 test executions in total.
No skipped or missing tests.
vk_queue validation errors
BASE consistently reports WRITE_AFTER_WRITE hazards
during vkQueueSubmit.
The baseline count is subject to the validation layer's
duplicate_message_limit of 10.
Every HEAD run reports:
Validation positive control
All 12 vk_sync_validation executions passed:
Conclusion
The fix is reproducible on both tested NVIDIA
architectures. All six baseline vk_queue failures
became passes on the PR head, with zero reported
vk_queue validation errors.
No regressions observed in the selected tests.
This is a targeted correctness check, not a full
runtime regression or performance benchmark.
Synthetic fixtures only. No game files used.
AI-assisted test automation and result analysis.
@DesertGamer on GitHub · 2026-11-24 13:19 UTC · original
Independent check of this PR on NVIDIA, as asked for in #14. Windows 11, RTX 5070, driver 617.14, MSVC, Vulkan SDK 1.4.363.0 validation layer,
LEONIDA_VK_VALIDATION=1,vk_queue_testbuilt from the same tree each time.WRITE_AFTER_WRITEreportsmain21625bca8validation errors: 10main+ this PR (99eba8ab5)validation errors: 0,vk_queue_test: OKThe backlog line is the same in both (256 submits, 62 or 63 command buffers of the cap 64, 3 waits that time out), so the barrier does not change the cap behaviour the test checks. No game files, no game data.
AI-assisted: yes (Claude Code, Sonnet 5.5)
@QemmHD on GitHub · 2026-11-24 16:25 UTC · original
Merging.
Why merged: Every queue submission now starts with a full memory barrier, which matches D3D12's ExecuteCommandLists boundary. Under synchronization validation, main's vk_queue_test fails with 10 WRITE_AFTER_WRITE errors; with this PR it reports "4 of 4 submissions start with a full memory barrier" and 0 errors. Three independent NVIDIA checks agree (kawaii-shakal, Timon360SB, DesertGamer).
Why it's good: Cost, measured here because it was the open question: d3d12_bindless_churn (96 frames, many ExecuteCommandLists on 2 queues), 5 alternating runs, median, main vs PR: deferred 437.7 vs 433.8 ms, async 432.6 vs 437.3 ms, old-wait 438.3 vs 433.4 ms, old-wait async 440.2 vs 443.6 ms. vk_queue_test: 0.374 vs 0.370 s. All within run-to-run noise (about ±2%). These are synthetic tests, so there's no game-load number yet.
Tested on Windows 11 / RTX 4070 SUPER (NVIDIA 621.24), VS 2022 + Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0. Alone on main, its tests passed both plain and with LEONIDA_VK_VALIDATION=1. Cumulative: #388, #418, #421, #434, #470, #484, #485, #486 and #488 merged onto main
1504c1af6(a225e593e). There the repo-consistency set gives 566 passed / 5 skipped / 0 failed, compileall is clean, and full ctest is 306/308. The 2 failures are the same pre-existing ones as main (d3d12_execute_indirect_validation, d3d12_depth_resolve), with the same skip set. git merge-tree against current main98a977b4b: 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).