feat(d3d12_x): add D3D12 descriptor heaps and descriptor creation #63

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

@⁠Dark3581 on GitHub · 2026-11-23 01:04 UTC · original
Dark3581:feat/descriptor-heaps → main · +1124 −14 · 16 files · 1 commits · merged 2026-11-23 01:07 UTC

What

ID3D12DescriptorHeap, the device's descriptor creation and copies, and the command list calls that use descriptors:

  • resources/DescriptorSizes.cpp: the four handle increments as a configuration where every value starts unset, so unset is distinguishable from 0. Translated shaders compute descriptor addresses with the console's increment compiled in, so these values have to be the console's, and nothing has given them yet. A heap whose size is unset is refused with that cause. A shader resource size must hold the eight-word image descriptor and a sampler size the four-word sampler descriptor, the key sizes the translator's lookup reads.
  • objects/DescriptorHeap.cpp:
    • Shader-visible heaps sit in the buffer window (#36), so GetGPUDescriptorHandleForHeapStart is the address shaders read descriptor words from; other heaps sit in CPU memory.
    • Each slot has a CPU-side record of the Vulkan view, sampler or attachment it describes.
    • Handles resolve to their heap and index through a registry.
    • GetDesc and both handle getters use the MSVC-ABI handling from #60.
    • Refused: shader-visible RTV or DSV heaps, unknown flags, other GPU nodes, empty or over-4 GB heaps.
  • objects/DescriptorWriter.cpp, which the device's Create*View, CreateSampler and CopyDescriptors* will forward to:
    • CBV and buffer SRV/UAV write the V# words from #55 and clear the rest of the slot. Null views write zeros.
    • RTV and DSV become Vulkan image views, cached per resource and destroyed with it, with the attachment extent and layers for the view's mip. Samplers are cached per description.
    • Texture SRV/UAV and samplers are recorded in CPU-only heaps and copied with them. Image and sampler words in a shader-visible heap, written directly or copied there, stop the title, because the console's T# and S# layouts are not sourced.
    • CopyDescriptors handles source and destination ranges of different sizes.
  • objects/CommandList.cpp:
    • SetDescriptorHeaps.
    • OMSetRenderTargets, which reads the descriptors at the call, as D3D12 does, including single-range handles and null views.
    • ClearRenderTargetView and ClearDepthStencilView, with optional rectangles.
    • The bound heaps and targets are kept for the draws that come next.
  • Resource::View: the per-resource image view cache.

Tested

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

  • pso_probe descriptors-gpu --validate, 38 checks:

    • unset and too-small sizes refused, and heap byte counts;
    • five heaps and three refusals; the shader-visible heap's CPU and GPU handles are the same window address below 4 GB; CPU-only heaps have no GPU handle; handle resolution, including misaligned and past-the-end handles;
    • CBV, structured SRV and raw UAV words decoded back to their base, stride, records and bounds, and a null CBV is all zero;
    • CopyDescriptorsSimple and multi-range CopyDescriptors into the shader-visible heap;
    • two identical RTVs share one view, while the default RTV (a 2D array view) gets its own; a null RTV, a DSV, a texture SRV copied within a CPU-only heap, and identical samplers sharing one VkSampler;
    • on a command list: OMSetRenderTargets (separate handles, then one range with a null view) and SetDescriptorHeaps;
    • ClearRenderTargetView (full, then a rectangle) and ClearDepthStencilView read back with the expected colors and depth;
    • every window range returned after release.

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

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

The test uses increments of 32, 16, 64 and 64 bytes. These are test values, not the console's.

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; buffer descriptor words and the image and sampler key sizes from the translator's documentation (as in #55 and the descriptor hash table)
  • AI-assisted: yes
**@⁠Dark3581** on GitHub · 2026-11-23 01:04 UTC · [original](https://github.com/Dark3581/AnyBox/pull/63) `Dark3581:feat/descriptor-heaps` → `main` · +1124 −14 · 16 files · 1 commits · merged 2026-11-23 01:07 UTC ### What `ID3D12DescriptorHeap`, the device's descriptor creation and copies, and the command list calls that use descriptors: - **`resources/DescriptorSizes.cpp`**: the four handle increments as a configuration where every value starts unset, so unset is distinguishable from 0. Translated shaders compute descriptor addresses with the console's increment compiled in, so these values have to be the console's, and nothing has given them yet. A heap whose size is unset is refused with that cause. A shader resource size must hold the eight-word image descriptor and a sampler size the four-word sampler descriptor, the key sizes the translator's lookup reads. - **`objects/DescriptorHeap.cpp`**: - Shader-visible heaps sit in the buffer window (#36), so `GetGPUDescriptorHandleForHeapStart` is the address shaders read descriptor words from; other heaps sit in CPU memory. - Each slot has a CPU-side record of the Vulkan view, sampler or attachment it describes. - Handles resolve to their heap and index through a registry. - `GetDesc` and both handle getters use the MSVC-ABI handling from #60. - Refused: shader-visible RTV or DSV heaps, unknown flags, other GPU nodes, empty or over-4 GB heaps. - **`objects/DescriptorWriter.cpp`**, which the device's `Create*View`, `CreateSampler` and `CopyDescriptors*` will forward to: - CBV and buffer SRV/UAV write the V# words from #55 and clear the rest of the slot. Null views write zeros. - RTV and DSV become Vulkan image views, cached per resource and destroyed with it, with the attachment extent and layers for the view's mip. Samplers are cached per description. - Texture SRV/UAV and samplers are recorded in CPU-only heaps and copied with them. **Image and sampler words in a shader-visible heap, written directly or copied there, stop the title**, because the console's T# and S# layouts are not sourced. - `CopyDescriptors` handles source and destination ranges of different sizes. - **`objects/CommandList.cpp`**: - `SetDescriptorHeaps`. - `OMSetRenderTargets`, which reads the descriptors at the call, as D3D12 does, including single-range handles and null views. - `ClearRenderTargetView` and `ClearDepthStencilView`, with optional rectangles. - The bound heaps and targets are kept for the draws that come next. - `Resource::View`: the per-resource image view cache. ### Tested Windows 10, RTX 3070 Ti (driver 621.14), Khronos validation layer. - `pso_probe descriptors-gpu --validate`, 38 checks: - unset and too-small sizes refused, and heap byte counts; - five heaps and three refusals; the shader-visible heap's CPU and GPU handles are the same window address below 4 GB; CPU-only heaps have no GPU handle; handle resolution, including misaligned and past-the-end handles; - CBV, structured SRV and raw UAV words decoded back to their base, stride, records and bounds, and a null CBV is all zero; - `CopyDescriptorsSimple` and multi-range `CopyDescriptors` into the shader-visible heap; - two identical RTVs share one view, while the default RTV (a 2D array view) gets its own; a null RTV, a DSV, a texture SRV copied within a CPU-only heap, and identical samplers sharing one `VkSampler`; - on a command list: `OMSetRenderTargets` (separate handles, then one range with a null view) and `SetDescriptorHeaps`; - **`ClearRenderTargetView` (full, then a rectangle) and `ClearDepthStencilView` read back with the expected colors and depth**; - every window range returned after release. 0 validation errors. The test runs in the `pipeline_state` test. - MinGW `ctest`: 72 of 72. With MSVC 2022, `descriptors-gpu`, `commandlist-gpu` and `resources-gpu` pass, and every target builds except `ab_gameinput`, which needs `gameinput.lib`, which this machine doesn't have. `python tools/check_conventions.py` and `debt_fold.py --check`: ok. The test uses increments of 32, 16, 64 and 64 bytes. These are test values, not the console's. ### 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; buffer descriptor words and the image and sampler key sizes from the translator's documentation (as in #55 and the descriptor hash table) - [x] AI-assisted: yes
ID3D12DescriptorHeap puts shader-visible heaps in the buffer window and keeps a CPU-side record per slot; the descriptor writer creates buffer descriptors, render target, depth-stencil and texture views (cached per resource) and samplers, and copies descriptors. Command lists bind heaps and render targets and clear through descriptors. Descriptor sizes are unset until a title gives them, and image and sampler words in shader-visible heaps stop the title until their layouts are sourced.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 19:16:55 +00:00
github manually merged commit 8669bef0db into gh-pr/63/base 2026-11-26 19:16:56 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.