feat(d3d12_x): add D3D12 command allocators and command lists on Vulkan #62

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

@⁠Dark3581 on GitHub · 2026-11-23 00:43 UTC · original
Dark3581:feat/command-lists → main · +879 −20 · 15 files · 1 commits · merged 2026-11-23 00:46 UTC

What

ID3D12CommandAllocator and ID3D12GraphicsCommandList, plus ExecuteCommandLists on the queue from #60, recording into Vulkan command buffers through the command recorder (#51–#54) on the resources from #61:

  • objects/CommandAllocator.cpp: a Vulkan command pool on the device's queue family. Each list Reset takes one primary command buffer from it, and its own Reset resets the pool and reuses those buffers. Direct, compute and copy types; other types are refused.
  • objects/CommandList.cpp:
    • Create/Reset/Close: a second Close, or a Reset while recording, returns E_FAIL. A list on an allocator of another type is refused. Close ends with a barrier that makes GPU writes visible to the CPU, so a readback after a fence wait sees them as in D3D12.
    • ResourceBarrier: transitions of whole resources or single subresources (mip, layer and plane from SplitSubresource/PlaneAspect), buffer transitions, UAV and aliasing barriers, batched into one vkCmdPipelineBarrier2. The list remembers the states its barriers set, so later copies use the matching image layouts. Split barriers stop the title.
    • CopyBufferRegion, CopyTextureRegion (footprint to texture, texture to footprint and texture to texture, with boxes and destination offsets), CopyResource (buffers, and textures subresource by subresource), ResolveSubresource.
    • IASetVertexBuffers/IASetIndexBuffer (GPU addresses mapped into the buffer window), IASetPrimitiveTopology, RSSetViewports, RSSetScissorRects, OMSetBlendFactor, OMSetStencilRef.
    • Draws, dispatches, pipeline state, root signatures and arguments, descriptor heaps, render targets, clears and ExecuteIndirect stop the title with "not implemented yet" until descriptor heap and pipeline state objects exist. Queries, predication, stream output, tiles and bundles stop the title. Resources AnyBox did not create, and recording into a closed list, stop the title too.
  • objects/CommandQueue.cpp: ExecuteCommandLists queues the closed lists' command buffers as one submission, ordered with the queue's signals and waits. Work behind a held wait is held with it. Foreign lists, lists still recording and lists of another type stop the title.
  • The device loads vkResetCommandPool.

Tested

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

  • pso_probe commandlist-gpu --validate, 26 checks in a 64 MiB window:

    • interfaces, type and refusals: a video allocator, a list on a compute allocator, Reset while recording, a second Close;
    • an upload footprint copied into mip 1 of a 2-mip texture, a subresource barrier COPY_DEST to COPY_SOURCE, then read back unchanged;
    • a boxed texture copy landing at the destination offset with the surrounding bytes untouched, and a buffer region copy, all through ExecuteCommandLists with Signal and an event;
    • after allocator and list Reset: CopyResource between two buffers, and between two textures followed by an all-subresource barrier and a readback of mip 1;
    • the allocator reuses its command buffer.

    0 validation errors. The test runs in the pipeline_state test.

  • MinGW ctest: 72 of 72. With MSVC 2022, commandlist-gpu and fence-gpu pass and every target builds except ab_gameinput, which needs gameinput.lib, which this machine doesn't have (the same before this change). python tools/check_conventions.py and debt_fold.py --check: ok.

The queue's CommandQueue debt entry is still in the unfolded fragment from #60, so this PR updates it there.

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 headers and documentation for the command list, allocator and queue semantics; Vulkan specification for the host-visibility barrier
  • AI-assisted: yes
**@⁠Dark3581** on GitHub · 2026-11-23 00:43 UTC · [original](https://github.com/Dark3581/AnyBox/pull/62) `Dark3581:feat/command-lists` → `main` · +879 −20 · 15 files · 1 commits · merged 2026-11-23 00:46 UTC ### What `ID3D12CommandAllocator` and `ID3D12GraphicsCommandList`, plus `ExecuteCommandLists` on the queue from #60, recording into Vulkan command buffers through the command recorder (#51–#54) on the resources from #61: - **`objects/CommandAllocator.cpp`**: a Vulkan command pool on the device's queue family. Each list `Reset` takes one primary command buffer from it, and its own `Reset` resets the pool and reuses those buffers. Direct, compute and copy types; other types are refused. - **`objects/CommandList.cpp`**: - `Create`/`Reset`/`Close`: a second `Close`, or a `Reset` while recording, returns `E_FAIL`. A list on an allocator of another type is refused. `Close` ends with a barrier that makes GPU writes visible to the CPU, so a readback after a fence wait sees them as in D3D12. - `ResourceBarrier`: transitions of whole resources or single subresources (mip, layer and plane from `SplitSubresource`/`PlaneAspect`), buffer transitions, UAV and aliasing barriers, batched into one `vkCmdPipelineBarrier2`. The list remembers the states its barriers set, so later copies use the matching image layouts. Split barriers stop the title. - `CopyBufferRegion`, `CopyTextureRegion` (footprint to texture, texture to footprint and texture to texture, with boxes and destination offsets), `CopyResource` (buffers, and textures subresource by subresource), `ResolveSubresource`. - `IASetVertexBuffers`/`IASetIndexBuffer` (GPU addresses mapped into the buffer window), `IASetPrimitiveTopology`, `RSSetViewports`, `RSSetScissorRects`, `OMSetBlendFactor`, `OMSetStencilRef`. - Draws, dispatches, pipeline state, root signatures and arguments, descriptor heaps, render targets, clears and `ExecuteIndirect` stop the title with "not implemented yet" until descriptor heap and pipeline state objects exist. Queries, predication, stream output, tiles and bundles stop the title. Resources AnyBox did not create, and recording into a closed list, stop the title too. - **`objects/CommandQueue.cpp`**: `ExecuteCommandLists` queues the closed lists' command buffers as one submission, ordered with the queue's signals and waits. Work behind a held wait is held with it. Foreign lists, lists still recording and lists of another type stop the title. - The device loads `vkResetCommandPool`. ### Tested Windows 10, RTX 3070 Ti (driver 621.14), Khronos validation layer. - `pso_probe commandlist-gpu --validate`, 26 checks in a 64 MiB window: - interfaces, type and refusals: a video allocator, a list on a compute allocator, `Reset` while recording, a second `Close`; - **an upload footprint copied into mip 1 of a 2-mip texture**, a subresource barrier COPY_DEST to COPY_SOURCE, then read back unchanged; - a boxed texture copy landing at the destination offset with the surrounding bytes untouched, and a buffer region copy, all through `ExecuteCommandLists` with `Signal` and an event; - after allocator and list `Reset`: `CopyResource` between two buffers, and between two textures followed by an all-subresource barrier and a readback of mip 1; - the allocator reuses its command buffer. 0 validation errors. The test runs in the `pipeline_state` test. - MinGW `ctest`: 72 of 72. With MSVC 2022, `commandlist-gpu` and `fence-gpu` pass and every target builds except `ab_gameinput`, which needs `gameinput.lib`, which this machine doesn't have (the same before this change). `python tools/check_conventions.py` and `debt_fold.py --check`: ok. The queue's `CommandQueue` debt entry is still in the unfolded fragment from #60, so this PR updates it there. ### 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 headers and documentation for the command list, allocator and queue semantics; Vulkan specification for the host-visibility barrier - [x] AI-assisted: yes
ID3D12CommandAllocator is a Vulkan command pool; ID3D12GraphicsCommandList records barriers per subresource, copies, CopyResource, resolves and input-assembler and rasterizer state through the command recorder, and ExecuteCommandLists queues closed lists in order with the queue's signals and waits. Draws, dispatches and binding stop the title until descriptor heaps and pipeline state objects exist.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 19:16:52 +00:00
github manually merged commit 5e55146d39 into gh-pr/62/base 2026-11-26 19:16:53 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.