feat(d3d12_x): create vertex input from the input layout and the shader's inputs #46

Manually merged
github merged 1 commit from gh-pr/46/head into gh-pr/46/base 2026-11-26 19:15:39 +00:00
Owner

@⁠Dark3581 on GitHub · 2026-11-22 21:06 UTC · original
Dark3581:feat/vertex-input → main · +693 −15 · 17 files · 1 commits · merged 2026-11-22 21:10 UTC

What

Vertex input for graphics pipelines. A translated vertex shader reads each vertex input at the location of its D3D input register (the translator's rule, documented in its design notes), so the runtime has to bind a title's input layout by semantic to those locations.

  • Store format 3: shader_store.py build also writes inputs.txt, one <sha256> <location> <semantic> <index> <type> <mask> line per vertex input, from the translation's vertex_inputs and input signature. A module whose inputs and signature disagree counts as invalid. The C++ store loads it into ShaderModule::inputs and validates every field; a store without inputs.txt asks to be rebuilt.
  • pso/VertexInput.cpp: matches each D3D12_INPUT_ELEMENT_DESC to the vertex shader input with the same semantic name (compared without case, as D3D12 does) and index, at that input's location. D3D12_APPEND_ALIGNED_ELEMENT places an element after the previous one in its slot, aligned to the smaller of 4 bytes and its size. Bindings are per slot, per vertex or per instance, with strides left to draw time (the pipeline already keeps them dynamic). Elements the shader does not read are left out. Refused with an error naming the element: a shader input with no element, a format whose class (float, unsigned, signed) differs from the input's type, instance step rates other than 1, a slot mixing rates, a semantic named twice, unmapped formats, slots past 31 and offsets past 2047.
  • pso_probe: input-selftest, a vertex-input case in graphics-gpu (a test shader with float and unsigned inputs on two slots), and graphics-title, which turns a title's vertex shader into a pipeline through the store, an input layout built from its own signature and the render state path. shaders_pso runs it on eight vertex shaders.

The append alignment is an assumption, recorded in the debt fragment with the other gaps.

Tested

Windows 10, MinGW build, RTX 3070 Ti (driver 621.14).

  • pso_probe input-selftest: offsets with appended elements of 1, 2 and 4 bytes, two slots with per-instance data, an empty layout, format sizes and classes, 13 refusals with their messages.
  • pso_probe graphics-gpu --validate: 8 pipelines (the 7 from #44 plus vertex input), 0 validation errors.
  • On one title's store, rebuilt in format 3 (1,776 inputs across 787 vertex shaders): shaders_store finds all 26,503 containers with stage, subgroup size and input count matching the translation; shaders_pso turns 8 sampled title vertex shaders with 1 to 3 inputs into graphics pipelines, and its compute and offline-cache parts still pass.
  • ctest: 66 of 66. tools/tests: 82. python tools/check_conventions.py: ok. No bare std::min/std::max (#38, #45).

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 input layout documentation; the translator's documented vertex input rule (location = D3D input register)
  • AI-assisted: yes
**@⁠Dark3581** on GitHub · 2026-11-22 21:06 UTC · [original](https://github.com/Dark3581/AnyBox/pull/46) `Dark3581:feat/vertex-input` → `main` · +693 −15 · 17 files · 1 commits · merged 2026-11-22 21:10 UTC ### What Vertex input for graphics pipelines. A translated vertex shader reads each vertex input at the location of its D3D input register (the translator's rule, documented in its design notes), so the runtime has to bind a title's input layout by semantic to those locations. - **Store format 3**: `shader_store.py build` also writes `inputs.txt`, one `<sha256> <location> <semantic> <index> <type> <mask>` line per vertex input, from the translation's `vertex_inputs` and input signature. A module whose inputs and signature disagree counts as invalid. The C++ store loads it into `ShaderModule::inputs` and validates every field; a store without `inputs.txt` asks to be rebuilt. - **`pso/VertexInput.cpp`**: matches each `D3D12_INPUT_ELEMENT_DESC` to the vertex shader input with the same semantic name (compared without case, as D3D12 does) and index, at that input's location. `D3D12_APPEND_ALIGNED_ELEMENT` places an element after the previous one in its slot, aligned to the smaller of 4 bytes and its size. Bindings are per slot, per vertex or per instance, with strides left to draw time (the pipeline already keeps them dynamic). Elements the shader does not read are left out. Refused with an error naming the element: a shader input with no element, a format whose class (float, unsigned, signed) differs from the input's type, instance step rates other than 1, a slot mixing rates, a semantic named twice, unmapped formats, slots past 31 and offsets past 2047. - `pso_probe`: `input-selftest`, a vertex-input case in `graphics-gpu` (a test shader with float and unsigned inputs on two slots), and `graphics-title`, which turns a title's vertex shader into a pipeline through the store, an input layout built from its own signature and the render state path. `shaders_pso` runs it on eight vertex shaders. The append alignment is an assumption, recorded in the debt fragment with the other gaps. ### Tested Windows 10, MinGW build, RTX 3070 Ti (driver 621.14). - `pso_probe input-selftest`: offsets with appended elements of 1, 2 and 4 bytes, two slots with per-instance data, an empty layout, format sizes and classes, 13 refusals with their messages. - `pso_probe graphics-gpu --validate`: 8 pipelines (the 7 from #44 plus vertex input), 0 validation errors. - On one title's store, rebuilt in format 3 (1,776 inputs across 787 vertex shaders): `shaders_store` finds all 26,503 containers with stage, subgroup size and input count matching the translation; `shaders_pso` turns 8 sampled title vertex shaders with 1 to 3 inputs into graphics pipelines, and its compute and offline-cache parts still pass. - `ctest`: 66 of 66. `tools/tests`: 82. `python tools/check_conventions.py`: ok. No bare `std::min`/`std::max` (#38, #45). ### 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 input layout documentation; the translator's documented vertex input rule (location = D3D input register) - [x] AI-assisted: yes
The store writes inputs.txt (format 3): each vertex shader input's location, which the translator sets to its D3D input register, with its semantic, index, component type and mask, and the C++ store loads it. VertexInput matches the input layout's elements to those inputs by semantic name and index, places appended elements, builds per-vertex and per-instance bindings with strides left to draw time, and refuses uncovered inputs, type mismatches, other step rates and unmapped formats. pso_probe gains a self test, a GPU case with real vertex inputs and graphics-title, which shaders_pso runs on eight of a title's vertex shaders.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 19:15:38 +00:00
github manually merged commit 915fd5c2ba into gh-pr/46/base 2026-11-26 19:15:39 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.