feat(d3d12_x): record clears, copies and resolves on Vulkan #51

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

@⁠Dark3581 on GitHub · 2026-11-22 22:03 UTC · original
Dark3581:feat/command-recorder → main · +1013 −4 · 12 files · 1 commits · merged 2026-11-22 22:07 UTC

What

The data-moving half of command lists, from public D3D12 semantics:

  • commands/CommandRecorder.cpp, on a Vulkan command buffer:
    • ClearRenderTarget and ClearDepthStencil: whole views through a dynamic rendering pass with a clear load, or rectangles through vkCmdClearAttachments (clamped to the view, empty ones skipped); depth and stencil chosen by the clear flags and the view's aspects.
    • CopyBufferRegion with bounds checks; CopyBufferToTexture and CopyTextureToBuffer through placed footprints with an optional box; CopyTexture between subresources with a box; ResolveSubresource for multisampled color.
    • The image layout of each copy comes from the D3D12 state the caller passes (the expected copy or resolve state, or COMMON); Transition, BufferTransition and UnorderedAccessBarrier wrap #48's barriers; InitializeTexture moves a new texture out of UNDEFINED into its initial state's layout (validation caught that this was missing).
  • commands/CopyLayout.cpp: texel and block sizes for every texture format, subresource index to mip, layer and plane, the desktop copyable-footprint rule (256-byte row pitch, 512-byte placement) and the footprint-to-VkBufferImageCopy translation (row length in texels or blocks, block-aligned offsets, block-compressed edge blocks clamped to the mip, anything else past the mip refused).
  • The device loads vkCmdBeginRendering, vkCmdEndRendering, vkCmdClearAttachments and the copy and resolve commands.

Whether the console's GetCopyableFootprints matches the desktop rule is unknown, so the debt fragment says the device must not answer a title with it until that is measured.

Tested

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

  • pso_probe commands-selftest: block sizes, subresource splits, mip extents, the footprints of a 3-mip 100x50 array (pitches, offsets, total size) and an 8x8 BC1 chain, three regions field by field (a mip, a box, a 2x2 BC edge mip), and 9 refusals.
  • pso_probe commands-gpu --validate records one command buffer and reads 14 results back to host memory: a red clear and a green rectangle (inside, on and past its edge); an uploaded mip 1 read back byte for byte; a texture copy of the green square into a blue target (inside and past its edge); a depth clear of 0.25 with a 0.75 rectangle read back as floats; a 4x MSAA clear resolved to single-sampled; 16x16 BC1 blocks uploaded and read back byte for byte; a 4 KiB buffer copy; and a buffer copy past the end refused. 0 validation errors. Both run in the pipeline_state test.
  • MinGW ctest: 66 of 66. The d3d12_x targets also build with MSVC 2022. 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 command list, copy and footprint documentation, Vulkan 1.3 specification
  • AI-assisted: yes
**@⁠Dark3581** on GitHub · 2026-11-22 22:03 UTC · [original](https://github.com/Dark3581/AnyBox/pull/51) `Dark3581:feat/command-recorder` → `main` · +1013 −4 · 12 files · 1 commits · merged 2026-11-22 22:07 UTC ### What The data-moving half of command lists, from public D3D12 semantics: - **`commands/CommandRecorder.cpp`**, on a Vulkan command buffer: - `ClearRenderTarget` and `ClearDepthStencil`: whole views through a dynamic rendering pass with a clear load, or rectangles through `vkCmdClearAttachments` (clamped to the view, empty ones skipped); depth and stencil chosen by the clear flags and the view's aspects. - `CopyBufferRegion` with bounds checks; `CopyBufferToTexture` and `CopyTextureToBuffer` through placed footprints with an optional box; `CopyTexture` between subresources with a box; `ResolveSubresource` for multisampled color. - The image layout of each copy comes from the D3D12 state the caller passes (the expected copy or resolve state, or `COMMON`); `Transition`, `BufferTransition` and `UnorderedAccessBarrier` wrap #48's barriers; `InitializeTexture` moves a new texture out of `UNDEFINED` into its initial state's layout (validation caught that this was missing). - **`commands/CopyLayout.cpp`**: texel and block sizes for every texture format, subresource index to mip, layer and plane, the desktop copyable-footprint rule (256-byte row pitch, 512-byte placement) and the footprint-to-`VkBufferImageCopy` translation (row length in texels or blocks, block-aligned offsets, block-compressed edge blocks clamped to the mip, anything else past the mip refused). - The device loads `vkCmdBeginRendering`, `vkCmdEndRendering`, `vkCmdClearAttachments` and the copy and resolve commands. Whether the console's `GetCopyableFootprints` matches the desktop rule is unknown, so the debt fragment says the device must not answer a title with it until that is measured. ### Tested Windows 10, RTX 3070 Ti (driver 621.14), Khronos validation layer. - `pso_probe commands-selftest`: block sizes, subresource splits, mip extents, the footprints of a 3-mip 100x50 array (pitches, offsets, total size) and an 8x8 BC1 chain, three regions field by field (a mip, a box, a 2x2 BC edge mip), and 9 refusals. - `pso_probe commands-gpu --validate` records one command buffer and reads 14 results back to host memory: a red clear and a green rectangle (inside, on and past its edge); an uploaded mip 1 read back byte for byte; a texture copy of the green square into a blue target (inside and past its edge); a depth clear of 0.25 with a 0.75 rectangle read back as floats; a 4x MSAA clear resolved to single-sampled; 16x16 BC1 blocks uploaded and read back byte for byte; a 4 KiB buffer copy; and a buffer copy past the end refused. 0 validation errors. Both run in the `pipeline_state` test. - MinGW `ctest`: 66 of 66. The `d3d12_x` targets also build with MSVC 2022. `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 command list, copy and footprint documentation, Vulkan 1.3 specification - [x] AI-assisted: yes
CommandRecorder records render-target and depth-stencil clears (whole or by rectangles, through dynamic rendering), buffer copies, copies between textures and placed footprints, texture copies with boxes and resolves on a Vulkan command buffer, with layouts taken from the D3D12 states and a first transition of new textures out of UNDEFINED. CopyLayout gives texel and block sizes, splits subresource indices, computes desktop copyable footprints and turns a footprint into a VkBufferImageCopy, clamping block-compressed edge blocks to the mip. The device loads the rendering, clear, copy and resolve commands; pso_probe gains a self test and a GPU test that reads 14 results back and compares them.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 19:16:05 +00:00
github manually merged commit f53a467f38 into gh-pr/51/base 2026-11-26 19:16:07 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.