Merge pull request #554 from jackonick/bench-routes

Benchmark routes: VICTORY_BENCH_ROUTE=downtown|drive
This commit is contained in:
goldfishdev
2026-12-05 14:22:01 -06:00
committed by GitHub
10 changed files with 2141 additions and 14 deletions

View File

@ -130,6 +130,7 @@ existing `local/menu.conf` is migrated once, with a backup at
| `VICTORY_FSR_4K` | unset | FSR 4 (or FSR 3.1 fallback on RDNA 2/3) to the output size; requires `CONSOLE=series-x` and `./setup.sh fsr4` |
| `VICTORY_FIDELITYFX_FRAMEGEN` | unset | AMD frame generation over FSR 4 (or FSR 3.1 fallback on RDNA 2/3); `4`: experimental ML frame generation (FSR FG 4.x from the driver, direct path only; RDNA 4, run `./setup.sh win11` once for a Windows 11 prefix, and an amdxc64.dll shim with MLFG support from GE-Proton 11, Proton-EM 10.0-33+ or proton-cachyos (`./setup.sh fsr4` picks it); without it, falls back to the built-in 3.x generator on the direct path, never the proxy) |
| `VICTORY_BVH_BUILDER` | `1` | `0`: no ray tracing |
| `VICTORY_BENCH_ROUTE` | unset | `downtown`, or the experimental `drive`; see [Benchmark routes](#benchmark-routes) |
| `VICTORY_CARD_PULL` | unset | `0`: CPU reads GPU memory; `1`: GPU copies; unset auto |
| `VICTORY_PANEL` | `full` | `full`, `compact`, `fps`, `off`; `F3` hides, `Shift+F3` steps |
| `VICTORY_LOG` | `info` | `info`, `warn`, `error`, `off` |
@ -200,7 +201,9 @@ mouse-lock keys, DualSense/DualShock details and controller settings are in
`rt` runs with ray tracing on, `nort` with it off. `VICTORY_BENCH_MINUTES` sets
the length: 1 to 240, default 5. The run uses Series X, FSR 4 Quality to
3840x2160, no frame generation, intro skipped and the full panel.
The `F1` menu's benchmark rows start the same run.
The `F1` menu's benchmark rows start the same run. Benchmark runs force
`VICTORY_FRAME_INTERVAL_MS=0`, so a play cap in `run.conf` or the title's
settings does not limit the measured frame rate.
Enter (and the first controller's A) is pressed once a second from 5 to 65
seconds. The game closes after the requested time. For runs of 2 minutes or
@ -213,6 +216,60 @@ log is made. The game restarts with your settings; a crash also writes results
and restarts. Uploading to the [PortWatch](https://portwatch-vi.xyz/lab/#report)
form is manual.
### Benchmark routes
```sh
./run.sh play VICTORY_BENCH=nort VICTORY_BENCH_MINUTES=6 VICTORY_BENCH_ROUTE=downtown
./run.sh play VICTORY_BENCH=rt VICTORY_BENCH_MINUTES=6 VICTORY_BENCH_ROUTE=drive
./run.sh play VICTORY_BENCH_ROUTE=drive # just watch it, no recording
```
`VICTORY_BENCH_ROUTE` takes the player along a fixed route, built into
VIctory (no mods needed). Downtown aims to show runs on different machines the
same places; drive is an experimental demo. Coordinates are fixed in the code,
not taken from your save.
After a 15 second settle, each route waits for the ground at its start to
stream in (downtown at the corner, drive over the start) and for the car to be
made; the route clock starts after that setup, so its start is about 15
seconds plus load time after the player appears. It sets the time to 12:00 with
the clock paused and the weather to clear (`sunny`, held), allows no wanted
level (a police chase would make runs differ), and makes the player invincible.
Use downtown against downtown for comparable figures; the drive route is an
experimental demo whose path and scenes vary from run to run.
- `downtown`: a noclip flight around a 2400 m square over the city (corner
-2600, -1000), at 30 m/s, 40 m above the ground (following it, smoothed),
in a Dinka Blista with collision off, the camera sweeping 60 degrees each
way every 6 seconds. One lap is about 5 min 20 s; the default 5 minute run
stops before the lap ends, so set `VICTORY_BENCH_MINUTES=6` for a full lap.
- `drive`: **experimental, not comparable.** The player is put at -2556,
6948 in a Dinka Blista, and the game's own AI drives to -2405, 6862.5, a
vehicle-node point, turns around and comes back, with traffic on. The AI
may take a different road each time: in the six-minute gate run, legs took
111, 31 and 63 seconds, and another leg had passed 155 seconds when the run
ended; the first lap took 142 seconds, and the next was not finished after
more than 218 seconds. The earlier -2399, 7172 to -2566, 7202 leg left the
road network and drove into trees; the vehicle-node query found no road at
either point. A leg not done in 600 seconds stops the route instead of
skipping it, but a normal 6-minute run ends well before that, so a stuck
experimental-drive run can still report `ran`; use downtown for gate
comparisons. Each leg's log line has its time and distance; keep those lines
with the result, and do not compare drive figures across machines.
With `VICTORY_BENCH`, the run's time and its figures start when the route
starts; the first 30 seconds of the route are left out, and
`bench_stats.txt` names the route and says whether it ran or stopped. The game
log has a `bench route:` line for the start, each lap or leg, and anything that
stops the route. A route that cannot start (another game build, a fault in a
game call, a failed spawn) is not recorded as a route: the benchmark is timed
and skipped as a normal run. A failure after setup has begun to change the
world (a ground or spawn timeout, a refused car) is marked
`route_status=failed_after_setup`; that run is not comparable and should not
be submitted. A route that stops after starting is recorded as
`route_status=stopped`; the game may then be in an inconsistent state, so
restart it.
The routes need game build 1.0.2.1 (Xbox Series) and do not mix with ViceHook,
which hooks the same game function.
## Diagnostics and development
Build the diagnostics profile with `PROFILE=diag ./build.sh`. Page sampling, RT
@ -262,4 +319,5 @@ cxy0072019-sketch and [gassy](https://codeberg.org/erry/coasting/src/branch/sex)
## License
GPL-3.0-or-later. See [LICENSE](LICENSE).
GPL-3.0-or-later. See [LICENSE](LICENSE). Third-party notices are in
[THIRD-PARTY.md](THIRD-PARTY.md).

38
THIRD-PARTY.md Normal file
View File

@ -0,0 +1,38 @@
# Third-party notices
## ViceHook
Parts of `crates/victory-loader/src/bench_route.rs` follow ViceHook's script
hook, native-call guard, thread election and spawn implementation
(<https://github.com/0x000NULL/vicehook>, MIT).
MIT License
Copyright (c) 2026 Ethan Aldrich
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
## Native database
The native ids, names and argument layouts in `bench_route.rs` follow the
GTA VI NativeDB from ScriptHook VI
(<https://github.com/modpapi/scripthook-vi>), licensed under CC BY 4.0
(<https://creativecommons.org/licenses/by/4.0/>), as carried by ViceHook's
`sdk/inc/natives.h`. The MIT text above covers ViceHook's own code; the
database is attributed here separately.

View File

@ -442,6 +442,14 @@ pub fn run(
// SAFETY: as above.
unsafe { victory_loader::range_allocator::apply(image.base(), size) };
}
// A fixed benchmark route (VICTORY_BENCH_ROUTE=downtown|drive, off
// without it): the game's script tick hooked to take the player along.
#[cfg(windows)]
if execute {
let size = image.info().size_of_image as usize;
// SAFETY: the image stays mapped and nothing of it has run yet.
unsafe { victory_loader::bench_route::apply_asked(image.base(), size) };
}
if !execute {
println!("not executing (pass --execute to start the title)");
return Ok(());

View File

@ -2,11 +2,20 @@
//! `VICTORY_BENCH=rt` or `nort` over the user's settings, and the game
//! closes itself after `VICTORY_BENCH_MINUTES`. Here: what was asked, and
//! the frame rate figures.
//!
//! `VICTORY_BENCH_ROUTE` adds a fixed route the player is taken along (see
//! [`Route`]; driven by `victory_loader::bench_route`). In a benchmark run
//! with a route, the run's clock starts when the route does; the first
//! [`ROUTE_SKIPPED_SECONDS`] of route frames are left out of its figures.
/// Minutes at the start left out of the figures (loading and menus), in
/// runs of at least twice this.
pub const SKIPPED_SECONDS: f64 = 60.0;
/// Seconds at the start of a route left out of its figures: streaming and
/// first-use work, kept out of cross-machine comparisons.
pub const ROUTE_SKIPPED_SECONDS: f64 = 30.0;
/// Whether this process is a benchmark run.
pub fn running() -> bool {
std::env::var("VICTORY_BENCH").is_ok_and(|v| v == "rt" || v == "nort")
@ -49,6 +58,154 @@ pub fn presses_enter() -> bool {
)
}
/// A fixed route for benchmark runs (`VICTORY_BENCH_ROUTE`): the same
/// places, the same way, on every machine (game build 1.0.2.1).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Route {
/// `downtown`: a noclip flight around a 2400 m square over the city, at
/// 30 m/s, 40 m above the ground, the camera sweeping side to side.
Downtown,
/// `drive`: experimental. The game's AI drives the player's car to a fixed
/// road point and back, with traffic, but may choose different roads; its
/// measured scenes and lap times are not comparable between runs.
Drive,
}
impl Route {
/// The route `VICTORY_BENCH_ROUTE` names (case ignored), if any.
pub fn parse(name: &str) -> Option<Route> {
match name.trim().to_ascii_lowercase().as_str() {
"downtown" => Some(Route::Downtown),
"drive" => Some(Route::Drive),
_ => None,
}
}
/// Its name, as `VICTORY_BENCH_ROUTE` takes it.
pub fn name(self) -> &'static str {
match self {
Route::Downtown => "downtown",
Route::Drive => "drive",
}
}
}
/// The route asked for with `VICTORY_BENCH_ROUTE`, if a known one.
pub fn route() -> Option<Route> {
static ROUTE: std::sync::OnceLock<Option<Route>> = std::sync::OnceLock::new();
*ROUTE.get_or_init(|| {
std::env::var("VICTORY_BENCH_ROUTE")
.ok()
.and_then(|v| Route::parse(&v))
})
}
static ROUTE_STATE: std::sync::atomic::AtomicU8 =
std::sync::atomic::AtomicU8::new(RouteState::Pending as u8);
/// How the route asked for stands in a benchmark run.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
pub enum RouteState {
/// Asked for, not started yet.
Pending,
/// Under way at the end of the run.
Running,
/// Could not start: another build, a handler mismatch, or a fault before
/// the route began. A benchmark run then goes on as a normal one.
Failed,
/// Failed after setup had begun to change the world (time, weather,
/// invincibility, player position). The run is not a normal free-roam
/// benchmark and its figures are not comparable.
FailedAfterSetup,
/// Ran, then stopped early.
Stopped,
}
/// Sets how the route stands.
pub fn set_route_state(state: RouteState) {
ROUTE_STATE.store(state as u8, std::sync::atomic::Ordering::Relaxed);
}
/// How the route asked for stands.
pub fn route_state() -> RouteState {
match ROUTE_STATE.load(std::sync::atomic::Ordering::Relaxed) {
x if x == RouteState::Running as u8 => RouteState::Running,
x if x == RouteState::Failed as u8 => RouteState::Failed,
x if x == RouteState::FailedAfterSetup as u8 => RouteState::FailedAfterSetup,
x if x == RouteState::Stopped as u8 => RouteState::Stopped,
_ => RouteState::Pending,
}
}
/// Starts the route only if it is still pending. A concurrent failure (for
/// example the benchmark's wait timeout) wins; the caller must stop.
pub fn try_start_route() -> bool {
ROUTE_STATE
.compare_exchange(
RouteState::Pending as u8,
RouteState::Running as u8,
std::sync::atomic::Ordering::Relaxed,
std::sync::atomic::Ordering::Relaxed,
)
.is_ok()
}
/// The `downtown` flight: the square's corner (x, y), the ground height the
/// flight is measured from where the ground has not streamed in yet, the
/// side in metres, the speed in m/s and the height above the ground.
pub const DOWNTOWN_CORNER: (f32, f32) = (-2600.0, -1000.0);
pub const DOWNTOWN_GROUND: f32 = 5.0;
pub const DOWNTOWN_SIDE: f32 = 2400.0;
pub const DOWNTOWN_SPEED: f32 = 30.0;
pub const DOWNTOWN_UP: f32 = 40.0;
/// The `drive` route's two points (absolute map x, y), driven in order and
/// around again; the car starts at the first, facing the second. The second
/// is a vehicle-node point, but the AI may take different roads to it; the
/// route is experimental and its scenes are not comparable between runs.
pub const DRIVE_WAYPOINTS: [(f32, f32); 2] = [(-2556.0, 6948.0), (-2405.0, 6862.5)];
/// The game's heading (degrees, 0 north, counter-clockwise) of travel from
/// `from` to `to`.
pub fn heading(from: (f32, f32), to: (f32, f32)) -> f32 {
(-(to.0 - from.0)).atan2(to.1 - from.1).to_degrees()
}
/// Where the `downtown` flight is `seconds` after it started: (x, y), the
/// heading, and the laps completed. Corner, then +x, +y, back -x, -y.
pub fn downtown_at(seconds: f32) -> ((f32, f32), f32, u32) {
let side = DOWNTOWN_SIDE;
let corners = [
(0.0, 0.0),
(side, 0.0),
(side, side),
(0.0, side),
(0.0, 0.0),
];
let travelled = seconds.max(0.0) * DOWNTOWN_SPEED;
let d = travelled % (4.0 * side);
let leg = ((d / side) as usize).min(3);
let f = (d - leg as f32 * side) / side;
let (a, b) = (corners[leg], corners[leg + 1]);
let (x0, y0) = DOWNTOWN_CORNER;
let at = (x0 + a.0 + (b.0 - a.0) * f, y0 + a.1 + (b.1 - a.1) * f);
(at, heading(a, b), (travelled / (4.0 * side)) as u32)
}
/// The camera's sweep (radians, relative to the heading) `seconds` into the
/// flight: +-60 degrees over a 6 s period.
pub fn downtown_sweep(seconds: f32) -> f32 {
(seconds * std::f32::consts::TAU / 6.0).sin() * 60f32.to_radians()
}
/// The flight's height over smoothed ground `ground` (none yet: the
/// reference height).
pub fn downtown_height(ground: Option<f32>) -> f32 {
let floor = DOWNTOWN_GROUND + DOWNTOWN_UP;
ground.map_or(floor, |g| floor.max(g + DOWNTOWN_UP))
}
/// The times between presented frames, in seconds.
#[derive(Default)]
pub struct Recorder {
@ -84,12 +241,35 @@ impl Recorder {
} else {
0.0
};
self.summary_skipping(skip)
}
/// The figures, leaving out the first `skip` seconds of frames.
pub fn summary_skipping(&self, skip: f64) -> Option<Summary> {
self.summary_between(skip, None)
}
/// The figures, leaving out the first `skip` seconds and any frame that
/// starts at or after `end` seconds.
pub fn summary_between(&self, skip: f64, end: Option<f64>) -> Option<Summary> {
let mut at = 0.0;
let first = self.frames.iter().position(|dt| {
at += dt;
at > skip
})?;
let frames = &self.frames[first..];
let frames: Vec<f64> = self
.frames
.iter()
.copied()
.filter(|dt| {
let start = at;
at += dt;
at > skip && end.is_none_or(|end| start < end)
})
.collect();
Self::summarize(&frames)
}
fn summarize(frames: &[f64]) -> Option<Summary> {
if frames.is_empty() {
return None;
}
let seconds: f64 = frames.iter().sum();
let average = frames.len() as f64 / seconds;
let mut sorted = frames.to_vec();
@ -159,4 +339,48 @@ mod tests {
assert_eq!(r.summary().unwrap().frames, 100);
assert_eq!(Recorder::default().summary(), None);
}
#[test]
fn a_stopped_run_ends_at_the_stop_time() {
let mut r = Recorder::default();
(0..100).for_each(|_| r.add(0.1));
let s = r.summary_between(1.0, Some(5.0)).unwrap();
assert!((40..=41).contains(&s.frames));
assert!((s.seconds - 4.0).abs() < 0.11);
let s = r.summary_between(0.0, Some(5.0)).unwrap();
assert!((50..=51).contains(&s.frames));
}
#[test]
fn routes_are_named_as_documented() {
assert_eq!(Route::parse("downtown"), Some(Route::Downtown));
assert_eq!(Route::parse(" Drive "), Some(Route::Drive));
assert_eq!(Route::parse("beach"), None);
assert_eq!(Route::Drive.name(), "drive");
}
#[test]
fn the_flight_goes_around_the_square() {
let close = |a: f32, b: f32| (a - b).abs() < 0.01;
let ((x, y), h, laps) = downtown_at(0.0);
assert!(close(x, -2600.0) && close(y, -1000.0) && laps == 0);
// East first (heading -90: the game's headings turn left from north).
assert!(close(h, -90.0));
let ((x, y), h, _) = downtown_at(40.0);
assert!(close(x, -2600.0 + 1200.0) && close(y, -1000.0) && close(h, -90.0));
let ((x, y), h, _) = downtown_at(100.0);
assert!(close(x, -200.0) && close(y, -1000.0 + 600.0) && close(h, 0.0));
let ((x, y), _, laps) = downtown_at(320.0 + 10.0);
assert!(close(x, -2300.0) && close(y, -1000.0) && laps == 1);
assert!(close(downtown_sweep(1.5), 60f32.to_radians()));
assert!(close(downtown_height(None), 45.0));
assert!(close(downtown_height(Some(100.0)), 140.0));
assert!(close(downtown_height(Some(-20.0)), 45.0));
}
#[test]
fn the_drive_starts_toward_the_first_leg() {
assert!(heading(DRIVE_WAYPOINTS[0], DRIVE_WAYPOINTS[1]) < 0.0);
assert_eq!(DRIVE_WAYPOINTS.len(), 2);
}
}

View File

@ -2,23 +2,102 @@
//! timed from the first one, and when the time is up the frame about to be
//! presented, panel included, is saved as `screenshot.png` with the figures
//! (`bench_stats.txt`) in `VICTORY_BENCH_DIR`, and the game ends.
//!
//! With a route (`VICTORY_BENCH_ROUTE`) the frames are timed from the
//! route's start, after [`bench::ROUTE_SKIPPED_SECONDS`] of route warm-up; a
//! route that cannot start is not recorded as one and the run is timed and
//! skipped as a normal benchmark.
use std::path::PathBuf;
use std::sync::Mutex;
use std::time::{Duration, Instant};
use victory_core::bench::{self, Recorder};
use victory_core::bench::{self, Recorder, Route, RouteState};
use windows::Win32::Graphics::Direct3D12::*;
use windows::Win32::Graphics::Dxgi::Common::*;
/// The longest a benchmark run waits for its route to start.
const ROUTE_WAIT: Duration = Duration::from_secs(600);
#[derive(Default)]
struct Run {
/// The first frame presented, while waiting for the route.
first: Option<Instant>,
started: Option<Instant>,
last: Option<Instant>,
sampled: Option<Instant>,
frames: Recorder,
vram_peak: u64,
ram_peak: u64,
/// Seconds from the route's start to the frame the route stopped on.
route_stopped_at: Option<f64>,
}
/// How a run's route frames are summarized and labelled.
#[derive(Debug, PartialEq)]
struct RouteAccounting {
ran: bool,
failed: bool,
invalid: bool,
status: &'static str,
skip: f64,
end: Option<f64>,
}
/// The accounting for a requested route and its final state.
fn route_accounting(
route: Option<Route>,
state: RouteState,
stopped_at: Option<f64>,
) -> RouteAccounting {
if route.is_none() {
return RouteAccounting {
ran: false,
failed: false,
invalid: false,
status: "none",
skip: 0.0,
end: None,
};
}
match state {
RouteState::Pending | RouteState::Failed => RouteAccounting {
ran: false,
failed: true,
invalid: false,
status: "failed",
skip: 0.0,
end: None,
},
RouteState::FailedAfterSetup => RouteAccounting {
ran: false,
failed: true,
invalid: true,
status: "failed_after_setup",
skip: 0.0,
end: None,
},
RouteState::Running => RouteAccounting {
ran: true,
failed: false,
invalid: false,
status: "ran",
skip: bench::ROUTE_SKIPPED_SECONDS,
end: None,
},
RouteState::Stopped => RouteAccounting {
ran: true,
failed: false,
invalid: false,
status: "stopped",
skip: if stopped_at.is_some_and(|stopped| stopped < bench::ROUTE_SKIPPED_SECONDS) {
0.0
} else {
bench::ROUTE_SKIPPED_SECONDS
},
end: stopped_at,
},
}
}
static RUN: Mutex<Option<Run>> = Mutex::new(None);
@ -44,8 +123,34 @@ pub(crate) fn presented(memory: impl FnOnce() -> (u64, u64)) {
return;
}
let now = Instant::now();
let route = bench::route();
with(|r| {
r.started.get_or_insert(now);
if r.started.is_none() {
if route.is_some() {
match bench::route_state() {
RouteState::Pending => {
if now.duration_since(*r.first.get_or_insert(now)) < ROUTE_WAIT {
return;
}
tracing::warn!(
"benchmark: the route did not start in {} s; timing a normal run from now",
ROUTE_WAIT.as_secs()
);
bench::set_route_state(RouteState::Failed);
}
RouteState::Failed | RouteState::FailedAfterSetup => {}
RouteState::Running | RouteState::Stopped => {}
}
}
r.started = Some(now);
}
if route.is_some()
&& r.route_stopped_at.is_none()
&& bench::route_state() == RouteState::Stopped
&& let Some(started) = r.started
{
r.route_stopped_at = Some(now.duration_since(started).as_secs_f64());
}
if let Some(last) = r.last.replace(now) {
r.frames.add(now.duration_since(last).as_secs_f64());
}
@ -146,8 +251,37 @@ pub(crate) fn finish(shot: Option<ReadBack>) -> ! {
Err(e) => tracing::warn!(error = %e, "benchmark: no screenshot"),
}
}
let route = bench::route();
let state = bench::route_state();
with(|r| {
if let Some(s) = r.frames.summary() {
if state == RouteState::Stopped
&& r.route_stopped_at.is_none()
&& let Some(started) = r.started
{
r.route_stopped_at = Some(started.elapsed().as_secs_f64());
}
let accounting = route_accounting(route, state, r.route_stopped_at);
if accounting.ran {
let route = route.expect("checked above");
text.push_str(&format!("route={}\n", route.name()));
text.push_str(&format!("route_status={}\n", accounting.status));
if let Some(stopped) = r.route_stopped_at {
text.push_str(&format!("route_stopped_at={stopped:.1}\n"));
}
text.push_str(&format!("route_skip={:.0}\n", accounting.skip));
} else if accounting.failed {
text.push_str("route_failed=1\n");
text.push_str(&format!("route_status={}\n", accounting.status));
if accounting.invalid {
text.push_str("route_invalid=1\n");
}
}
let summary = if accounting.ran {
r.frames.summary_between(accounting.skip, accounting.end)
} else {
r.frames.summary()
};
if let Some(s) = summary {
text.push_str(&format!(
"seconds={:.0}\nframes={}\naverage={:.1}\nlow_1pct={:.1}\nlowest={:.1}\nhighest={:.1}\n",
s.seconds, s.frames, s.average, s.low_1pct, s.lowest, s.highest
@ -234,3 +368,76 @@ fn png(width: u32, height: u32, raw: &[u8]) -> Vec<u8> {
chunk(&mut png, b"IEND", &[]);
png
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn route_accounting_covers_every_state_and_stop_time() {
let none = RouteAccounting {
ran: false,
failed: false,
invalid: false,
status: "none",
skip: 0.0,
end: None,
};
assert_eq!(route_accounting(None, RouteState::Pending, None), none);
assert_eq!(
route_accounting(Some(Route::Downtown), RouteState::Failed, None),
RouteAccounting {
ran: false,
failed: true,
invalid: false,
status: "failed",
skip: 0.0,
end: None,
}
);
assert_eq!(
route_accounting(Some(Route::Downtown), RouteState::FailedAfterSetup, None),
RouteAccounting {
ran: false,
failed: true,
invalid: true,
status: "failed_after_setup",
skip: 0.0,
end: None,
}
);
assert_eq!(
route_accounting(Some(Route::Downtown), RouteState::Running, None),
RouteAccounting {
ran: true,
failed: false,
invalid: false,
status: "ran",
skip: 30.0,
end: None,
}
);
assert_eq!(
route_accounting(Some(Route::Drive), RouteState::Stopped, Some(42.5)),
RouteAccounting {
ran: true,
failed: false,
invalid: false,
status: "stopped",
skip: 30.0,
end: Some(42.5),
}
);
assert_eq!(
route_accounting(Some(Route::Drive), RouteState::Stopped, Some(10.0)),
RouteAccounting {
ran: true,
failed: false,
invalid: false,
status: "stopped",
skip: 0.0,
end: Some(10.0),
}
);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -21,6 +21,8 @@
//! point on a thread with the stack size the image asks for; from then
//! on, pass every thread start and end on to the attached images.
#[cfg(windows)]
pub mod bench_route;
#[cfg(windows)]
mod console_insn;
mod crash;

View File

@ -163,6 +163,7 @@ mentioned in its header. Diagnostics settings are listed under
| `VICTORY_HAPTICS_LOG=1` | Logs haptic levels |
| `VICTORY_BENCH_MINUTES` | Benchmark length: 1 to 240, default 5 |
| `VICTORY_METER_OCCLUDED=1` | The frame meter also counts frames the swap chain did not show because the window is covered, for timing runs behind other windows. Off by default |
| `VICTORY_BENCH_ROUTE` | `downtown`, or the experimental `drive`: a route for benchmark runs; see [Benchmark routes](../README.md#benchmark-routes). Off without it |
| `LSFGVK_PROFILE=<profile>` | [lsfg-vk](https://lsfg-vk.dev) 2.x frame generation with that profile from its `conf.toml`. Off by default |
| `LSFG_PROCESS=<entry>` | The equivalent for lsfg-vk 1.0 |
| `VERBOSE=1` | Turns Wine, vkd3d-proton and DXVK log lines back on |

18
run.sh
View File

@ -3,7 +3,7 @@
mapfile -d '' given < <(env -0)
restart_env=()
for kv in "${given[@]}"; do
case "$kv" in VICTORY_BENCH=*|VICTORY_BENCH_MINUTES=*) ;; *) restart_env+=("$kv");; esac
case "$kv" in VICTORY_BENCH=*|VICTORY_BENCH_MINUTES=*|VICTORY_BENCH_ROUTE=*) ;; *) restart_env+=("$kv");; esac
done
source "$(dirname "$(readlink -f "$0")")/env.sh"
mode=$1; shift
@ -124,6 +124,16 @@ if [ -f "$root/run.conf" ]; then
fi
export VICTORY_MENU_FILE=$(win "$root/run.conf") VICTORY_MENU_STATE=$(win "$root/local") VICTORY_MENU_DEFS=$(win "$root/run.conf.default")
for kv in "$@"; do case "$kv" in *=*) export "$kv";; esac; done
if [ "$mode" = play ] && [ -n "${VICTORY_BENCH_ROUTE:-}" ]; then
route=${VICTORY_BENCH_ROUTE}
route=${route#"${route%%[![:space:]]*}"}
route=${route%"${route##*[![:space:]]}"}
route=${route,,}
case "$route" in
downtown|drive) ;;
*) echo "VICTORY_BENCH_ROUTE must be downtown or drive (got '$VICTORY_BENCH_ROUTE')"; exit 1;;
esac
fi
# A benchmark run (VICTORY_BENCH=rt|nort): PortWatch's settings over the
# user's for this run only.
bench=
@ -133,12 +143,14 @@ if [ "$mode" = play ] && [[ ${VICTORY_BENCH:-} =~ ^(rt|nort)$ ]]; then
VICTORY_LOD_SCALE VICTORY_SMALL_CULL VICTORY_VEHICLE_LOD_BIAS VICTORY_QUAD_GUARD VICTORY_BVH_HARDWARE \
VICTORY_PLACED_COPIED VICTORY_KEEP_GPU_WRITTEN VICTORY_WARM LSFGVK_PROFILE LSFG_PROCESS
export CONSOLE=series-x VICTORY_FSR_4K=quality VICTORY_OUTPUT=3840x2160 VICTORY_SKIP_BINK=1 VICTORY_PANEL=full
# A play cap (run.conf or the title's settings) must not limit a benchmark.
export VICTORY_FRAME_INTERVAL_MS=0
export VICTORY_BVH_BUILDER=$([ "$bench" = rt ] && echo 1 || echo 0)
export VICTORY_BENCH_MINUTES=${VICTORY_BENCH_MINUTES:-5}
benchdir=$root/local/benchmark/$(date +%Y%m%d-%H%M%S)-$bench
mkdir -p "$benchdir"
export VICTORY_BENCH_DIR=$(win "$benchdir")
echo "Benchmark (ray tracing $([ "$bench" = rt ] && echo on || echo off)): the game closes itself after $VICTORY_BENCH_MINUTES min of frames. Results: $benchdir"
echo "Benchmark (ray tracing $([ "$bench" = rt ] && echo on || echo off)${VICTORY_BENCH_ROUTE:+, route $VICTORY_BENCH_ROUTE}): the game closes itself after $VICTORY_BENCH_MINUTES min of frames. Results: $benchdir"
fi
if [ "${MUTE:-0}" = 1 ]; then source "$root/tools/mute.sh"; mute; fi
# lsfg-vk (Lossless Scaling frame generation, a Vulkan layer) only when asked for, by naming the profile
@ -307,7 +319,7 @@ if [ -n "$bench" ] && [ -z "$again" ]; then
fi
if [ -n "$again" ]; then
restart_args=()
for kv in "$@"; do case "$kv" in VICTORY_BENCH=*|VICTORY_BENCH_MINUTES=*) ;; *) restart_args+=("$kv");; esac; done
for kv in "$@"; do case "$kv" in VICTORY_BENCH=*|VICTORY_BENCH_MINUTES=*|VICTORY_BENCH_ROUTE=*) ;; *) restart_args+=("$kv");; esac; done
[[ $next =~ ^(rt|nort):([0-9]+)$ ]] && restart_args+=("VICTORY_BENCH=${BASH_REMATCH[1]}" "VICTORY_BENCH_MINUTES=${BASH_REMATCH[2]}")
echo "Restarting the game..."
# Let the old session give its memory back first: the RAM cap of the next

View File

@ -28,9 +28,45 @@ ram=$(awk '/MemTotal/{printf "%.0f GB", $2/1048576}' /proc/meminfo)
os=$(. /etc/os-release 2>/dev/null; echo "${PRETTY_NAME:-Linux}")
version=$(git -C "$root" log -1 --format='%h (%cs)' 2>/dev/null)
git -C "$root" diff --quiet HEAD 2>/dev/null || version="$version, with local changes"
if [ -n "${s[route]:-}" ]; then
route_skip=${s[route_skip]:-30}
if [ "$route_skip" = 0 ]; then
measured_note="no route warm-up is left out"
else
measured_note="the first ${route_skip} s of the route are left out"
fi
route_display=${s[route]}
if [ "${s[route_status]:-}" = stopped ]; then
banner="INCOMPLETE: route stopped at ${s[route_stopped_at]:-?} s after start; figures are cut at the stop."
else
banner=""
fi
# The drive route is experimental: its path and scenes vary between runs.
if [ "${s[route]}" = drive ]; then
if [ -n "$banner" ]; then
banner="$banner
EXPERIMENTAL: drive figures are not comparable; do not submit them."
else
banner="EXPERIMENTAL: drive figures are not comparable; do not submit them."
fi
fi
elif [ "${s[route_invalid]:-0}" = 1 ] || [ "${s[route_status]:-}" = failed_after_setup ]; then
measured_note="INVALID RUN: the route failed after setup; the run is not comparable and should not be submitted"
route_display="none (route failed after setup)"
banner="INVALID RUN: route failed after setup; do not submit these figures."
elif [ "${s[route_failed]:-0}" = 1 ]; then
measured_note="the route failed to start; the run is timed as a normal benchmark"
route_display="none (route failed to start)"
banner=""
else
measured_note="the first minute is left out of runs of 2 min or more"
route_display="none (free roam)"
banner=""
fi
cat > "$dir/bench_results.txt" <<TXT
PortWatch Lab report: https://portwatch-vi.xyz/lab/#report
Copy each answer into the form. Lines marked "you:" are for you to answer.
$banner
== What you tested ==
Build: VIctory-xmem (lobomfz/VIctory-xmem in the list)
@ -45,6 +81,9 @@ Version: ${version:-you: git log -1 in the build folder}
Upscaler: $fsr
Render: 2560x1440 upscaled to a 3840x2160 output
Ray tracing: $([ "$rt" = rt ] && echo On || echo Off)
Route: $route_display
Route status: ${s[route_status]:-not applicable}
Route stop: ${s[route_stopped_at]:-not stopped}${s[route_stopped_at]:+ s after start}
Frame generation, RSR, NIS: none
you: also check nothing in your driver or desktop adds them
(AFMF, lsfg-vk, gamescope upscaling).
@ -59,7 +98,7 @@ Average: $(get average)
Lowest: $(get lowest) (slowest whole second)
Highest: $(get highest) (quickest whole second)
1% low: $(get low_1pct) (for your notes)
Measured: $(get seconds) s, $(get frames) frames (the first minute is left out of runs of 2 min or more;
Measured: $(get seconds) s, $(get frames) frames ($measured_note;
loading screens or menus after it are counted: say so, or run again)
Frame-time log: not made by this benchmark. The form takes PresentMon, CapFrameX or OCAT recordings.