fix(vk): a new Program member no longer drops every player's shader cache #3059

Merged
HumanBean merged 1 commit from HumanBean/Longshot:fix/shader-cache-stamp into main 2026-12-03 07:56:58 +00:00
Owner

Summary

Some updates made every player prepare all their shaders again although nothing about the shaders had changed. One cause: the shader caches' stamp held sizeof(Program), so any member added to that struct, even one only the running game reads, dropped every cache (251.6 s on a Steam Deck in a tester's run of #223). A cache record is written field by field, so that size measured only members nobody stores.

This takes it out of the stamp, and adds two inputs the stamp missed: the compute mesh path's record layout as resolved (its default lives in mesh_mode.h, which no stamp held) and libstdc++'s version. A new check holds what the stamp takes, what is written as it lies, and which headers the stamped files include.

Read first: translator_stamp in gpu/vk/vk_shader.cpp, then tests/test_translator_stamp_inputs.py.

Not done here: tracking which translator parts each program used. By the files they touch, 18 of the 20 translator changes since v3.1.0 changed shared code and would still have redone everything, so it is not worth its risk as designed.

Fixes #1510

Testing

Tested: Linux, RTX 3090 (NVIDIA 620.70.06). dev.py rt built and prepared 38,809 programs; dev.py smoke passed (in play from kokiri-start, 900 frames, the menu opened). Then a throwaway build with an unused member added to Program was run on the same folder: the log says 544 program keys kept, 1375 KB, the programs the first run translated (the sandboxed run keeps its own longshot_programs.fallback.bin). tests/test_translator_stamp_inputs.py passes here and fails on main (sizeof(Program)). mise run test: 864 passed, 6 failed, 12 skipped; all six failing files also fail on main @ 9a926c2e.

Still to test:

  • Windows: build and start the game, expecting one shader preparation and none at the start after it (by hand)

Measurements

Nothing to measure: no speed or picture change. The effect is whether a cache is kept, shown in Testing.

Risks

The stamp moves once, so the first start after this prepares the shaders again. main already changed translator files since v3.2.0, so stable players pay nothing extra; nightly players pay it once.

A member added to Program that does need keeping must be written in put_head/program_cache_save and take a new kProgramCacheFormat; before, the size change dropped the old cache by accident. Reverting is enough.

Checklist

Ready for review

  • One topic, on current main; the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says.
  • mise run test passes (any failure that also fails on main is named): test_framegen_auto_dlss, test_menu_ini_keys, test_option_ids, test_settings_area_keys, test_vk_wb_cpu_words_fast and test_lifter also fail on main @ 9a926c2e.
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • A fix: a game-free test that fails on main and passes here.
  • A check under tests/ that reads changed source is updated, not weakened.
  • Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

🤖 Generated with Claude Code

## Summary Some updates made every player prepare all their shaders again although nothing about the shaders had changed. One cause: the shader caches' stamp held `sizeof(Program)`, so any member added to that struct, even one only the running game reads, dropped every cache (251.6 s on a Steam Deck in a tester's run of #223). A cache record is written field by field, so that size measured only members nobody stores. This takes it out of the stamp, and adds two inputs the stamp missed: the compute mesh path's record layout as resolved (its default lives in `mesh_mode.h`, which no stamp held) and libstdc++'s version. A new check holds what the stamp takes, what is written as it lies, and which headers the stamped files include. Read first: `translator_stamp` in `gpu/vk/vk_shader.cpp`, then `tests/test_translator_stamp_inputs.py`. Not done here: tracking which translator parts each program used. By the files they touch, 18 of the 20 translator changes since v3.1.0 changed shared code and would still have redone everything, so it is not worth its risk as designed. Fixes #1510 ## Testing **Tested:** Linux, RTX 3090 (NVIDIA 620.70.06). `dev.py rt` built and prepared 38,809 programs; `dev.py smoke` passed (in play from `kokiri-start`, 900 frames, the menu opened). Then a throwaway build with an unused member added to `Program` was run on the same folder: the log says `544 program keys kept, 1375 KB`, the programs the first run translated (the sandboxed run keeps its own `longshot_programs.fallback.bin`). `tests/test_translator_stamp_inputs.py` passes here and fails on `main` (`sizeof(Program)`). `mise run test`: 864 passed, 6 failed, 12 skipped; all six failing files also fail on `main` @ 9a926c2e. **Still to test:** - Windows: build and start the game, expecting one shader preparation and none at the start after it (by hand) ## Measurements Nothing to measure: no speed or picture change. The effect is whether a cache is kept, shown in Testing. ## Risks The stamp moves once, so the first start after this prepares the shaders again. `main` already changed translator files since v3.2.0, so stable players pay nothing extra; nightly players pay it once. A member added to `Program` that does need keeping must be written in `put_head`/`program_cache_save` and take a new `kProgramCacheFormat`; before, the size change dropped the old cache by accident. Reverting is enough. ## Checklist ### Ready for review - [x] One topic, on current `main`; the title is a Conventional Commit. - [x] Tested on my own PC, in the game for a change the game runs, as Testing says. - [x] `mise run test` passes (any failure that also fails on `main` is named): `test_framegen_auto_dlss`, `test_menu_ini_keys`, `test_option_ids`, `test_settings_area_keys`, `test_vk_wb_cpu_words_fast` and `test_lifter` also fail on `main` @ 9a926c2e. - [x] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [x] A fix: a game-free test that fails on `main` and passes here. - [x] A check under `tests/` that reads changed source is updated, not weakened. - [ ] Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
fix(vk): the shader caches' stamp no longer holds Program's size, and holds the compute mesh layout and libstdc++'s version
Some checks failed
CI / What the change needs (pull_request) Successful in 8s
CI / Third-party parts and guide screenshots (pull_request) Successful in 12s
PR description / Title and description (pull_request_target) Failing after 6s
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Successful in 19s
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Failing after 13m1s
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Failing after 1m26s
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Successful in 14m40s
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Successful in 13m8s
CI / Website build and checks (pull_request) Failing after 35s
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Failing after 48m10s
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Failing after 1h0m10s
a7e1fa017a
A record is written field by field, so sizeof(Program) measured only members nobody stores: any one added made every
player prepare every shader again (251.6 s on a Steam Deck in a tester's run). The compute mesh path's default record
layout (mesh_mode.h) and libstdc++'s version were inputs the stamp missed. A new game-free check holds what the stamp
takes, what is written as it lies, and which headers the stamped files include.

Moves the stamp once. Closes #1510.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Author
Owner

Tested in game: Linux, RTX 3090, NVIDIA 620.70.06: dev.py smoke from kokiri-start passed (900 frames in play, the menu opened). A second run with a throwaway build that adds a member to Program kept all 544 program keys the first run translated.

Tested in game: Linux, RTX 3090, NVIDIA 620.70.06: dev.py smoke from kokiri-start passed (900 frames in play, the menu opened). A second run with a throwaway build that adds a member to Program kept all 544 program keys the first run translated.
HumanBean changed title from WIP: fix(vk): a new Program member no longer drops every player's shader cache to fix(vk): a new Program member no longer drops every player's shader cache 2026-12-03 07:56:54 +00:00
HumanBean deleted branch fix/shader-cache-stamp 2026-12-03 07:56:58 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
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.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!3059
No description provided.