Water light on, PS4 pads, F1 menu saves at once, long-session memory, memory switches

Rendering and memory (GPL-3.0 code ported in; credits in the source):
- Water: 64-lane compute programs on 32-lane waves keep each wave
  together through loops and set up shared memory from the first
  thread, so the water's tiled light no longer leaves dark blocks. It
  runs by default now (VICTORY_WATER_LIGHT=0 leaves it out; an empty
  value, an earlier version's saved OFF, runs it). Also cloud tiles and
  the screen probes' ray activation.
- Placed views: their padding cleared as before; folding a buffer
  view's first element into its address is VICTORY_PLACED_FOLD=1, off:
  with it on, clothing and caps swapped to other variants for single
  frames in the boat cutscene.
- Texture sweep: textures whose copy was let go leave the looks until
  used again. Static samplers made first, in one order. Small buffers
  made ahead of the first 3D frame.
- play mode: VICTORY_TEXSPK_PASS_MS=8, VICTORY_PASSES_HOT=1,
  VICTORY_HELPER_PRIORITY=1.
- Memory switches, all off: VICTORY_SLOT_EVICT, VICTORY_ALLOCATOR_TRIM,
  VICTORY_BUDGET_PACK (and VICTORY_LIST_POOL_IDLE_S).

Input: DualShock 4 (0x05C4, 0x09CC, 0x0BA0 adapter) read over HID, USB
and Bluetooth, beside the DualSense; PlayStation pads rumble, and stop
when the game ends (issue #352).

F1 menu: every change is saved at once; it saves to
victory-settings.txt in VICTORY_HOME or %LOCALAPPDATA%\victory however
the game was started (no more "NO SETTINGS FILE").

Warm-up start: its 30 s count from the first frame of 100 draws or
more, not from the start: waiting at the title screen restarted it too
early and the next run still sat at 14 fps.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
trustno1-coderandClaude Opus 5.5 committed 2026-11-27 15:03:27 -08:00
1 parent df2daafeb1
commit 64d4931b3d
44 files changed
+4664 -952

No files matched your search

+19 -12
View File
@@ -1,4 +1,4 @@
//! A 2560x1440 SDR display for the supported Series X retail image (GTA VI
//! A 2560x1440 SDR display for the supported Series X retail image (the game,
//! 1.0.2.1): the title presents at 3840x2160 on Series X, its scene drawn at
//! 2560x1440 and scaled up by its own temporal pass. With 1440p asked for
//! (`VICTORY_NATIVE_1440P=1`, or `VICTORY_RENDER_1080P=1` for a 1920x1080
@@ -16,11 +16,18 @@ use victory_formats::texture::{Dimension, Swizzle, Texture, TextureDesc};
use victory_hle::streamline::Mode;
use victory_loader::PreparedImage;
const RETAIL_BUILD: &str = "b99f876b74d4a77f03af5f878223b27bd647b5c35a79d5decd9f716504239e93";
/// Whether `bytes` are the stock ones whose BLAKE3 hash (hex) is `hash`.
/// The stock bytes of each place patched are kept as their hash only: no
/// bytes of the title are in this repository.
fn same(bytes: &[u8], hash: &str) -> bool {
blake3::hash(bytes).to_hex().as_str() == hash
}
pub(super) const RETAIL_BUILD: &str = "b99f876b74d4a77f03af5f878223b27bd647b5c35a79d5decd9f716504239e93";
pub(super) const WIDTH: u32 = 2560;
pub(super) const HEIGHT: u32 = 1440;
const SDR_MODE: u32 = 0x0615_c100;
const STOCK_SDR_MODE: [u8; 16] = [0, 15, 0, 0, 112, 8, 0, 0, 60, 0, 0, 0, 1, 0, 0, 0];
const STOCK_SDR_MODE: &str = "abfb5438d8153b6a0b8d08f33f4f0066e5383925b55aacc5f669131f3f51d4cf";
const SCANOUT_RESERVATION: u32 = 0x0247_ad4a;
const TEMPORAL_SCALE: u32 = 0x028f_1e7e;
const UI_VIEWPORT_LOAD: u32 = 0x0580_48d4;
@@ -34,7 +41,7 @@ pub(super) fn prepare(image: &mut PreparedImage, render_1080p: bool) -> Result<(
);
let mode = field::<16>(image, SDR_MODE)?;
ensure!(*mode == STOCK_SDR_MODE, "unexpected Series X SDR mode");
ensure!(same(&mode[..], STOCK_SDR_MODE), "unexpected Series X SDR mode");
mode[..4].copy_from_slice(&WIDTH.to_le_bytes());
mode[4..8].copy_from_slice(&HEIGHT.to_le_bytes());
@@ -79,18 +86,18 @@ pub(super) fn prepare(image: &mut PreparedImage, render_1080p: bool) -> Result<(
/// title's own temporal pass, or on Series S with the upscaler there the
/// FidelityFX path, 7).
const RENDERER_SELECTION: u32 = 0x007e_9421;
const STOCK_RENDERER_SELECTION: [u8; 8] = [0xb8, 6, 0, 0, 0, 0x0f, 0x45, 0xc1];
const STOCK_RENDERER_SELECTION: &str = "f0633abf37df17124108b1e37be64645bd4b2412b0524c2f89334f22bd948464";
/// The FidelityFX path's render size: the console check's result (Series S)
/// is noted as the FidelityFX quality mode and picks the scaled branch
/// (`movzx eax, al; mov [r14+0x90], eax; test al, al; jne`), whose scale
/// multiplies the output size.
const UPSCALER_SIZING: u32 = 0x028e_f69a;
const STOCK_UPSCALER_SIZING: [u8; 14] = [0x0f, 0xb6, 0xc0, 0x41, 0x89, 0x86, 0x90, 0, 0, 0, 0x84, 0xc0, 0x75, 0x0a];
const STOCK_UPSCALER_SIZING: &str = "2ae2ac102d12ca003cb218413ef018e4dba68fc2003654a30c1743e13a820ffd";
/// The native branch's load of 1.0, and the scaled branch's of the scale.
const NATIVE_LOAD: u32 = 0x028e_f6a8;
const STOCK_NATIVE_LOAD: [u8; 10] = [0xc5, 0xfa, 0x10, 0x05, 0x28, 0x78, 0x6d, 0x03, 0xeb, 0x08];
const STOCK_NATIVE_LOAD: &str = "2579c24601d173b086a8136edf54ffd82720e6bf186f9139274bb09a45ddadf5";
const SCALED_LOAD: u32 = 0x028e_f6b2;
const STOCK_SCALED_LOAD: [u8; 8] = [0xc5, 0xfa, 0x10, 0x05, 0xa2, 0xe2, 0x86, 0x03];
const STOCK_SCALED_LOAD: &str = "e218882c95d2e16163a409d55b3451519414eb87c4d6220785dc09852d4e14f4";
/// The scale the scaled branch loads (shared with other code: not written).
const UPSCALER_SCALE: u32 = 0x0615_d95c;
@@ -112,10 +119,10 @@ pub(super) fn prepare_upscaler(image: &mut PreparedImage, mode: Mode) -> Result<
image.original_hash.to_hex().as_str() == RETAIL_BUILD,
"the upscaler path is only known for the retail build {RETAIL_BUILD}"
);
ensure!(*field::<8>(image, RENDERER_SELECTION)? == STOCK_RENDERER_SELECTION, "unexpected renderer selection");
ensure!(*field::<14>(image, UPSCALER_SIZING)? == STOCK_UPSCALER_SIZING, "unexpected upscaler render size selection");
ensure!(*field::<10>(image, NATIVE_LOAD)? == STOCK_NATIVE_LOAD, "unexpected upscaler native scale load");
ensure!(*field::<8>(image, SCALED_LOAD)? == STOCK_SCALED_LOAD, "unexpected upscaler scaled load");
ensure!(same(&field::<8>(image, RENDERER_SELECTION)?[..], STOCK_RENDERER_SELECTION), "unexpected renderer selection");
ensure!(same(&field::<14>(image, UPSCALER_SIZING)?[..], STOCK_UPSCALER_SIZING), "unexpected upscaler render size selection");
ensure!(same(&field::<10>(image, NATIVE_LOAD)?[..], STOCK_NATIVE_LOAD), "unexpected upscaler native scale load");
ensure!(same(&field::<8>(image, SCALED_LOAD)?[..], STOCK_SCALED_LOAD), "unexpected upscaler scaled load");
ensure!(*field::<4>(image, UPSCALER_SCALE)? == (2.0f32 / 3.0).to_le_bytes(), "unexpected upscaler scale");
let temporal = f32::from_le_bytes(*field::<4>(image, TEMPORAL_SCALE)?);
ensure!(
+9 -3
View File
@@ -69,6 +69,12 @@ const SETTINGS: &[(&str, &str)] = &[
("VICTORY_UPLOAD_AHEAD", "1"),
("VICTORY_SHOW_AFTER", "1"),
("VICTORY_MAP_THREADS", "1"),
// A frame's texture passes within 8 ms together; helpers woken at each submission's start
// (foxhound 0.2.0-pre.4, from its PR #13; its launcher sets 8 and 1)
("VICTORY_TEXSPK_PASS_MS", "8"),
("VICTORY_PASSES_HOT", "1"),
// The layer's threads a frame waits for, above normal priority (foxhound: cutscene worst second 74.8 -> 63.8 ms)
("VICTORY_HELPER_PRIORITY", "1"),
// Shader writes into big write-combined copies stay on the card
("VICTORY_WC_NO_BACK", "1"),
("VICTORY_WC_NO_BACK_MIN_KB", "1024"),
@@ -747,7 +753,7 @@ fn mod_dlls(here: &Path) -> Vec<String> {
}
/// How long the first start of a new victory.exe plays before it restarts.
const WARMUP_SECONDS: u32 = 20;
const WARMUP_SECONDS: u32 = 30;
/// The file that says this victory.exe (its bytes) had its warm-up start:
/// `%LOCALAPPDATA%\victory\warmed\<hash>`. `None`: the exe could not be read.
@@ -839,8 +845,8 @@ pub(crate) fn prepare(o: &Play) -> Result<Ready> {
&& let Some(mark) = warmup_mark(&home, &program)
&& !mark.exists()
{
println!("First start of this version of victory.exe: the game restarts by itself after {WARMUP_SECONDS} seconds,");
println!("once (a new version's first run otherwise stays at about 14 fps).");
println!("First start of this version of victory.exe: the game restarts by itself {WARMUP_SECONDS} seconds after it");
println!("loads into the game (press A at the title screen), once (a new version's first run otherwise stays at about 14 fps).");
s.insert("VICTORY_WARMUP_RESTART".to_owned(), WARMUP_SECONDS.to_string());
s.insert("VICTORY_WARMUP_MARK".to_owned(), mark.to_string_lossy().into_owned());
}
+4 -2
View File
@@ -465,8 +465,10 @@ fn retranslate(folder: &std::path::Path, into: &std::path::Path, view_limit: u32
}
}
println!("{} containers not found", missing.len());
victory_shader::emit::set_host_max_wave(64);
victory_shader::emit::set_host_rdna(true);
// (`VICTORY_HOST_WAVE=32`: as for a host of 32-lane waves; `VICTORY_HOST_RDNA=0`: not AMD's.)
let wave = std::env::var("VICTORY_HOST_WAVE").ok().and_then(|v| v.trim().parse().ok()).unwrap_or(64);
victory_shader::emit::set_host_max_wave(wave);
victory_shader::emit::set_host_rdna(std::env::var_os("VICTORY_HOST_RDNA").is_none_or(|v| v != "0"));
victory_shader::emit::set_view_heap_limit(view_limit);
victory_shader::emit::set_raw_views(raw_views);
let all: Vec<_> = wanted.iter().collect();
+72 -3
View File
@@ -38,6 +38,70 @@ fn check_cpu_features() -> Result<()> {
check_cpu_features_with(has_avx2, skip.as_deref())
}
/// The executable a run was pointed at: the file itself, or, given a folder, the one
/// executable in it (of several, the one whose name begins with `game`).
/// What to tell when the executable is not the retail build that the 1440p
/// and DLSS patches know: often it is that build, changed in place by
/// another tool (an FPS unlock changed 6 bytes and kept the stock file as
/// `.exe.bak`: issue #6 of the public repository). A file beside it whose
/// name begins as the executable's, of the same size, that hashes to the
/// retail build is named.
fn changed_copy(exe: &Path) -> String {
let len = std::fs::metadata(exe).map_or(0, |m| m.len());
let stem = exe.file_stem().and_then(|s| s.to_str()).unwrap_or_default().to_ascii_lowercase();
let stock = exe
.parent()
.and_then(|dir| std::fs::read_dir(dir).ok())
.into_iter()
.flatten()
.flatten()
.map(|entry| entry.path())
.filter(|p| {
p.as_path() != exe
&& p.file_name().and_then(|n| n.to_str()).is_some_and(|n| n.to_ascii_lowercase().starts_with(&stem))
&& std::fs::metadata(p).is_ok_and(|m| m.is_file() && m.len() == len)
})
.find(|p| std::fs::read(p).is_ok_and(|bytes| blake3::hash(&bytes).to_hex().as_str() == native_1440p::RETAIL_BUILD));
match stock {
Some(stock) => format!(
"{} is not the unchanged retail executable: it was changed in place (for example by an FPS patch). The unchanged one is {}: copy it back over the changed one, or choose the 1080p class or DLSS off. (For more than 30 fps use the launcher's frame-rate setting.)",
exe.display(),
stock.display()
),
None => format!(
"{} is not the unchanged retail executable of version 1.0.2.1 (another build, or changed in place, for example by an FPS patch). 1440p output and DLSS need the unchanged file: restore it, or choose the 1080p class or DLSS off.",
exe.display()
),
}
}
fn title_executable(given: &Path) -> Result<std::path::PathBuf> {
if !given.is_dir() {
anyhow::ensure!(given.exists(), "{} does not exist: give the title's executable, or the folder it is in", given.display());
return Ok(given.to_path_buf());
}
let mut exes: Vec<std::path::PathBuf> = std::fs::read_dir(given)
.with_context(|| format!("listing {}", given.display()))?
.filter_map(|e| e.ok().map(|e| e.path()))
.filter(|p| p.is_file() && p.extension().is_some_and(|x| x.eq_ignore_ascii_case("exe")))
.collect();
exes.sort();
let game = |p: &std::path::PathBuf| {
p.file_name().is_some_and(|n| n.to_string_lossy().to_ascii_lowercase().starts_with("game"))
};
if exes.len() > 1 && exes.iter().filter(|p| game(p)).count() == 1 {
exes.retain(game);
}
match exes.as_slice() {
[one] => Ok(one.clone()),
[] => anyhow::bail!(
"{} is a folder with no executable in it: give the title's executable, or the folder it is in",
given.display()
),
_ => anyhow::bail!("{} is a folder with {} executables in it: give the title's own", given.display(), exes.len()),
}
}
#[cfg(windows)]
pub fn run(
exe: &Path,
@@ -85,6 +149,10 @@ pub fn run(
upscaler.map(|m| format!(", scene at the {} scale ({})", m.name(), m.scale())).unwrap_or_default()
);
}
// A folder in place of the executable: the title's executable in it (reading a folder
// as a file fails with "Access is denied", which says nothing of the mistake).
let found = title_executable(exe)?;
let exe = found.as_path();
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();
@@ -102,7 +170,8 @@ pub fn run(
if upscaler.is_some() && render_1080p {
println!("display VICTORY_RENDER_1080P is left out: VICTORY_DLSS_MODE sets the scene's size");
}
let (w, h) = native_1440p::prepare(&mut prepared, render_1080p && upscaler.is_none())?;
let (w, h) = native_1440p::prepare(&mut prepared, render_1080p && upscaler.is_none())
.map_err(|e| if victory_game::identify(&hash).is_some() { e } else { e.context(changed_copy(exe)) })?;
// SAFETY: nothing else runs yet; the title and the display mode list
// read these later.
unsafe {
@@ -209,7 +278,7 @@ pub fn run(
);
println!("missing dlls {message}");
// None of their imports can be bound, so the title stops at its first
// call into one (Grand Theft Auto VI 1.0.2.1 at +0x2237178 during
// call into one (the game, build 1.0.2.1, at +0x2237178 during
// System Init, #930) with nothing saying why. Stubs only if asked for.
if execute && matches!(unimplemented, Unimplemented::Trap) {
anyhow::bail!(
@@ -406,7 +475,7 @@ fn timers(base: usize, size: usize) {
/// Debugging aid: `VICTORY_POKE=<rva>:<byte>,...` (hex) writes the byte at
/// each title+rva twice a second. A title that ends itself when its main
/// loop has not ticked for a while (Grand Theft Auto VI: 30 s) runs on
/// loop has not ticked for a while (the game: 30 s) runs on
/// through slower frames with its tick flag poked. The address must be
/// writable title data.
#[cfg(all(windows, feature = "diagnostics"))]
+17
View File
@@ -98,6 +98,13 @@ struct Totals {
pub fn run(paths: Vec<PathBuf>, verbose: bool, disasm: bool) -> Result<()> {
let paths = crate::default_paths(paths)?;
let mut t = Totals::default();
// `VICTORY_SHADER_ONLY=<hash>,<hash>`: only the containers with these hashes (the 16
// digits a run's log names a shader by); `VICTORY_SHADER_SAVE=<folder>`: each one's
// bytes written there as `<hash>.bin`.
let only: Option<Vec<String>> = std::env::var("VICTORY_SHADER_ONLY")
.ok()
.map(|v| v.split(',').map(|h| h.trim().to_ascii_lowercase()).filter(|h| !h.is_empty()).collect());
let save = std::env::var_os("VICTORY_SHADER_SAVE").map(PathBuf::from);
for root in &paths {
for entry in walkdir::WalkDir::new(root)
.into_iter()
@@ -120,6 +127,16 @@ pub fn run(paths: Vec<PathBuf>, verbose: bool, disasm: bool) -> Result<()> {
eprintln!("corrupt record {}{}", path.display(), source.label());
continue;
};
if let Some(only) = &only {
let hash = blake3::hash(&bytes).to_hex();
if !only.iter().any(|h| h == &hash[..16]) {
continue;
}
if let Some(dir) = &save {
std::fs::create_dir_all(dir)?;
std::fs::write(dir.join(format!("{}.bin", &hash[..16])), &bytes)?;
}
}
let Ok(container) = Container::parse(&bytes) else {
continue;
};