Card memory the CPU maps: windows, sends and scratch (VICTORY_WINDOWS_BAR_MB, VICTORY_SEND_BAR, VICTORY_SCRATCH_BAR); the card's own stamps (VICTORY_CARD_SPANS)

GPU_UPLOAD heaps, all off by default. Replayed yard frame (capture
play-1125-0127): 36.3 ms; windows in the card's memory 31.9, sends 32.7.
Replay: --pace, --breadcrumbs, copies counted by the memory they cross.
VICTORY_GPU_LOAD_MS: what the title's GPU timestamps show.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
localandClaude Opus 5.5 committed 2026-11-25 03:35:03 -06:00
1 parent ad30f2cb1f
commit bd68f5e175
9 files changed
+549 -12

No files matched your search

+37 -1
View File
@@ -715,7 +715,10 @@ impl Written {
Written::GpuTimestamp => {
static START: std::sync::OnceLock<std::time::Instant> = std::sync::OnceLock::new();
let elapsed = START.get_or_init(std::time::Instant::now).elapsed();
(elapsed.as_nanos() / (1_000_000_000 / u128::from(TIMESTAMP_FREQUENCY))) as u64
let now = (elapsed.as_nanos() / (1_000_000_000 / u128::from(TIMESTAMP_FREQUENCY))) as u64;
#[cfg(all(windows, feature = "diagnostics"))]
crate::host::spans::stamped(at as usize, now);
as_loaded(now, at as usize, gpu_load())
}
Written::SystemTimestamp => system_timestamp(),
};
@@ -730,6 +733,31 @@ impl Written {
}
}
/// What the title's GPU time is made to look like, in ticks
/// (`VICTORY_GPU_LOAD_MS`; unset: as it is).
///
/// The title asks for four GPU timestamps a frame, in pairs of 16 bytes, the
/// start in the second eight and the end in the first. All of them are written
/// when the frame's last submissions land, within microseconds, so every pair
/// says the card did nothing.
fn gpu_load() -> u64 {
static LOAD: std::sync::OnceLock<u64> = std::sync::OnceLock::new();
*LOAD.get_or_init(|| {
let ms = std::env::var("VICTORY_GPU_LOAD_MS").ok().and_then(|v| v.trim().parse::<u64>().ok()).unwrap_or(0);
ms * (TIMESTAMP_FREQUENCY / 1000)
})
}
/// The timestamp written at `at` when the clock says `now`, if a pair's start
/// is to lie `load` ticks before its end.
fn as_loaded(now: u64, at: usize, load: u64) -> u64 {
if at & 8 != 0 {
now.saturating_sub(load).max(1)
} else {
now
}
}
fn system_timestamp() -> u64 {
#[cfg(windows)]
{
@@ -1072,6 +1100,14 @@ mod tests {
assert_eq!(new[35], execute_x as *const ()); // 0x118
}
#[test]
fn a_pair_of_timestamps_shows_the_load_it_is_given() {
let (start, end) = (0xd0419_6698, 0xd0419_6690);
assert_eq!(as_loaded(5_000_000, end, 4_000_000) - as_loaded(5_000_000, start, 4_000_000), 4_000_000);
assert_eq!(as_loaded(5_000_000, start, 0), 5_000_000);
assert_eq!(as_loaded(5, start, 100), 1);
}
#[test]
fn timestamps_and_values_are_written() {
let mut at = [0u64; 2];