feat(d3d12_x): execute indirect draws and dispatches #53

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

@⁠Dark3581 on GitHub · 2026-11-22 23:07 UTC · original
Dark3581:feat/execute-indirect → main · +479 −6 · 15 files · 1 commits · merged 2026-11-22 23:09 UTC

What

ExecuteIndirect for the signatures that map straight to Vulkan:

  • commands/IndirectCommands.cpp: TranslateCommandSignature accepts a signature whose only argument is a draw, indexed draw or dispatch, with a stride of at least the argument size and a multiple of 4. Refused with the argument named: signatures that also change constants, views or vertex and index buffers per command, a draw or dispatch that is not the last argument, mesh and ray dispatches, other nodes.
  • CommandRecorder::ExecuteIndirect: D3D12_DRAW_ARGUMENTS, D3D12_DRAW_INDEXED_ARGUMENTS and D3D12_DISPATCH_ARGUMENTS have the layouts of VkDrawIndirectCommand, VkDrawIndexedIndirectCommand and VkDispatchIndirectCommand (checked with static_assert), so the argument buffer is used as it is. A count buffer uses vkCmdDrawIndirectCount / vkCmdDrawIndexedIndirectCount (drawIndirectCount); without multiDrawIndirect the draws are recorded one by one; dispatches are recorded one per command, and a dispatch count buffer is refused. Offsets, alignment and bounds are checked.
  • The device enables multiDrawIndirect and drawIndirectCount when offered, and the title buffer window's buffer can also be bound as vertex, index, indirect and uniform buffer, so a title's buffers in it can be used for all of these.

Tested

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

  • pso_probe indirect-selftest: argument sizes and layouts, three accepted signatures and 7 refusals with their messages.
  • pso_probe indirect-gpu --validate draws into a blue target through ExecuteIndirect and reads the pixels back: two draw commands with a 32-byte stride cover both halves; the same with a count buffer holding 1 draws only the first, and with 0 draws nothing; an indexed indirect draw covers the lower-right half; an indirect dispatch of 2 groups writes 128 values and not the 129th; a dispatch with a count buffer, arguments past the buffer and misaligned arguments are refused. 5 checks, 0 validation errors. The window probe still passes with the wider buffer usage.
  • 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 signature and indirect argument documentation, Vulkan 1.3 specification
  • AI-assisted: yes
**@⁠Dark3581** on GitHub · 2026-11-22 23:07 UTC · [original](https://github.com/Dark3581/AnyBox/pull/53) `Dark3581:feat/execute-indirect` → `main` · +479 −6 · 15 files · 1 commits · merged 2026-11-22 23:09 UTC ### What `ExecuteIndirect` for the signatures that map straight to Vulkan: - **`commands/IndirectCommands.cpp`**: `TranslateCommandSignature` accepts a signature whose only argument is a draw, indexed draw or dispatch, with a stride of at least the argument size and a multiple of 4. Refused with the argument named: signatures that also change constants, views or vertex and index buffers per command, a draw or dispatch that is not the last argument, mesh and ray dispatches, other nodes. - **`CommandRecorder::ExecuteIndirect`**: `D3D12_DRAW_ARGUMENTS`, `D3D12_DRAW_INDEXED_ARGUMENTS` and `D3D12_DISPATCH_ARGUMENTS` have the layouts of `VkDrawIndirectCommand`, `VkDrawIndexedIndirectCommand` and `VkDispatchIndirectCommand` (checked with `static_assert`), so the argument buffer is used as it is. A count buffer uses `vkCmdDrawIndirectCount` / `vkCmdDrawIndexedIndirectCount` (`drawIndirectCount`); without `multiDrawIndirect` the draws are recorded one by one; dispatches are recorded one per command, and a dispatch count buffer is refused. Offsets, alignment and bounds are checked. - The device enables `multiDrawIndirect` and `drawIndirectCount` when offered, and the title buffer window's buffer can also be bound as vertex, index, indirect and uniform buffer, so a title's buffers in it can be used for all of these. ### Tested Windows 10, RTX 3070 Ti (driver 621.14), Khronos validation layer. - `pso_probe indirect-selftest`: argument sizes and layouts, three accepted signatures and 7 refusals with their messages. - `pso_probe indirect-gpu --validate` draws into a blue target through `ExecuteIndirect` and reads the pixels back: two draw commands with a 32-byte stride cover both halves; the same with a count buffer holding 1 draws only the first, and with 0 draws nothing; an indexed indirect draw covers the lower-right half; an indirect dispatch of 2 groups writes 128 values and not the 129th; a dispatch with a count buffer, arguments past the buffer and misaligned arguments are refused. 5 checks, 0 validation errors. The `window` probe still passes with the wider buffer usage. - 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 signature and indirect argument documentation, Vulkan 1.3 specification - [x] AI-assisted: yes
TranslateCommandSignature accepts command signatures whose only argument is a draw, indexed draw or dispatch and refuses the rest with the argument named. CommandRecorder::ExecuteIndirect records them with Vulkan's indirect commands, whose argument layouts equal D3D12's (checked at compile time), uses the count variants for a count buffer, records draws one by one without multiDrawIndirect and dispatches one by one, and checks offsets and bounds. The device enables multiDrawIndirect and drawIndirectCount when offered, and the title buffer window can also be bound as vertex, index, indirect and uniform buffer. pso_probe gains a self test and a GPU test that reads the drawn pixels and dispatched values back.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 19:16:15 +00:00
github manually merged commit 534ca206fb into gh-pr/53/base 2026-11-26 19:16:17 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.