From 5dda41ddff71e3f6052b843c115d2e09e89df41d Mon Sep 17 00:00:00 2001 From: readmet3xt-lab <238408149+readmet3xt-lab@users.noreply.github.com> Date: Fri, 27 Nov 2026 00:28:36 +0530 Subject: [PATCH] VICTORY_QUEUE_HOST_TEXTURES=0: records of textures the host writes are not queued for the texture pass (off) A slot's record of a texture object the host renders to or writes (a target, depth or unordered access texture) is queued for the pass over textures picked by index like any texture. The pass takes such a slot, finds nothing to bring up to date (it makes and uploads nothing for it) and takes it out; the title writes such views into its tables' slots every frame, so they come back, each time a take of the queue's lock, a place among the slots due and a few microseconds of the pass (58,978 of 90,699 slots taken in 5 s of a cutscene found nothing to do, coolfox-20261126-233017 18:02:23; 18ff932 says how many were such views). With the switch, such a record takes the slot out of the queue as a buffer view's does (`note_buffer`; with the queue's marks, without its lock when it is not queued). Counted since the start in the lock line. Off by default (not behaviour-neutral, though the pass did nothing for these slots): fewer slots are due, so a pass reaches others sooner, the catch-up budget (VICTORY_TEXTURE_CATCHUP, started by the count due; off in the launcher) starts less often, and a bake's pass is asked for less often (it runs when the queue's write count changed). Co-Authored-By: Claude Opus 5.5 --- crates/victory-gpu/src/descriptor/host.rs | 50 ++++++++++++++++++++++- crates/victory-gpu/src/host.rs | 4 +- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/crates/victory-gpu/src/descriptor/host.rs b/crates/victory-gpu/src/descriptor/host.rs index e0194e7..7e1968f 100644 --- a/crates/victory-gpu/src/descriptor/host.rs +++ b/crates/victory-gpu/src/descriptor/host.rs @@ -1035,6 +1035,49 @@ fn not_taken(site: usize) { }); } +/// Whether a slot's record of a texture object the host renders to or writes +/// (a target, depth or unordered access texture: not `resource::title_fills`) +/// is queued for the pass over textures picked by index, as any texture +/// (`VICTORY_QUEUE_HOST_TEXTURES=0`: it is not; the slot leaves the queue as +/// a buffer view's would). +/// +/// The pass takes such a slot and finds nothing to bring up to date: it +/// neither makes nor uploads anything for it, and takes it out +/// (`draw.rs` `heap_textures`, the first of its "nothing to bring up to +/// date"). The title writes such views into its tables' slots every frame, +/// so they are queued again and again, take the queue's lock, and stand +/// among the slots due (58,978 of 90,699 slots the pass took in 5 s of a +/// cutscene found nothing to do, coolfox-20261126-233017 18:02:23; the line +/// of 18ff932 says how many of those were such views). Off by default: the +/// slots due are fewer, so a pass reaches others sooner, the catch-up budget +/// (`VICTORY_TEXTURE_CATCHUP`, by the count due) starts less often, and a +/// bake's pass is asked less often (the queue's write count). +pub(crate) fn queue_host_textures() -> bool { + static ON: std::sync::OnceLock = std::sync::OnceLock::new(); + *ON.get_or_init(|| std::env::var_os("VICTORY_QUEUE_HOST_TEXTURES").is_none_or(|v| v != "0")) +} + +/// Records of textures the host writes left out of the queue +/// ([`queue_host_textures`]) since the start, counted by each thread in +/// batches. +pub(crate) static HOST_TEXTURES_LEFT_OUT: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(0); + +fn host_texture_left_out() { + const BATCH: u32 = 64; + thread_local! { + static N: std::cell::Cell = const { std::cell::Cell::new(0) }; + } + N.with(|n| { + let now = n.get() + 1; + if now >= BATCH { + HOST_TEXTURES_LEFT_OUT.fetch_add(u64::from(now), std::sync::atomic::Ordering::Relaxed); + n.set(0); + } else { + n.set(now); + } + }); +} + /// The queue of title slots whose texture view waits to be brought up to /// date for shaders that pick textures by index: which are due, and in /// which order (no host heap needed, so it is tested without one). @@ -3086,7 +3129,12 @@ impl HostHeap { } Some(View::Shader(r, _)) if crate::resource::buffer_bytes(*r as crate::object::This).is_none() => { OBJECT_TEXTURE_SLOTS.fetch_add(1, std::sync::atomic::Ordering::Relaxed); - true + // A texture the host renders to or writes: nothing for the + // pass to bring up to date ([`queue_host_textures`]). + queue_host_textures() || crate::resource::title_fills(*r as crate::object::This) || { + host_texture_left_out(); + false + } } _ => false, }; diff --git a/crates/victory-gpu/src/host.rs b/crates/victory-gpu/src/host.rs index c8a99e3..11636df 100644 --- a/crates/victory-gpu/src/host.rs +++ b/crates/victory-gpu/src/host.rs @@ -9203,7 +9203,8 @@ impl Meter { stale views, {} else); waited for {} ms ({}, {}, {}, {}, {}, {}, {} ms by the same places); held {} ms \ taking the slots due, {} ms making slots due, {} ms for stale views; not taken {} times, as nothing would \ have changed ({} noting a slot's record, {} by table reads, {} for stale views); since the start, {} slots \ - taken out by a table read after the first of their frame (VICTORY_TABLED_REREAD=1)", + taken out by a table read after the first of their frame (VICTORY_TABLED_REREAD=1), {} records of textures \ + the host writes left out of the queue (VICTORY_QUEUE_HOST_TEXTURES=0)", taken.iter().sum::(), taken[0], taken[1], @@ -9228,6 +9229,7 @@ impl Meter { skipped[4], skipped[5], crate::descriptor::host::TABLED_WRITES[2].load(Ordering::Relaxed), + crate::descriptor::host::HOST_TEXTURES_LEFT_OUT.load(Ordering::Relaxed), ); } }