translate --cache [--pipelines]: pipeline pre-build ported from upstream (first run loads instead of making) #1223

Open
regiumlepidi wants to merge 4 commits from upstream-pr/1226 into main
regiumlepidi commented 2026-11-26 00:53:09 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by regiumlepidi on 2026-11-26T00:53:09Z.


Ports upstream VIctory's pipeline pre-build (victory translate --cache [--pipelines], Marvisak/VIctory 13f91ca) to this fork, so a first run loads the shader pack's pipelines from the library instead of making them while the title waits.

What it adds

  • victory-game: upstream's cityhash, shaderpack and pipelines (the pack's pipeline records), and the SGD5 databases' state tables. This fork's zlib-rs unpacking and records() are kept.
  • translate --cache: translates every shader of the given archives into the shader cache. --pipelines also makes every nameable pipeline of the pack into the pipeline library, by the same code a run makes it with (host::HostPipeline::new). The library key comes from one function (make::key) shared by the run and the pre-build, so a run finds them under the same names.
  • prebuilt-pipelines.txt in the cache dir lets a stopped pre-build go on where it was. A run never reads or writes it. VICTORY_PREBUILD_KEYS=<file> lists the keys and makes nothing.
  • The shader cache key and the shader crate are not touched.

Use: run it with the same VICTORY_* switches as the run (VICTORY_SHADER_OPT, VICTORY_WAVE_DEEP_SKIPS_NOT, heap map/window, root SRV switches change translations or names), the same build profile and features, and the run's VICTORY_CACHE_DIR. Don't pre-build into a cache a run is using: both save the same library file.

victory translate --cache --pipelines <game dir>/shaders.rpf <game dir>/game.exe <game dir>/XboxBvhBuilder.dll <game dir>/amd_fidelityfx_upscaler_xbox.dll

Measured on an RTX 5070 Ti (16 GB, 9800X3D, NVIDIA 617.42), diagnostics build, Series S profile, run-279 switch set:

  • Pre-build from a warm shader cache: 25,985 shader containers (22,533 translated, 289 refused) in 106 s. 28,164 pipelines in the pack: 21,558 made plus 5,566 already in the library in 476 s on 16 threads. 1,040 skipped, mostly states the records don't name (852 rasteriser, 139 depth-stencil) and 28 refused by the host.
  • A second pre-build after a rebuild of the tree found all 27,124 in the library, 0 made, in 132 s.
  • 25-minute runs from boot through the opening cutscene to player control: 1 pipeline made, 942 loaded from the library. Median frame line went from 1.9 fps (earlier run making pipelines as it went) to 11.7–11.9 fps, steady 10–13 in the world. The switch set also changed between those runs, so not all of that is the pre-build. See issue #696 for the numbers.
  • About 17% of the early list's pipelines are not described by the pack and are still made at run time.

Tests: victory-game 16/16, victory 1/1. victory-gpu passes apart from warp_budget_saturates_without_wraparound_and_preserves_draw_fields, which is flaky on main too (3 of 4 runs fail on WARP: it assumes group order). Not formatted beyond the existing style; main isn't rustfmt-clean either.

No game files or data are included. The port was made and tested with an AI assistant (Claude Code).

🤖 Generated with Claude Code

<!-- greyfinch-sync:fxceless/victory-fork:issue:5501895727 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1226). Originally posted by [regiumlepidi](https://github.com/regiumlepidi) on 2026-11-26T00:53:09Z. --- Ports upstream VIctory's pipeline pre-build (`victory translate --cache [--pipelines]`, Marvisak/VIctory 13f91ca) to this fork, so a first run loads the shader pack's pipelines from the library instead of making them while the title waits. **What it adds** - `victory-game`: upstream's `cityhash`, `shaderpack` and `pipelines` (the pack's pipeline records), and the SGD5 databases' state tables. This fork's zlib-rs unpacking and `records()` are kept. - `translate --cache`: translates every shader of the given archives into the shader cache. `--pipelines` also makes every nameable pipeline of the pack into the pipeline library, by the same code a run makes it with (`host::HostPipeline::new`). The library key comes from one function (`make::key`) shared by the run and the pre-build, so a run finds them under the same names. - `prebuilt-pipelines.txt` in the cache dir lets a stopped pre-build go on where it was. A run never reads or writes it. `VICTORY_PREBUILD_KEYS=<file>` lists the keys and makes nothing. - The shader cache key and the shader crate are not touched. **Use**: run it with the same `VICTORY_*` switches as the run (`VICTORY_SHADER_OPT`, `VICTORY_WAVE_DEEP_SKIPS_NOT`, heap map/window, root SRV switches change translations or names), the same build profile and features, and the run's `VICTORY_CACHE_DIR`. Don't pre-build into a cache a run is using: both save the same library file. ``` victory translate --cache --pipelines <game dir>/shaders.rpf <game dir>/game.exe <game dir>/XboxBvhBuilder.dll <game dir>/amd_fidelityfx_upscaler_xbox.dll ``` **Measured** on an RTX 5070 Ti (16 GB, 9800X3D, NVIDIA 617.42), diagnostics build, Series S profile, run-279 switch set: - Pre-build from a warm shader cache: 25,985 shader containers (22,533 translated, 289 refused) in 106 s. 28,164 pipelines in the pack: 21,558 made plus 5,566 already in the library in 476 s on 16 threads. 1,040 skipped, mostly states the records don't name (852 rasteriser, 139 depth-stencil) and 28 refused by the host. - A second pre-build after a rebuild of the tree found all 27,124 in the library, 0 made, in 132 s. - 25-minute runs from boot through the opening cutscene to player control: **1 pipeline made, 942 loaded** from the library. Median frame line went from 1.9 fps (earlier run making pipelines as it went) to 11.7–11.9 fps, steady 10–13 in the world. The switch set also changed between those runs, so not all of that is the pre-build. See issue #696 for the numbers. - About 17% of the early list's pipelines are not described by the pack and are still made at run time. **Tests**: `victory-game` 16/16, `victory` 1/1. `victory-gpu` passes apart from `warp_budget_saturates_without_wraparound_and_preserves_draw_fields`, which is flaky on `main` too (3 of 4 runs fail on WARP: it assumes group order). Not formatted beyond the existing style; `main` isn't `rustfmt`-clean either. No game files or data are included. The port was made and tested with an AI assistant (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
slauko commented 2026-11-26 08:04:56 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by slauko on 2026-11-26T07:30:25Z.


Ran it under Linux/Wine (RTX 3080 Ti, vkd3d-proton ec20719, uiliannn's line; your two commits from 006c3530, with Shader::new carrying that line's three ambient fields). Three observations:

  1. The pre-build itself. The first block (the 2,411 pipelines earlier runs drew with) took about 7 minutes on 15 threads; at 2,302 of it, 633 had been made, 1,666 were in the library and 1,005 skipped. A made pipeline cost about 13 worker-seconds in that block (1.1 a second on 15 threads); the rest of the pack went at 2.6 to 7.6 a second (3,350 of 27,160 in 12.5 minutes, then I stopped it). Your 476 s for 21,558 on 16 threads is 0.35 seconds each: this stack is about 35 times slower at making one.
  2. A stack overflow in the tool. thread '<unknown>' (872) has overflowed its stack, once, 20 seconds in; the tool went on, and with it one pipeline. The pre-build's threads are plain std::thread::scope spawns (prebuild.rs, translate.rs): unlike the run's workers (make.rs: 16 MiB, VIctory#1528) they set no stack size.
  3. A load is not cheap under vkd3d-proton. The first run after it loaded 2,096 pipelines from the library and made 30, so the pre-build does what it says. But a load took a median of 279 ms; compute 530 ms (the ninetieth part 12.8 s), pixel and vertex 2.3 s: 5,378 core-seconds for the 2,096. In an earlier run of the same kind (931 loaded, 27 made) with VKD3D_SHADER_DUMP_PATH set, vkd3d-proton translated 1,092 shaders to SPIR-V again (246 MB of it), and its cache file is 1 MB. So on this stack the pre-build moves the cost from making to loading; the minutes to the first scene stayed (459 s before, 497 s after).

VICTORY_PIPELINE_TIMES=1 (in my line) is what gave the numbers of the third point: every load and every making with its time.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7185530545 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1226#issuecomment-7185530545). Originally posted by [slauko](https://github.com/slauko) on 2026-11-26T07:30:25Z. --- Ran it under Linux/Wine (RTX 3080 Ti, vkd3d-proton `ec20719`, uiliannn's line; your two commits from `006c3530`, with `Shader::new` carrying that line's three ambient fields). Three observations: 1. **The pre-build itself.** The first block (the 2,411 pipelines earlier runs drew with) took about 7 minutes on 15 threads; at 2,302 of it, 633 had been made, 1,666 were in the library and 1,005 skipped. A made pipeline cost about 13 worker-seconds in that block (1.1 a second on 15 threads); the rest of the pack went at 2.6 to 7.6 a second (3,350 of 27,160 in 12.5 minutes, then I stopped it). Your 476 s for 21,558 on 16 threads is 0.35 seconds each: this stack is about 35 times slower at making one. 2. **A stack overflow in the tool.** `thread '<unknown>' (872) has overflowed its stack`, once, 20 seconds in; the tool went on, and with it one pipeline. The pre-build's threads are plain `std::thread::scope` spawns (`prebuild.rs`, `translate.rs`): unlike the run's workers (`make.rs`: 16 MiB, VIctory#1528) they set no stack size. 3. **A load is not cheap under vkd3d-proton.** The first run after it loaded 2,096 pipelines from the library and made 30, so the pre-build does what it says. But a load took a median of 279 ms; compute 530 ms (the ninetieth part 12.8 s), pixel and vertex 2.3 s: 5,378 core-seconds for the 2,096. In an earlier run of the same kind (931 loaded, 27 made) with `VKD3D_SHADER_DUMP_PATH` set, vkd3d-proton translated 1,092 shaders to SPIR-V again (246 MB of it), and its cache file is 1 MB. So on this stack the pre-build moves the cost from making to loading; the minutes to the first scene stayed (459 s before, 497 s after). `VICTORY_PIPELINE_TIMES=1` (in my line) is what gave the numbers of the third point: every load and every making with its time.
regiumlepidi commented 2026-11-26 09:08:03 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by regiumlepidi on 2026-11-26T08:19:07Z.


Thanks for running it on that stack — useful numbers.

  1. Stack overflow: right, the pre-build's scoped threads had the default stack. Fixed in a small helper (prebuild::worker) that gives every pre-build worker the run's 16 MiB (pipeline/make.rs, VIctory#1528), used by all four of the PR's spawns (the three in prebuild.rs and the one in translate.rs); pushed just now. Smoke-tested on Windows/D3D12: 22,525 shader containers translated in 90 s into an empty cache with the new workers, no panic. I can't reproduce the overflow here (native D3D12), so if you get the chance, a rerun on your line would confirm it.

  2. Cost per made pipeline under vkd3d-proton (~35×): that is the driver/translation stack's compile cost, not something the pre-build changes; the pre-build only moves it ahead of the run. On a stack where one make is ~13 worker-seconds the whole pack is probably not worth pre-building — VICTORY_PREBUILD_KEYS plus the early list (the ~2,400 pipelines earlier runs drew with, which it already does first) is the part that pays off. I can add a --early-only style limit if that would help on Linux; say so.

  3. Library loads at ~279 ms median under vkd3d-proton: agreed this caps what a pre-build can give there: D3D12 pipeline library loads that trigger a SPIR-V re-translation are on vkd3d-proton's side (its own shader cache / VKD3D_SHADER_CACHE_PATH would be the lever, not this PR). On native D3D12 here a load is cheap: 942 loaded, 1 made in a 25-minute run, no stalls.

(Replying with Claude Code's help.)

<!-- greyfinch-sync:fxceless/victory-fork:comment:7186449484 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1226#issuecomment-7186449484). Originally posted by [regiumlepidi](https://github.com/regiumlepidi) on 2026-11-26T08:19:07Z. --- Thanks for running it on that stack — useful numbers. 2. **Stack overflow:** right, the pre-build's scoped threads had the default stack. Fixed in a small helper (`prebuild::worker`) that gives every pre-build worker the run's 16 MiB (`pipeline/make.rs`, VIctory#1528), used by all four of the PR's spawns (the three in `prebuild.rs` and the one in `translate.rs`); pushed just now. Smoke-tested on Windows/D3D12: 22,525 shader containers translated in 90 s into an empty cache with the new workers, no panic. I can't reproduce the overflow here (native D3D12), so if you get the chance, a rerun on your line would confirm it. 1. **Cost per made pipeline under vkd3d-proton (~35×):** that is the driver/translation stack's compile cost, not something the pre-build changes; the pre-build only moves it ahead of the run. On a stack where one make is ~13 worker-seconds the whole pack is probably not worth pre-building — `VICTORY_PREBUILD_KEYS` plus the early list (the ~2,400 pipelines earlier runs drew with, which it already does first) is the part that pays off. I can add a `--early-only` style limit if that would help on Linux; say so. 3. **Library loads at ~279 ms median under vkd3d-proton:** agreed this caps what a pre-build can give there: D3D12 pipeline library loads that trigger a SPIR-V re-translation are on vkd3d-proton's side (its own shader cache / `VKD3D_SHADER_CACHE_PATH` would be the lever, not this PR). On native D3D12 here a load is cheap: 942 loaded, 1 made in a 25-minute run, no stalls. (Replying with Claude Code's help.)
slauko commented 2026-11-26 10:06:46 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by slauko on 2026-11-26T09:25:45Z.


A correction to my earlier comment here, from a library rebuilt after the translator changed (same translate --cache --pipelines, 15 workers, 3,491 of 27,160 pipelines, 1,443 made in 15 minutes):

loads median p90 core-seconds made
m3/m5, library from before the change 1,575 to 2,096 279 ms 12.8 s 1,300 to 5,378
m18, library rebuilt with --pipelines 1,691 1 ms 1,115 ms 615

The scene came at 107 s (160 s before, 497 s on the first library) and the run ended at 183 s.

So "the pre-build moves the cost from making to loading, and the minutes stay" was about a stale library, not about loading: translate --pipelines makes the host device and translates with its facts (wave size, view heap clamp), and blobs made under an older translator — or made without the device — no longer match, so nearly every load was a miss that re-made the pipeline in the driver. With a matching library a load is a hit and costs about nothing.

Worth saying in the tool's output, I think: the library's age/fingerprint next to "N found in the library, M made" would have told me this on day one. (vkd3d-proton.cache in the run's cache directory also grows over runs; I cannot separate the two hits, but the median going from 279 ms to 1 ms is not a cache that filled up gradually.)

<!-- greyfinch-sync:fxceless/victory-fork:comment:7187974771 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1226#issuecomment-7187974771). Originally posted by [slauko](https://github.com/slauko) on 2026-11-26T09:25:45Z. --- A correction to my earlier comment here, from a library rebuilt **after** the translator changed (same `translate --cache --pipelines`, 15 workers, 3,491 of 27,160 pipelines, 1,443 made in 15 minutes): | loads | median | p90 | core-seconds | made | |---|---:|---:|---:|---:| | `m3`/`m5`, library from before the change | 1,575 to 2,096 | 279 ms | 12.8 s | 1,300 to 5,378 | 30 | | `m18`, library rebuilt with `--pipelines` | 1,691 | **1 ms** | 1,115 ms | **615** | 6 | The scene came at 107 s (160 s before, 497 s on the first library) and the run ended at 183 s. So "the pre-build moves the cost from making to loading, and the minutes stay" was about a **stale** library, not about loading: `translate --pipelines` makes the host device and translates with its facts (wave size, view heap clamp), and blobs made under an older translator — or made without the device — no longer match, so nearly every load was a miss that re-made the pipeline in the driver. With a matching library a load is a hit and costs about nothing. Worth saying in the tool's output, I think: the library's age/fingerprint next to "N found in the library, M made" would have told me this on day one. (`vkd3d-proton.cache` in the run's cache directory also grows over runs; I cannot separate the two hits, but the median going from 279 ms to 1 ms is not a cache that filled up gradually.)
regiumlepidi commented 2026-11-26 11:05:32 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by regiumlepidi on 2026-11-26T10:44:57Z.


Thanks for the correction: that makes sense, and the stale library was a trap the tool should have pointed out. Pushed b55f713:

  • host-pipelines.stamp is written with every library save: the "namer" of whoever saved it (the translator's fingerprint with the host facts and switches it reads, plus the shader cache / host description / library code: what decides a pipeline's name) and the save time. At start, a run or pre-build compares it with its own and logs either host pipeline library last saved under this run's translator and switches (with its age), or a warning that the library was saved under another translator or other switches, so most loads will miss and remake the pipeline, and that victory translate --cache --pipelines in the run's environment rebuilds it. A library with no stamp (saved by an older build) gets a one-line hint instead.
  • Also found while testing it: my port had left a stray mod rejected_bind_tests; in pipeline.rs with no such file, so cargo test -p victory-gpu --lib didn't compile on this branch. Removed. victory-gpu lib tests: 213 passed, 6 ignored (Windows/D3D12, RTX 5070 Ti), plus a small unit test for the stamp.

The stamp tracks the last save. A library that held pipelines from two translators still says "this run's" after the newer one saved; the old entries then miss quietly. That seems the right trade-off over fingerprinting every entry.

(Written with Claude Code's help.)

<!-- greyfinch-sync:fxceless/victory-fork:comment:7189783401 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1226#issuecomment-7189783401). Originally posted by [regiumlepidi](https://github.com/regiumlepidi) on 2026-11-26T10:44:57Z. --- Thanks for the correction: that makes sense, and the stale library was a trap the tool should have pointed out. Pushed b55f713: - **`host-pipelines.stamp`** is written with every library save: the "namer" of whoever saved it (the translator's fingerprint with the host facts and switches it reads, plus the shader cache / host description / library code: what decides a pipeline's name) and the save time. At start, a run or pre-build compares it with its own and logs either `host pipeline library last saved under this run's translator and switches` (with its age), or a **warning** that the library was saved under another translator or other switches, so most loads will miss and remake the pipeline, and that `victory translate --cache --pipelines` in the run's environment rebuilds it. A library with no stamp (saved by an older build) gets a one-line hint instead. - Also found while testing it: my port had left a stray `mod rejected_bind_tests;` in `pipeline.rs` with no such file, so `cargo test -p victory-gpu --lib` didn't compile on this branch. Removed. `victory-gpu` lib tests: 213 passed, 6 ignored (Windows/D3D12, RTX 5070 Ti), plus a small unit test for the stamp. The stamp tracks the *last* save. A library that held pipelines from two translators still says "this run's" after the newer one saved; the old entries then miss quietly. That seems the right trade-off over fingerprinting every entry. (Written with Claude Code's help.)
lukinhasnojento commented 2026-11-27 14:53:44 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by lukinhasnojento on 2026-11-27T14:53:44Z.


Additional local cold-start observation (2026-11-27), shared as a preliminary result: using this PR’s pipeline pre-build with a prioritized set of 1,468 early-use keys, the title advanced into the prologue without reproducing the previously observed +0x23cf683 watchdog during the observation window. The library loaded; performance was still about 1–2 FPS, with hundreds of dropped draws and pipelines still being created. This is one run and does not establish a general fix or stable gameplay. A broader pre-build is still being evaluated. No game files, derived assets, screenshots, or raw logs are attached.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7221365364 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1226#issuecomment-7221365364). Originally posted by [lukinhasnojento](https://github.com/lukinhasnojento) on 2026-11-27T14:53:44Z. --- Additional local cold-start observation (2026-11-27), shared as a preliminary result: using this PR’s pipeline pre-build with a prioritized set of 1,468 early-use keys, the title advanced into the prologue without reproducing the previously observed +0x23cf683 watchdog during the observation window. The library loaded; performance was still about 1–2 FPS, with hundreds of dropped draws and pipelines still being created. This is one run and does not establish a general fix or stable gameplay. A broader pre-build is still being evaluated. No game files, derived assets, screenshots, or raw logs are attached.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1226:upstream-pr/1226'
git switch 'upstream-pr/1226'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/1226'
git switch 'upstream-pr/1226'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1226'
git switch 'upstream-pr/1226'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1226'
git switch 'main'
git merge --squash 'upstream-pr/1226'
git switch 'main'
git merge --ff-only 'upstream-pr/1226'
git switch 'main'
git merge 'upstream-pr/1226'
git push origin 'main'
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
fxceless/victory-fork!1223
No description provided.