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

Closed
github-bot wants to merge 5 commits from gh-pr/1730/head into gh-pr/1730/base
Owner

@⁠Nixitov on GitHub · 2026-11-24 21:28 UTC · original
Nixitov:feat/cache-fill → main · +275 −25 · 9 files · 5 commits · closed without merging

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).

**@⁠Nixitov** on GitHub · 2026-11-24 21:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/1730) `Nixitov:feat/cache-fill` → `main` · +275 −25 · 9 files · 5 commits · closed without merging ## 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).
Split the atomic write out of get_or_convert so a caller that has the
output in hand (an offline shader fill, keyed the same way) can publish
it without translating twice. Same write-then-rename, same key.
store(container, shader) publishes through victory-pipeline's cache
under the key host_shader reads: this build (the executable's BLAKE3 and
the loop limit) and the container's bytes. The converter id and version
are shared constants now, so an offline fill and the runtime cannot
drift apart. The unit test stores a translation and reads it back
through host_shader.

Container::bytes is the container cut where its header ends: a walk
finds containers inside larger files, and hashing the file's tail would
make every entry unreachable from the runtime, which passes exactly the
container.
Every translation the batch emits is now stored where `victory run`
reads it: --cache opens the runtime's cache and stores one entry per
container, for the program `emit::translate` picks. Duplicate
containers, which the report counts once, are still translated and
stored as the runtime would.

The final line says how many entries were written and where.
A title's archives take minutes of CPU-bound translation and the report
only comes at the end, so a run looks idle (its CPU total can read near
zero while the worker threads spin). Print the containers and programs
reached to stderr every five seconds until the walk ends.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:43:07 +00:00
github-bot closed this pull request 2026-11-26 04:43:07 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 01:25 UTC · original

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** on GitHub · 2026-11-25 01:25 UTC · [original](https://github.com/Marvisak/VIctory/pull/1730#issuecomment-7149527673) 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.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 01:35 UTC · original

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

**@⁠Marvisak** on GitHub · 2026-11-25 01:35 UTC · [original](https://github.com/Marvisak/VIctory/pull/1730#issuecomment-7149719592) <!-- 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

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1730
No description provided.