feat(d3d12_x): create the Vulkan device, the title layout and compute pipelines #34

Manually merged
github merged 1 commit from gh-pr/34/head into gh-pr/34/base 2026-11-26 19:14:43 +00:00
Owner

@⁠Dark3581 on GitHub · 2026-11-22 10:21 UTC · original
Dark3581:feat/vulkan-pipelines → main · +1756 −57 · 19 files · 1 commits · merged 2026-11-22 10:23 UTC

What

The runtime half of the Vulkan backend planned in #4, up to what can be built without a title's executable: the device, the pipeline layout the translated shaders expect, and compute pipeline creation from the shader store.

  • VulkanDevice picks a Vulkan 1.3 GPU that supports every shader feature a store names (discrete first), enables exactly those plus the bindless layout's descriptor-indexing features (partially bound, sampled and storage image update-after-bind) and subgroup size control, and opens one graphics and compute queue. An unknown feature name stops device creation rather than being ignored. The layout's descriptor counts are checked against the device's update-after-bind limits. Optional validation loads the Khronos layer and counts its errors through a debug messenger.
  • TitleLayout: set 0 with twenty bindings (2D, 2D-array, 1D and 3D sampled images, samplers, the descriptor hash table as a storage buffer, and 2D, 2D-array, 3D and 1D storage images per component class) and a 144-byte push constant range for all stages. The binding types come from what the translated modules declare; array sizes are AnyBox's choice and recorded as debt.
  • PipelineCompiler: reads and checks SPIR-V, creates compute pipelines (requiring the module's subgroup size when the device can), and keeps a pipeline cache on disk that is reused only when its header matches this GPU and driver and is replaced atomically. Batches run small modules in parallel, then each module over 4 MiB alone: large modules need several GB each inside the driver, and compiling them side by side can run out of memory.
  • anybox-pipeline-probe (layout, selftest, validation, compile) and tools/spirv_layout.py, which reads the descriptor bindings a SPIR-V module declares and compares them with the layout.
  • Tests: pipeline_probe (layout contents; device, compile, cache save and reload, a foreign cache rejected, both batch modes; and a 160-byte push constant block that the validation layer must catch), tools_test_spirv_layout, and with the shader options from #33 shaders_layout (every stored module against the layout) and shaders_compute (60 evenly spaced compute modules up to 1 MiB, validated).
  • Debt fragment for VulkanDevice, TitleLayout and PipelineCompiler.

Graphics pipelines are not here: they need the title's pipeline state, which only its pipeline creation calls give.

Tested

  • Windows 10, MinGW GCC 15.2, RTX 3070 Ti (driver Vulkan 1.4.357), Vulkan SDK 1.4.363 validation layer: 60 of 60 tests pass without the shader options; check_conventions.py and debt_fold.py --check pass.
  • On one title's store (25,889 modules, current upstream translator): shaders_layout finds all 25,889 modules fit the layout, largest push constant use 144 bytes; shaders_compute compiles 60 of 60 with 0 validation errors. A wider manual run compiled 120 of 120 compute modules up to 5.9 MB, evenly spaced over the store, with 0 validation errors (82 with subgroup size 32 required, 38 wave64-emulated at any size; 1,098 s, 85 MB cache). The validation self-test shows the layer catches a push constant range outside the layout. No game data in the PR.

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: #33 (merged)
  • Fixes: none
  • Unblocks: none
  • Source of behaviour: binding types and push constant size read from translated modules (tools/spirv_layout.py); Vulkan behaviour from the Vulkan 1.3 specification and the Khronos validation layer
  • AI-assisted: yes
**@⁠Dark3581** on GitHub · 2026-11-22 10:21 UTC · [original](https://github.com/Dark3581/AnyBox/pull/34) `Dark3581:feat/vulkan-pipelines` → `main` · +1756 −57 · 19 files · 1 commits · merged 2026-11-22 10:23 UTC ### What The runtime half of the Vulkan backend planned in #4, up to what can be built without a title's executable: the device, the pipeline layout the translated shaders expect, and compute pipeline creation from the shader store. - **`VulkanDevice`** picks a Vulkan 1.3 GPU that supports every shader feature a store names (discrete first), enables exactly those plus the bindless layout's descriptor-indexing features (partially bound, sampled and storage image update-after-bind) and subgroup size control, and opens one graphics and compute queue. An unknown feature name stops device creation rather than being ignored. The layout's descriptor counts are checked against the device's update-after-bind limits. Optional validation loads the Khronos layer and counts its errors through a debug messenger. - **`TitleLayout`**: set 0 with twenty bindings (2D, 2D-array, 1D and 3D sampled images, samplers, the descriptor hash table as a storage buffer, and 2D, 2D-array, 3D and 1D storage images per component class) and a 144-byte push constant range for all stages. The binding types come from what the translated modules declare; array sizes are AnyBox's choice and recorded as debt. - **`PipelineCompiler`**: reads and checks SPIR-V, creates compute pipelines (requiring the module's subgroup size when the device can), and keeps a pipeline cache on disk that is reused only when its header matches this GPU and driver and is replaced atomically. Batches run small modules in parallel, then each module over 4 MiB alone: large modules need several GB each inside the driver, and compiling them side by side can run out of memory. - **`anybox-pipeline-probe`** (`layout`, `selftest`, `validation`, `compile`) and **`tools/spirv_layout.py`**, which reads the descriptor bindings a SPIR-V module declares and compares them with the layout. - Tests: `pipeline_probe` (layout contents; device, compile, cache save and reload, a foreign cache rejected, both batch modes; and a 160-byte push constant block that the validation layer must catch), `tools_test_spirv_layout`, and with the shader options from #33 `shaders_layout` (every stored module against the layout) and `shaders_compute` (60 evenly spaced compute modules up to 1 MiB, validated). - Debt fragment for `VulkanDevice`, `TitleLayout` and `PipelineCompiler`. Graphics pipelines are not here: they need the title's pipeline state, which only its pipeline creation calls give. ### Tested - Windows 10, MinGW GCC 15.2, RTX 3070 Ti (driver Vulkan 1.4.357), Vulkan SDK 1.4.363 validation layer: 60 of 60 tests pass without the shader options; `check_conventions.py` and `debt_fold.py --check` pass. - On one title's store (25,889 modules, current upstream translator): `shaders_layout` finds all 25,889 modules fit the layout, largest push constant use 144 bytes; `shaders_compute` compiles 60 of 60 with 0 validation errors. A wider manual run compiled 120 of 120 compute modules up to 5.9 MB, evenly spaced over the store, with 0 validation errors (82 with subgroup size 32 required, 38 wave64-emulated at any size; 1,098 s, 85 MB cache). The validation self-test shows the layer catches a push constant range outside the layout. No game data in the PR. ### 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: #33 (merged) - [x] Fixes: none - [x] Unblocks: none - [x] Source of behaviour: binding types and push constant size read from translated modules (`tools/spirv_layout.py`); Vulkan behaviour from the Vulkan 1.3 specification and the Khronos validation layer - [x] AI-assisted: yes
VulkanDevice picks a Vulkan 1.3 GPU that supports every shader feature a
store names and enables exactly those plus the bindless layout's
descriptor-indexing features. TitleLayout is set 0 and the 144-byte push
constant range the translated modules declare. PipelineCompiler builds
compute pipelines from stored modules with a pipeline cache that is only
reused on the same GPU and driver, compiling large modules one at a time.
anybox-pipeline-probe drives it, and the shaders_layout and shaders_compute
tests check it against a title's whole store.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 19:14:41 +00:00
github manually merged commit e938cb0a82 into gh-pr/34/base 2026-11-26 19:14:43 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.