feat(d3d12_x): look up console shaders in a store of translated SPIR-V #31

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

@⁠Dark3581 on GitHub · 2026-11-22 03:26 UTC · original
Dark3581:feat/shader-store → main · +710 −1 · 11 files · 1 commits · merged 2026-11-22 03:29 UTC

What

Second of the three pull requests planned in #4. Console shaders carry precompiled GPU code and no DXIL, so d3d12_x will take each one from a shader store: SPIR-V modules translated ahead of time by a separate tool. AnyBox contains no translator.

  • Key: SHA-256 of the whole DXBC container, up to the size in its header (bytes after it are ignored, so a longer BytecodeLength still matches). The container's own HASH part is not used: in one title's package 789 HASH values are shared, 496 of them by containers with different bytes.
  • tools/shader_store.py build <carved> <translated> <store> imports a translated shader set (carved .dxbc + carve index.json; <name>.spv + translation index.json with stage) and writes modules.txt (<sha256>\t<stage>\t<path>, paths relative to the store) and modules.json (the translator's per-module details). Byte-identical containers share a module; a hash whose copies translate to different bytes or stages is dropped and counted, as are missing and invalid entries. lookup <store> <container> prints the module for one container.
  • d3d12_x store library (store/ShaderStore.cpp, linked into ab_d3d12_x.dll): parses modules.txt strictly, validates a container, hashes it with BCrypt and traces each hit or miss (ANYBOX_TRACE=d3d12_x). TitleShaderStore() loads once from ANYBOX_SHADER_STORE or shaders beside the executable. Nothing calls it yet; pipeline creation will (debt entry added).
  • Documented under "Shader store" in GAME_TESTING.md and in the USAGE environment table.

Tested

  • Windows 10, MinGW WinLibs GCC 15.2 UCRT, Ninja, Release, clean build directory: no warnings, CTest 55/55; shader_store and lib_rootsig passed 5 repeats.
  • shader_store (CTest): builds a synthetic store with the Python tool (a duplicate, a file name with a space, an untranslated shader), then checks the C++ side: SHA-256 test vectors, container size validation, strict index parsing (bad line, bad stage, missing file), lookups including a miss, agreement with shader_store.py lookup, and TitleShaderStore with and without ANYBOX_SHADER_STORE.
  • test_shader_store (Python): declared-size hashing, duplicate and conflict handling (different bytes, different stage), missing and invalid entries, index round trip and rejection of malformed lines. Full tools suite 56/56.
  • On one title's translated shader set (26,503 containers): the store holds 25,889 modules, 614 duplicates, 0 missing, 0 invalid, 0 conflicts; the C++ lookup found 150 of 150 randomly sampled real containers and agreed with modules.txt on each; loading the 25,889-line index takes about 70 ms. No game data in the PR.
  • check_conventions.py, debt_fold.py --check, progress.py --json pass.

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: DXBC container header (size field at offset 24) as already read by tools/shader_scan.py; SHA-256 through Windows CNG (BCrypt)
  • AI-assisted: yes
**@⁠Dark3581** on GitHub · 2026-11-22 03:26 UTC · [original](https://github.com/Dark3581/AnyBox/pull/31) `Dark3581:feat/shader-store` → `main` · +710 −1 · 11 files · 1 commits · merged 2026-11-22 03:29 UTC ### What Second of the three pull requests planned in #4. Console shaders carry precompiled GPU code and no DXIL, so `d3d12_x` will take each one from a **shader store**: SPIR-V modules translated ahead of time by a separate tool. AnyBox contains no translator. - **Key:** SHA-256 of the whole DXBC container, up to the size in its header (bytes after it are ignored, so a longer `BytecodeLength` still matches). The container's own `HASH` part is not used: in one title's package 789 `HASH` values are shared, 496 of them by containers with different bytes. - **`tools/shader_store.py build <carved> <translated> <store>`** imports a translated shader set (carved `.dxbc` + carve `index.json`; `<name>.spv` + translation `index.json` with `stage`) and writes `modules.txt` (`<sha256>\t<stage>\t<path>`, paths relative to the store) and `modules.json` (the translator's per-module details). Byte-identical containers share a module; a hash whose copies translate to different bytes or stages is dropped and counted, as are missing and invalid entries. `lookup <store> <container>` prints the module for one container. - **`d3d12_x` store library** (`store/ShaderStore.cpp`, linked into `ab_d3d12_x.dll`): parses `modules.txt` strictly, validates a container, hashes it with BCrypt and traces each hit or miss (`ANYBOX_TRACE=d3d12_x`). `TitleShaderStore()` loads once from `ANYBOX_SHADER_STORE` or `shaders` beside the executable. Nothing calls it yet; pipeline creation will (debt entry added). - Documented under "Shader store" in GAME_TESTING.md and in the USAGE environment table. ### Tested - Windows 10, MinGW WinLibs GCC 15.2 UCRT, Ninja, Release, clean build directory: no warnings, CTest 55/55; `shader_store` and `lib_rootsig` passed 5 repeats. - `shader_store` (CTest): builds a synthetic store with the Python tool (a duplicate, a file name with a space, an untranslated shader), then checks the C++ side: SHA-256 test vectors, container size validation, strict index parsing (bad line, bad stage, missing file), lookups including a miss, agreement with `shader_store.py lookup`, and `TitleShaderStore` with and without `ANYBOX_SHADER_STORE`. - `test_shader_store` (Python): declared-size hashing, duplicate and conflict handling (different bytes, different stage), missing and invalid entries, index round trip and rejection of malformed lines. Full tools suite 56/56. - On one title's translated shader set (26,503 containers): the store holds 25,889 modules, 614 duplicates, 0 missing, 0 invalid, 0 conflicts; the C++ lookup found 150 of 150 randomly sampled real containers and agreed with `modules.txt` on each; loading the 25,889-line index takes about 70 ms. No game data in the PR. - `check_conventions.py`, `debt_fold.py --check`, `progress.py --json` pass. ### Checklist <!-- Rules behind each item: CONTRIBUTING.md --> - [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: DXBC container header (size field at offset 24) as already read by `tools/shader_scan.py`; SHA-256 through Windows CNG (BCrypt) - [x] AI-assisted: yes
Console shaders hold precompiled GPU code and no DXIL, so d3d12_x will take each one from a shader store: SPIR-V modules translated ahead of time by a separate tool, keyed by the SHA-256 of the whole DXBC container, since the container's HASH part is shared by different containers. tools/shader_store.py builds modules.txt and modules.json from a translated shader set and checks that byte-identical containers translate identically; the d3d12_x store library parses modules.txt, validates and hashes a container through BCrypt and traces hits and misses. shader_store and test_shader_store cover both sides and that they agree on every key.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 19:14:29 +00:00
github manually merged commit f8b2f50c65 into gh-pr/31/base 2026-11-26 19:14:29 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.