victory: run makes the title's shaders and pipelines before it starts, with a progress window (once; kept on disk) #2905

Open
0xkn0wh3r3 wants to merge 3 commits from upstream-pr/2907 into main
0xkn0wh3r3 commented 2026-11-25 23:38:04 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-25T23:38:04Z.


translate --cache --pipelines makes every shader and pipeline a title can ask for, but only when someone runs it. Otherwise the first runs translate shaders at first use, so draws wait, and make pipelines on worker threads, so draws are dropped meanwhile. That happens again after every translator change.

With this PR, run --execute makes them itself, before the title starts, with a progress window. It does nothing on later starts unless something changed.

What

  • Which files. The title's shaders.rpf, its executable and its DLLs: the files the README's translate --cache --pipelines line names (startup::shader_files).

  • Done once, kept on disk. The shader cache and the pipeline library keep the work, as before. A stamp in the cache folder (prebuild/<title dir hash>.txt) records what was finished:

    • shaders: a fingerprint of the files (path, size, time written) and of the shader cache's build directory, which names the translator and its settings;
    • pipelines: that, plus the GPU and driver (new victory_gpu::adapter_identity).

    A start with nothing new reads the stamp and goes on at once.

  • The work. What isn't done runs on a thread of its own, using the existing code (translate::warm, prebuild::run).

  • How long the title waits is set by VICTORY_PREBUILD:

    Value The title waits for
    shaders (default) the shaders (minutes, once per translator)
    all the pipelines too (about 20 minutes on 16 threads; hours after a translator change that touches most programs)
    off nothing; nothing is made ahead

    Pipelines the title doesn't wait for are made behind it on half the processor's threads. Their progress shows in the window caption, after the frame rate (new victory_gpu::set_caption_status).

  • Progress window (splash): plain GDI on its own thread, since the GPU is busy with the work. Four times a second it shows:

    • the phase and the file;
    • done of total, time spent and an estimate of time left;
    • the last log lines.

    Esc, or closing the window, starts the title at once; the rest goes on behind it.

  • How progress reaches it. translate::report, which both halves already use for their console progress lines, also feeds a small progress state, and their summary lines go into its log.

Tests

  • progress: progress line and time-left estimate, durations, the log keeping its last lines.
  • startup:
    • the VICTORY_PREBUILD modes;
    • the stamp's round trip;
    • the fingerprint changing with a file's contents, the file list and the GPU part, and staying the same otherwise;
    • the shader file list.
  • splash: the window's lines, and the window opening and closing on its own thread. That test caught a crash: GDI was given empty text for blank lines.
  • cargo test -p victory: 23 passed. cargo clippy -p victory --all-targets and -p victory-gpu --all-targets are clean, with and without --features diagnostics.

Not verified

  • Not run with the title: no game data here. What a cold start shows, and how long the shader half takes on a given machine, needs a run.
  • Pipelines made behind a running title share the pipeline library with the run's own pipeline workers, as the run's workers already do with each other. A run would show whether the extra CPU load matters during play; VICTORY_PREBUILD=all avoids the overlap.
<!-- greyfinch-sync:Marvisak/VIctory:issue:6616020311 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2907). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-25T23:38:04Z. --- `translate --cache --pipelines` makes every shader and pipeline a title can ask for, but only when someone runs it. Otherwise the first runs translate shaders at first use, so draws wait, and make pipelines on worker threads, so draws are dropped meanwhile. That happens again after every translator change. With this PR, `run --execute` makes them itself, before the title starts, with a progress window. It does nothing on later starts unless something changed. ## What - **Which files.** The title's `shaders.rpf`, its executable and its DLLs: the files the README's `translate --cache --pipelines` line names (`startup::shader_files`). - **Done once, kept on disk.** The shader cache and the pipeline library keep the work, as before. A stamp in the cache folder (`prebuild/<title dir hash>.txt`) records what was finished: - **shaders:** a fingerprint of the files (path, size, time written) and of the shader cache's build directory, which names the translator and its settings; - **pipelines:** that, plus the GPU and driver (new `victory_gpu::adapter_identity`). A start with nothing new reads the stamp and goes on at once. - **The work.** What isn't done runs on a thread of its own, using the existing code (`translate::warm`, `prebuild::run`). - **How long the title waits** is set by `VICTORY_PREBUILD`: | Value | The title waits for | |---|---| | `shaders` (default) | the shaders (minutes, once per translator) | | `all` | the pipelines too (about 20 minutes on 16 threads; hours after a translator change that touches most programs) | | `off` | nothing; nothing is made ahead | Pipelines the title doesn't wait for are made behind it on half the processor's threads. Their progress shows in the window caption, after the frame rate (new `victory_gpu::set_caption_status`). - **Progress window** (`splash`): plain GDI on its own thread, since the GPU is busy with the work. Four times a second it shows: - the phase and the file; - done of total, time spent and an estimate of time left; - the last log lines. Esc, or closing the window, starts the title at once; the rest goes on behind it. - **How progress reaches it.** `translate::report`, which both halves already use for their console progress lines, also feeds a small `progress` state, and their summary lines go into its log. ## Tests - `progress`: progress line and time-left estimate, durations, the log keeping its last lines. - `startup`: - the `VICTORY_PREBUILD` modes; - the stamp's round trip; - the fingerprint changing with a file's contents, the file list and the GPU part, and staying the same otherwise; - the shader file list. - `splash`: the window's lines, and the window opening and closing on its own thread. That test caught a crash: GDI was given empty text for blank lines. - `cargo test -p victory`: 23 passed. `cargo clippy -p victory --all-targets` and `-p victory-gpu --all-targets` are clean, with and without `--features diagnostics`. ## Not verified - Not run with the title: no game data here. What a cold start shows, and how long the shader half takes on a given machine, needs a run. - Pipelines made behind a running title share the pipeline library with the run's own pipeline workers, as the run's workers already do with each other. A run would show whether the extra CPU load matters during play; `VICTORY_PREBUILD=all` avoids the overlap.
kotekompotek commented 2026-11-26 00:03:12 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T23:52:56Z.

Review: COMMENTED


Scoped review: this turns the manual translate-then-run flow into a prebuild step with a stamp keyed on files/translator/GPU — the right invalidation key, and Esc-to-start keeps it non-blocking. VICTORY_PREBUILD=shaders/all/off covers the use cases in the README. Size-wise it's a feature PR; the knob surface and cache-stamp design look right.

<!-- greyfinch-sync:Marvisak/VIctory:review:6066644955 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2907#pullrequestreview-6066644955). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T23:52:56Z. **Review:** COMMENTED --- Scoped review: this turns the manual translate-then-run flow into a prebuild step with a stamp keyed on files/translator/GPU — the right invalidation key, and Esc-to-start keeps it non-blocking. VICTORY_PREBUILD=shaders/all/off covers the use cases in the README. Size-wise it's a feature PR; the knob surface and cache-stamp design look right.
fuzeofficlal commented 2026-11-26 00:03:12 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T23:52:58Z.

Review: COMMENTED


Verified head 2a7b2aaa cleanly merged onto origin/main (63bcca43) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + D3D12 WARP + VICTORY_D3D12_DEBUG=1).

Findings

  1. Main-thread hang if the prebuild worker panics under default Mode::Shaders (apps/victory/src/startup.rs:748-751): For Mode::Shaders, waited only checks shaders_done.load(Ordering::Acquire) and does not check work.is_finished(). If "victory prebuild" panics inside translate::warm before storing shaders_done = true at line 729, the main thread loops indefinitely waiting for shaders_done. Checking work.is_finished() || shaders_done.load(Ordering::Acquire) (or setting shaders_done via an RAII drop guard) prevents a hang.
  2. Cross-PR Linux build conflict with #2890: apps/victory/src/startup.rs:692, 738, 778, 781 unconditionally call victory_gpu::adapter_identity(), victory_gpu::set_caption_status(...), and crate::prebuild::run(...), whereas crates/victory-gpu/src/lib.rs:967-969 gates the first two under #[cfg(windows)] (and #2890 gates mod prebuild under #[cfg(windows)]). Worth gating/stubbing for non-Windows builds so #2907 and #2890 merge cleanly together.

Concurrency & Fallback Review

  • Memory ordering and background safety look solid: xmem::low_guards and d3d12x::use_shader_cache initialize before startup::prepare; background prebuild::run shares victory_gpu::pipeline::library safely via NAMES.hold(name), state mutex, and write_atomically's global lock; individual warm/prebuild failures warn without blocking launch or writing stale stamps.

Local Verification

  • cargo test --locked -p victory: 23/23 unit tests (including progress::tests 3/3, splash::tests 2/2, startup::tests 4/4) + 4/4 integration tests passed.
  • victory-gpu host::tests (--features diagnostics, VICTORY_D3D12_DEBUG=1): 16/16 on RTX 5090 (non-descriptor tests) and 31/31 on WARP.
  • cargo clippy --locked -p victory -p victory-gpu --all-targets -- -D warnings (default and --features victory-gpu/diagnostics) & cargo xtask policy (194 files ok): clean.
<!-- greyfinch-sync:Marvisak/VIctory:review:6066645137 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2907#pullrequestreview-6066645137). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T23:52:58Z. **Review:** COMMENTED --- Verified head `2a7b2aaa` cleanly merged onto `origin/main` (`63bcca43`) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + D3D12 WARP + `VICTORY_D3D12_DEBUG=1`). ### Findings 1. **Main-thread hang if the prebuild worker panics under default `Mode::Shaders` (`apps/victory/src/startup.rs:748-751`)**: For `Mode::Shaders`, `waited` only checks `shaders_done.load(Ordering::Acquire)` and does **not** check `work.is_finished()`. If `"victory prebuild"` panics inside `translate::warm` before storing `shaders_done = true` at line 729, the main thread loops indefinitely waiting for `shaders_done`. Checking `work.is_finished() || shaders_done.load(Ordering::Acquire)` (or setting `shaders_done` via an RAII drop guard) prevents a hang. 2. **Cross-PR Linux build conflict with `#2890`**: `apps/victory/src/startup.rs:692, 738, 778, 781` unconditionally call `victory_gpu::adapter_identity()`, `victory_gpu::set_caption_status(...)`, and `crate::prebuild::run(...)`, whereas `crates/victory-gpu/src/lib.rs:967-969` gates the first two under `#[cfg(windows)]` (and `#2890` gates `mod prebuild` under `#[cfg(windows)]`). Worth gating/stubbing for non-Windows builds so `#2907` and `#2890` merge cleanly together. ### Concurrency & Fallback Review - Memory ordering and background safety look solid: `xmem::low_guards` and `d3d12x::use_shader_cache` initialize before `startup::prepare`; background `prebuild::run` shares `victory_gpu::pipeline::library` safely via `NAMES.hold(name)`, `state` mutex, and `write_atomically`'s global lock; individual warm/prebuild failures warn without blocking launch or writing stale stamps. ### Local Verification - `cargo test --locked -p victory`: **23/23** unit tests (including `progress::tests` 3/3, `splash::tests` 2/2, `startup::tests` 4/4) + **4/4** integration tests passed. - `victory-gpu` `host::tests` (`--features diagnostics`, `VICTORY_D3D12_DEBUG=1`): **16/16** on RTX 5090 (non-descriptor tests) and **31/31** on WARP. - `cargo clippy --locked -p victory -p victory-gpu --all-targets -- -D warnings` (default and `--features victory-gpu/diagnostics`) & `cargo xtask policy` (`194 files ok`): clean.
alexandruiulian201-bot commented 2026-11-26 00:03:36 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by alexandruiulian201-bot on 2026-11-25T23:48:26Z.


The CI failure is because apps/victory/Cargo.toml added windows-sys without updating Cargo.lock, and CI runs with --locked.
Note: running cargo check --workspace (or cargo update --workspace) will add just the windows-sys entry for victory in Cargo.lock without bumping unrelated dependency versions (avoid cargo generate-lockfile)

<!-- greyfinch-sync:Marvisak/VIctory:comment:7178077922 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2907#issuecomment-7178077922). Originally posted by [alexandruiulian201-bot](https://github.com/alexandruiulian201-bot) on 2026-11-25T23:48:26Z. --- The CI failure is because `apps/victory/Cargo.toml` added `windows-sys` without updating `Cargo.lock`, and CI runs with `--locked`. Note: running `cargo check --workspace` (or `cargo update --workspace`) will add just the `windows-sys` entry for `victory` in `Cargo.lock` without bumping unrelated dependency versions (avoid `cargo generate-lockfile`)
0xkn0wh3r3 commented 2026-11-26 01:03:56 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-26T00:05:07Z.


@fuzeofficlal thanks, that was a real hang. Fixed in 69a0d48a: the wait is now startup::ready(mode, work.is_finished(), shaders_done), so the title starts once the worker has ended for any reason, including a panic, or once its shaders are done in the default mode. The new test the_title_starts_when_the_work_is_over_or_its_shaders_are_done covers both. The earlier CI failure was a missing Cargo.lock update, fixed in 2710e9c8.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7178377686 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2907#issuecomment-7178377686). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-26T00:05:07Z. --- @fuzeofficlal thanks, that was a real hang. Fixed in 69a0d48a: the wait is now `startup::ready(mode, work.is_finished(), shaders_done)`, so the title starts once the worker has ended for any reason, including a panic, or once its shaders are done in the default mode. The new test `the_title_starts_when_the_work_is_over_or_its_shaders_are_done` covers both. The earlier CI failure was a missing `Cargo.lock` update, fixed in 2710e9c8.
Marvisak commented 2026-11-26 03:05:06 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T02:19:26Z.


Automated triage for the maintainers.

Thanks for the reply. The offer to make the prebuild opt-in (VICTORY_PREBUILD=on) is noted. The windows-sys dependency and whether the launcher owns the prebuild step are still the maintainer's decision, so the verdict stays needs work: needs the maintainer's decision.

CI: passing.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7180691147 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2907#issuecomment-7180691147). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-26T02:19:26Z. --- <!-- victory-triage v1 head=69a0d48a980d9cd0a06121bb5147b80203af57c6 verdict=needs-work at=2026-11-26T07:23:33Z --> Automated triage for the maintainers. Thanks for the reply. The offer to make the prebuild opt-in (`VICTORY_PREBUILD=on`) is noted. The `windows-sys` dependency and whether the launcher owns the prebuild step are still the maintainer's decision, so the verdict stays **needs work: needs the maintainer's decision**. CI: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
0xkn0wh3r3 commented 2026-11-26 07:01:52 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-26T06:42:24Z.


Understood: the windows-sys dependency and whether the launcher should own the prebuild step and its window are your call. If you'd rather not change the default, I can make the prebuild opt-in (VICTORY_PREBUILD=on) so run --execute behaves as before unless asked.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7184700179 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2907#issuecomment-7184700179). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-26T06:42:24Z. --- Understood: the `windows-sys` dependency and whether the launcher should own the prebuild step and its window are your call. If you'd rather not change the default, I can make the prebuild opt-in (`VICTORY_PREBUILD=on`) so `run --execute` behaves as before unless asked.
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/2907:upstream-pr/2907'
git switch 'upstream-pr/2907'

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/2907'
git switch 'upstream-pr/2907'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2907'
git switch 'upstream-pr/2907'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2907'
git switch 'main'
git merge --squash 'upstream-pr/2907'
git switch 'main'
git merge --ff-only 'upstream-pr/2907'
git switch 'main'
git merge 'upstream-pr/2907'
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
Marvisak/VIctory!2905
No description provided.