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

Merged
derz92 merged 1 commit from upstream-pr/342 into main 2026-11-27 16:04:49 +00:00
derz92 commented 2026-11-27 13:04:45 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by derz92 on 2026-11-27T13:04:45Z.


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)
<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:5527114448 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/342). Originally posted by [derz92](https://github.com/derz92) on 2026-11-27T13:04:45Z. --- ## 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)
LakshanSivakumar commented 2026-11-27 16:05:17 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T16:05:17Z.


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.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7222840659 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/342#issuecomment-7222840659). Originally posted by [LakshanSivakumar](https://github.com/LakshanSivakumar) on 2026-11-27T16:05:17Z. --- 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.
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
LakshanSivakumar/Native-Victory-macOS!342
No description provided.