feat(d3d12_x): add D3D12 fence and command queue objects on Vulkan #60

Manually merged
github merged 1 commit from gh-pr/60/head into gh-pr/60/base 2026-11-26 19:16:44 +00:00
Owner

@⁠Dark3581 on GitHub · 2026-11-23 00:20 UTC · original
Dark3581:feat/fence-queue → main · +689 −7 · 13 files · 1 commits · merged 2026-11-23 00:22 UTC

What

The first D3D12 objects as real COM objects on the public interfaces, so the device can hand them to a title:

  • objects/ObjectBase.hpp: DeviceChildBase<Interface> gives reference counting, QueryInterface over the object's interface chain (IUnknown, ID3D12Object, ID3D12DeviceChild plus each object's own), private data with D3D12's semantics (size queries, DXGI_ERROR_MORE_DATA, DXGI_ERROR_NOT_FOUND, stored interfaces kept referenced), names, and a parent device that the child keeps a reference to.
  • objects/Fence.cpp: ID3D12Fence1 on a Vulkan timeline semaphore: GetCompletedValue, CPU Signal, SetEventOnCompletion with an event (signalled from a waiting thread that holds a duplicate handle and a reference) or without one (a blocking wait).
  • objects/CommandQueue.cpp: ID3D12CommandQueue Signal and Wait through vkQueueSubmit2, GetTimestampFrequency from the device's timestamp period, and GetDesc. All D3D12 queues share the device's one Vulkan queue, so a Wait recorded before the matching Signal (legal in D3D12, common across queues) would block the Vulkan queue forever. A queue therefore holds a wait whose value nothing has promised yet, and every operation after it, on the CPU; a fence that gets a promise (a submitted GPU signal or a CPU signal) wakes the queues watching it, as D3D12 itself stalls such queues.
  • The device enables timelineSemaphore, loads the semaphore and vkQueueSubmit2 functions, and serializes queue submission with a lock that Submit also takes.
  • Methods that return a structure (GetDesc) need the MSVC ABI the title is built with; MinGW builds of the objects define WIDL_EXPLICIT_AGGREGATE_RETURNS, which declares them with the explicit return pointer that ABI uses.

ExecuteCommandLists with lists, tile mappings and clock calibration stop the title for now; markers do nothing (listed as silent stubs).

Tested

Windows 10, RTX 3070 Ti (driver 621.14), Khronos validation layer.

  • pso_probe fence-gpu --validate, 37 checks: shared fences and video queues refused; six interfaces queried from a fence, a foreign one refused; private data (missing, size, short buffer, value, a stored interface); names and creation flags; a queue description read back through GetDesc; the timestamp frequency; a GPU signal waking an event; a wait recorded on one queue before the signal on another holds two operations back and then runs them once the other queue signals, without a deadlock; a CPU signal releasing a held GPU wait; signalling the current value again and a blocking wait on a reached value. 0 validation errors. Runs in the pipeline_state test.
  • MinGW ctest: 72 of 72. With MSVC 2022 the targets build and fence-gpu passes (by-value GetDesc). python tools/check_conventions.py and debt_fold.py --check: ok.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • python tools/check_conventions.py passes (no comments in code, one declaration per export, Conventional Commit subjects)
  • Unimplemented paths stop (AbxNotImplemented / AbxUnsupported); silent stubs are listed under Silent stubs through a debt fragment
  • Known gaps added, changed or removed through docs/dev/debt/changes/<branch>.md
  • Generic behaviour, not specific to one title
  • No game files, keys, notes or logs added to the repository
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • Source of behaviour: public D3D12 fence and command queue documentation, Vulkan 1.3 timeline semaphores and synchronization2
  • AI-assisted: yes
**@⁠Dark3581** on GitHub · 2026-11-23 00:20 UTC · [original](https://github.com/Dark3581/AnyBox/pull/60) `Dark3581:feat/fence-queue` → `main` · +689 −7 · 13 files · 1 commits · merged 2026-11-23 00:22 UTC ### What The first D3D12 objects as real COM objects on the public interfaces, so the device can hand them to a title: - **`objects/ObjectBase.hpp`**: `DeviceChildBase<Interface>` gives reference counting, `QueryInterface` over the object's interface chain (`IUnknown`, `ID3D12Object`, `ID3D12DeviceChild` plus each object's own), private data with D3D12's semantics (size queries, `DXGI_ERROR_MORE_DATA`, `DXGI_ERROR_NOT_FOUND`, stored interfaces kept referenced), names, and a parent device that the child keeps a reference to. - **`objects/Fence.cpp`**: `ID3D12Fence1` on a Vulkan timeline semaphore: `GetCompletedValue`, CPU `Signal`, `SetEventOnCompletion` with an event (signalled from a waiting thread that holds a duplicate handle and a reference) or without one (a blocking wait). - **`objects/CommandQueue.cpp`**: `ID3D12CommandQueue` `Signal` and `Wait` through `vkQueueSubmit2`, `GetTimestampFrequency` from the device's timestamp period, and `GetDesc`. All D3D12 queues share the device's one Vulkan queue, so a `Wait` recorded before the matching `Signal` (legal in D3D12, common across queues) would block the Vulkan queue forever. A queue therefore holds a wait whose value nothing has promised yet, and every operation after it, on the CPU; a fence that gets a promise (a submitted GPU signal or a CPU signal) wakes the queues watching it, as D3D12 itself stalls such queues. - The device enables `timelineSemaphore`, loads the semaphore and `vkQueueSubmit2` functions, and serializes queue submission with a lock that `Submit` also takes. - Methods that return a structure (`GetDesc`) need the MSVC ABI the title is built with; MinGW builds of the objects define `WIDL_EXPLICIT_AGGREGATE_RETURNS`, which declares them with the explicit return pointer that ABI uses. `ExecuteCommandLists` with lists, tile mappings and clock calibration stop the title for now; markers do nothing (listed as silent stubs). ### Tested Windows 10, RTX 3070 Ti (driver 621.14), Khronos validation layer. - `pso_probe fence-gpu --validate`, 37 checks: shared fences and video queues refused; six interfaces queried from a fence, a foreign one refused; private data (missing, size, short buffer, value, a stored interface); names and creation flags; a queue description read back through `GetDesc`; the timestamp frequency; a GPU signal waking an event; **a wait recorded on one queue before the signal on another holds two operations back and then runs them once the other queue signals, without a deadlock**; a CPU signal releasing a held GPU wait; signalling the current value again and a blocking wait on a reached value. 0 validation errors. Runs in the `pipeline_state` test. - MinGW `ctest`: 72 of 72. With MSVC 2022 the targets build and `fence-gpu` passes (by-value `GetDesc`). `python tools/check_conventions.py` and `debt_fold.py --check`: ok. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] `python tools/check_conventions.py` passes (no comments in code, one declaration per export, Conventional Commit subjects) - [x] Unimplemented paths stop (`AbxNotImplemented` / `AbxUnsupported`); silent stubs are listed under Silent stubs through a debt fragment - [x] Known gaps added, changed or removed through `docs/dev/debt/changes/<branch>.md` - [x] Generic behaviour, not specific to one title - [x] No game files, keys, notes or logs added to the repository - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] Source of behaviour: public D3D12 fence and command queue documentation, Vulkan 1.3 timeline semaphores and synchronization2 - [x] AI-assisted: yes
ObjectBase gives the D3D12 COM objects reference counting, QueryInterface over their interface chain, private data, names and a parent device. Fence implements ID3D12Fence1 on a timeline semaphore (completed value, CPU signal, events and blocking waits). CommandQueue implements ID3D12CommandQueue's signal and wait on the device's Vulkan queue, holding a wait for an unpromised value and the work after it on the CPU until a GPU or CPU signal promises it, so a wait recorded before its signal cannot deadlock the shared queue. The device enables timeline semaphores and locks its queue; MinGW builds use the explicit aggregate return the MSVC ABI has. pso_probe gains a GPU test with 37 checks.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 19:16:42 +00:00
github manually merged commit f0b9486df3 into gh-pr/60/base 2026-11-26 19:16:44 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.