feat(d3d12_x): create compute pipelines from pipeline state descriptions, cache first #43

Manually merged
github merged 3 commits from gh-pr/43/head into gh-pr/43/base 2026-11-26 19:15:22 +00:00
Owner

@⁠Dark3581 on GitHub · 2026-11-22 20:18 UTC · original
Dark3581:feat/compute-pipeline-state → main · +867 −54 · 23 files · 3 commits · merged 2026-11-22 20:21 UTC

What

The pipeline state path for compute, ready for the device's CreateComputePipelineState once a title's calls show the device's shape:

  • Store format 2: modules.txt is <sha256> <stage> <subgroup> <path>, the subgroup size a pipeline must require (32, 64, or 0 for any) taken from the translation. Copies of one container that disagree on it count as a conflict. The C++ store keeps each module's key and subgroup size. Rebuild an existing store with the shader_store target.
  • pso/PipelineState.cpp: resolves a D3D12_COMPUTE_PIPELINE_STATE_DESC to its stored module through the SHA-256 of the shader container. It refuses a missing shader, a non-DXBC blob, a module whose stage is not cs, any pipeline state flag, and a node other than the first, each with its own error. A cached pipeline blob is ignored (it holds console GPU code) and the root signature is not needed, because every pipeline uses the title layout.
  • vulkan/PipelineLibrary.cpp: creates each pipeline once and is thread-safe (concurrent requests for one key wait for the single creation). It first asks the driver for the pipeline without compiling (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT, the device now enables pipelineCreationCacheControl when offered), compiles only when that fails, and refuses a module over the run-time compile limit instead of compiling it. Some modules need far more memory to compile than a PC can commit; the offline shader_pipelines run fills the cache the title then only loads.
  • Fix: PipelineCache read and wrote its file in one stream call, which fails with the MinGW runtime for a file this size (a title's cache passes 4 GB), so it started empty. It now reads and writes in 64 MiB pieces.

Tested

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

  • New pipeline_state test (fake store with real compute SPIR-V): every resolution error; 6 requests on 4 threads for 2 shaders create 2 pipelines; a saved cache gives ready on the next run (driver reports a cache hit, 0.000 s); with an empty cache, a module over the limit is refused with nothing compiled, and the same module under a higher limit is compiled.
  • anybox-pipeline-probe selftest: file pieces of 4096 and 1000 bytes, whole-file and default sizes, errors and an empty file.
  • On one title's store (26,503 containers, rebuilt in format 2: 4,939 modules require 32, 11,321 require 64, 9,629 any): shaders_store finds all 26,503 with the right stage and subgroup size. New shaders_pso: 12 compute shaders up to 1 MiB go from their carved containers to pipelines; the largest (43 MiB, which needs about 75 GB to compile) is refused in 0.3 s with an empty cache instead of compiled. With the 4.74 GB offline cache (loaded in about 7 s), 9 of the 13 come back ready; the other 3 small ones lie in the part of the offline run that is still going.
  • ctest: 61 of 61. tools/tests: 81. python tools/check_conventions.py: 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: D3D12 D3D12_COMPUTE_PIPELINE_STATE_DESC and Vulkan 1.3 pipeline creation cache control, both public; the translator's index for subgroup sizes
  • AI-assisted: yes
**@⁠Dark3581** on GitHub · 2026-11-22 20:18 UTC · [original](https://github.com/Dark3581/AnyBox/pull/43) `Dark3581:feat/compute-pipeline-state` → `main` · +867 −54 · 23 files · 3 commits · merged 2026-11-22 20:21 UTC ### What The pipeline state path for compute, ready for the device's `CreateComputePipelineState` once a title's calls show the device's shape: - **Store format 2**: `modules.txt` is `<sha256> <stage> <subgroup> <path>`, the subgroup size a pipeline must require (32, 64, or 0 for any) taken from the translation. Copies of one container that disagree on it count as a conflict. The C++ store keeps each module's key and subgroup size. Rebuild an existing store with the `shader_store` target. - **`pso/PipelineState.cpp`**: resolves a `D3D12_COMPUTE_PIPELINE_STATE_DESC` to its stored module through the SHA-256 of the shader container. It refuses a missing shader, a non-DXBC blob, a module whose stage is not `cs`, any pipeline state flag, and a node other than the first, each with its own error. A cached pipeline blob is ignored (it holds console GPU code) and the root signature is not needed, because every pipeline uses the title layout. - **`vulkan/PipelineLibrary.cpp`**: creates each pipeline once and is thread-safe (concurrent requests for one key wait for the single creation). It first asks the driver for the pipeline without compiling (`VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT`, the device now enables `pipelineCreationCacheControl` when offered), compiles only when that fails, and refuses a module over the run-time compile limit instead of compiling it. Some modules need far more memory to compile than a PC can commit; the offline `shader_pipelines` run fills the cache the title then only loads. - **Fix**: `PipelineCache` read and wrote its file in one stream call, which fails with the MinGW runtime for a file this size (a title's cache passes 4 GB), so it started empty. It now reads and writes in 64 MiB pieces. ### Tested Windows 10, MinGW build, RTX 3070 Ti (driver 621.14). - New `pipeline_state` test (fake store with real compute SPIR-V): every resolution error; 6 requests on 4 threads for 2 shaders create 2 pipelines; a saved cache gives `ready` on the next run (driver reports a cache hit, 0.000 s); with an empty cache, a module over the limit is `refused` with nothing compiled, and the same module under a higher limit is `compiled`. - `anybox-pipeline-probe selftest`: file pieces of 4096 and 1000 bytes, whole-file and default sizes, errors and an empty file. - On one title's store (26,503 containers, rebuilt in format 2: 4,939 modules require 32, 11,321 require 64, 9,629 any): `shaders_store` finds all 26,503 with the right stage and subgroup size. New `shaders_pso`: 12 compute shaders up to 1 MiB go from their carved containers to pipelines; the largest (43 MiB, which needs about 75 GB to compile) is refused in 0.3 s with an empty cache instead of compiled. With the 4.74 GB offline cache (loaded in about 7 s), 9 of the 13 come back `ready`; the other 3 small ones lie in the part of the offline run that is still going. - `ctest`: 61 of 61. `tools/tests`: 81. `python tools/check_conventions.py`: 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: D3D12 `D3D12_COMPUTE_PIPELINE_STATE_DESC` and Vulkan 1.3 pipeline creation cache control, both public; the translator's index for subgroup sizes - [x] AI-assisted: yes
modules.txt becomes <sha256> <stage> <subgroup> <path> (store format 2): the subgroup size a pipeline must require, 32, 64 or 0 for any, taken from the translation. Copies of one container that disagree on it are a conflict. The C++ store keeps each module's key and subgroup size.
PipelineState resolves a compute pipeline state description to its stored module. PipelineLibrary creates each pipeline once, thread-safe: it first asks the driver for the pipeline without compiling, compiles only when that fails, and refuses a module over the run-time compile limit instead of compiling it, because some modules need more memory than a PC can commit. Adds the pipeline_state test and the shaders_pso check on a title's own containers.
A title's pipeline cache passes 4 GB, and one stream read or write of that size fails with the MinGW runtime, so PipelineCache started empty on a 4.4 GB cache. ReadWholeFile and WriteWholeFile now move the data in pieces; the probe self test checks odd piece sizes, errors and an empty file.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 19:15:19 +00:00
github manually merged commit 1674fe4d67 into gh-pr/43/base 2026-11-26 19:15:22 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.