shaders: fill fspx_state_sha256 from library sidecars (FSPX-LIBRARY-STATE-FILL) #2095

Closed
Undefined3301 wants to merge 1 commit from upstream-pr/2095 into main
Undefined3301 commented 2026-11-25 20:04:58 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Undefined3301 on 2026-11-25T20:04:58Z.


Item: FSPX-LIBRARY-STATE-FILL

What

Adds tools/fill_fspx_library_states.py, which fills a missing fspx_state_sha256 in an existing pipeline-library translation index (<shaders>/library/index.json) from its <name>.state sidecars, plus tests/test_fill_fspx_library_states.py (standard library only, synthetic state files).

Why

An FSPX program that carries a kind-0 state is matched by both fspx_code_sha256 and fspx_state_sha256 (ShaderLibrary::program_candidates, runtime/src/shader_library.h). An index entry written before the sidecar key was recorded has the code hash but no state hash, so the incoming state filters every entry out and the pipeline is stubbed even though its translation exists.

Measured

Retail boot, RTX 4080, NVIDIA 621.24: 934 distinct FSPX compute programs reached slot 67 with a kind-0 state and were refused (no translated compute shader ... entries 1). 923 have a translation and a .state sidecar but no state key. After filling the index the count drops to 11 (the 29-program FidelityFX DLL has 27 translated here; 2 still fail the decoder) and those 923 pipelines are created for real. The boot then reaches the story transition instead of stalling one scene earlier.

The 923 entries are translations the current translator no longer reproduces (fall-through into undecodable words), so re-running library_shaders drops them rather than recording the key; the tool repairs an existing work folder in place and is idempotent (second run: 0 added).

Tests

python -I tests/test_fill_fspx_library_states.py     # 5 tests, OK
python -m compileall -q tools/fill_fspx_library_states.py tests/test_fill_fspx_library_states.py

AI-assisted: yes (DeepSeek V4.1 Flash via OpenCode/T3 Code). The tool writes LF and sorts keys atomically like the translator; no game data is in the test.

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5498305222 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/2095). Originally posted by [Undefined3301](https://github.com/Undefined3301) on 2026-11-25T20:04:58Z. --- Item: FSPX-LIBRARY-STATE-FILL ## What Adds `tools/fill_fspx_library_states.py`, which fills a missing `fspx_state_sha256` in an existing pipeline-library translation index (`<shaders>/library/index.json`) from its `<name>.state` sidecars, plus `tests/test_fill_fspx_library_states.py` (standard library only, synthetic state files). ## Why An FSPX program that carries a kind-0 state is matched by both `fspx_code_sha256` and `fspx_state_sha256` (`ShaderLibrary::program_candidates`, `runtime/src/shader_library.h`). An index entry written before the sidecar key was recorded has the code hash but no state hash, so the incoming state filters every entry out and the pipeline is stubbed even though its translation exists. ## Measured Retail boot, RTX 4080, NVIDIA 621.24: 934 distinct FSPX compute programs reached slot 67 with a kind-0 state and were refused (`no translated compute shader ... entries 1`). 923 have a translation and a `.state` sidecar but no state key. After filling the index the count drops to 11 (the 29-program FidelityFX DLL has 27 translated here; 2 still fail the decoder) and those 923 pipelines are created for real. The boot then reaches the story transition instead of stalling one scene earlier. The 923 entries are translations the current translator no longer reproduces (`fall-through into undecodable words`), so re-running `library_shaders` drops them rather than recording the key; the tool repairs an existing work folder in place and is idempotent (second run: 0 added). ## Tests ```` python -I tests/test_fill_fspx_library_states.py # 5 tests, OK python -m compileall -q tools/fill_fspx_library_states.py tests/test_fill_fspx_library_states.py ```` AI-assisted: yes (DeepSeek V4.1 Flash via OpenCode/T3 Code). The tool writes LF and sorts keys atomically like the translator; no game data is in the test.
Undefined3301 commented 2026-11-25 20:22:32 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Undefined3301 on 2026-11-25T20:22:32Z.


Freeing the single open-PR slot that accounts without 2 merged PRs are limited to: the V# 47-bit range fix is the smaller, CPU-test-covered change, so it goes first. The tool and its tests stay on this branch; I will reopen this PR after the next merge (or resubmit it as a finding if the build side is preferred).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7173576831 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/2095#issuecomment-7173576831). Originally posted by [Undefined3301](https://github.com/Undefined3301) on 2026-11-25T20:22:32Z. --- Freeing the single open-PR slot that accounts without 2 merged PRs are limited to: the V# 47-bit range fix is the smaller, CPU-test-covered change, so it goes first. The tool and its tests stay on this branch; I will reopen this PR after the next merge (or resubmit it as a finding if the build side is preferred).

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!2095
No description provided.