Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
3ae2e21
Publish the working VIctory prologue snapshot.
KyleS98 Nov 25, 2026
ba0b1dc
Series S without DLSS: the title keeps its own upscaler, not FSR 4 (2…
KyleS98 Nov 27, 2026
69e0a93
Pipelines: the host first sees the static samplers in the same order …
KyleS98 Nov 27, 2026
edbc9c6
Write watch: the guards' lock can be waited for awake at first (VICTO…
KyleS98 Nov 27, 2026
3a20b11
README: VIctory-Neo (what it does, measured on an RTX 3090 Ti; quick …
KyleS98 Nov 27, 2026
bbc008c
VIctory-Neo moves onto the tree of trustno1-coder/VIctory-NVIDIA (d12…
KyleS98 Nov 27, 2026
a5b1335
Workspace tests pass on main again: the two budget tests pin VICTORY_…
jptorres96 Nov 27, 2026
d10daaa
README: the second change is described as what was shown (a fresh pip…
KyleS98 Nov 27, 2026
1e829b8
Merge trustno1-coder/VIctory-NVIDIA main (0cef07e): FSR 3 frame gener…
KyleS98 Nov 27, 2026
e9bb461
Shaders: the console's waterfall over a first-lane table offset is pr…
KyleS98 Nov 27, 2026
fe91b27
README: 32 frames a second, 62 shown with FSR 3 frame generation; the…
KyleS98 Nov 27, 2026
159f379
Revert the waterfall-by-shape change: with it, a wall in the prologue…
KyleS98 Nov 27, 2026
fb39630
README: back to the numbers without the reverted waterfall change (31…
KyleS98 Nov 27, 2026
2516a4b
README: DLSS frame generation on RTX 20/30 through MFG Unlocker (2x t…
KyleS98 Nov 27, 2026
b65b349
Merge trustno1-coder/VIctory-NVIDIA main (a4d05e7): save sharing in t…
KyleS98 Nov 28, 2026
018d54f
Two-die Ryzens and 8 GB cards: frame threads on one die, target reser…
claude Nov 28, 2026
271ff7d
Render target reserve settles once targets hold 1 GiB (Series S never…
claude Nov 28, 2026
eb439f9
TEMPORARY: diagnostics build by default, for one measurement of the c…
claude Nov 28, 2026
28483ba
Revert the temporary diagnostics build by default
claude Nov 28, 2026
4e91f84
Barrier groups that order no write left without a wait (VICTORY_SELEC…
claude Nov 28, 2026
02e2345
Revert selective barrier groups (VICTORY_SELECTIVE_BARRIERS)
claude Nov 28, 2026
59330bd
No wait after the clamp of one indirect command (VICTORY_INDIRECT_ONE…
claude Nov 28, 2026
08b5ed5
Log the build's commit and the VICTORY_ switches at the start of a run
claude Nov 28, 2026
f304112
Revert VICTORY_INDIRECT_ONE_WAIT
claude Nov 28, 2026
8afdf42
Input: the captured mouse turns the camera, and a start can give the …
KyleS98 Nov 28, 2026
c800cb2
Build: thin LTO, one codegen unit, x86-64-v3; the layer's own allocat…
KyleS98 Nov 28, 2026
3a6b62e
Refreshes: the vectorised compare at the two places that still compar…
KyleS98 Nov 28, 2026
9165dd0
Retired objects: a queue to each thread
KyleS98 Nov 28, 2026
b50184c
Cores: on a processor of two dies the layer's own threads keep to the…
KyleS98 Nov 28, 2026
37b0ace
Shaders: the console's waterfall over a first-lane table offset is pr…
KyleS98 Nov 27, 2026
0fb1e38
Write watch: a write fault asks about its one page, not about the reg…
KyleS98 Nov 28, 2026
38b768c
Play: no loop that keeps the card awake, write faults without the loc…
KyleS98 Nov 28, 2026
59a41b7
README: the build of 28 November (37 frames a second in the cell at t…
KyleS98 Nov 28, 2026
346bd2c
Cores: with processors of our own, the threads that translate lists k…
KyleS98 Nov 28, 2026
c79bb63
README: 39 frames a second in the cell with the layer's threads on th…
KyleS98 Nov 28, 2026
b0504e5
Merge upstream main (63b902f) into Neo
KyleS98 Nov 28, 2026
b71075e
Cores: VICTORY_TITLE_CPUS says where the title's threads run
KyleS98 Nov 28, 2026
316a8c0
Stand-in light: each part has a switch that VICTORY_AB can flip in a run
KyleS98 Nov 28, 2026
a6e85c6
Stand-in light: the light of transparent surfaces and particles is bo…
KyleS98 Nov 28, 2026
3aca295
Ambient: hold the resolved reflections to the light around (glowing e…
Ahyildiz Nov 28, 2026
8556a37
Card copies: big ones compared where written lately, and steps wait o…
ballsimulation Nov 27, 2026
7485770
Diagnostics: passes skipped in turn, to see one view with and without…
KyleS98 Nov 28, 2026
cfecf35
Play: the reflections' hold and the transparent light's bound on, the…
KyleS98 Nov 28, 2026
9a8e317
Input: the tables' letters go by their place alone, as upstream has them
KyleS98 Nov 28, 2026
81239fb
README, docs: the build of 28 November, afternoon; what was tried for…
KyleS98 Nov 28, 2026
5a86970
docs: the linker's row in what was tried for speed
KyleS98 Nov 28, 2026
7f6a7c9
Small and large texture pieces in blocks of their own (VICTORY_POOL_C…
claude Nov 28, 2026
9cf2601
Merge KyleS98/VIctory-Neo main (5a86970) into the 3070 Ti fork
claude Nov 28, 2026
e282553
Shaders and pipelines kept where VICTORY_SHADER_CACHE_DIR says
claude Nov 28, 2026
a1c607e
Shaders: VICTORY_WATERFALL_SHAPE=0 leaves Neo's proof of waterfalls b…
claude Nov 28, 2026
3e16f0d
Shaders: waterfalls proven by their shape off by default (VICTORY_WAT…
claude Nov 28, 2026
e6140be
Cores: VICTORY_OWN_CPUS=auto only where the title's sixteen processor…
claude Nov 28, 2026
8a9b37c
Shaders: VICTORY_WATERFALL_SHAPE=compute proves waterfalls by their s…
claude Nov 28, 2026
adbf7fd
Shaders, docs: VICTORY_WATERFALL_SHAPE=compute broke a face too
claude Nov 28, 2026
0b54581
docs: the 9900X guide with DLSS Performance and FSR 3 frame generatio…
claude Nov 28, 2026
0f8cc20
Merge pull request #81
trustno1-coder Nov 28, 2026
7fae2b2
Merge pull request #1179
trustno1-coder Nov 28, 2026
24a5d03
Merge pull request #949
trustno1-coder Nov 28, 2026
6c87718
Merge pull request #938
trustno1-coder Nov 28, 2026
cc1b924
Shaders: upstream's face-program exemption from shared memory's bound…
claude Nov 28, 2026
fa55d86
Precaching for VILauncher: PRECACHE.cmd, and shaders, warm and preloa…
claude Nov 29, 2026
9304ffb
run: MFG Unlocker loaded where VICTORY_MFG_UNLOCKER_DLL names it, as …
claude Nov 29, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
[alias]
xtask = "run --quiet --package xtask --"

# AVX2, BMI and FMA wherever the compiler finds a use for them (the title's
# own code needs AVX2 already: the consoles' processors have it).
[target.x86_64-pc-windows-msvc]
rustflags = ["-C", "target-cpu=x86-64-v3"]
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,6 @@ Thumbs.db
# What the F1 menu saved
/victory-settings.txt
/victory-settings.*.txt

# The game folder the launch and precache scripts remember (a path on this PC)
/game_dir.txt
19 changes: 19 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ license = "GPL-3.0-or-later"
publish = false

[workspace.dependencies]
mimalloc = { version = "0.1", default-features = false }
# Internal crates
victory-core = { path = "crates/victory-core" }
victory-pe = { path = "crates/victory-pe" }
Expand Down Expand Up @@ -71,9 +72,26 @@ opt-level = 2

[profile.release]
debug = "line-tables-only"
# One unit a crate and inlining across crates: the thread that prepares
# submissions spends its frame in small calls from victory-gpu into
# victory-hle and victory-shader and back.
lto = "thin"
codegen-units = 1

# The development build: release code generation plus the `diagnostics`
# feature (`cargo build --profile diag -p victory --features diagnostics`),
# kept in its own folder so it does not evict the plain release build.
[profile.diag]
inherits = "release"

# A build for the PC it is built on: release plus whole-program optimisation
# (`lto`, one code generation unit). Built with the CPU's own instructions
# (`scripts\play-foxhound.ps1 -Build native` sets RUSTFLAGS=-C target-cpu=native:
# AVX-512 on a Ryzen 9000), so the exe may not start on another processor.
# Into target\native, beside the release build, not in its place. Slower to
# build (several minutes more); helps the CPU side (the shader translator,
# hashing, copies), not the card.
[profile.native]
inherits = "release"
lto = "fat"
codegen-units = 1
12 changes: 12 additions & 0 deletions PRECACHE.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@echo off
rem Precaching: every shader of the title translated and the recorded pipelines built ahead of play,
rem into C:\VictoryCache (VICTORY_SHADER_CACHE_DIR) with the victory.exe VILauncher built. ASCII only.
rem PRECACHE.cmd as above
rem PRECACHE.cmd -GameDir "E:\Game" another game folder (else game_dir.txt, asked once)
setlocal
set "PS1=%~dp0scripts\precache.ps1"
set "PSH=powershell"
where pwsh >nul 2>nul && set "PSH=pwsh"
%PSH% -NoProfile -ExecutionPolicy Bypass -File "%PS1%" %*
echo.
pause
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ speed, in the picture and in simply being able to play it:
card a frame. They are left out there: no blocks and 30 fps instead of 25
on the first boat ride (RTX 5070), with water that is darker and bluer.
WATER LIGHT in the menu (`VICTORY_WATER_LIGHT=1`) runs them again.
`--set VICTORY_WATER_VOLUME_PORTALS=1` separately enables an experimental
lowering for the volume-portals compute shader on 32-lane hosts. An explicit
`VICTORY_WAVE_WIDE` setting takes precedence.
- **One command to play**: the launcher builds the layer the first time and
applies what the menu saved.
- **`Get-NVIDIA-DLSS.cmd`**: the eight NVIDIA files that are loaded, about
Expand Down Expand Up @@ -354,6 +357,9 @@ to check memory on systems with 32 GB of RAM or GPUs with 8 GB of VRAM.
- [docs/architecture.md](docs/architecture.md): the layer's parts.
- [docs/findings.md](docs/findings.md): measurements behind the choices.
- [docs/dlss.md](docs/dlss.md): DLSS and Frame Generation.
- [docs/ryzen-9900x-rtx-3070ti.md](docs/ryzen-9900x-rtx-3070ti.md): a
two-die Ryzen with an 8 GB card: what the layer does for it and the
settings to start from.
- [docs/linux-proton.md](docs/linux-proton.md): building on Linux and first
runs under Proton (experimental).
- [docs/fork-ray-tracing.md](docs/fork-ray-tracing.md): the title's ray tracing
Expand All @@ -365,6 +371,12 @@ to check memory on systems with 32 GB of RAM or GPUs with 8 GB of VRAM.

A tree of other people's work with a little on top; the history is kept.

- **[VIctory-Neo](https://github.com/KyleS98/VIctory-Neo)** by KyleS98,
merged on 2026-11-28 (GPL-3.0-or-later, from the same base, `63b902f`):
translated shaders that wait less, the layer's threads on the die the
title does not use (`VICTORY_OWN_CPUS`), write faults without the write
watch's lock, no loop that keeps the card awake, the reflections' hold
indoors and its speed measurements (docs/speed-methods.md).
- **[foxhound](https://github.com/readmet3xt-lab/foxhound)** by
readmet3xt-lab: the base of this fork since 2026-11-26, and through it:
- **[VIctory](https://github.com/Marvisak/VIctory)** by Marvisak and its
Expand Down
4 changes: 4 additions & 0 deletions apps/victory/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ clap.workspace = true
walkdir.workspace = true

[features]
default = ["mimalloc"]
# Our own allocations through mimalloc (`--no-default-features`: the process
# heap, as before).
mimalloc = ["victory-hle/mimalloc"]
# Debug-level logs and the debugging switches (frame capture, stack dumps,
# the host debug layer, scripted keys). Off in a plain release build.
diagnostics = [
Expand Down
16 changes: 16 additions & 0 deletions apps/victory/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,22 @@
//! the `D3D12` folder (or Windows' own, without one) came too late and every
//! start asked for 614. Loaded on its first use instead, it reads that version.
fn main() {
// The commit this build is of, for the log's first lines (a launcher that
// builds the repository by itself says nothing of which one it built).
let commit = std::process::Command::new("git")
.args(["rev-parse", "--short=10", "HEAD"])
.output()
.ok()
.filter(|o| o.status.success())
.and_then(|o| String::from_utf8(o.stdout).ok())
.map(|s| s.trim().to_owned())
.filter(|s| !s.is_empty())
.unwrap_or_else(|| "unknown".to_owned());
println!("cargo:rustc-env=VICTORY_COMMIT={commit}");
for git in ["../../.git/HEAD", "../../.git/refs/heads", "../../.git/packed-refs"] {
println!("cargo:rerun-if-changed={git}");
}
println!("cargo:rerun-if-changed=build.rs");
if std::env::var("CARGO_CFG_TARGET_ENV").as_deref() == Ok("msvc") {
println!("cargo:rustc-link-arg-bins=/EXPORT:D3D12SDKVersion,DATA");
println!("cargo:rustc-link-arg-bins=/EXPORT:D3D12SDKPath,DATA");
Expand Down
31 changes: 31 additions & 0 deletions apps/victory/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,12 @@ fn main() -> Result<()> {
title_args,
} => {
victory_hle::runtime::set_title_args(title_args);
// MFG Unlocker where `VICTORY_MFG_UNLOCKER_DLL` names it, as `play` does: a launcher
// that starts `run` itself (VILauncher) had no way to load it.
#[cfg(windows)]
if execute {
play::load_mfg();
}
run::run(&exe, unimplemented, strict, execute, console)
}
#[cfg(all(windows, feature = "diagnostics"))]
Expand Down Expand Up @@ -578,6 +584,31 @@ fn show_config() -> Result<()> {
}

/// Paths given on the command line, or the configured game + test titles.
/// The folder of the translated shaders, with the pipelines beside it:
/// `<VICTORY_SHADER_CACHE_DIR>\shaders` where that is set, else the cache's
/// `shaders`. `victory run`, `shaders`, `warm` and `preload` all
/// keep to it, so that a preload fills the folder the runs read.
///
/// A launcher that keeps the cache in a folder of its own may empty it: on
/// an RTX 3070 Ti started by VILauncher, 7 of 11 sessions in a day began
/// with no translation and no pipeline library (hits=0, about 2,250
/// shaders translated and 800 pipelines made again, the first cutscene
/// black for a minute), the sessions after a change of its launch options
/// or an update. A folder it does not know of keeps them.
pub(crate) fn shader_cache_dir(cfg: &victory_core::Config) -> Result<PathBuf> {
match std::env::var_os("VICTORY_SHADER_CACHE_DIR").filter(|v| !v.is_empty()) {
Some(root) => {
use anyhow::Context as _;
let dir = PathBuf::from(root).join("shaders");
std::fs::create_dir_all(&dir).with_context(|| format!("creating {} (VICTORY_SHADER_CACHE_DIR)", dir.display()))?;
// (On stderr: the processes of `warm` answer on stdout, line by line.)
eprintln!("shaders kept in {} (VICTORY_SHADER_CACHE_DIR)", dir.display());
Ok(dir)
}
None => cfg.cache_subdir("shaders"),
}
}

pub(crate) fn default_paths(paths: Vec<PathBuf>) -> Result<Vec<PathBuf>> {
if !paths.is_empty() {
return Ok(paths);
Expand Down
35 changes: 29 additions & 6 deletions apps/victory/src/play.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ const SETTINGS: &[(&str, &str)] = &[
("VICTORY_CARD_REHASH_RUNS", "1"),
("VICTORY_JOIN_COPIES", "1"),
("VICTORY_CARD_STEPS", "2"),
("VICTORY_CARD_AWAKE", "1"),
// Neo: no loop that keeps the card's clocks up. It took a tenth of the card (RTX 3090 Ti, the
// prologue's cell: the card 86 % busy with it and 76 % without, 30.7 and 31.7 frames a second).
("VICTORY_CARD_AWAKE", "0"),
("VICTORY_CARD_BUFFERS_MIN_KB", "64"),
("VICTORY_INDIRECT_WINDOW", "1"),
("VICTORY_INDIRECT_BATCH", "2"),
Expand Down Expand Up @@ -102,17 +104,33 @@ const SETTINGS: &[(&str, &str)] = &[
("VICTORY_AMBIENT", "0.8"),
("VICTORY_AMBIENT_AIR", "1.5"),
("VICTORY_AMBIENT_SPECULAR", "1"),
// Indoors, without it: the reflections the title resolves hold the sky's light (a
// terrarium's glass, a table top and a floor show white), and the dust in the air is lit
// as under the open sky (white specks)
("VICTORY_AMBIENT_REFLECT", "1"),
("VICTORY_AMBIENT_REFLECT_IN", "CS_TemporalResolve2_Opaque,CS_TemporalResolve1_Alpha"),
("VICTORY_AMBIENT_ALPHA", "4"),
// Pixel programs keep the console's early depth test
("VICTORY_EARLY_DEPTH", "1"),
// Left out: the decal heap's defragmentation and the heat-haze pass
("VICTORY_LEAVE_OUT", "02384a60fda6f2d0,731a39171b568298"),
// Pipelines the title makes are written down, for `victory warm`
("VICTORY_PIPELINE_BOOK", "1"),
// Memory stack (skornuta): texture slots left unused are given back, old command allocators
// are taken anew, small buffers share card memory (off since .8; on again 2026-11-28)
("VICTORY_SLOT_EVICT", "1"),
("VICTORY_ALLOCATOR_TRIM", "1"),
("VICTORY_BUDGET_PACK", "1"),
// (The tree this is built on turns the memory stack on here: VICTORY_SLOT_EVICT,
// VICTORY_ALLOCATOR_TRIM, VICTORY_BUDGET_PACK. Not in Neo: in the prologue's cell on an
// RTX 3090 Ti it took 38.5 frames a second where 39.4 ran without, and the process held as
// much memory either way; `--set VICTORY_SLOT_EVICT=1` and so on turn it on.)
// Neo, measured in the prologue's cell on an RTX 3090 Ti and a Ryzen 9 9950X3D (README):
// the title's write faults open their block without the write watch's one lock, and a
// store that faults is done beside the guard (one that changes nothing is left out)
("VICTORY_FAULT_UNLOCKED", "1"),
("VICTORY_STORE_BESIDE", "1"),
// On a processor of two dies the layer's own threads keep to the die the title does not use
("VICTORY_OWN_CPUS", "auto"),
// The title's own rate is 60, not 30: above 30 frames a second it would otherwise step
// 1/30 s a frame and run fast (the same loop of an idle animation 6.07 s at 36.8 frames a
// second without, 7.43 s with; 7.33 s at 30)
("VICTORY_FRAME_INTERVAL_MS", "16.667"),
];

/// Path settings a start keeps from its surroundings; every other
Expand Down Expand Up @@ -370,6 +388,11 @@ fn settings(o: &Play, menu: &[(String, String)], streamline: Option<&Path>) -> (
}
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());
// The title's own rate with it (`VICTORY_FRAME_INTERVAL_MS`, 60 in `SETTINGS`): a cap under 60
// is the rate the title is given too, 30 its own.
if (1..60).contains(&fps) {
set("VICTORY_FRAME_INTERVAL_MS", &format!("{:.3}", 1000.0 / f64::from(fps)));
}
for (k, v) in menu.iter().filter(|(k, _)| !k.starts_with("VICTORY_MENU_")) {
if v.is_empty() {
s.remove(k);
Expand Down
84 changes: 82 additions & 2 deletions apps/victory/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,16 @@ pub fn run(
if execute {
check_cpu_features()?;
}
// Which build, and with which switches: a launcher that builds and starts
// the layer by itself (VILauncher) shows neither, and a switch that never
// reached the layer looked like one that changed nothing.
let mut switches: Vec<String> = std::env::vars()
.filter(|(k, _)| k.starts_with("VICTORY_"))
.map(|(k, v)| format!("{k}={v}"))
.collect();
switches.sort();
println!("build commit {}", env!("VICTORY_COMMIT"));
victory_hle::log_build(env!("VICTORY_COMMIT"), &switches.join(" "));
// A title that relaunched itself: the old process must be gone first.
victory_hle::modules::lifecycle::wait_for_previous();
let cfg = victory_core::Config::load()?;
Expand Down Expand Up @@ -156,10 +166,15 @@ pub fn run(
let original = std::fs::read(exe).with_context(|| format!("reading {}", exe.display()))?;
let mut prepared = victory_loader::prepare(&original)?;
let hash = prepared.original_hash.to_hex();
match victory_game::identify(&hash) {
let build = victory_game::identify(&hash);
match build {
Some(build) => println!("build {} ({hash})", build.label),
None => println!("build unknown ({hash})"),
}
// (Not with the title's FidelityFX path asked for: DLSS, frame
// generation and `VICTORY_FSR_PATH` take the title's FidelityFX
// upscaler, which the known build's patches turn off.)
apply_title_patches(&mut prepared, build, upscaler.is_none())?;

// A 1440p output instead of the Series X's 4K one (`native_1440p`): the
// patched image goes to a folder of its own, beside the stock one.
Expand Down Expand Up @@ -211,7 +226,7 @@ pub fn run(
} else {
cfg.cache_subdir("images")?
};
victory_hle::modules::d3d12x::use_shader_cache(cfg.cache_subdir("shaders")?);
victory_hle::modules::d3d12x::use_shader_cache(crate::shader_cache_dir(&cfg)?);
let image = victory_loader::load(&prepared, &images)?;
// The program is mapped from the copy `load` wrote: the file's bytes
// and their patched copy are not read again, and were held for the
Expand Down Expand Up @@ -761,3 +776,68 @@ mod cpu_check_tests {
pub fn run(_: &Path, _: Unimplemented, _: bool, _: bool, _: Console) -> Result<()> {
anyhow::bail!("running titles requires Windows")
}

/// Bytes as lower-case hex.
#[cfg(windows)]
fn hex_str(bytes: &[u8]) -> String {
bytes.iter().map(|b| format!("{b:02x}")).collect()
}

/// The known build's code patches (`VICTORY_TITLE_PATCHES=0`: none; none
/// either unless `own_upscaler`: they make the title keep its own upscaler,
/// and the FidelityFX path of DLSS and frame generation needs the title's
/// choice left alone), then
/// any from `VICTORY_TITLE_PATCH=<rva>:<old hex>:<new hex>,...`. The old
/// bytes must be there (another build of the title is refused), and the
/// patched copy has a file name of its own.
#[cfg(windows)]
fn apply_title_patches(
prepared: &mut victory_loader::PreparedImage,
build: Option<&victory_game::KnownBuild>,
own_upscaler: bool,
) -> Result<()> {
let mut patches = Vec::new();
let mut names = Vec::new();
if !own_upscaler && build.is_some_and(|b| !b.patches.is_empty()) {
println!("title patch none: the title's FidelityFX path is asked for, its choice of upscaler is left to it");
} else if std::env::var("VICTORY_TITLE_PATCHES").as_deref() != Ok("0") {
for p in build.map_or(&[][..], |b| b.patches) {
patches.push((p.rva, p.expect.to_vec(), p.write.to_vec()));
names.push(p.name.to_owned());
}
}
let spec = std::env::var("VICTORY_TITLE_PATCH").unwrap_or_default();
for one in spec.split(',').filter(|p| !p.trim().is_empty()) {
let parts: Vec<&str> = one.split(':').collect();
anyhow::ensure!(
parts.len() == 3,
"VICTORY_TITLE_PATCH entry is not <rva>:<old>:<new>: {one}"
);
let rva = u32::from_str_radix(parts[0].trim().trim_start_matches("0x"), 16)?;
patches.push((rva, from_hex(parts[1])?, from_hex(parts[2])?));
names.push("VICTORY_TITLE_PATCH".to_owned());
}
if patches.is_empty() {
return Ok(());
}
prepared.patch(&patches)?;
for ((rva, old, new), name) in patches.iter().zip(names) {
println!(
"title patch +{rva:#x} {name}: {} -> {}",
hex_str(old),
hex_str(new)
);
}
Ok(())
}

/// Bytes from hex digits.
#[cfg(windows)]
fn from_hex(s: &str) -> Result<Vec<u8>> {
let s = s.trim();
anyhow::ensure!(s.len().is_multiple_of(2), "odd hex length: {s}");
(0..s.len())
.step_by(2)
.map(|i| u8::from_str_radix(&s[i..i + 2], 16).map_err(anyhow::Error::from))
.collect()
}
Loading