A texture filled while the runtime remaps takes the pages that are there
With VICTORY_TEXTURE_NO_WAIT=1 a refresh that met the runtime remapping title memory read the whole chain or nothing. A texture the title holds only the smaller levels of is never all there, so nothing was read, and the upload recorded before put the staging buffer's zeros over the levels on the card. A staging buffer never filled now takes the pages that are there; what was away for the moment of a change is read after it, and a filling with less than was mapped makes the slots due again (at most 8 times in a row). VICTORY_TEXTURE_FILL=0: as before. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
f0bc1d234c
commit
a2e7bf901f
6 files changed
+282
-10
No files matched your search
@@ -147,6 +147,36 @@ pub(crate) fn levels_waiting(start: u64) {
|
||||
WAITING.lock().unwrap_or_else(|e| e.into_inner()).insert(start, crate::host::moment());
|
||||
}
|
||||
|
||||
/// Placed textures (by the start of their memory) filled while the runtime
|
||||
/// was remapping with less than was mapped of them
|
||||
/// (`crate::texture::fill_unlocked`), whose slots the next texture pass
|
||||
/// makes due again; and how often in a row that was, which ends it: memory
|
||||
/// that is shown and cannot be read would be uploaded again every frame.
|
||||
static SHORT: Mutex<(std::collections::BTreeSet<u64>, std::collections::BTreeMap<u64, u32>)> =
|
||||
Mutex::new((std::collections::BTreeSet::new(), std::collections::BTreeMap::new()));
|
||||
|
||||
/// Fillings in a row of one texture that got less than was mapped, after
|
||||
/// which its slots wait for the next notice of its memory.
|
||||
const SHORT_IN_A_ROW: u32 = 8;
|
||||
|
||||
/// The placed texture at `start` was filled with less than was mapped.
|
||||
pub(crate) fn read_short(start: u64) {
|
||||
let mut short = SHORT.lock().unwrap_or_else(|e| e.into_inner());
|
||||
let times = short.1.entry(start).or_insert(0);
|
||||
*times += 1;
|
||||
if *times <= SHORT_IN_A_ROW {
|
||||
short.0.insert(start);
|
||||
}
|
||||
}
|
||||
|
||||
/// The placed texture at `start` was filled with all that was mapped.
|
||||
pub(crate) fn read_all(start: u64) {
|
||||
let mut short = SHORT.lock().unwrap_or_else(|e| e.into_inner());
|
||||
if !short.1.is_empty() {
|
||||
short.1.remove(&start);
|
||||
}
|
||||
}
|
||||
|
||||
/// Title memory by the placed texture views that describe it: per span of
|
||||
/// memory (its start, its end at full size) the title slots holding a
|
||||
/// view of a texture that takes exactly that span. A console title need
|
||||
@@ -1284,6 +1314,30 @@ impl HostHeap {
|
||||
slots.len()
|
||||
}
|
||||
|
||||
/// Makes the slots of the textures filled with less than was mapped
|
||||
/// ([`read_short`]) due from the next frame on. Returns how many.
|
||||
pub(crate) fn texture_slots_short(&self, frame: u64) -> usize {
|
||||
if self.sampler {
|
||||
return 0;
|
||||
}
|
||||
let starts = std::mem::take(&mut SHORT.lock().unwrap_or_else(|e| e.into_inner()).0);
|
||||
if starts.is_empty() {
|
||||
return 0;
|
||||
}
|
||||
let mut slots: Vec<u32> = {
|
||||
let placed = self.placed.lock().unwrap_or_else(|e| e.into_inner());
|
||||
starts.iter().flat_map(|&start| placed.slots_at(start)).collect()
|
||||
};
|
||||
slots.sort_unstable();
|
||||
slots.dedup();
|
||||
slots.retain(|&slot| !self.tabled_lately(slot, frame));
|
||||
let mut textures = self.textures.lock().unwrap_or_else(|e| e.into_inner());
|
||||
for &slot in &slots {
|
||||
textures.changed(slot, frame, frame + 1);
|
||||
}
|
||||
slots.len()
|
||||
}
|
||||
|
||||
/// Takes the ranges of title memory written behind the guards' back
|
||||
/// since the last call ([`page_written`]) and finds the slots whose
|
||||
/// placed texture holds bytes of them ([`Spans::slots_holding`]). A
|
||||
@@ -2939,6 +2993,26 @@ fn null_view(at: D3D12_CPU_DESCRIPTOR_HANDLE) {
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
/// A texture filled with less than was mapped is looked at again, but
|
||||
/// not for ever: memory that is shown and cannot be read ends it, and a
|
||||
/// filling that got everything starts the count anew.
|
||||
#[test]
|
||||
fn a_short_filling_is_looked_at_again_a_few_times() {
|
||||
// An address no other test names.
|
||||
let start = 0x7fee_1234_0000u64;
|
||||
let pending = || super::SHORT.lock().unwrap().0.remove(&start);
|
||||
for _ in 0..super::SHORT_IN_A_ROW {
|
||||
super::read_short(start);
|
||||
assert!(pending());
|
||||
}
|
||||
super::read_short(start);
|
||||
assert!(!pending());
|
||||
super::read_all(start);
|
||||
super::read_short(start);
|
||||
assert!(pending());
|
||||
super::read_all(start);
|
||||
}
|
||||
|
||||
/// A null texture UAV keeps the title's dimension (3D for the world's
|
||||
/// wind field), and is 2D when the title names none.
|
||||
#[test]
|
||||
|
||||
Reference in new issue
Block a user