Textures from the first level viewed; equal uploads left out; bakes take textures as they are; kept by the card's real room

Placed textures are read, kept on the card and uploaded from the first level their views show (VICTORY_HELD_LEVELS=0: whole;
after victory-amd 4436f8f1's spans). An upload of the bytes a host copy holds is left out (VICTORY_TEXTURE_SAME=0). A slot
shows its new view once that view's upload has run. A decoration bake takes slots due a few frames later too and waits for
memory being remapped (VICTORY_BAKE_EXACT=0). Host copies go only past 88 % of the budget, the longest idle first
(VICTORY_TEXTURE_KEEP=1: the rule before). A slot rewritten with other filler words keeps its view.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
localandClaude Opus 5.5 committed 2026-11-25 02:56:28 -06:00
1 parent 320c93a30c
commit c00a0bbd79
6 files changed
+866 -45

No files matched your search

+12 -1
View File
@@ -20,7 +20,7 @@
use std::collections::{BTreeMap, VecDeque};
use std::ffi::c_void;
use std::sync::Mutex;
use std::sync::atomic::{AtomicU32, Ordering};
use std::sync::atomic::{AtomicU32, AtomicU64, Ordering};
use windows::Win32::Graphics::Direct3D12::*;
use windows::core::{GUID, HRESULT, IUnknown, Interface};
@@ -199,6 +199,15 @@ fn lock<T>(m: &'static Mutex<T>) -> std::sync::MutexGuard<'static, T> {
m.lock().unwrap_or_else(|e| e.into_inner())
}
/// Bytes of the pieces textures hold now.
static HELD: AtomicU64 = AtomicU64::new(0);
/// Bytes of the texture blocks no texture holds: the card's memory in use
/// by us that new textures take first.
pub(crate) fn texture_room() -> u64 {
(lock(&TEXTURES).blocks() as u64 * BLOCK).saturating_sub(HELD.load(Ordering::Relaxed))
}
/// For the memory line: blocks of textures and of staging buffers, in MiB.
#[cfg(feature = "diagnostics")]
pub(crate) fn memory() -> [u64; 2] {
@@ -282,6 +291,7 @@ unsafe extern "system" fn release(this: *mut c_void) -> u32 {
let left = (*this.cast::<Reclaim>()).references.fetch_sub(1, Ordering::AcqRel) - 1;
if left == 0 {
let gone = Box::from_raw(this.cast::<Reclaim>());
HELD.fetch_sub(gone.piece.len, Ordering::Relaxed);
lock(&TEXTURES).give(gone.piece, now());
}
left
@@ -351,6 +361,7 @@ pub(crate) unsafe fn texture(
let result = unsafe { device.CreatePlacedResource(&heap, piece.start, &d, state, None, &mut made) };
match (result, made) {
(Ok(()), Some(made)) => {
HELD.fetch_add(piece.len, Ordering::Relaxed);
give_back_with(&made, piece);
Some(made)
}