Shaders: pipeline cache joined to the programs (shader-bindings --cache) #155

Manually merged
github merged 4 commits from gh-pr/155/head into gh-pr/155/base 2026-11-26 20:13:54 +00:00
Owner

@⁠holdmysocks on GitHub · 2026-11-24 13:28 UTC · original
holdmysocks:claude/shader-pipeline-cache → master · +303 −7 · 3 files · 4 commits · merged 2026-11-24 13:41 UTC

Second part of SIX-95, on top of #147 (merged).

What

sixng shader-bindings --cache also reads the pipeline cache (the compressed entry of shaders.rpf) and joins its stages to the compiled programs.

  • Cache layout (as reported, and confirmed on the data): a 0x80-byte header, graphics pipeline records of 0x70 bytes, compute pipeline records of 0x18 bytes, a metadata directory and a code directory of 8 bytes per entry, the metadata area, the code area. The areas add up to the file size exactly.
  • Stage metadata: a 16- or 24-byte header and 32-byte records. 0x42 = a resource the compiled code uses (access, type, register, space); 0x43 = a 16-byte digest that is also in the compiled program, which joins a stage to a program record.
  • Join to the declarations of #147: a read record's space and register equal a declared resource's (flag 0x40 = space 1, 0x80 = space 2, the material's; register = index, plus 256 for kinds with bit 0x80).
  • With --programs --cache every declared resource of a program gets used: true / false, and the program gets compiled.pipelines.

Checked on the game data

  • 25,471 graphics and 2,693 compute pipelines; 54,576 metadata blobs, of which 20,318 are stage blobs; 21,522 code blobs.
  • 18,642 of the 24,804 programs are a stage of some pipeline; 6,162 are in none.
  • All 313,482 read records match a declared resource of the same program; none is unmatched. This also pins the meaning of the scope flags that #147 left open.
  • 22,583 declared resources are never read by the compiled code (samplers are counted here too: the cache has no sampler records).
  • About 6 s. cargo test -p sixng-core: 164 passed (one new test on a synthetic cache).

Not decoded

  • The 31,984 write records: their registers follow another numbering that was not worked out, so written resources are listed but not matched to declarations.
  • The 0x41 records (where the code finds each resource), the state and vertex-layout blobs, and the code itself.
  • A program that several pipelines use is read from the stage blob of one of them; the blobs were not compared with each other.
  • This still does not name the unnamed texture parameters, and material textures still do not appear as bindings: a material's textures are reached through its constant buffer (space 2).
**@⁠holdmysocks** on GitHub · 2026-11-24 13:28 UTC · [original](https://github.com/holdmysocks/SixNG/pull/155) `holdmysocks:claude/shader-pipeline-cache` → `master` · +303 −7 · 3 files · 4 commits · merged 2026-11-24 13:41 UTC Second part of SIX-95, on top of #147 (merged). ## What `sixng shader-bindings --cache` also reads the pipeline cache (the compressed entry of `shaders.rpf`) and joins its stages to the compiled programs. - **Cache layout** (as reported, and confirmed on the data): a 0x80-byte header, graphics pipeline records of 0x70 bytes, compute pipeline records of 0x18 bytes, a metadata directory and a code directory of 8 bytes per entry, the metadata area, the code area. The areas add up to the file size exactly. - **Stage metadata**: a 16- or 24-byte header and 32-byte records. `0x42` = a resource the compiled code uses (access, type, register, space); `0x43` = a 16-byte digest that is also in the compiled program, which joins a stage to a program record. - **Join to the declarations of #147**: a read record's space and register equal a declared resource's (flag 0x40 = space 1, 0x80 = space 2, the material's; register = index, plus 256 for kinds with bit 0x80). - With `--programs --cache` every declared resource of a program gets `used: true / false`, and the program gets `compiled.pipelines`. ## Checked on the game data - 25,471 graphics and 2,693 compute pipelines; 54,576 metadata blobs, of which 20,318 are stage blobs; 21,522 code blobs. - 18,642 of the 24,804 programs are a stage of some pipeline; 6,162 are in none. - **All 313,482 read records match a declared resource of the same program; none is unmatched.** This also pins the meaning of the scope flags that #147 left open. - 22,583 declared resources are never read by the compiled code (samplers are counted here too: the cache has no sampler records). - About 6 s. `cargo test -p sixng-core`: 164 passed (one new test on a synthetic cache). ## Not decoded - The 31,984 write records: their registers follow another numbering that was not worked out, so written resources are listed but not matched to declarations. - The `0x41` records (where the code finds each resource), the state and vertex-layout blobs, and the code itself. - A program that several pipelines use is read from the stage blob of one of them; the blobs were not compared with each other. - This still does not name the unnamed texture parameters, and material textures still do not appear as bindings: a material's textures are reached through its constant buffer (space 2).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 20:13:51 +00:00
github manually merged commit 5e1eba210c into gh-pr/155/base 2026-11-26 20:13:54 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.