feat(d3d12_x): build buffer descriptors for constant buffer and buffer views #55

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

@⁠Dark3581 on GitHub · 2026-11-22 23:22 UTC · original
Dark3581:feat/buffer-descriptors → main · +444 −3 · 8 files · 1 commits · merged 2026-11-22 23:26 UTC

What

On the console a view is not a driver object: CreateConstantBufferView and the buffer forms of CreateShaderResourceView/CreateUnorderedAccessView write hardware buffer descriptors (V#, four words) into the descriptor heap, and the translated shaders read them directly. This adds the encoder for those words:

  • resources/BufferDescriptor.cpp: EncodeBufferDescriptor/DecodeBufferDescriptor with the fields where the translator reads them (its design notes): base address = word 0 and word 1 bits 15:0 (48 bits), stride = word 1 bits 29:16, records = word 2, component selects = word 3 bits 11:0 (3 bits each; 0 and 1 are constants, 4 to 7 are X to W), format = word 3 bits 18:12 (GFX10 buffer format), bounds mode = word 3 bits 29:28; resource level (word 3 bit 24) is 1, as in the translator's own test descriptor 0x31016fac, which the test reproduces exactly.
  • Views, with the bounds mode whose hardware behaviour the translator documents: constant buffers and raw views use byte bounds (mode 3, records in bytes), structured views element and stride bounds (mode 0, records in elements, the stride), typed views index bounds (mode 1, the element size as stride, the hardware format code, D3D12's 0, 0, 0, 1 for missing components, and the SRV's component mapping applied to the selects). FirstElement moves the base address.
  • TypedBufferFormatOf: DXGI formats to GFX10 buffer format codes, from the public hardware format enumeration the translator also uses (the channel order of the names runs from the top bit, so R11G11B10_FLOAT is 10_11_11_FLOAT and R10G10B10A2 is 2_10_10_10).
  • Refused with the cause named: addresses past 48 bits, strides past 14 bits or not a multiple of 4, structured views with a format, raw views without R32_TYPELESS, formats without a typed encoding, views past the buffer or with no elements, unknown flags, texture dimensions and UAVs with a counter.

Which values the console driver itself writes for each view type is not known; these follow how the shaders read them, and the debt fragment says so. Nothing writes the words yet: that needs the device's view methods and descriptor heaps.

Tested

  • pso_probe buffers-selftest (no GPU): an encoded descriptor word by word and its decode, the translator's reference word 3, the address and stride limits, the format codes, a constant buffer view, raw, structured and typed shader resource views field by field (offsets from FirstElement, records, stride, format, bounds, selects; one typed view word by word), a component-mapped view, a typed UAV, and 10 refusals with their messages. Runs 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: the translator's documented descriptor fields and measured bounds modes; the public RDNA2 buffer resource descriptor and GFX10 buffer format enumeration; public D3D12 view documentation
  • AI-assisted: yes
**@⁠Dark3581** on GitHub · 2026-11-22 23:22 UTC · [original](https://github.com/Dark3581/AnyBox/pull/55) `Dark3581:feat/buffer-descriptors` → `main` · +444 −3 · 8 files · 1 commits · merged 2026-11-22 23:26 UTC ### What On the console a view is not a driver object: `CreateConstantBufferView` and the buffer forms of `CreateShaderResourceView`/`CreateUnorderedAccessView` write hardware buffer descriptors (V#, four words) into the descriptor heap, and the translated shaders read them directly. This adds the encoder for those words: - **`resources/BufferDescriptor.cpp`**: `EncodeBufferDescriptor`/`DecodeBufferDescriptor` with the fields where the translator reads them (its design notes): base address = word 0 and word 1 bits 15:0 (48 bits), stride = word 1 bits 29:16, records = word 2, component selects = word 3 bits 11:0 (3 bits each; 0 and 1 are constants, 4 to 7 are X to W), format = word 3 bits 18:12 (GFX10 buffer format), bounds mode = word 3 bits 29:28; resource level (word 3 bit 24) is 1, as in the translator's own test descriptor `0x31016fac`, which the test reproduces exactly. - Views, with the bounds mode whose hardware behaviour the translator documents: constant buffers and raw views use byte bounds (mode 3, records in bytes), structured views element and stride bounds (mode 0, records in elements, the stride), typed views index bounds (mode 1, the element size as stride, the hardware format code, D3D12's 0, 0, 0, 1 for missing components, and the SRV's component mapping applied to the selects). `FirstElement` moves the base address. - `TypedBufferFormatOf`: DXGI formats to GFX10 buffer format codes, from the public hardware format enumeration the translator also uses (the channel order of the names runs from the top bit, so `R11G11B10_FLOAT` is `10_11_11_FLOAT` and `R10G10B10A2` is `2_10_10_10`). - Refused with the cause named: addresses past 48 bits, strides past 14 bits or not a multiple of 4, structured views with a format, raw views without `R32_TYPELESS`, formats without a typed encoding, views past the buffer or with no elements, unknown flags, texture dimensions and UAVs with a counter. Which values the console driver itself writes for each view type is not known; these follow how the shaders read them, and the debt fragment says so. Nothing writes the words yet: that needs the device's view methods and descriptor heaps. ### Tested - `pso_probe buffers-selftest` (no GPU): an encoded descriptor word by word and its decode, the translator's reference word 3, the address and stride limits, the format codes, a constant buffer view, raw, structured and typed shader resource views field by field (offsets from `FirstElement`, records, stride, format, bounds, selects; one typed view word by word), a component-mapped view, a typed UAV, and 10 refusals with their messages. Runs 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: the translator's documented descriptor fields and measured bounds modes; the public RDNA2 buffer resource descriptor and GFX10 buffer format enumeration; public D3D12 view documentation - [x] AI-assisted: yes
BufferDescriptor encodes the four-word buffer descriptors the translated shaders decode, with the fields where the translator reads them (base address in 48 bits, stride, records, component selects, format, bounds mode) and resource level 1, and decodes them for checks. Constant buffer, raw, structured and typed buffer shader resource and unordered access views map to byte, element-and-stride and index bounds, typed formats to their hardware format codes with D3D12's defaults for missing components, and the view's component mapping to the selects; invalid and unsupported views are refused. pso_probe gains a self test that checks words field by field, including the word the translator's own tests use.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 19:16:22 +00:00
github manually merged commit 81bba99929 into gh-pr/55/base 2026-11-26 19:16:24 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.