translate: --cache DIR fills the runtime's shader cache #1729

Closed
Nixitov wants to merge 5 commits from upstream-pr/1730 into main
Nixitov commented 2026-11-24 21:28:05 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Nixitov on 2026-11-24T21:28:05Z.


What it did

victory translate translated every shader in a pack and printed the report, and threw the translations away. The runtime then translated the same containers again the first time a frame asked for them, inside the frame path.

What it does now

  • victory_gpu::shader_cache::store(container, shader) publishes a translation through victory-pipeline's cache under exactly the key host_shader reads (this build's fingerprint and the container's bytes) and with the same encoding, so the runtime finds it as a hit. Cache::store is public now (split out of get_or_convert, same write-then-rename) so an entry the caller already converted can be published without translating a second time.
  • Container::bytes() is the container cut where its header says it ends. A walk finds containers inside larger files, and hashing the file's tail would key every entry where the runtime never looks, since the runtime passes exactly the container.
  • victory translate --cache DIR opens the runtime's cache and stores one entry per container, for the program emit::translate picks (the first VS/PS/CS/MS program), which is the one the runtime caches. Duplicate containers, which the report counts once, are still translated and stored as the runtime would. The last line says how many entries were written and where.
  • A run prints how far it has got to stderr every five seconds. A full pack walk is ~110 s and previously printed nothing until the end, which looked like a hang.

Measured

RTX 5070, Windows 11 26200.9974, driver 617.14:

  • A full pack walk: 23,230 translations in 110 s, 22,625 entries written.
  • The next victory run against that cache: 1,578 hits, 0 misses. The startup pipeline backlog falls from a peak of 652 "being made" to 200 (a run against the same cache a second time).
  • No frame-rate claim: the frame here is GPU-bound. What changes is that translation leaves the frame path.

Tested

Base main ffe310e:

  • cargo build --release -p victory: clean.
  • cargo test --release -p victory-gpu: 52 passed, 1 ignored, including shader_cache::tests::a_stored_translation_is_what_host_shader_returns (store then host_shader returns the same DXIL, so both key alike) and entries_round_trip_and_reject_damage.
  • cargo test --release -p victory-shader dxbc: 3 passed, including bytes_stop_where_the_header_says (a container followed by other bytes hashes only its own).
  • cargo test --release -p victory-pipeline: passed.
  • cargo clippy --workspace --all-targets --locked -- -D warnings, with and without --all-features: clean.
  • victory translate <a container> --cache DIR opens the folder and reports the entries written.

No game data.

AI-assisted (DeepSeek V4.1 Flash coding agent).

<!-- greyfinch-sync:Marvisak/VIctory:issue:6591768621 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1730). Originally posted by [Nixitov](https://github.com/Nixitov) on 2026-11-24T21:28:05Z. --- ## What it did `victory translate` translated every shader in a pack and printed the report, and threw the translations away. The runtime then translated the same containers again the first time a frame asked for them, inside the frame path. ## What it does now - `victory_gpu::shader_cache::store(container, shader)` publishes a translation through `victory-pipeline`'s cache under exactly the key `host_shader` reads (this build's fingerprint and the container's bytes) and with the same encoding, so the runtime finds it as a hit. `Cache::store` is public now (split out of `get_or_convert`, same write-then-rename) so an entry the caller already converted can be published without translating a second time. - `Container::bytes()` is the container cut where its header says it ends. A walk finds containers inside larger files, and hashing the file's tail would key every entry where the runtime never looks, since the runtime passes exactly the container. - `victory translate --cache DIR` opens the runtime's cache and stores one entry per container, for the program `emit::translate` picks (the first VS/PS/CS/MS program), which is the one the runtime caches. Duplicate containers, which the report counts once, are still translated and stored as the runtime would. The last line says how many entries were written and where. - A run prints how far it has got to stderr every five seconds. A full pack walk is ~110 s and previously printed nothing until the end, which looked like a hang. ## Measured RTX 5070, Windows 11 26200.9974, driver 617.14: - A full pack walk: 23,230 translations in 110 s, 22,625 entries written. - The next `victory run` against that cache: 1,578 hits, 0 misses. The startup pipeline backlog falls from a peak of 652 "being made" to 200 (a run against the same cache a second time). - No frame-rate claim: the frame here is GPU-bound. What changes is that translation leaves the frame path. ## Tested Base `main` `ffe310e`: - `cargo build --release -p victory`: clean. - `cargo test --release -p victory-gpu`: 52 passed, 1 ignored, including `shader_cache::tests::a_stored_translation_is_what_host_shader_returns` (store then `host_shader` returns the same DXIL, so both key alike) and `entries_round_trip_and_reject_damage`. - `cargo test --release -p victory-shader dxbc`: 3 passed, including `bytes_stop_where_the_header_says` (a container followed by other bytes hashes only its own). - `cargo test --release -p victory-pipeline`: passed. - `cargo clippy --workspace --all-targets --locked -- -D warnings`, with and without `--all-features`: clean. - `victory translate <a container> --cache DIR` opens the folder and reports the entries written. No game data. AI-assisted (DeepSeek V4.1 Flash coding agent).
catminou4 commented 2026-11-24 22:02:08 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T21:41:06Z.

Review: APPROVED


Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (ffe310e), cargo test -p victory-pipeline --locked → 5 passed, 0 failed. Windows-gated execution/hardware tests only run on Windows.

translate --cache DIR fills the runtime's shader cache: CacheFill::open uses victory_gpu::shader_cache on Windows (with a not(windows) fallback), key_input hashes container+build, store/publish do atomic replace, and two pipeline-cache tests pin store-replaces-without-converting and stored==host_shader output. The bulk of the diff (apps translate CLI, gpu shader_cache, README/docs) is Windows-only; the pipeline cache logic is what macOS verified.

<!-- greyfinch-sync:Marvisak/VIctory:review:6047861252 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1730#pullrequestreview-6047861252). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T21:41:06Z. **Review:** APPROVED --- Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (ffe310e), cargo test -p victory-pipeline --locked → 5 passed, 0 failed. Windows-gated execution/hardware tests only run on Windows. translate --cache DIR fills the runtime's shader cache: CacheFill::open uses victory_gpu::shader_cache on Windows (with a not(windows) fallback), key_input hashes container+build, store/publish do atomic replace, and two pipeline-cache tests pin store-replaces-without-converting and stored==host_shader output. The bulk of the diff (apps translate CLI, gpu shader_cache, README/docs) is Windows-only; the pipeline cache logic is what macOS verified.
upstream-sync closed this pull request 2026-11-25 02:05:01 +00:00
Marvisak commented 2026-11-25 02:06:01 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:25:17Z.


Automated triage for the maintainers. Closing because this change is already in main, or main has since replaced the code it patches.

translate --cache DIR filling the runtime's shader cache: main has this as translate --cache (the warm-up, commit c47b5297), with the cache keyed by the translator.

If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7149527673 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1730#issuecomment-7149527673). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T01:25:17Z. --- Automated triage for the maintainers. Closing because this change is already in `main`, or `main` has since replaced the code it patches. `translate --cache DIR` filling the runtime's shader cache: main has this as `translate --cache` (the warm-up, commit c47b5297), with the cache keyed by the translator. If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.
Marvisak commented 2026-11-25 02:06:12 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:35:16Z.


Automated triage for the maintainers.

Needs rebase. This pull request conflicts with main (conflicting: README.md, apps/victory/src/main.rs, apps/victory/src/translate.rs, crates/victory-gpu/src/shader_cache.rs, crates/victory-pipeline/src/cache.rs). It will be reviewed once it is rebased onto the current main.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7149719592 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1730#issuecomment-7149719592). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T01:35:16Z. --- <!-- victory-triage v1 head=87a93820d96d99c669fbe26d8aca683fba0128fb verdict=needs-rebase at=2026-11-25T01:35:15Z --> Automated triage for the maintainers. **Needs rebase.** This pull request conflicts with `main` (conflicting: `README.md`, `apps/victory/src/main.rs`, `apps/victory/src/translate.rs`, `crates/victory-gpu/src/shader_cache.rs`, `crates/victory-pipeline/src/cache.rs`). It will be reviewed once it is rebased onto the current `main`. --- _Generated by [Claude Code](https://claude.ai/code)_

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
Marvisak/VIctory!1729
No description provided.