Make every shader first on a new version's first start, and go by whether MFG Unlocker loaded #1897

Open
igorevv wants to merge 7 commits from upstream-pr/1897 into main
igorevv commented 2026-11-29 01:57:36 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by igorevv on 2026-11-29T01:57:36Z.


Make every shader first on a new version's first start, and go by whether MFG Unlocker loaded

Summary

Three small launcher/Streamline fixes, each about a signal that did not mean what it
looked like.

  1. The first start of a new victory.exe now builds every shader before the game's
    first frame, instead of playing for ten seconds and restarting itself.
  2. DLSS Frame Generation is asked for because MFG Unlocker actually loaded, not
    because the launcher set an environment variable naming it.
  3. The older warm-up restart, which 1 leaves reachable, gets its mark back — without
    it, opting into --set VICTORY_WARMUP_RESTART restarts on every start.

Total: 5 files, +89 / −34. No behaviour changes outside these paths.


1. First start: make every shader first, once

The problem

A new victory.exe with DLSS Frame Generation on runs at about 14 fps on its first
start and normally from then on (#515, #574). The existing answer is a warm-up: play
ten seconds, then restart the game.

Turning that into a shader preload looked like a two-line change, and it was not —
it had three separate ways to fail.

It never ran at all. main.rs reads VICTORY_PRELOAD before prepare() is
called:

let preload = options.preload || std::env::var_os("VICTORY_PRELOAD").is_some_and(|v| v == "1");
let done = play::prepare(options).and_then(|ready| {
    if preload { play::preload(&ready.exe); }

and prepare() only exports its settings into the environment afterwards, in
std::env::set_var. Setting VICTORY_PRELOAD from prepare() therefore had no
effect on the start that set it.

It would have run on every start. The mark in
%LOCALAPPDATA%\victory\warmed was written only by the layer's warmup(), which
returns on its first line unless VICTORY_WARMUP_RESTART is above zero:

pub(crate) fn warmup_seconds() -> Option<u64> {
    get("VICTORY_WARMUP_RESTART").parse().ok().filter(|s| *s > 0)
}

With the restart replaced by a preload, nothing would ever write the mark, mark.exists()
would stay false, and every start would preload again — replacing a one-off ten-second
restart with a full shader build on every launch.

It left dead code behind. WARMUP_SECONDS lost its only use, which clippy -D warnings
rejects.

The change

prepare() writes the mark itself and reports the decision through the struct it
already returns:

pub(crate) struct Ready {
    pub(crate) exe: PathBuf,
    pub(crate) series_s: bool,
    /// The first start of this victory.exe: every shader is made before the
    /// game runs (`preload`), since the driver has none of them yet.
    pub(crate) preload: bool,
}
let mut preload = false;
if !s.contains_key("VICTORY_WARMUP_RESTART")
    && s.get("VICTORY_FRAMEGEN").is_some_and(|v| v == "1")
    && let Some(mark) = warmup_mark(&home, &program)
    && !mark.exists()
{
    if let Some(dir) = mark.parent() {
        let _ = std::fs::create_dir_all(dir);
    }
    let _ = std::fs::write(&mark, "this victory.exe made every shader on its first start\r\n");
    println!("First start of this version of victory.exe: every shader is made before the game starts,");
    println!("once (this takes a while, and a new version's first run otherwise stays at about 14 fps).");
    preload = true;
}

and main.rs honours either source of the request:

if preload || ready.preload {
    play::preload(&ready.exe);
}

WARMUP_SECONDS is removed with it.

The upstream condition VICTORY_FRAMEGEN == "1" is kept deliberately. Per #515 and
#574 it is Streamline's swap chain that holds a first run at 14 fps, not first runs in
general — preloading for everyone would cost minutes of shader work to fix a problem
those users do not have.

--set VICTORY_WARMUP_RESTART=<seconds> still asks for the older restart.

README.md is updated to describe what actually happens now.


2. MFG Unlocker: go by whether it loaded

The problem

The launcher sets VICTORY_MFG_UNLOCKER_DLL when F1's MFG UNLOCKER is on and the DLL
is on disk, but the DLL can still fail to load — and load_mfg only reports that on
the console:

match victory_hle::streamline::load_mod("MFG Unlocker (F1, MFG UNLOCKER)", &dll) {
    Ok(()) => println!("MFG Unlocker loaded ({}). Backspace opens its menu.", dll.display()),
    Err(code) => println!("MFG Unlocker did not load (Windows error {code}): running without it."),
}

Reading that variable as proof that the mod is in means a failed load still forces
DLSS Frame Generation on, on a card whose driver had said no.

The change

load_mod records the load where the rest of the layer can see it:

/// MFG Unlocker is in this process: [`load_mod`] loaded it. Its wrapping of NVIDIA's frame
/// generation is what may make DLSS Frame Generation run on a card the driver says has none.
/// The launcher's variable alone proves nothing — the DLL can fail to load, and the launcher
/// only reports that on the console.
static MFG_LOADED: AtomicBool = AtomicBool::new(false);
/// Whether MFG Unlocker actually loaded here ([`load_mod`]).
pub fn mfg_loaded() -> bool {
    MFG_LOADED.load(Acquire)
}

init, check_run and the start notice read mfg_loaded() instead of the variable.

When the mod is in, the card's own answer for DLSS_G is not the one to go by — an
RTX 20 or 30 says no and the mod makes it run anyway — while Reflex is still asked of
the driver, because frame generation needs its markers either way:

let framegen = if mfg_loaded && framegen_asked {
    let card = supported(abi::FEATURE_DLSS_G);
    tracing::info!(
        card_says = card.as_ref().err().map(String::as_str).unwrap_or("supported"),
        "MFG Unlocker is loaded: DLSS Frame Generation is asked for whatever the card answers"
    );
    report("Reflex", abi::FEATURE_REFLEX, supported(abi::FEATURE_REFLEX), sl)
} else { .. }

The start notice also keeps its own reading of the card, so a mod loaded the traditional
way — beside victory.exe as winmm.dll, with no variable set — still says so:

let unlocked_by_mod = f.mfg_loaded || (!f.adapter.is_empty() && !dlss_framegen_card(&f.adapter));

3. Warm-up restart: name its mark, or every start warms up again

The problem

Commit 1 makes the preload the default first start, but leaves
--set VICTORY_WARMUP_RESTART=<seconds> as the way back to the old behaviour. That
restart's mark is written by the layer:

// crates\victory-gpu\src\host\menu.rs
fn warmup(&mut self) {
    let Some(seconds) = warmup_seconds() else { return };
    ...
    let mark = std::path::PathBuf::from(get("VICTORY_WARMUP_MARK"));
    if !mark.as_os_str().is_empty() {
        ...
        let _ = std::fs::write(&mark, "this victory.exe was warmed up ...\r\n");
    }
    self.restart(false);
}

The layer is told the seconds and nothing else. It reads the mark's path from
VICTORY_WARMUP_MARK, and writes nothing when that is empty.

Commit 1 sets VICTORY_WARMUP_MARK only inside the preload branch, which is skipped
whenever VICTORY_WARMUP_RESTART is set. Before commit 1 both variables were set
together, so this is a regression in that commit: with the opt-in, no mark is ever
written, mark.exists() stays false, and every start of the same exe warms up, restarts,
and does it again on the next start.

The change

The launcher names the mark on the opt-in path too, and keeps warmup_mark lazy so a
start that needs no mark does not hash the exe:

let mut preload = false;
if s.contains_key("VICTORY_WARMUP_RESTART") {
    // The layer writes that one's mark; give it the path when there is one to write.
    if let Some(mark) = warmup_mark(&home, &program).filter(|m| !m.exists()) {
        s.insert("VICTORY_WARMUP_MARK".to_owned(), mark.to_string_lossy().into_owned());
    }
} else if s.get("VICTORY_FRAMEGEN").is_some_and(|v| v == "1")
    && let Some(mark) = warmup_mark(&home, &program).filter(|m| !m.exists())
{
    ...
}

One file, apps/victory/src/play.rs, and no new state: the mark that the preload branch
writes is the same one the layer now writes again.


Testing

Run on Windows, x86_64-pc-windows-msvc, one after the other on this branch:

cargo check --workspace
    Finished `dev` profile — no errors
cargo test -p victory
    test result: ok. 29 passed; 0 failed
    test result: ok. 2 passed; 0 failed        (tests/census.rs)
cargo test -p victory-gpu --lib streamline
    test result: ok. 24 passed; 0 failed

Commit 3 is launcher-side only — it sets an environment variable before the layer starts
— so there is no GPU path to test for it, and it was not run in the game.

cargo clippy --all-features --all-targets reports nothing in any of the five files
touched here. The warnings it still reports elsewhere (manual_is_multiple_of at
streamline.rs:2329, transmute in victory-loader, dropping_copy_types in
pipeline/known.rs, two in indirect.rs) are present on f9dfb76 before this branch.

What is not fixed here

  • indirect::tests::host_list_budget_starts_empty_at_each_submission and
    indirect::tests::warp_batch_charges_every_execution fail on f9dfb76 already;
    this branch does not touch indirect.rs. They fail deterministically on this machine,
    alone or with the rest: the clamp still empties the records but never charges the
    budget word (spent reads 0 where 134217728 is expected).
  • The pre-existing clippy warnings listed above are untouched, so
    clippy -D warnings is not green on this base.

One thing worth checking before merge

The preload replaces the warm-up restart on the first start, and the two do different
work: the preload builds shaders, while the restart ran the game through once and left
the driver's cache warm. If the 14 fps seen in #515/#574 is Streamline's swap chain and
not shader compilation, this trades a working ten-second restart for a preload that does
not fix it.

It needs a run on hardware where the problem reproduces — an RTX 20 or 30 with MFG
Unlocker, or an RTX 40/50 on a fresh build. --set VICTORY_WARMUP_RESTART=10 restores
the old behaviour for anyone who hits it; with commit 3 that path now marks the exe and
runs once, as it did before this branch.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5546618844 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1897). Originally posted by [igorevv](https://github.com/igorevv) on 2026-11-29T01:57:36Z. --- # Make every shader first on a new version's first start, and go by whether MFG Unlocker loaded ## Summary Three small launcher/Streamline fixes, each about a signal that did not mean what it looked like. 1. The first start of a new `victory.exe` now builds every shader *before* the game's first frame, instead of playing for ten seconds and restarting itself. 2. DLSS Frame Generation is asked for because MFG Unlocker **actually loaded**, not because the launcher set an environment variable naming it. 3. The older warm-up restart, which 1 leaves reachable, gets its mark back — without it, opting into `--set VICTORY_WARMUP_RESTART` restarts on every start. Total: 5 files, +89 / −34. No behaviour changes outside these paths. --- ## 1. First start: make every shader first, once ### The problem A new `victory.exe` with DLSS Frame Generation on runs at about 14 fps on its first start and normally from then on (#515, #574). The existing answer is a warm-up: play ten seconds, then restart the game. Turning that into a shader preload looked like a two-line change, and it was not — it had three separate ways to fail. **It never ran at all.** `main.rs` reads `VICTORY_PRELOAD` *before* `prepare()` is called: ```rust let preload = options.preload || std::env::var_os("VICTORY_PRELOAD").is_some_and(|v| v == "1"); let done = play::prepare(options).and_then(|ready| { if preload { play::preload(&ready.exe); } ``` and `prepare()` only exports its settings into the environment afterwards, in `std::env::set_var`. Setting `VICTORY_PRELOAD` from `prepare()` therefore had no effect on the start that set it. **It would have run on every start.** The mark in `%LOCALAPPDATA%\victory\warmed` was written only by the layer's `warmup()`, which returns on its first line unless `VICTORY_WARMUP_RESTART` is above zero: ```rust pub(crate) fn warmup_seconds() -> Option<u64> { get("VICTORY_WARMUP_RESTART").parse().ok().filter(|s| *s > 0) } ``` With the restart replaced by a preload, nothing would ever write the mark, `mark.exists()` would stay false, and every start would preload again — replacing a one-off ten-second restart with a full shader build on every launch. **It left dead code behind.** `WARMUP_SECONDS` lost its only use, which `clippy -D warnings` rejects. ### The change `prepare()` writes the mark itself and reports the decision through the struct it already returns: ```rust pub(crate) struct Ready { pub(crate) exe: PathBuf, pub(crate) series_s: bool, /// The first start of this victory.exe: every shader is made before the /// game runs (`preload`), since the driver has none of them yet. pub(crate) preload: bool, } ``` ```rust let mut preload = false; if !s.contains_key("VICTORY_WARMUP_RESTART") && s.get("VICTORY_FRAMEGEN").is_some_and(|v| v == "1") && let Some(mark) = warmup_mark(&home, &program) && !mark.exists() { if let Some(dir) = mark.parent() { let _ = std::fs::create_dir_all(dir); } let _ = std::fs::write(&mark, "this victory.exe made every shader on its first start\r\n"); println!("First start of this version of victory.exe: every shader is made before the game starts,"); println!("once (this takes a while, and a new version's first run otherwise stays at about 14 fps)."); preload = true; } ``` and `main.rs` honours either source of the request: ```rust if preload || ready.preload { play::preload(&ready.exe); } ``` `WARMUP_SECONDS` is removed with it. The upstream condition `VICTORY_FRAMEGEN == "1"` is **kept deliberately**. Per #515 and #574 it is Streamline's swap chain that holds a first run at 14 fps, not first runs in general — preloading for everyone would cost minutes of shader work to fix a problem those users do not have. `--set VICTORY_WARMUP_RESTART=<seconds>` still asks for the older restart. `README.md` is updated to describe what actually happens now. --- ## 2. MFG Unlocker: go by whether it loaded ### The problem The launcher sets `VICTORY_MFG_UNLOCKER_DLL` when F1's MFG UNLOCKER is on and the DLL is on disk, but the DLL can still fail to load — and `load_mfg` only reports that on the console: ```rust match victory_hle::streamline::load_mod("MFG Unlocker (F1, MFG UNLOCKER)", &dll) { Ok(()) => println!("MFG Unlocker loaded ({}). Backspace opens its menu.", dll.display()), Err(code) => println!("MFG Unlocker did not load (Windows error {code}): running without it."), } ``` Reading that variable as proof that the mod is in means a **failed** load still forces DLSS Frame Generation on, on a card whose driver had said no. ### The change `load_mod` records the load where the rest of the layer can see it: ```rust /// MFG Unlocker is in this process: [`load_mod`] loaded it. Its wrapping of NVIDIA's frame /// generation is what may make DLSS Frame Generation run on a card the driver says has none. /// The launcher's variable alone proves nothing — the DLL can fail to load, and the launcher /// only reports that on the console. static MFG_LOADED: AtomicBool = AtomicBool::new(false); /// Whether MFG Unlocker actually loaded here ([`load_mod`]). pub fn mfg_loaded() -> bool { MFG_LOADED.load(Acquire) } ``` `init`, `check_run` and the start notice read `mfg_loaded()` instead of the variable. When the mod is in, the card's own answer for `DLSS_G` is not the one to go by — an RTX 20 or 30 says no and the mod makes it run anyway — while Reflex is still asked of the driver, because frame generation needs its markers either way: ```rust let framegen = if mfg_loaded && framegen_asked { let card = supported(abi::FEATURE_DLSS_G); tracing::info!( card_says = card.as_ref().err().map(String::as_str).unwrap_or("supported"), "MFG Unlocker is loaded: DLSS Frame Generation is asked for whatever the card answers" ); report("Reflex", abi::FEATURE_REFLEX, supported(abi::FEATURE_REFLEX), sl) } else { .. } ``` The start notice also keeps its own reading of the card, so a mod loaded the traditional way — beside `victory.exe` as `winmm.dll`, with no variable set — still says so: ```rust let unlocked_by_mod = f.mfg_loaded || (!f.adapter.is_empty() && !dlss_framegen_card(&f.adapter)); ``` --- ## 3. Warm-up restart: name its mark, or every start warms up again ### The problem Commit 1 makes the preload the default first start, but leaves `--set VICTORY_WARMUP_RESTART=<seconds>` as the way back to the old behaviour. That restart's mark is written by the layer: ```rust // crates\victory-gpu\src\host\menu.rs fn warmup(&mut self) { let Some(seconds) = warmup_seconds() else { return }; ... let mark = std::path::PathBuf::from(get("VICTORY_WARMUP_MARK")); if !mark.as_os_str().is_empty() { ... let _ = std::fs::write(&mark, "this victory.exe was warmed up ...\r\n"); } self.restart(false); } ``` The layer is told the seconds and nothing else. It reads the mark's path from `VICTORY_WARMUP_MARK`, and writes nothing when that is empty. Commit 1 sets `VICTORY_WARMUP_MARK` only inside the preload branch, which is skipped whenever `VICTORY_WARMUP_RESTART` is set. Before commit 1 both variables were set together, so this is a regression in that commit: with the opt-in, no mark is ever written, `mark.exists()` stays false, and every start of the same exe warms up, restarts, and does it again on the next start. ### The change The launcher names the mark on the opt-in path too, and keeps `warmup_mark` lazy so a start that needs no mark does not hash the exe: ```rust let mut preload = false; if s.contains_key("VICTORY_WARMUP_RESTART") { // The layer writes that one's mark; give it the path when there is one to write. if let Some(mark) = warmup_mark(&home, &program).filter(|m| !m.exists()) { s.insert("VICTORY_WARMUP_MARK".to_owned(), mark.to_string_lossy().into_owned()); } } else if s.get("VICTORY_FRAMEGEN").is_some_and(|v| v == "1") && let Some(mark) = warmup_mark(&home, &program).filter(|m| !m.exists()) { ... } ``` One file, `apps/victory/src/play.rs`, and no new state: the mark that the preload branch writes is the same one the layer now writes again. --- ## Testing Run on Windows, `x86_64-pc-windows-msvc`, one after the other on this branch: ``` cargo check --workspace Finished `dev` profile — no errors cargo test -p victory test result: ok. 29 passed; 0 failed test result: ok. 2 passed; 0 failed (tests/census.rs) cargo test -p victory-gpu --lib streamline test result: ok. 24 passed; 0 failed ``` Commit 3 is launcher-side only — it sets an environment variable before the layer starts — so there is no GPU path to test for it, and it was not run in the game. `cargo clippy --all-features --all-targets` reports nothing in any of the five files touched here. The warnings it still reports elsewhere (`manual_is_multiple_of` at `streamline.rs:2329`, `transmute` in `victory-loader`, `dropping_copy_types` in `pipeline/known.rs`, two in `indirect.rs`) are present on `f9dfb76` before this branch. ## What is not fixed here - `indirect::tests::host_list_budget_starts_empty_at_each_submission` and `indirect::tests::warp_batch_charges_every_execution` fail on `f9dfb76` already; this branch does not touch `indirect.rs`. They fail deterministically on this machine, alone or with the rest: the clamp still empties the records but never charges the budget word (`spent` reads 0 where 134217728 is expected). - The pre-existing clippy warnings listed above are untouched, so `clippy -D warnings` is not green on this base. ## One thing worth checking before merge The preload replaces the warm-up restart on the first start, and the two do different work: the preload builds shaders, while the restart ran the game through once and left the driver's cache warm. If the 14 fps seen in #515/#574 is Streamline's swap chain and not shader compilation, this trades a working ten-second restart for a preload that does not fix it. It needs a run on hardware where the problem reproduces — an RTX 20 or 30 with MFG Unlocker, or an RTX 40/50 on a fresh build. `--set VICTORY_WARMUP_RESTART=10` restores the old behaviour for anyone who hits it; with commit 3 that path now marks the exe and runs once, as it did before this branch.
trustno1-coder commented 2026-11-29 08:27:46 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by trustno1-coder on 2026-11-29T08:27:46Z.


Thank you! An earlier version of this pull request was merged into main with its original commits and is part of v2026.11.29.01, where you are credited. GitHub does not show it as merged because new commits were pushed here after that merge. It stays open so those newer commits can be looked at next.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7253119903 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1897#issuecomment-7253119903). Originally posted by [trustno1-coder](https://github.com/trustno1-coder) on 2026-11-29T08:27:46Z. --- Thank you! An earlier version of this pull request was merged into main with its original commits and is part of [v2026.11.29.01](https://github.com/trustno1-coder/VIctory-NVIDIA/releases/tag/v2026.11.29.01), where you are credited. GitHub does not show it as merged because new commits were pushed here after that merge. It stays open so those newer commits can be looked at next.
dyshay commented 2026-11-29 17:49:01 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by dyshay on 2026-11-29T17:49:01Z.


Merged into our fork's integration branch for testing (dyshay/VIctory-NVIDIA, branch janus-prs). I read the full diff first: no network access, process spawning, binaries, build or dependency changes, or game data. It builds with --profile diag --features diagnostics, and the CPU tests of the touched crates pass. Runs on an RTX 4090 are queued (Series S with ray tracing, and Series X, DLSS Quality). Frame times will follow here.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7259986603 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1897#issuecomment-7259986603). Originally posted by [dyshay](https://github.com/dyshay) on 2026-11-29T17:49:01Z. --- Merged into our fork's integration branch for testing ([dyshay/VIctory-NVIDIA](https://github.com/dyshay/VIctory-NVIDIA/tree/janus-prs), branch `janus-prs`). I read the full diff first: no network access, process spawning, binaries, build or dependency changes, or game data. It builds with `--profile diag --features diagnostics`, and the CPU tests of the touched crates pass. Runs on an RTX 4090 are queued (Series S with ray tracing, and Series X, DLSS Quality). Frame times will follow here.
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/1897:upstream-pr/1897'
git switch 'upstream-pr/1897'

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/1897'
git switch 'upstream-pr/1897'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1897'
git switch 'upstream-pr/1897'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1897'
git switch 'main'
git merge --squash 'upstream-pr/1897'
git switch 'main'
git merge --ff-only 'upstream-pr/1897'
git switch 'main'
git merge 'upstream-pr/1897'
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
trustno1-coder/VIctory-NVIDIA!1897
No description provided.