diff options
| author | ItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com> | 2026-11-22 23:06:28 -0500 |
|---|---|---|
| committer | ItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com> | 2026-11-22 23:06:28 -0500 |
| commit | 95b2e2c8bd7d20019231eda0007628fa2f2b5350 (patch) | |
| tree | 588294b0fe61c6a9d21ada1f56277d000a4d47d6 /docs/d3d12_vulkan.md | |
| parent | 1af1f9e39344ca73bfec9a0e3536fa4254a00b13 (diff) | |
| parent | 003baa94c1fcba61e324dbeb947e8bd401f4f837 (diff) | |
Merge pull request #2951 from AlxcBTW
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'docs/d3d12_vulkan.md')
| -rw-r--r-- | docs/d3d12_vulkan.md | 101 |
1 files changed, 70 insertions, 31 deletions
diff --git a/docs/d3d12_vulkan.md b/docs/d3d12_vulkan.md index 21b99a78f..734b882b3 100644 --- a/docs/d3d12_vulkan.md +++ b/docs/d3d12_vulkan.md | |||
| @@ -2312,37 +2312,76 @@ mapped stages/accesses, and if no single layout serves all uses, use `GENERAL` a | |||
| 2312 | (`CommandList` is a value; the application may `Reset` its list at once) and holds the operation. Everything the | 2312 | (`CommandList` is a value; the application may `Reset` its list at once) and holds the operation. Everything the |
| 2313 | queue is asked to do after it (batches, Signals, queue markers) goes behind it, so per-queue order is kept. | 2313 | queue is asked to do after it (batches, Signals, queue markers) goes behind it, so per-queue order is kept. |
| 2314 | The held operations are recorded and submitted, in order, on their own `VkQueue` as soon as the Signals they wait for | 2314 | The held operations are recorded and submitted, in order, on their own `VkQueue` as soon as the Signals they wait for |
| 2315 | have been submitted: by the thread that submits that Signal, after it has released its own queue's lock (or by the | 2315 | have been submitted: by the thread that submits that Signal (or makes the CPU `Signal`), after it has dropped its own |
| 2316 | thread of a CPU `Signal`). There is no worker thread and no caller ever waits for the GPU or for a Signal: the cost | 2316 | queue's state lock. There is no worker thread and no GPU wait is added, but the call that releases is not free: that |
| 2317 | moves to that thread and is what the held `ExecuteCommandLists` would have cost anyway. One thread releases at a time | 2317 | thread records the held batches (what the `ExecuteCommandLists` would have cost, including whatever `execute` does |
| 2318 | (the others leave a note and the running one makes another pass), a release that submits a Signal lets the next | 2318 | for the lists, such as the bindless upload's wait for the device until D3D-314 removes it) while it still holds the |
| 2319 | queue's front run in the same pass, so chains (C waits B, B waits A, in any submission order) and operations with | 2319 | mutex of the D3D12 queue whose `Signal` or `Wait` it is in, so other calls on that queue wait meanwhile; and |
| 2320 | several waits resolve in dependency order, and the layout tracker follows that order. A wait whose value has been | 2320 | `remove_fence`, queue destruction and presenter destruction wait for a release in progress. One thread releases at a |
| 2321 | reached by a submitted Signal never blocks again. The normal case (the Signal submitted first) is unchanged: no copy, | 2321 | time (the others leave a note and the running one makes another pass); a release that submits a Signal lets the |
| 2322 | no hold, the same `vkQueueSubmit`. Holding on the CPU also avoids a Wait and its Signal landing in the wrong order on | 2322 | next queue's front run in the same pass, so chains (C waits B, B waits A, in any submission order) and operations |
| 2323 | one `VkQueue`, which would not make forward progress on the GPU (Vulkan-Docs issue 1262). Edge cases: a queue | 2323 | with several waits resolve in dependency order, and the layout tracker follows that order. A wait whose value has |
| 2324 | destroyed with held operations reports them once (stderr: `queue destroyed with N held operation(s) never | 2324 | been reached by a submitted Signal never blocks again (vkd3d-proton's rule too). The normal case (the Signal |
| 2325 | submitted: waits for a fence value (V) that no Signal reached`) and goes on without waiting; a fence nobody signals | 2325 | submitted first) is unchanged: no copy, no hold, the same `vkQueueSubmit`. Holding on the CPU also avoids a Wait and |
| 2326 | holds back only the queues that wait for it (and those that wait for what they would have signaled), never the | 2326 | its Signal landing in the wrong order on one `VkQueue`, which would not make forward progress on the GPU |
| 2327 | others; a fence released while operations wait for it drops them and says so; a Signal value that is not above | 2327 | (Vulkan-Docs issue 1262): the test also runs with every D3D12 queue on one `VkQueue` and with two. |
| 2328 | the fence's (Vulkan timelines only increase) is still dropped with a note, as before. Failures of a held | 2328 | What a held operation keeps alive, as D3D12's queue does: the fences it waits on and signals, until its submission |
| 2329 | `ExecuteCommandLists` (what the call would have returned) are printed when it is released, not returned from the | 2329 | has completed on the GPU (a released fence stays until then, which also removes the destroy-while-pending |
| 2330 | call. Not covered: sparse `UpdateTileMappings` while a queue holds work still submits at once, and the resources a | 2330 | validation error the unheld path could hit); the pipeline states and root signatures of its lists (copied from the |
| 2331 | held batch names must stay alive until its fence signals (the layer does not pin them; the deferred-destruction | 2331 | recording before the application may `Reset` it, so releasing a PSO right after `ExecuteCommandLists` is fine). |
| 2332 | tickets only know submitted work, D3D-203). Facts from vkd3d-proton (LGPL, approach only, nothing copied): it keeps | 2332 | Resources are not kept: a resource released while a batch that names it is held fails that batch at release. |
| 2333 | a CPU-side virtual value and pending signals per fence and blocks the queue's submission thread until a signal that | 2333 | Order against other work: a held `Signal(F, v)` released after an unheld `Signal(F, w)` with `w >= v` leaves the |
| 2334 | satisfies a wait has been submitted, so Vulkan never sees a wait without a submitted signal; a satisfied wait stays | 2334 | Vulkan signal out (timelines only increase; waits for `v` already pass), decided under the submit lock so the |
| 2335 | satisfied. It also maps virtual fence values to physical timeline values so a D3D12 `Signal` of a lower value works; | 2335 | order of the checks is the order of the submissions, and the value counts as submitted only once the |
| 2336 | the layer does not yet (the value is dropped with a note). Resources are `VK_SHARING_MODE_EXCLUSIVE` and every | 2336 | `vkQueueSubmit` succeeded (a failed Signal releases nobody and its retry goes through); `Present` is queued behind |
| 2337 | D3D12 queue is in the graphics family, so no ownership transfer is needed; with dedicated compute/transfer families | 2337 | held work too (below). Fence keep-alives are released outside the queue lock, at the next `ExecuteCommandLists`, |
| 2338 | they would need `CONCURRENT` (vkd3d-proton does that, because D3D12 gives no information for transfers). | 2338 | `Signal`, `Wait` or marker once their submission has completed. Edge cases: |
| 2339 | Measured: `d3d12_queue_handover_test` runs 358 cases on the layer (371 on the RTX 5070 Laptop, which gives three | 2339 | a queue destroyed with held operations reports them once (stderr: `queue destroyed with N held operation(s) never |
| 2340 | queues per type) and 369 on the host runtime: three-stage chains (produce, relay, consume) over all 27 queue type | 2340 | submitted: waits for a fence value (V) that no Signal reached`) and goes on without waiting, and the CPU waits on |
| 2341 | assignments and all 6 submission orders (consumer first among them), two producers (texture from one queue, buffer | 2341 | the fences of its held Signals are completed, as a released fence completes them; queues that wait for those fences |
| 2342 | from another) with one consumer, a chain released by a CPU `Signal`, a CPU `Signal` before and after the `Wait`, | 2342 | stay held and are reported when they go; a fence nobody signals holds back only the queues that wait for it (and |
| 2343 | a never-signaled fence and a fence released while a batch waits; results compared byte for byte, sync validation | 2343 | for what they would have signaled), never the others; a Signal value that is not above the fence's is still |
| 2344 | clean. With holding disabled the same test fails 236 cases on the layer and validation reports | 2344 | dropped with a note at call time, as before (vkd3d-proton instead maps virtual fence values to physical timeline |
| 2345 | `VUID-vkCmdDraw-None-09600`. | 2345 | values; the layer does not yet). A held `ExecuteCommandLists` that fails when it is released does not return its |
| 2346 | result to a call that has returned: it is printed, `last_execute_result` and `VulkanQueue::take_held_failure` | ||
| 2347 | report it, the `Signal` behind it still signals (the work did not run; nothing waits forever, as for a failure that is | ||
| 2348 | not held), and its waits stay for the queue's next submission, as after a failed `vkQueueSubmit`. A queue does not | ||
| 2349 | hold `UpdateTileMappings` / `CopyTileMappings`: they still submit at once, before earlier held work, and take the | ||
| 2350 | queue's pending waits (documented limit). `VulkanQueue::idle` waits for submitted work only. | ||
| 2351 | `Present` (`VulkanPresenter`): when any queue holds work, a presented back buffer would be blitted as it was before | ||
| 2352 | that work, so the Present is queued instead (`QueueHolds::after_held`), returns success as a held | ||
| 2353 | `ExecuteCommandLists` does, and is submitted, in order with the presents queued before it, by the thread that | ||
| 2354 | releases the last operation held when it was called. It is not blocked on the calling thread because the Signal that | ||
| 2355 | releases the work may be one that thread makes after `Present` returns. Held work that is never released holds back | ||
| 2356 | the presents after it (device-wide, since the layer cannot tell which batch draws into which back buffer). A | ||
| 2357 | blank present reads nothing and is only ordered behind earlier queued presents. At most 8 presents queue up; the | ||
| 2358 | next one waits for held work to release (logged once; `set_abort` ends the wait), as a full frame-latency queue | ||
| 2359 | does. A queued present reports `last_present_tore()` false, which the Xbox PresentX path turns into the default | ||
| 2360 | vblank sync for the frame pacer. The presenter's state is guarded by one mutex (the counters are atomics, so | ||
| 2361 | reading them never waits for a present blocked on a swapchain image); `set_abort` has its own. | ||
| 2362 | Facts from vkd3d-proton (LGPL, approach only, nothing copied): it keeps a CPU-side virtual value and pending signals | ||
| 2363 | per fence and blocks the queue's submission thread until a signal that satisfies a wait has been submitted, so Vulkan | ||
| 2364 | never sees a wait without a submitted signal. Resources are `VK_SHARING_MODE_EXCLUSIVE` and every D3D12 queue is in | ||
| 2365 | the graphics family, so no ownership transfer is needed; with dedicated compute/transfer families they would need | ||
| 2366 | `CONCURRENT` (vkd3d-proton does that, because D3D12 gives no information for transfers). | ||
| 2367 | Every mode of the handover test ends with the same cases on the host runtime (the expected data is the CPU's | ||
| 2368 | pattern in all of them, so that run shows the cases are valid D3D12 and holds the layer's modes to one bar). | ||
| 2369 | The pipeline-state and root-signature pins are covered end to end by `d3d12_m4_compute_test`: the compute list is | ||
| 2370 | executed while held, its two PSOs and root signature are released and the list is Reset, the copy that releases | ||
| 2371 | it is submitted, and the output is compared with the CPU (it reads zeros without the pins). | ||
| 2372 | Measured: `d3d12_queue_handover_test` (three modes: the standalone device with a `VkQueue` per D3D12 queue, then the | ||
| 2373 | host runtime; `--two-queues`, a caller-owned device with two `VkQueue`s handed over; `--shared-queue`, one) runs | ||
| 2374 | 592 cases on the layer on the Radeon 880M and the RTX 5070 (also with one shared `VkQueue`; 8 with two handed over) and 587 on the host runtime: pairs and three-stage chains (produce, relay, consume) | ||
| 2375 | over the queue type assignments that fit and all 6 submission orders (consumer first among them), two producers | ||
| 2376 | (texture from one queue, buffer from another) with one consumer, a chain released by a CPU `Signal`, a CPU | ||
| 2377 | `Signal` before and after the `Wait`, a never-signaled fence, a fence released while a batch waits, a held Signal | ||
| 2378 | of a fence the application released, a held Signal below an unheld one on a shared fence, teardown with a held | ||
| 2379 | Signal under a CPU wait, and 200 rounds with two threads signalling and releasing at once; results compared byte | ||
| 2380 | for byte, sync validation clean. With holding disabled the test fails 236 cases and validation reports | ||
| 2381 | `VUID-vkCmdDraw-None-09600`; with the monotonic check disabled it reports | ||
| 2382 | `VUID-VkSubmitInfo-pSignalSemaphores-03242`; `vk_presenter_sync_test` and `d3d12_m4_compute_test` (which | ||
| 2383 | submits the compute list first and releases its PSOs and root signature before the copy that feeds it) fail | ||
| 2384 | without the Present ordering and the pins. | ||
| 2346 | - `SetEventOnCompletion(value, hEvent)`: a small wait thread calls `vkWaitSemaphores` and `SetEvent`. Reuse one | 2385 | - `SetEventOnCompletion(value, hEvent)`: a small wait thread calls `vkWaitSemaphores` and `SetEvent`. Reuse one |
| 2347 | thread with a condition variable; do not create a thread per fence. | 2386 | thread with a condition variable; do not create a thread per fence. |
| 2348 | - `GetCompletedValue` is `vkGetSemaphoreCounterValue`; CPU `Signal` is `vkSignalSemaphore`. | 2387 | - `GetCompletedValue` is `vkGetSemaphoreCounterValue`; CPU `Signal` is `vkSignalSemaphore`. |