The depth bounds test works (#82); faster defaults; textures are on the card before the character bake; one host copy per placed texture

- The depth bounds test (#82 by Kaivyyy, as is): a pipeline that enables
  it is made from a DEPTH_STENCIL1 stream under its own library name, and
  the title's OMSetDepthBounds reaches the host list. Before, such draws
  passed at every depth. On the test machine (RTX 4070) the first room is
  lit by its lamp for the first time: walls, table, bunks.
- Defaults: what shaders wrote is copied back by a thread of its own
  (stage 2), wide copy-back, card copies from 1 MiB up to 1,024 MB, and
  256 lists in the air. About 230 ms a frame where it was about 400.
  Off: VICTORY_RELAY=0, VICTORY_WIDE_BACK=0, VICTORY_CARD_BUFFERS_MIN_MB=16
  VICTORY_CARD_BUFFERS_MB=512, VICTORY_LATE_WAIT_LISTS=128.
- Textures picked by index are uploaded while loading and before a draw of
  the title's decoration bake, which samples them by index and runs once
  (VICTORY_EARLY_TEXTURES_MS, VICTORY_BAKE_TEXTURES_MS; 0 turns each off).
- Placed textures are keyed without the filler words of their description:
  two views that differed only there each had a host copy
  (VICTORY_PLACED_FILLER=1 keeps the old key).
- VICTORY_TEXTURE_ROOM_PERCENT (90, unchanged) sets how full the card may
  get before textures picked by index wait.

Known: the first room's walls are still missing in some launches, and
shaded areas are too dark (the bounce light has no ray-tracing structure
to trace yet).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
fxcelessandClaude Fable 5.2 committed 2026-11-24 20:22:06 -05:00
1 parent a803c87c48
commit c96b4f2b83
8 files changed
+761 -76

No files matched your search

+62 -3
View File
@@ -457,9 +457,65 @@ static HOST_WRITTEN: Mutex<Option<std::collections::HashSet<usize>>> = Mutex::ne
/// A host copy or resolve writes `resource`.
pub(crate) fn host_written(resource: This) {
let mut set = HOST_WRITTEN.lock().unwrap_or_else(|e| e.into_inner());
set.get_or_insert_with(Default::default)
.insert(resource as usize);
let new = {
let mut set = HOST_WRITTEN.lock().unwrap_or_else(|e| e.into_inner());
set.get_or_insert_with(Default::default).insert(resource as usize)
};
// Diagnostics (run 177): where its title memory is, for placed views
// the title reads that memory through ([`placed_in_host_written`]).
if new && let Some((at, desc)) = crate::resource::texture_memory(resource) {
// SAFETY: 56 bytes in the description's layout.
let words = unsafe { std::ptr::from_ref(&desc).cast::<[u32; 14]>().read_unaligned() };
let bytes = crate::resource::placed_bytes(&words).unwrap_or(0);
if !at.is_null() && bytes > 0 {
HOST_WRITTEN_AT
.lock()
.unwrap_or_else(|e| e.into_inner())
.insert(at as u64, (bytes, words[4], words[6], words[7], words[8], resource as usize));
}
}
}
/// The title memory of textures the host copied into, by address: bytes
/// and description words 4, 6, 7 and 8 (width, height, layers and levels,
/// format).
static HOST_WRITTEN_AT: Mutex<std::collections::BTreeMap<u64, (u64, u32, u32, u32, u32, usize)>> =
Mutex::new(std::collections::BTreeMap::new());
/// A texture the title placed at `address` (description words `desc`) was
/// made: says so once if it lies in the memory of a texture the host
/// copied into ([`host_written`]). Its own host copy is filled from title
/// memory, which the copy never reached: the copied texels are on the
/// card in the other texture, where no shader that reads this view finds
/// them.
pub(crate) fn placed_in_host_written(address: u64, desc: &[u32; 14]) {
let hit = {
let map = HOST_WRITTEN_AT.lock().unwrap_or_else(|e| e.into_inner());
map.range(..=address)
.next_back()
.filter(|(at, d)| address < **at + d.0)
.map(|(at, d)| (*at, *d))
};
if let Some((at, (bytes, width, height, layers_levels, format, _))) = hit {
static SAID: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(0);
if SAID.fetch_add(1, std::sync::atomic::Ordering::Relaxed) < 200 {
tracing::warn!(
view_address = format_args!("{address:#x}"),
view_offset = address - at,
view_width = desc[4],
view_height = desc[6],
view_layers_levels = format_args!("{:#x}", desc[7]),
view_format = desc[8],
copied_address = format_args!("{at:#x}"),
copied_bytes = bytes,
copied_width = width,
copied_height = height,
copied_layers_levels = format_args!("{layers_levels:#x}"),
copied_format = format,
"HERO LEAD: a placed texture view lies in the memory of a texture the host copied into: it is filled from title memory, which the copy never reached"
);
}
}
}
/// Whether the host GPU wrote `resource` by a copy or resolve
@@ -483,6 +539,9 @@ pub(crate) fn forget(resource: usize) {
if let Some(set) = set.as_mut() {
set.remove(&resource);
}
// Its memory may be given to other textures now (run 177: most of the
// "HERO LEAD" lines were views in memory a released texture had held).
HOST_WRITTEN_AT.lock().unwrap_or_else(|e| e.into_inner()).retain(|_, d| d.5 != resource);
let mut through = THROUGH.lock().unwrap_or_else(|e| e.into_inner());
if let Some(through) = through.as_mut() {
through.remove(&resource);