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

+77 -7
View File
@@ -280,10 +280,10 @@ impl Detached {
}
}
/// A host list that has run and waits to be used again, and the bytes of
/// upload memory it keeps.
/// A host list that has run and waits to be used again, the bytes of
/// upload memory it keeps, and when it was put there ([`idle_trim`]).
#[cfg(windows)]
struct Idle(crate::host::HostList, u64);
struct Idle(crate::host::HostList, u64, u64);
// SAFETY: D3D12 objects are free-threaded, and an idle list is touched by
// nobody until it is taken out again.
@@ -309,6 +309,37 @@ static IDLE: std::sync::Mutex<(Vec<Idle>, u64)> = std::sync::Mutex::new((Vec::ne
#[cfg(windows)]
const IDLE_MOST: (usize, u64) = (512, 256 << 20);
// Idle-list trim: memory stack by skornuta (skornuta/victory-memory-stack 57fb136, GPL-3.0),
// patch 13 (and the idle trim of its base).
/// Idle lists destroyed by [`idle_trim`] since the start.
#[cfg(windows)]
pub(crate) static TRIMMED_LISTS: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(0);
/// After how many seconds an idle list nobody took is destroyed, with its
/// command allocators: `VICTORY_LIST_POOL_IDLE_S=<seconds>`, or with
/// `VICTORY_ALLOCATOR_TRIM=1` its time (`crate::host::allocator_trim`);
/// neither: never, as before. The pool is last in, first out, so the
/// oldest entries are the surplus of a spike.
#[cfg(windows)]
fn idle_trim() -> Option<u64> {
static S: std::sync::OnceLock<Option<u64>> = std::sync::OnceLock::new();
*S.get_or_init(|| {
std::env::var("VICTORY_LIST_POOL_IDLE_S")
.ok()
.and_then(|v| v.trim().parse().ok())
.filter(|&s| s > 0)
.or_else(crate::host::allocator_trim)
})
}
/// How many of the first of `pushed_at` (oldest first) are older than
/// `max_age` at `now`.
#[cfg(windows)]
fn stale(pushed_at: impl Iterator<Item = u64>, now: u64, max_age: u64) -> usize {
pushed_at.take_while(|&t| now.saturating_sub(t) > max_age).count()
}
/// Whether host lists that have run are used again (on by default;
/// `VICTORY_LIST_POOL=0`: each is made new and thrown away, as before).
#[cfg(windows)]
@@ -324,13 +355,13 @@ fn fresh_list() -> Option<crate::host::HostList> {
let idle = {
let mut idle = IDLE.lock().unwrap_or_else(|e| e.into_inner());
let taken = idle.0.pop();
if let Some(Idle(_, bytes)) = &taken {
if let Some(Idle(_, bytes, _)) = &taken {
idle.1 -= bytes;
}
taken
};
match idle {
Some(Idle(list, _)) => Some(list),
Some(Idle(list, _, _)) => Some(list),
None => crate::host::host().and_then(|h| h.new_list().ok()),
}
}
@@ -348,7 +379,12 @@ pub(crate) fn recycle(lists: Vec<Detached>, ran: &[usize]) {
// The descriptor slots and the upload memory its commands named.
drop(_state);
drop(_uploads);
if !ran.contains(&i) || IDLE.lock().unwrap_or_else(|e| e.into_inner()).0.len() >= IDLE_MOST.0 {
if !ran.contains(&i) {
continue;
}
if IDLE.lock().unwrap_or_else(|e| e.into_inner()).0.len() >= IDLE_MOST.0 {
// Its submission has run: its prelude serves another list.
host.give_prelude();
continue;
}
// As the title's reset does: what the list kept for its commands
@@ -357,8 +393,21 @@ pub(crate) fn recycle(lists: Vec<Detached>, ran: &[usize]) {
let bytes = host.scratch_kept();
let mut idle = IDLE.lock().unwrap_or_else(|e| e.into_inner());
if idle.0.len() < IDLE_MOST.0 && idle.1 + bytes <= IDLE_MOST.1 {
idle.0.push(Idle(host, bytes));
let now = crate::host::now_ms();
idle.0.push(Idle(host, bytes, now));
idle.1 += bytes;
// With `VICTORY_ALLOCATOR_TRIM=1` (memory stack by skornuta,
// skornuta/victory-memory-stack 57fb136, GPL-3.0): lists the
// frames did not need for that long are destroyed, with their
// allocators. Their submissions have run, as every idle list's.
if let Some(secs) = idle_trim() {
let n = stale(idle.0.iter().map(|i| i.2), now, secs * 1000);
let gone: Vec<Idle> = idle.0.drain(..n).collect();
idle.1 -= gone.iter().map(|i| i.1).sum::<u64>();
TRIMMED_LISTS.fetch_add(n as u64, std::sync::atomic::Ordering::Relaxed);
drop(idle);
drop(gone);
}
}
}
}
@@ -1932,6 +1981,15 @@ mod state {
fn count_draw() {
DRAWS.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
DRAWS_EVER.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
}
/// Every draw recorded since the start (the warm-up start watches it).
static DRAWS_EVER: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(0);
/// Draws recorded since the start, any kind ([`take_counts`] empties its own count).
pub(crate) fn draws_ever() -> u64 {
DRAWS_EVER.load(std::sync::atomic::Ordering::Relaxed)
}
/// Draws of the kinds the host does not run yet (indirect, mesh), and
@@ -2452,6 +2510,18 @@ mod tests {
use super::*;
use crate::object::slot;
/// Only the oldest idle lists, those past the age, are stale (memory
/// stack by skornuta, skornuta/victory-memory-stack 57fb136, GPL-3.0).
#[cfg(windows)]
#[test]
fn only_the_oldest_idle_lists_are_stale() {
assert_eq!(stale([10, 20, 900, 950].into_iter(), 1000, 100), 2);
assert_eq!(stale([950u64].into_iter(), 1000, 100), 0);
assert_eq!(stale(std::iter::empty(), 1000, 100), 0);
// A clock that reads earlier than a push does not make it stale.
assert_eq!(stale([2000u64].into_iter(), 1000, 100), 0);
}
#[test]
fn every_inline_command_falls_back_to_the_table() {
let null = std::ptr::null();