shader: key cached translations on the translator's own dependencies, not the whole Cargo.lock #343

Manually merged
github merged 1 commit from github-bot/gh-342 into main 2026-11-27 16:13:14 +00:00 AGit
Owner

@⁠derz92 on GitHub · 2026-11-27 13:04 UTC · original
derz92:fix/shader-key-own-dependencies → main · +186 −11 · 5 files · 1 commits · merged 2026-11-27 16:04 UTC

What this changes

Refs #334.

VICTORY_SHADER_SOURCE_HASH, the build key of the native shader disk cache, no longer hashes the whole workspace Cargo.lock. It takes the lock entries (name version source checksum) of the packages victory-shader depends on, directly or not, and still takes the translator's sources, manifest, build script and the rustc version. Bumping a crate the translator uses still changes the key; a dependency added or bumped elsewhere in the workspace no longer makes the next launch a cold start.

The lock reading is in crates/victory-shader/lock.rs. build.rs includes it, and so does a test module (src/lock_tests.rs). lock.rs itself is hashed. cargo:rerun-if-changed still watches Cargo.lock, so the key is recomputed whenever the lock file changes, and stays the same unless the translator's part of it changed. docs/native-host.md says what the key holds.

How it was tested

  • Effect, measured: with this change, the key was ef9a2da70d8d8b55 before and after adding a path dependency to apps/victory (which changes Cargo.lock). On main the same edit changed the key, and the next run translated 3,483 shaders before the story load where the run before translated none. The boot stuttered for about 50 s (#332 has the pacing numbers).
  • cargo test -p victory-shader: 357 passed. New: lock_tests::the_key_takes_the_translator_s_dependencies_only (a synthetic lock file: an app's dependency changing leaves the entries alone; a dependency of a dependency changing, in a lock holding two versions of it, changes them), and the_workspace_lock_file_names_the_translator_s_dependencies (the real lock file gives miniz_oxide and thiserror, and not victory-shader itself). tests::test_modules_are_test_only passes with the new *_tests.rs module.
  • cargo test --target x86_64-apple-darwin -p victory-hle -p victory-loader -p victory: all pass except host_posix::ucrt::tests::dlls_that_are_not_the_c_runtime_are_left_alone, which fails the same way on main at 86786a72.
  • cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings
  • cargo xtask policy
  • Ran the game: not needed. The change only decides which cached translations stay valid. Apple M5 Max, macOS 26.5.

Checklist

  • No game files, game code, disassembly listings or SDK files are included
  • Guesses about undocumented console behaviour are marked in the code and in docs/native-host.md (none)
  • New diagnostics are behind a VICTORY_* variable and documented (none)
**@⁠derz92** on GitHub · 2026-11-27 13:04 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/342) `derz92:fix/shader-key-own-dependencies` → `main` · +186 −11 · 5 files · 1 commits · merged 2026-11-27 16:04 UTC ## What this changes Refs #334. `VICTORY_SHADER_SOURCE_HASH`, the build key of the native shader disk cache, no longer hashes the whole workspace `Cargo.lock`. It takes the lock entries (`name version source checksum`) of the packages `victory-shader` depends on, directly or not, and still takes the translator's sources, manifest, build script and the rustc version. Bumping a crate the translator uses still changes the key; a dependency added or bumped elsewhere in the workspace no longer makes the next launch a cold start. The lock reading is in `crates/victory-shader/lock.rs`. `build.rs` includes it, and so does a test module (`src/lock_tests.rs`). `lock.rs` itself is hashed. `cargo:rerun-if-changed` still watches `Cargo.lock`, so the key is recomputed whenever the lock file changes, and stays the same unless the translator's part of it changed. docs/native-host.md says what the key holds. ## How it was tested - **Effect, measured:** with this change, the key was `ef9a2da70d8d8b55` before and after adding a path dependency to `apps/victory` (which changes `Cargo.lock`). On main the same edit changed the key, and the next run translated 3,483 shaders before the story load where the run before translated none. The boot stuttered for about 50 s (#332 has the pacing numbers). - [x] `cargo test -p victory-shader`: 357 passed. New: `lock_tests::the_key_takes_the_translator_s_dependencies_only` (a synthetic lock file: an app's dependency changing leaves the entries alone; a dependency of a dependency changing, in a lock holding two versions of it, changes them), and `the_workspace_lock_file_names_the_translator_s_dependencies` (the real lock file gives `miniz_oxide` and `thiserror`, and not `victory-shader` itself). `tests::test_modules_are_test_only` passes with the new `*_tests.rs` module. - [x] `cargo test --target x86_64-apple-darwin -p victory-hle -p victory-loader -p victory`: all pass except `host_posix::ucrt::tests::dlls_that_are_not_the_c_runtime_are_left_alone`, which fails the same way on main at 86786a72. - [x] `cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings` - [x] `cargo xtask policy` - [ ] Ran the game: not needed. The change only decides which cached translations stay valid. Apple M5 Max, macOS 26.5. ## Checklist - [x] No game files, game code, disassembly listings or SDK files are included - [x] Guesses about undocumented console behaviour are marked in the code and in docs/native-host.md (none) - [x] New diagnostics are behind a `VICTORY_*` variable and documented (none)
VICTORY_SHADER_SOURCE_HASH folded in the whole workspace lock file, so a
dependency added or bumped anywhere (an app's, a test tool's) made every
cached translation cold: about 16,000 shaders translated again at the
next launch, and the boot stuttered. It now takes the lock entries of the
packages victory-shader depends on, directly or not (lock.rs, included by
build.rs and by the tests).

Refs #334
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 13:08:29 +00:00
github manually merged commit 1940b142c6 into main 2026-11-27 16:13:14 +00:00
Author
Owner

@⁠LakshanSivakumar on GitHub · 2026-11-27 16:05 UTC · original

Merged in be7dc1b5 with the other shader PRs from tonight. Ran the tests (native arm64), Windows clippy, the policy check and a release build on the merged tree, and swept my full corpus of 21,600 shaders before and after: 0 lost, 352 newly translated, every changed output accounted for. I have not run the game on it yet. Thanks.

**@⁠LakshanSivakumar** on GitHub · 2026-11-27 16:05 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/342#issuecomment-7222840659) Merged in be7dc1b5 with the other shader PRs from tonight. Ran the tests (native arm64), Windows clippy, the policy check and a release build on the merged tree, and swept my full corpus of 21,600 shaders before and after: 0 lost, 352 newly translated, every changed output accounted for. I have not run the game on it yet. Thanks.
This discussion has been locked. Commenting is limited to contributors.
No description provided.