Repository navigation
Runtime: queue Wait before Signal — hold the batch until its Signal is submitted, so layouts follow dependency order across queues - #2951
Conversation
|
Independent Windows 11 (26200) check of
CTest passed on both GPUs with no validation errors/VUIDs. The never-signaled-fence case reported the held operations and destroyed the queue without hanging. Synthetic inputs only. AI-assisted testing and reporting. |
…ity, fence lifetime, teardown, docs) - Present is queued behind held work (QueueHolds::after_held) and submitted in order by the releasing thread. - Held batches keep the pipeline states and root signatures of their lists; fences a queue waits on or signals are kept until the submission has completed on the GPU (a D3D12 queue holds them). - A held Signal released below an unheld one on the same fence leaves the Vulkan signal out (claimed under the submit lock). - A queue destroyed with held Signals completes the CPU waits on their fences and reports it. - A failed held batch is reported (take_held_failure, last_execute_result), its waits stay for the next submission, and the Signal behind it still signals. - d3d12_queue_handover_test: pairs, two-thread signalling stress, held Signal of a released fence, shared fence, teardown with a CPU waiter; --two-queues and --shared-queue modes on a caller-owned device. - Tests for each fix in vk_presenter_sync_test, vk_queue_query_sync_test and d3d12_m4_compute_test; docs section 4.4. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…docs counts Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
I've pushed
Tested
Thanks @Doffi4 for independently confirming This stays a draft until a second review pass is done. AI-assisted (Claude Code). |
…ng and bound, teardown pump, tests) - A Signal counts as submitted only after vkQueueSubmit succeeded: a failed submit releases no waiter and the retry goes through. - ~VulkanQueue pumps after dropping held work; fence keep-alives are also drained in wait() and marker(). - VulkanPresenter: counters are atomics, read_back/enable_capture take the presenter mutex, set_abort has its own mutex, a deferred present reports not tearing, and at most 8 presents queue up before the caller waits. - Tests: three presents (blit, blank, composed) queued behind held work run in order, a present behind a destroyed queue's held work runs, a failed Signal does not release its waiters; the handover modes also run on the host runtime. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
I've pushed
Tested
Handover test cases, with the host runtime on the 880M adapter:
AI-assisted (Claude Code). |
|
Independently tested With
The runtime build completed. The first M4 attempt could not read a generated fixture inside the sandbox. It passed on the rerun with fixture access. Synthetic fixtures only. AI-assisted testing and reporting. |
|
Independent Windows/NVIDIA check of exact head Additional finding: the deferred-present cap can be bypassed by cancellation. The existing focused suite passes, but a separate synthetic probe against this head filled the queue with eight deferred presents, set The path is submit / wait_for_room: The external probe used the same presenter/context setup as VulkanFence gate(context, 0);
// 'held' is a closed CommandList: COMMON -> RENDER_TARGET, clear, -> COMMON.
const CommandList* ptr = &held;
queue.wait(gate.semaphore(), 1);
EXPECT(queue.execute({&ptr, 1}) == ReplayResult::success);
const auto shown = presenter.presented();
for (unsigned i = 0; i < 8; ++i)
EXPECT(presenter.present(1, true) == VK_SUCCESS);
presenter.set_abort([] { return true; });
unsigned accepted = 0;
for (unsigned i = 0; i < 12; ++i)
accepted += presenter.present(1, true) == VK_SUCCESS;
presenter.set_abort({});
EXPECT(gate.signal(1));
EXPECT(queue.idle());
// Observed: accepted == 12, presenter.presented() - shown == 20.A separate local diagnostic control, leaving the PR worktree untouched, made Hardware/toolchain: desktop GeForce RTX 5070 Ti, NVIDIA 617.14; Windows 11 Pro 25H2, build 26200.9974; MSVC 19.51.36260 (x64), Windows SDK 10.0.26100, Vulkan SDK 1.4.363.0, Ninja/RelWithDebInfo. The handwritten M4 assembly was built through the existing fixture builder using a local llvm-mc-compatible shim over AMD RGA 2.15's LLVM 23 9/9 focused CTest entries passed both normally and with
In two-queue mode only COPY/COMPUTE fit (1/1/0 queues available); the test explicitly reports the 27 three-role assignments it cannot run. The eight executed cases pass; this does not claim full three-role coverage in that mode. The other passing entries were
Execution caveat: the unmodified Reproduction after building the corresponding targets: $env:DISABLE_RTSS_LAYER = '1'
$env:DISABLE_VULKAN_OBS_CAPTURE = '1'
$env:VK_LAYER_bandicam_helper_DEBUG_1 = '1'
$env:LEONIDA_VK_VALIDATION = '1'
ctest --test-dir runtime/build -C RelWithDebInfo -V --timeout 400 -R '^(vk_queue_query_sync|vk_overlapping_occlusion|vk_presenter_sync|d3d12_queue_wait(_timeout)?|d3d12_queue_handover(_two_queues|_shared_queue)?|d3d12_m4_compute)$'Environment control: the first validated run was 8/9 because the installed Bandicam implicit layer was still inserted despite the RTSS/OBS switches. Synthetic fixtures only; no game files used. AI-assisted testing and reporting (Codex). |
|
Tested 48cee7c under Wine 11.21 (Fedora 45) on AMD Radeon 610M iGPU (RDNA2 gfx1036, RADV Mesa 26.2.6) and NVIDIA RTX 4070 Ti (615.78.08): pass. This is the first run on Linux Vulkan drivers, and the first AMD run on this head. Focused tests:
RADV exposes a single queue in its graphics family on this chip, so only the one-queue paths run there. Those paths pass, including the shared-queue handover. Full ctest (clang-cl + xwin cross-build):
Not run or not covered here:
AI-assisted (Claude Code); numbers copied from the run logs. |
# Conflicts: # docs/d3d12_vulkan.md
|
Tested 48cee7c on NVIDIA RTX 4070 SUPER (driver 616.92), Windows 11 26200, MSVC 14.44, Vulkan SDK 1.4.363, RelWithDebInfo: pass, no regression against main f847748.
|
|
Tested 48cee7c on an RX 9070 (RDNA4), AMD 26.11.1, Windows 11 (26300), VS 2022 Build Tools, RelWithDebInfo with SDL3: pass Full AI-assisted |
|
Tested 48cee7c (merged onto main f847748) on NVIDIA GeForce RTX 4060 Ti, driver 610.88 (32.0.16.1088), Windows 11 26200, MSVC 14.51.36231 (VS 2026), Vulkan SDK 1.4.363.0: pass on an idle machine, with an intermittent watchdog hit under load
AI-assisted (Claude). |
|
I've merged main at Tested with
AI-assisted (Claude Code). |
What and why
This PR makes a queue Wait for a Signal that is submitted later work in the Vulkan layer, including handing resources between queues. It follows up D3D-97, closes the M4 gap from #1791, and was claimed in #1548.
The bug: a queue's
ExecuteCommandListsis replayed against oneLayoutTrackerin call order. A batch that waits for a Signal submitted later was therefore recorded against the layouts from before the work it waits for. A copy list got replayed againstUNDEFINED, and validation flagged it.The fix:
runtime/src/queue_holds.h.CommandLists are copied, so the app canResetits lists, and Signals and markers queue behind the held batch, which keeps per-queue order.Signal, records and submits the held work in dependency order, each batch on its ownVkQueue. There is no worker thread and the CPU never blocks on the GPU. This also avoids a Wait landing before its Signal on oneVkQueue, which would never make progress on the GPU.vkQueueSubmit.Edge cases: held work is reported, not hung on, when its queue is destroyed or its fence is released under it. A fence nobody signals holds back only its own waiters.
Prior art, approach only (vkd3d-proton, LGPL-2.1, no code copied): a satisfied wait never blocks again, which the monotonic table gives for free, and submission order is followed. Mapping virtual D3D12 fence values to physical Vulkan values is not done here. A Signal with a lower value is still dropped with a note, as before.
Queue families: every D3D12 queue is created in the graphics family, so the
EXCLUSIVEresources need no ownership transfer. A dedicated family would needCONCURRENT, which the docs note.Limits, documented in §4.4:
UpdateTileMappingsstill submits immediately while a queue holds work.ExecuteCommandListsis printed when the batch is released, not returned from the call.Existing tests changed. These relied on an unsatisfied Wait reaching
vkQueueSubmit:vk_queue_query_sync_testnow signals the fence first.vk_overlapping_occlusion_testdeclares the gate's Signal as submitted.d3d12_m4_compute_testnow submits the readback before the compute batch it waits for, so M4 runs the new path.Tested
New
d3d12_queue_handover_testruns the same cases on the layer and on the host D3D12 runtime, using the Radeon 880M adapter, and every case is byte-exact against what the CPU wrote:VUID-vkCmdDraw-None-09600.tests/test_ctest_registration.pyand the docs tests pass.Checklist
SKIP_RETURN_CODE 77, fails on any VUID)mainAI-assisted (Claude Code).
🤖 Generated with Claude Code