feat(d3d12_x): record draws and dispatches, with D3D12 viewports and winding #52

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

@⁠Dark3581 on GitHub · 2026-11-22 22:13 UTC · original
Dark3581:feat/draw-dispatch → main · +618 −6 · 14 files · 1 commits · merged 2026-11-22 22:15 UTC

What

The drawing half of command lists:

  • CommandRecorder gains BeginRendering/EndRendering over color and depth-stencil views, SetViewports (D3D12 viewports become Vulkan viewports with a negative height, so NDC +y is the top and D3D12's clockwise-front winding applies without changing the pipeline), SetScissors, SetPrimitiveTopology (every list, strip and adjacency topology; primitive restart on strips when the pipeline has a strip cut), SetBlendFactor, SetStencilReference, SetVertexBuffers with strides, SetIndexBuffer (R16 and R32), BindPipeline, SetPushConstants (up to the 144 bytes of the title layout), Draw, DrawIndexed and Dispatch.
  • VulkanTopology and VulkanViewport are pure and tested on their own; inverted depth ranges are accepted as in D3D12, empty, non-finite and out-of-range viewports are refused.
  • Fix in GraphicsPipeline (#44): a pipeline without vertex buffers no longer declares the vertex stride dynamic. With it declared, every draw of such a pipeline needed a vkCmdBindVertexBuffers2 call first; the validation layer flagged it here, and 1,404 of the title's vertex shaders take no vertex buffers.

What goes in the push constant block (the title's root arguments as user registers, the heap base and the code base) is up to the caller; that mapping is not known yet and the debt entry says so.

Tested

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

  • pso_probe draw-selftest: topology mapping, the viewport flip field by field, an inverted depth range, and three refused viewports.
  • pso_probe draw-gpu --validate draws into a blue 64x64 target and reads the pixels back: a triangle given clockwise in D3D12 coordinates covers the upper-left half with the default rasterizer state; the same triangle is culled when counter-clockwise faces are front; a right-half viewport moves it into the right half; an indexed triangle from a vertex buffer (20-byte stride, two slots, one per instance) and an R16 index buffer covers the lower-right half; the pixel shader's alpha of 0.5 is stored as 127 or 128; a dispatch writes 256 values through a buffer address passed in push constants; a 148-byte push block is refused. 7 checks, 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 and viewport documentation, Vulkan 1.3 specification
  • AI-assisted: yes
**@⁠Dark3581** on GitHub · 2026-11-22 22:13 UTC · [original](https://github.com/Dark3581/AnyBox/pull/52) `Dark3581:feat/draw-dispatch` → `main` · +618 −6 · 14 files · 1 commits · merged 2026-11-22 22:15 UTC ### What The drawing half of command lists: - **`CommandRecorder`** gains `BeginRendering`/`EndRendering` over color and depth-stencil views, `SetViewports` (D3D12 viewports become Vulkan viewports with a negative height, so NDC +y is the top and D3D12's clockwise-front winding applies without changing the pipeline), `SetScissors`, `SetPrimitiveTopology` (every list, strip and adjacency topology; primitive restart on strips when the pipeline has a strip cut), `SetBlendFactor`, `SetStencilReference`, `SetVertexBuffers` with strides, `SetIndexBuffer` (R16 and R32), `BindPipeline`, `SetPushConstants` (up to the 144 bytes of the title layout), `Draw`, `DrawIndexed` and `Dispatch`. - `VulkanTopology` and `VulkanViewport` are pure and tested on their own; inverted depth ranges are accepted as in D3D12, empty, non-finite and out-of-range viewports are refused. - **Fix** in `GraphicsPipeline` (#44): a pipeline without vertex buffers no longer declares the vertex stride dynamic. With it declared, every draw of such a pipeline needed a `vkCmdBindVertexBuffers2` call first; the validation layer flagged it here, and 1,404 of the title's vertex shaders take no vertex buffers. What goes in the push constant block (the title's root arguments as user registers, the heap base and the code base) is up to the caller; that mapping is not known yet and the debt entry says so. ### Tested Windows 10, RTX 3070 Ti (driver 621.14), Khronos validation layer. - `pso_probe draw-selftest`: topology mapping, the viewport flip field by field, an inverted depth range, and three refused viewports. - `pso_probe draw-gpu --validate` draws into a blue 64x64 target and reads the pixels back: a triangle given clockwise in D3D12 coordinates covers the upper-left half with the default rasterizer state; the same triangle is culled when counter-clockwise faces are front; a right-half viewport moves it into the right half; an indexed triangle from a vertex buffer (20-byte stride, two slots, one per instance) and an R16 index buffer covers the lower-right half; the pixel shader's alpha of 0.5 is stored as 127 or 128; a dispatch writes 256 values through a buffer address passed in push constants; a 148-byte push block is refused. 7 checks, 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 and viewport documentation, Vulkan 1.3 specification - [x] AI-assisted: yes
CommandRecorder gains render passes over color and depth-stencil views, viewports flipped with a negative height so D3D12's y direction and winding apply, scissors, the primitive topology with strip cut, blend factor, stencil reference, vertex buffers with strides, index buffers, pipeline binding, a push constant block of up to 144 bytes, draws, indexed draws and dispatches. Graphics pipelines without vertex buffers no longer declare the vertex stride as dynamic, which the validation layer flagged for every draw without vertex buffers. pso_probe gains a self test and a GPU test that draws and dispatches and reads the pixels and values back.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 19:16:09 +00:00
github manually merged commit c6e6fa00f8 into gh-pr/52/base 2026-11-26 19:16:12 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.