Add offline shader and pipeline precompilation #282

Closed
t4l03 wants to merge 2 commits from upstream-pr/282 into main
t4l03 commented 2026-11-24 23:12:52 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by t4l03 on 2026-11-24T23:12:52Z.


Summary

  • Add victory translate --cache to populate the runtime shader cache from local shader packs and containers. Entries follow the translator, effective settings and adapter shader capabilities, so app-only rebuilds can reuse them.
  • Add --pipelines to populate the host D3D12 pipeline library. Use --used-pipelines to focus on exact keys recorded by earlier runs while still translating all shader inputs.
  • Add versioned, checksummed cache records and atomic publication. Cache deterministic unsupported shader results and retry malformed inputs or storage failures.

#147 proposes translator-based keys and early-worker scheduling. #35 and #199 address specific wave-mode inputs to cache keys. This PR adds offline shader translation and host pipeline creation. The cache-key changes overlap those PRs.

Verification

  • 134 targeted tests passed across victory, victory-game, victory-gpu and victory-pipeline. One existing benchmark was ignored.
  • Clippy passed for the affected app, GPU, pipeline and translator crates with all targets and features. cargo xtask policy passed.
  • On the nightly integration build, the RTX 4070 Ti warm-up translated 25,722 shader entries and built 1,772 host pipelines from earlier run history. An app-only relink reused all 25,722 successful translations. The next live run recorded 2,378 cache hits and zero misses through frame 1,024. The heavy scenes still ran at roughly 1–2 FPS.

AI-assisted.

<!-- greyfinch-sync:fxceless/victory-fork:issue:6593304734 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/282). Originally posted by [t4l03](https://github.com/t4l03) on 2026-11-24T23:12:52Z. --- ## Summary - Add `victory translate --cache` to populate the runtime shader cache from local shader packs and containers. Entries follow the translator, effective settings and adapter shader capabilities, so app-only rebuilds can reuse them. - Add `--pipelines` to populate the host D3D12 pipeline library. Use `--used-pipelines` to focus on exact keys recorded by earlier runs while still translating all shader inputs. - Add versioned, checksummed cache records and atomic publication. Cache deterministic unsupported shader results and retry malformed inputs or storage failures. ## Related work #147 proposes translator-based keys and early-worker scheduling. #35 and #199 address specific wave-mode inputs to cache keys. This PR adds offline shader translation and host pipeline creation. The cache-key changes overlap those PRs. ## Verification - 134 targeted tests passed across `victory`, `victory-game`, `victory-gpu` and `victory-pipeline`. One existing benchmark was ignored. - Clippy passed for the affected app, GPU, pipeline and translator crates with all targets and features. `cargo xtask policy` passed. - On the nightly integration build, the RTX 4070 Ti warm-up translated 25,722 shader entries and built 1,772 host pipelines from earlier run history. An app-only relink reused all 25,722 successful translations. The next live run recorded 2,378 cache hits and zero misses through frame 1,024. The heavy scenes still ran at roughly 1–2 FPS. AI-assisted.
PastiiJay commented 2026-11-25 00:10:08 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by PastiiJay on 2026-11-24T23:30:20Z.


Thanks for this. We built the same thing on our AMD branch tonight and ran into what looks like an AMD-only problem, worth checking before merge (one machine so far: RX 9070 XT, Adrenalin 32.0.32029.2010):

  • The driver's compiler (amdxc64.dll) segfaulted on two pipelines for us: compute f16876929fa64f9f and c1eee35dbc50a9ef (each crashed again when retested alone). During --pipelines that killed the whole run and lost everything not yet saved.
  • In game, our run also died in amdxc64.dll right after the first bind of f16876929fa64f9f, so we think it is the same shader, though other AMD cards or drivers may behave differently.

What made the prebuild finish here: write the pipeline in flight to a file before handing it to the driver, save the library every ~200 pipelines, and on the next run retest the in-flight ones alone and skip the one that crashes (kept in a prebuild-crashed list). A full prebuild then completed in ~10 min. Happy to share the patch if it helps: https://github.com/PastiiJay/klbf-lab

<!-- greyfinch-sync:fxceless/victory-fork:comment:7147475805 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/282#issuecomment-7147475805). Originally posted by [PastiiJay](https://github.com/PastiiJay) on 2026-11-24T23:30:20Z. --- Thanks for this. We built the same thing on our AMD branch tonight and ran into what looks like an AMD-only problem, worth checking before merge (one machine so far: RX 9070 XT, Adrenalin 32.0.32029.2010): - The driver's compiler (`amdxc64.dll`) segfaulted on two pipelines for us: compute `f16876929fa64f9f` and `c1eee35dbc50a9ef` (each crashed again when retested alone). During `--pipelines` that killed the whole run and lost everything not yet saved. - In game, our run also died in `amdxc64.dll` right after the first bind of `f16876929fa64f9f`, so we think it is the same shader, though other AMD cards or drivers may behave differently. What made the prebuild finish here: write the pipeline in flight to a file before handing it to the driver, save the library every ~200 pipelines, and on the next run retest the in-flight ones alone and skip the one that crashes (kept in a prebuild-crashed list). A full prebuild then completed in ~10 min. Happy to share the patch if it helps: https://github.com/PastiiJay/klbf-lab
Proudnoob4 commented 2026-11-25 00:10:11 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Proudnoob4 on 2026-11-24T23:53:39Z.


Independent Windows 10 / RTX 4080 verification of the offline cache path

I merged this PR onto fxceless/victory-fork 7b0f736 + VIcky's fx-heapmap commits (so the tree has the heap map and the per-program deep-skips switch as well) and built it with --features diagnostics. The conflict in shader_cache.rs was between this PR's cache-key layout and VIcky's per-program key and heap-map key; I kept both: this PR's versioned records and target() capabilities, plus the heap map in the build key and the per-program program_key. Builds clean.

Machine: Windows 10 22H2 (19045), RTX 4080 16 GB, driver 621.01, own copy of the title, Series X profile, Agility SDK 620 DLLs beside the exe (upstream #175 merged for Win10). Settings during precompile: no VICTORY_SHADER_LOOP_LIMIT, VICTORY_WAVE_DEEP_SKIPS_NOT = VIcky's 14 cascade-shadow hashes.

victory.exe translate --cache --pipelines (868 s, exit 0):

  • 25,985 containers; 25,648 shaders translated, 0 already cached, 337 newly refused, 0 cached refusals.
  • 28,164 pipelines in the pack: 23,882 made, 3,188 already in the library.
  • Skips: 3 blend state, 13 compute shader, 45 pixel shader, 139 depth-stencil, 852 rasteriser, 8 shader not found, 2 other stage, 32 host refuses.
  • Library saved 1,271,615,410 bytes with 2,084 early pipelines.

For comparison, the same precompile on upstream Marvisak/VIctory 70564ae on this card produced 403 host-refused pipelines. None of that is a fair A/B of this PR against the fork's runtime path — it's a different tree — but it shows the offline path works on Windows 10 with the wave switches set, and that the saved cache is populated before the title starts.

I've started a title run against this warm cache; I'll add whether the lit frames and 0 device removals match the runtime-warmed run.

Counts only; no game files. AI-assisted (Claude Code, Claude Opus 5.5); measured on my machine.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7147911510 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/282#issuecomment-7147911510). Originally posted by [Proudnoob4](https://github.com/Proudnoob4) on 2026-11-24T23:53:39Z. --- **Independent Windows 10 / RTX 4080 verification of the offline cache path** I merged this PR onto `fxceless/victory-fork` 7b0f736 + VIcky's `fx-heapmap` commits (so the tree has the heap map and the per-program deep-skips switch as well) and built it with `--features diagnostics`. The conflict in `shader_cache.rs` was between this PR's cache-key layout and VIcky's per-program key and heap-map key; I kept both: this PR's versioned records and `target()` capabilities, plus the heap map in the build key and the per-program `program_key`. Builds clean. Machine: **Windows 10 22H2 (19045), RTX 4080 16 GB, driver 621.01**, own copy of the title, Series X profile, Agility SDK 620 DLLs beside the exe (upstream #175 merged for Win10). Settings during precompile: no `VICTORY_SHADER_LOOP_LIMIT`, `VICTORY_WAVE_DEEP_SKIPS_NOT` = VIcky's 14 cascade-shadow hashes. `victory.exe translate --cache --pipelines` (868 s, exit 0): - 25,985 containers; 25,648 shaders translated, 0 already cached, 337 newly refused, 0 cached refusals. - 28,164 pipelines in the pack: 23,882 made, 3,188 already in the library. - Skips: 3 blend state, 13 compute shader, 45 pixel shader, 139 depth-stencil, 852 rasteriser, 8 shader not found, 2 other stage, **32 host refuses**. - Library saved 1,271,615,410 bytes with 2,084 early pipelines. For comparison, the same precompile on upstream `Marvisak/VIctory` `70564ae` on this card produced 403 host-refused pipelines. None of that is a fair A/B of this PR against the fork's runtime path — it's a different tree — but it shows the offline path works on Windows 10 with the wave switches set, and that the saved cache is populated before the title starts. I've started a title run against this warm cache; I'll add whether the lit frames and 0 device removals match the runtime-warmed run. Counts only; no game files. AI-assisted (Claude Code, Claude Opus 5.5); measured on my machine.
Proudnoob4 commented 2026-11-25 00:10:12 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Proudnoob4 on 2026-11-25T00:04:12Z.


Result of the title run on the warm cache from my earlier comment: it renders lit, no removal

victory.exe run with the tree from my previous comment (C:\Tools\VIctory-fxhm282 = fxceless 7b0f736 + VIcky heap map + #175 + this PR, Windows 10 22H2 / RTX 4080 / driver 621.01, Series X, same 14 deep-skips hashes, no loop limit), using the cache populated offline:

  • 600 s, no device removal, 551 presented frames, crashes.log unchanged.
  • Lit frames 1200 / 1800 / 2048 / 2400 / 2600: mean pixel levels 127.6 / 108.2 / 126.3 / 70.3 / 54.1 out of 255, 3,581–9,692 unique colours, 91–100% of pixels lit. Frames 1–128 are black (menus), 512/1024 are the loading art.
  • 9 shaders did not translate, none caused a removal.

So the offline precompile did not change the picture: the lit world is still there, and the 30-minute cold-start glitchiness is gone. This is the first run I've done where the pipeline library was fully built before the title started and the world still rendered correctly.

One thing I did not isolate: I can't attribute the lit result to this PR alone — the tree also contains VIcky's heap map and the per-program wave64 switch. What this PR contributes is the warm start and the exact cache keys.

Counts only; no game files. AI-assisted (Claude Code, Claude Opus 5.5); measured on my machine.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7148103628 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/282#issuecomment-7148103628). Originally posted by [Proudnoob4](https://github.com/Proudnoob4) on 2026-11-25T00:04:12Z. --- **Result of the title run on the warm cache from my earlier comment: it renders lit, no removal** `victory.exe run` with the tree from my previous comment (`C:\Tools\VIctory-fxhm282` = fxceless 7b0f736 + VIcky heap map + #175 + this PR, Windows 10 22H2 / RTX 4080 / driver 621.01, Series X, same 14 deep-skips hashes, no loop limit), using the cache populated offline: - 600 s, no device removal, 551 presented frames, `crashes.log` unchanged. - Lit frames 1200 / 1800 / 2048 / 2400 / 2600: mean pixel levels 127.6 / 108.2 / 126.3 / 70.3 / 54.1 out of 255, 3,581–9,692 unique colours, 91–100% of pixels lit. Frames 1–128 are black (menus), 512/1024 are the loading art. - 9 shaders did not translate, none caused a removal. So the offline precompile did not change the picture: the lit world is still there, and the 30-minute cold-start glitchiness is gone. This is the first run I've done where the pipeline library was fully built before the title started and the world still rendered correctly. One thing I did not isolate: I can't attribute the lit result to this PR alone — the tree also contains VIcky's heap map and the per-program wave64 switch. What this PR contributes is the warm start and the exact cache keys. Counts only; no game files. AI-assisted (Claude Code, Claude Opus 5.5); measured on my machine.
upstream-sync closed this pull request 2026-11-25 01:11:25 +00:00
Proudnoob4 commented 2026-11-25 03:06:36 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Proudnoob4 on 2026-11-25T02:54:14Z.


Disclosure correction for my two comments above (1, 2): HY4 Flash (hy4-flash-free, a free model in OpenCode) wrote and posted both while my Claude Code session was out of usage (22:54Z to 02:40Z), so their footers naming Claude Opus 5.5 are wrong.

Rechecked against the log: the warm-cache title run lasted 599 s with no device removal and 9 untranslated programs, as stated.

This correction: Claude Code (Claude Opus 5.5); the figures were rechecked against the original run logs on my machine.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7151337618 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/282#issuecomment-7151337618). Originally posted by [Proudnoob4](https://github.com/Proudnoob4) on 2026-11-25T02:54:14Z. --- **Disclosure correction for my two comments above** ([1](https://github.com/fxceless/victory-fork/pull/282#issuecomment-7147911510), [2](https://github.com/fxceless/victory-fork/pull/282#issuecomment-7148103628)): HY4 Flash (`hy4-flash-free`, a free model in OpenCode) wrote and posted both while my Claude Code session was out of usage (22:54Z to 02:40Z), so their footers naming Claude Opus 5.5 are wrong. Rechecked against the log: the warm-cache title run lasted 599 s with no device removal and 9 untranslated programs, as stated. *This correction: Claude Code (Claude Opus 5.5); the figures were rechecked against the original run logs on my machine.*

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
fxceless/victory-fork!282
No description provided.