AMD FSR 3 frame generation for cards without DLSS frame generation; start notice; F1 preload

- FSR 3 frame generation (AMD FidelityFX 2.x DLLs, never in the repository:
  VICTORY_FIDELITYFX_DIR or a fidelityfx folder beside victory.exe), 2x at most,
  with the HUD-less picture so the HUD is not doubled. Series X needs DLSS upscaling.
- F1 menu: FRAME GEN TYPE (auto, DLSS, FSR 3); PRELOAD SHADERS; unset rows read NOT SET;
  save and restart opens its own console window.
- A notice at the start (30 s on the picture, and in the console): the GPU, which
  frame generation runs, and why not (DLSS off, NVIDIA files missing, or the card).
- victory preload / --preload; warm keys its work to the program's path.
- Logs are named victory-nvidia-...; README: what each card supports, first.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
trustno1-coderandClaude Opus 5.5 committed 2026-11-27 09:06:36 -08:00
1 parent d12eb1b23d
commit 29d8dbf7d9
12 files changed
+1712 -118

No files matched your search

+23
View File
@@ -129,6 +129,17 @@ enum Command {
#[arg(long, hide = true)]
these: Option<String>,
},
/// Preload: `shaders` and then `warm` over the title's folder, and the
/// pipelines a run makes while it loads stored in the pipeline library
/// the runs start with; what they say is shown as they go (the F1 menu's "PRELOAD SHADERS" has the
/// launcher do this before the title starts). A while, maybe long on
/// slower hardware; an update of the translator or the driver needs it
/// again. Stopped, it goes on where it was the next time.
#[cfg(windows)]
Preload {
/// The title's folder (default: the configured game folder).
paths: Vec<PathBuf>,
},
/// Play: the title with this fork's settings, as a start with no
/// command at all does (a double click on the program beside the
/// title's `game_scarlett_master.exe`). F1 in the game is the settings
@@ -213,7 +224,12 @@ fn main() -> Result<()> {
// before anything else is set up.
#[cfg(windows)]
if let Command::Play(options) = &cli.command {
// (Read before `prepare` clears the `VICTORY_...` variables: the menu's restart sets it.)
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);
}
victory_core::logging::init("info");
let console = if ready.series_s { Console::SeriesS } else { Console::SeriesX };
run::run(&ready.exe, Unimplemented::Trap, false, true, console)
@@ -269,6 +285,13 @@ fn main() -> Result<()> {
#[cfg(windows)]
Command::Warm { jobs, limit, again, used, these } => warm::run(jobs, limit, again, used, these),
#[cfg(windows)]
Command::Preload { paths } => {
play::explain_preload();
translate::precompile(paths, None)?;
warm::run(None, None, false, false, None)?;
warm::into_library(None)
}
#[cfg(windows)]
Command::Play(_) => unreachable!("handled above"),
#[cfg(windows)]
Command::GetDlss => play::get_dlss(),
+95 -4
View File
@@ -88,9 +88,12 @@ const KEPT: &[&str] = &[
"VICTORY_CACHE_DIR",
"VICTORY_DATA_DIR",
"VICTORY_STREAMLINE_DIR",
"VICTORY_FIDELITYFX_DIR",
"VICTORY_LOG",
];
const FG_TYPES: [&str; 3] = ["auto", "dlss", "fsr"];
const RESOLUTIONS: [&str; 3] = ["1440", "1080to1440", "4k"];
const DLSS_MODES: [&str; 5] = ["off", "dlaa", "quality", "balanced", "performance"];
@@ -116,12 +119,55 @@ pub(crate) struct Play {
/// Frame generation not made ready at the start.
#[arg(long)]
no_framegen_ready: bool,
/// Which frame generation: auto (DLSS frame generation where the card has
/// it, RTX 40 and later, else AMD FSR 3), dlss, or fsr (2X at most). FSR 3
/// needs AMD's FidelityFX DLLs (`VICTORY_FIDELITYFX_DIR`, else a
/// `fidelityfx` folder beside this program) and, on Series X, DLSS.
#[arg(long, default_value = "auto", value_parser = FG_TYPES)]
fg_type: String,
/// Frames a second at most (30: the title's own rate; 1000: no cap).
#[arg(long, default_value_t = 1000, value_parser = clap::value_parser!(u32).range(1..=1000))]
fps: u32,
/// Add or override a switch, as often as needed: `--set VICTORY_X=1`.
#[arg(long = "set", value_name = "NAME=VALUE")]
more: Vec<String>,
/// Make every shader before the title starts (`victory preload`, as the
/// F1 menu's "PRELOAD SHADERS" does): a while, maybe long.
#[arg(long)]
pub(crate) preload: bool,
}
/// What a preload is, said before it begins.
pub(crate) fn explain_preload() {
println!();
println!("Preloading shaders: every shader of the title is translated, then the pipelines the game");
println!("made in earlier runs are built, and those it needs while loading are stored where it loads");
println!("them from at the start, so it does not stop to make them while you play.");
println!("This takes a while, and possibly a long time, depending on your hardware (CPU above all).");
println!("What is done is kept: stopped (close this window), the next preload goes on from there.");
println!("A later update of this build, or a new graphics driver, may need a new preload.");
println!();
}
/// Runs `victory preload` over the title's folder with this start's settings
/// (the translations depend on them), then lets the start go on, whatever came of it.
pub(crate) fn preload(exe: &Path) {
let folder = exe.parent().map(Path::to_path_buf).unwrap_or_default();
let began = std::time::Instant::now();
let done = std::env::current_exe().and_then(|program| {
std::process::Command::new(program)
.arg("preload")
.arg(&folder)
// Its own lines in this window; the start's log is the title's.
.env_remove("VICTORY_LOG_FILE")
.status()
});
let minutes = began.elapsed().as_secs_f64() / 60.0;
match done {
Ok(s) if s.success() => println!("Shaders preloaded in {minutes:.1} min. Starting the game."),
Ok(s) => println!("The preload stopped ({s}) after {minutes:.1} min; what it did is kept. Starting the game."),
Err(e) => println!("The preload did not start ({e}). Starting the game."),
}
}
/// `%LOCALAPPDATA%\victory`.
@@ -177,6 +223,7 @@ fn settings(o: &Play, menu: &[(String, String)], streamline: Option<&Path>) -> (
times = n;
}
}
let fg_type = saved("VICTORY_MENU_FG_TYPE").filter(|t| FG_TYPES.contains(t)).unwrap_or(&o.fg_type);
let fps = saved("VICTORY_MENU_FPS")
.and_then(|f| f.parse::<u32>().ok())
.filter(|f| (1..=1000).contains(f))
@@ -213,6 +260,22 @@ fn settings(o: &Play, menu: &[(String, String)], streamline: Option<&Path>) -> (
set("VICTORY_TEXTURE_ROOM_PERCENT", if framegen { "80" } else { "86" });
}
}
// AMD FSR 3 frame generation, made ready as DLSS frame generation is: auto, the layer uses
// it only where DLSS frame generation does not run; fsr, DLSS frame generation is not asked.
// The layer checks the files and the card and says at the start what runs and why not.
if fg_type != "dlss" && (framegen || !o.no_framegen_ready) {
set("VICTORY_FSR_FRAMEGEN", "1");
if fg_type == "fsr" {
s.remove("VICTORY_FRAMEGEN");
}
let mut set = |k: &str, v: &str| drop(s.insert(k.to_owned(), v.to_owned()));
let x = *framegen_x.get_or_insert(if framegen { times } else { 0 });
set("VICTORY_FRAMEGEN_X", &x.to_string());
if !s.contains_key("VICTORY_TEXTURE_ROOM_PERCENT") {
s.insert("VICTORY_TEXTURE_ROOM_PERCENT".to_owned(), if framegen { "80" } else { "86" }.to_owned());
}
}
let mut set = |k: &str, v: &str| drop(s.insert(k.to_owned(), v.to_owned()));
set("VICTORY_FRAME_INTERVAL_US", &(1_000_000.0 / f64::from(fps)).round().to_string());
for (k, v) in menu.iter().filter(|(k, _)| !k.starts_with("VICTORY_MENU_")) {
if v.is_empty() {
@@ -230,6 +293,7 @@ fn settings(o: &Play, menu: &[(String, String)], streamline: Option<&Path>) -> (
set("VICTORY_MENU_RES", res);
set("VICTORY_MENU_DLSS", if dlss_on { dlss } else { "off" });
set("VICTORY_MENU_FRAMEGEN", &framegen_x.unwrap_or(0).to_string());
set("VICTORY_MENU_FG_TYPE", fg_type);
set("VICTORY_MENU_FPS", &fps.to_string());
(s, series_s)
}
@@ -260,16 +324,21 @@ fn log_file(logs: &Path) -> Result<PathBuf> {
.flatten()
.flatten()
.map(|e| e.path())
.filter(|p| p.file_name().is_some_and(|n| n.to_string_lossy().starts_with("play-")))
// ("play-": the name before 2026-11-27; it sorts first, so goes first.)
.filter(|p| p.file_name().is_some_and(|n| n.to_string_lossy().starts_with(LOG_PREFIX) || n.to_string_lossy().starts_with("play-")))
.collect();
old.sort();
for gone in old.iter().rev().skip(9) {
let _ = std::fs::remove_file(gone);
}
let now = std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).map_or(0, |d| d.as_secs());
Ok(logs.join(format!("play-{}-{}.log", stamp(now), std::process::id())))
Ok(logs.join(format!("{LOG_PREFIX}{}-{}.log", stamp(now), std::process::id())))
}
/// The start of the built-in launcher's log names (scripts\play-foxhound.ps1's
/// are `victory-nvidia-<date>-<time>.log`, kept apart from these).
const LOG_PREFIX: &str = "victory-nvidia-play-";
/// Runs the fetcher: NVIDIA's files from NVIDIA's GitHub into `to`.
fn fetch(to: &Path) -> Result<()> {
std::fs::create_dir_all(to).with_context(|| format!("creating {}", to.display()))?;
@@ -416,8 +485,10 @@ mod tests {
dlss: "quality".to_owned(),
framegen: None,
no_framegen_ready: false,
fg_type: "auto".to_owned(),
fps: 1000,
more: Vec::new(),
preload: false,
}
}
@@ -444,9 +515,29 @@ mod tests {
#[test]
fn without_nvidias_files_there_is_no_dlss() {
let (s, _) = settings(&options(), &[], None);
let get = |k: &str| s.get(k).map(String::as_str);
assert!(!s.contains_key("VICTORY_DLSS") && !s.contains_key("VICTORY_FRAMEGEN"));
assert!(!s.contains_key("VICTORY_TEXTURE_ROOM_PERCENT"));
assert_eq!(s.get("VICTORY_MENU_DLSS").map(String::as_str), Some("off"));
assert_eq!(get("VICTORY_MENU_DLSS"), Some("off"));
// FSR 3 frame generation is made ready instead (the layer says whether it can run)
assert_eq!((get("VICTORY_FSR_FRAMEGEN"), get("VICTORY_FRAMEGEN_X")), (Some("1"), Some("0")));
assert_eq!(get("VICTORY_TEXTURE_ROOM_PERCENT"), Some("86"));
assert_eq!(get("VICTORY_MENU_FG_TYPE"), Some("auto"));
}
#[test]
fn fsr_chosen_leaves_dlss_frame_generation_unasked() {
let mut o = options();
o.framegen = Some(3);
let menu = parse_menu("VICTORY_MENU_FG_TYPE=fsr\r\n");
let (s, _) = settings(&o, &menu, Some(Path::new("x")));
let get = |k: &str| s.get(k).map(String::as_str);
assert_eq!((get("VICTORY_DLSS"), get("VICTORY_FRAMEGEN")), (Some("1"), None));
assert_eq!((get("VICTORY_FSR_FRAMEGEN"), get("VICTORY_FRAMEGEN_X")), (Some("1"), Some("3")));
assert_eq!((get("VICTORY_MENU_FG_TYPE"), get("VICTORY_MENU_FRAMEGEN")), (Some("fsr"), Some("3")));
// dlss: no FSR 3
o.fg_type = "dlss".to_owned();
let (s, _) = settings(&o, &[], Some(Path::new("x")));
assert_eq!((s.get("VICTORY_FRAMEGEN").map(String::as_str), s.get("VICTORY_FSR_FRAMEGEN")), (Some("1"), None));
}
#[test]
+9 -2
View File
@@ -60,13 +60,20 @@ pub fn run(
// is loaded before anything of the title or the host GPU, and fails soft;
// only if it offers one of them does the title render through its
// FidelityFX path, which DLSS takes over (`native_1440p::prepare_upscaler`).
let asked = victory_hle::streamline::Asked::from_env().map_err(anyhow::Error::msg)?;
let mut asked = victory_hle::streamline::Asked::from_env().map_err(anyhow::Error::msg)?;
asked.series_s = matches!(console, Console::SeriesS);
let available = victory_hle::streamline::init(&asked);
// `VICTORY_FSR_PATH=1`: the title's FidelityFX path at VICTORY_DLSS_MODE's
// scale with its own FidelityFX upscaling (no Streamline): DLSS's
// comparison, and on Series X what that path alone looks like.
let fsr_path = std::env::var_os("VICTORY_FSR_PATH").is_some_and(|v| v == "1");
let upscaler = (available.dlss || available.framegen || fsr_path).then_some(asked.mode);
// (FSR 3 frame generation reads the upscaling's inputs as DLSS Frame
// Generation does: the title renders through its FidelityFX path too.)
let upscaler = (available.dlss || available.framegen || available.fsr_framegen || fsr_path).then_some(asked.mode);
// What this card does for frame generation (also on the picture for the first seconds).
for (i, line) in victory_hle::streamline::notice_at_start().iter().enumerate() {
println!("{}{line}", if i == 0 { "frame gen " } else { " " });
}
if fsr_path && !asked.any() {
println!("upscaling the title's own FidelityFX at the {} scale (VICTORY_FSR_PATH=1)", asked.mode.name());
}
+65 -1
View File
@@ -32,8 +32,18 @@ pub fn run(jobs: Option<usize>, limit: Option<usize>, again: bool, used: bool, t
return make(&dir, &these);
}
let began = Instant::now();
// (A first preload on a PC no run has written pipelines down on yet: none known.)
std::fs::create_dir_all(&dir).with_context(|| format!("creating {}", dir.display()))?;
victory_hle::known_pipelines::use_translations(dir.with_file_name("shaders"));
let fingerprint = known::fingerprint();
// The driver keeps what is made here by program path: made by another copy of
// this program, a pipeline is not made for this one.
let fingerprint = {
let program = std::env::current_exe().map(|p| p.to_string_lossy().to_lowercase()).unwrap_or_default();
let mut h = blake3::Hasher::new();
h.update(known::fingerprint().as_bytes());
h.update(program.as_bytes());
h.finalize().to_hex()[..16].to_owned()
};
let done_file = dir.join("warm-done.txt");
let bad_file = dir.join("warm-bad.txt");
let keys = known::keys(&dir);
@@ -127,6 +137,60 @@ pub fn run(jobs: Option<usize>, limit: Option<usize>, again: bool, used: bool, t
Ok(())
}
/// `victory preload`'s last step: the pipelines a run makes while it loads
/// (the early list) and those that take a second or more, made again in this
/// process and stored in the host pipeline library the runs load at their
/// start. `run` made them in processes of their own first, so the driver has
/// them and they come quickly; those that ended a process are left out. Not
/// all the known ones: one process holding the compiler's memory for 88,000
/// pipelines is what `AT_ONCE` keeps `run` from.
pub fn into_library(jobs: Option<usize>) -> Result<()> {
let dir = folder()?;
let cfg = victory_core::Config::load()?;
known::use_library(cfg.cache_subdir("shaders")?);
let keys = known::keys(&dir);
let read = |file: &str| std::fs::read_to_string(dir.join(file)).unwrap_or_default();
let (bad, early, slow) = (read("warm-bad.txt"), read("early-pipelines.txt"), read("slow-pipelines.txt"));
let bad: HashSet<&str> = bad.lines().filter_map(|l| l.split(' ').next()).collect();
let early: HashSet<&str> = early.lines().collect();
let slow: HashSet<&str> = slow.lines().filter_map(|l| l.split(' ').next()).filter(|k| !k.is_empty()).collect();
let mut all: Vec<usize> = (0..keys.len())
.filter(|&n| {
let key = keys[n].as_str();
!bad.contains(key) && (early.contains(key) || slow.contains(key))
})
.collect();
all.sort_by_key(|&n| (!early.contains(keys[n].as_str()), &keys[n]));
let threads = jobs.unwrap_or_else(|| std::thread::available_parallelism().map_or(4, |n| n.get()) * 2 / 3).max(1);
println!("into the pipeline library: {} pipelines (loading and slow ones), {threads} threads", all.len());
let began = Instant::now();
let (count, made) = (AtomicUsize::new(0), AtomicUsize::new(0));
std::thread::scope(|s| {
for t in 0..threads {
let these: Vec<usize> = all.iter().copied().skip(t).step_by(threads).collect();
let (count, made, total, dir) = (&count, &made, all.len(), &dir);
s.spawn(move || {
known::make(dir, &these, |_, came| {
let Some((_, there)) = came else { return };
made.fetch_add(usize::from(there), Ordering::Relaxed);
let n = count.fetch_add(1, Ordering::Relaxed) + 1;
if n.is_multiple_of(500) {
println!("{n} of {total} in the library, {:.0} s", began.elapsed().as_secs_f64());
}
});
});
}
});
known::keep_library();
println!(
"{} of {} in the pipeline library in {:.0} s",
made.load(Ordering::Relaxed),
all.len(),
began.elapsed().as_secs_f64()
);
Ok(())
}
fn lock<T>(m: &Mutex<T>) -> std::sync::MutexGuard<'_, T> {
m.lock().unwrap_or_else(|e| e.into_inner())
}