Repository navigation
Conversation
…kets (D3D-486) ~VulkanFence destroyed its timeline semaphore at once, though submissions made before (a queue Signal behind other work, a GPU Wait for it) may still signal or wait for it: VUID-vkDestroySemaphore-semaphore-05149. A queue Wait not yet attached to a batch, or a held Signal of the fence, would also be submitted later with the destroyed handle. - vulkan_backend.h: DeferredDeletionQueue::Kind::semaphore; ~VulkanFence calls remove_fence, then defers the semaphore (retired once every submission made before the release has completed). VulkanQueue::discard_waiting_on also forgets the semaphore: a Wait not yet attached counts as reached (as a released fence does for the CPU), a held Signal of it signals nothing; held batches waiting on it are still dropped and reported. - queue_holds.h: remove_fence asks every queue, not only when something is held (a pending Wait names the fence too). - d3d12_queue_handover_test: case on the layer and the host runtime, behind a ~300 ms GPU gate on the COPY queue: A a Signal and a DIRECT Wait in flight, B a Wait not yet attached, C a held Signal; each fence is released right away, readbacks exact. With the semaphore destroyed at once (origin/main behaviour) the layer gave VUID-vkDestroySemaphore-semaphore-05149 (A, B), VUID-VkSubmitInfo-pWaitSemaphores-parameter (B) and an access violation. - docs/d3d12_vulkan.md 4.4. RTX 3060 / 617.14, LEONIDA_VK_VALIDATION=1 with sync validation: 374 layer cases, 372 host, 0 messages. AI-assisted.
…(D3D-496) When an ID3D12Fence was released while a queue held a batch waiting on it, VulkanQueue::discard_waiting_on dropped the batch and printed "that work is dropped". The host runtime lets the queue go on: the batch runs and a Signal after it is reached (measured on an RTX 5060 host, and by @Exopus-0x65f7ad0 on an RTX 5060 Ti with the debug layer on). discard_waiting_on now takes only the released fence's wait off each held operation, as ItsNotRexed#4663 already does for a Wait not yet attached to a submission; remove_fence's pump_ready then releases the operation in queue order once its other waits are met. No batch is dropped. d3d12_queue_handover_test's "fence released while a batch waits" now checks that behaviour on the layer and on the host runtime: the held batch copies data to stage[1] and signals 101, and after the release the Signal is reached and stage[1] reads back exact. Without the change the layer drops the batch and the case fails.
Kam471
left a comment
There was a problem hiding this comment.
Built and ran d3d12_queue_handover_test at d7e534067 on Windows 11, RTX 5070 Ti: exit 0.
fence released while a batch waits: the batch ran and its Signal was reached(the new D3D-496 case 2)fences released while in use (gate of 265 copies): A Signal and Wait in flight, B Wait not yet attached, C held Signal: every readback exact- Vulkan layer 374 cases, every one exact; Host D3D12 373 cases, every one exact.
The change lets a queue that is waiting on a released fence continue (releasing the wait) instead of stalling, matching the host; the added scenario covers the batch finishing and signalling.
Merge check: clean with #4663 (exit 0), which is the natural pair; conflicts with #4681 (vulkan_backend.h), #4557 (vulkan_backend.h, handover test), #4570 (queue_holds.h) and #4577 (docs, handover test). git diff --check clean. No blocking issue.
|
Tested I built For the negative control, I used NVIDIA driver 32.0.16.2101. AMD driver 32.0.21043.5001. Vulkan validation was off. AI-assisted. |
|
Tested Stacking: as declared, the branch is #4663 (
No blocking issue. AI-assisted. |
|
Tested |
|
An extra case this PR fixes: a crash (segfault) on
and then a segfault. The host D3D12 runs it fine. Results on RTX 5060 Ti / 621.14,
So this is one more reason to land this PR. A game that waits on a short-lived fence and releases it right away would crash on AI-assisted (Claude Code). Synthetic fences only, no game files. |
|
Tested d7e5340 on NVIDIA GeForce RTX 4080, driver 617.42, Windows 11 (clang-cl cross-build): d3d12_queue_handover_test exits 0. The Vulkan layer section reports 374 cases passed, every one exact, and the host D3D12 section reports 373 cases passed, every one exact, with 3/3/3 queues available per type (COPY/COMPUTE/DIRECT). "fence released while a batch waits: the batch ran and its Signal was reached" prints in both sections. The validation layer was not loaded in this run, and I did not run the pre-change negative control or check the stack ancestry (the PR is stacked on #4663). AI-assisted. |
|
Verified at head d7e5340 merged with current main: merges cleanly, code and comments self-consistent (the wait is stripped from held ops rather than dropping the batch, semaphore routed through deferred deletion), and D3D-496 is absent from main so nothing here is superseded. Merge-order finding, verified on the graph: your parent 0cc958d is the head of still-open #4663 and is not on main — #4663 must land first; #4756 also carries that commit, so the family should land in one order. The docs paragraph is disjoint from #3634's edits in the same file (merge-tree clean). C++ and GPU-gated cases not built here — the host-comparison measurements need a GPU recheck. No CI checks are scheduled on the branch. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only review). |
|
Tested d7e5340 on Intel UHD 770, driver 32.0.101.7088, Windows 11, MSVC, at the stack head (#4663's head 0cc958d is an ancestor), with the validation layer enabled: d3d12_queue_handover_test, rebuilt from scratch, exits 0. The host D3D12 section reports "373 cases passed, every one exact", including "fence released while a batch waits: the batch ran and its Signal was reached". The Vulkan layer section reports "0 cases passed": this GPU exposes 1/0/0 queues (COPY/COMPUTE/DIRECT), the test returns before any layer case runs, and the host section does not go through the Vulkan layer, so the layer side of this PR is not covered by this run and the absence of validation errors is not evidence about it. The ctest entries and the control without the vulkan_backend.h change were not run. AI-assisted. |
|
Tested
AI-assisted (Claude Code). |
main now pins the fences a queue waits on (the queue-holds review fixes) and its fence_released case, layer only, expects a batch waiting on a released fence to stay held. The host runtime runs it: this branch's fence_released, on the layer and the host, shows the batch runs and its Signal is reached (RTX 5060, WARP and NVIDIA). Resolved for the host behaviour: - ID3D12CommandQueue::Wait no longer pins the fence; Signal keeps its pin, so a held Signal of a released fence still signals (held_signal_survives_release). - QueueHolds::remove_fence keeps main's re-entrancy guard (in_pump) but not the held_ == 0 early-out: a Wait not yet attached to a submission names the fence too. - discard_waiting_on takes the released fence's wait off held work instead of dropping it. - d3d12_queue_handover_test keeps this branch's fence_released (layer and host) and main's never_signaled, held_signal_survives_release, monotonic_shared_fence, teardown_wakes_cpu_waiters and concurrent_signalling. - docs/d3d12_vulkan.md: main's text, with the keep-alive sentence corrected.
|
Merged current The conflict was semantic, not only textual. The queue-holds review fixes on So I resolved it for the host behaviour, and kept everything else from
Tested on RTX 5060, NVIDIA 621.01, Windows 11 23H2, MSVC 19.44, Ninja RelWithDebInfo, Vulkan SDK 1.4.363:
The branch still carries #4663's commit ( AI-assisted (Claude Code). |
|
Independent Windows check of 12b46ac8. RTX 3080 Ti, NVIDIA 621.35, MSVC 19.44, Vulkan SDK 1.4.363.0. In a focused The focused standalone mode crashed before reporting its case results. I haven't isolated the cause, so the standalone result is inconclusive. This was a subset of the queue-handover fixture. AI-assisted. |
D3D-496, case 2. Claimed in the coordination issue as: #4683 (comment) (from @Exopus-0x65f7ad0's finding)
Depends on: #4663 (D3D-486, @requiemsnkrp). This branch is stacked on its head
0cc958d0. Only the last commit is this PR's.What and why
When an
ID3D12Fenceis released while a queue holds a batch that waits on it,remove_fence→VulkanQueue::discard_waiting_ondrops the batch ([rt] d3d12: a fence was released while a queue still held work waiting on it; that work is dropped). The host runtime lets the queue go on: the batch runs and theSignalafter it is reached. An app may release a fence right after using it (a queueWaittakes no COM reference), so dropped batches mean missing GPU work and signals that never arrive.The change
VulkanQueue::discard_waiting_ontakes only the released fence's wait (semaphore + value) off each held operation, instead of erasing the operation. Runtime: keep a released fence's semaphore until the GPU is done with it (D3D-486) #4663 already does this for aWaitnot yet attached to a submission.remove_fence'spump_ready()then releases the operation in queue order once its other waits are met. The semaphore is never waited on after the release, so Runtime: keep a released fence's semaphore until the GPU is done with it (D3D-486) #4663's deferred retirement stays valid.queue_holds.h/vulkan_backend.hand thedocs/d3d12_vulkan.mdedge-case sentence describe the new behaviour.d3d12_queue_handover_test, case "fence released while a batch waits", now runs on the layer and on the host runtime. The held batch copies the upload data tostage[1]and signals 101. The test checks the Signal is not reached before the release, that nothing is reported dropped, that afterRelease()the Signal reaches 101, and that a second submission readsstage[1]back exact.Tested
On NVIDIA GeForce RTX 5060, driver 621.01, Windows 11 23H2 22631.6199, MSVC 19.44, Vulkan SDK 1.4.363:
d3d12_queue_handover_test:Vulkan layer: 374 cases passed, every one exactandHost D3D12 (NVIDIA GeForce RTX 5060): 373 cases passed, every one exact, exit 0. The same withLEONIDA_VK_VALIDATION=1(no VUIDs). The host line confirms the host lets the queue go on.vulkan_backend.hchange, the new case fails on the layer:line 600: the batch waiting on the released fence was dropped.cteston this branch: no new failure. The 3 failures are the ones of Runtime: keep a released fence's semaphore until the GPU is done with it (D3D-486) #4663's base on this 23H2 host:d3d12_shader_cache(fixed on latermain),d3d12_vulkan_device(d3d12_vulkan_device_test: tell Windows 11 23H2's runtime apart by ID3D12Device11 (TEST-724 follow-up) #4667) andd3d12_typeless_rtv(d3d12_typeless_rtv_test: compare castable MSAA RTVs on hosts without relaxed format casting (WARP 22621) #4658).Case 1 of D3D-496 (a postponed CPU
Signallost in~Fence→cancel_fence_waits) is not in this PR. It builds on #4282 and will be a follow-up.No game files. AI-assisted.