Merge agent/texqueue-ports: texture queue lock work (marks, batched tells, split lines; on), VICTORY_TABLED_REREAD and VICTORY_QUEUE_HOST_TEXTURES (off); ports of Belobug/VIctory-Belobug-AMD c278f0d, 4cd2d13+91018a5, 5d6bd84 (VICTORY_POOL_SMALL, VICTORY_SHOW_NEW_LATER, VICTORY_PRELUDE_UPLOADS; off)

Chain z1 (from the main path): A (new defaults) gameplay 33.9 ms p95 34.7, cutscene 38.8 ms p95 55; B (VICTORY_QUEUE_MARKS=0 VICTORY_QUEUE_BATCH=0, the old behaviour) gameplay 39.5 ms p95 54, cutscene 40.4 ms; C (TABLED_REREAD=1) 37.2 / 40.2 ms; D (QUEUE_HOST_TEXTURES=0) 36.4 / 41.8 ms.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
readmet3xt-labandClaude Opus 5.5 committed 2026-11-27 01:25:20 +05:30
commit 2ff3e4a3a0
8 files changed
+1390 -125

No files matched your search

+146 -4
View File
@@ -2336,6 +2336,9 @@ struct Deferred {
uploads: Vec<ID3D12Resource>,
/// Standalone upload footprints kept through this list's fence (movie planes).
plane_uploads: Vec<(Chunk, u64)>,
/// Title textures whose upload the list's prelude records if the check at
/// submission finds it due (`crate::texture::prelude_uploads`).
prelude_uploads: Vec<crate::texture::PreludeUpload>,
/// The bytes of `uploads` (counted in [`ALIVE`] while they are held).
upload_bytes: u64,
/// Host objects the list's commands name (pipelines, root signatures,
@@ -5765,7 +5768,9 @@ impl Host {
for list in runs {
list.run_deferred(&mut batch, &air, |i| own.as_ref().is_some_and(|own| own.takes(list, i)));
firsts.push(lists.len());
if let Some(prelude) = list.prelude() {
// (None unless `VICTORY_PRELUDE_UPLOADS=1`.)
let uploads = list.prelude_uploads(&mut batch);
if let Some(prelude) = list.prelude(&uploads) {
lists.push(Some(prelude));
}
lists.push(list.list.cast().ok());
@@ -6828,8 +6833,12 @@ impl HostList {
/// its real state to the one the list starts with; the textures' real
/// states become those the list ends with. For depth textures with a
/// colour twin it first copies the side the list uses as it finds it
/// from the other, if a list submitted earlier left it behind.
fn prelude(&self) -> Option<ID3D12CommandList> {
/// from the other, if a list submitted earlier left it behind. Title
/// textures whose upload is decided at submission (`uploads`,
/// `crate::texture::prelude_uploads`) are copied into their host copies
/// here, right before the list runs (Belobug/VIctory-Belobug-AMD
/// 5d6bd84).
fn prelude(&self, uploads: &[(crate::texture::PreludeUpload, bool)]) -> Option<ID3D12CommandList> {
const COPY_DEST: u32 = 0x400;
const COPY_SOURCE: u32 = 0x800;
let host_state = |state: u32| D3D12_RESOURCE_STATES(state as i32);
@@ -6884,13 +6893,45 @@ impl HostList {
}
}
}
// The uploads decided at submission: each host copy to the copy
// destination state, and from there to the state the list starts
// with (back to its real state if the list does not use it).
let mut aliasing = Vec::new();
for (upload, first_upload) in uploads {
let copy = &upload.copy;
let key = std::sync::Arc::as_ptr(copy) as usize;
// A texture cut from a block may lie where another did: what the
// card holds of that one is done with before the first upload
// into this one.
if crate::pool::on() && *first_upload {
aliasing.push(D3D12_RESOURCE_BARRIER {
Type: D3D12_RESOURCE_BARRIER_TYPE_ALIASING,
Flags: D3D12_RESOURCE_BARRIER_FLAG_NONE,
Anonymous: D3D12_RESOURCE_BARRIER_0 {
Aliasing: std::mem::ManuallyDrop::new(D3D12_RESOURCE_ALIASING_BARRIER {
pResourceBefore: std::mem::ManuallyDrop::new(None),
// SAFETY: a borrowed pointer the barrier never releases.
pResourceAfter: unsafe { std::mem::transmute_copy(&copy.texture) },
}),
},
});
}
let real = copying.get(&key).copied().unwrap_or_else(|| copy.state.load(Ordering::Relaxed));
if real != COPY_DEST {
to_copy.push(transition(&copy.texture, host_state(real), host_state(COPY_DEST)));
if !states.contains_key(&key) {
barriers.push(transition(&copy.texture, host_state(COPY_DEST), host_state(real)));
}
}
copying.insert(key, COPY_DEST);
}
barriers.extend(states.iter().filter_map(|(key, (first, last, copy))| {
let real = copy.state.swap(*last, Ordering::Relaxed);
let real = copying.get(key).copied().unwrap_or(real);
(real != *first)
.then(|| transition(&copy.texture, host_state(real), host_state(*first)))
}));
if barriers.is_empty() && syncs.is_empty() {
if barriers.is_empty() && syncs.is_empty() && uploads.is_empty() {
return None;
}
let Some((allocator, list)) = self
@@ -6905,12 +6946,18 @@ impl HostList {
let recorded = unsafe {
allocator.Reset().and_then(|()| {
list.Reset(allocator, None)?;
if !aliasing.is_empty() {
list.ResourceBarrier(&aliasing);
}
if !to_copy.is_empty() {
list.ResourceBarrier(&to_copy);
}
for (depth, twin, colour) in &syncs {
record_twin_copy(list, &depth.texture, twin, *colour);
}
for (upload, _) in uploads {
upload.record(list);
}
if !barriers.is_empty() {
list.ResourceBarrier(&barriers);
}
@@ -7501,6 +7548,32 @@ impl HostList {
self.deferred().copies.push(Step::Texture(staging));
}
/// [`HostList::defer_texture`] of a texture whose upload the list's
/// prelude records if the check finds it due
/// (`crate::texture::prelude_uploads`; [`HostList::prelude_uploads`]).
pub(crate) fn defer_prelude_upload(&self, upload: crate::texture::PreludeUpload) {
let mut deferred = self.deferred();
deferred.copies.push(Step::Texture(upload.staging()));
deferred.prelude_uploads.push(upload);
}
/// At submission, after the list's steps: the textures whose upload its
/// prelude records, each with whether it is the first upload into its
/// host copy. Their staging buffers are refreshed first (those the
/// submission's steps left pending). Ported from
/// Belobug/VIctory-Belobug-AMD 5d6bd84.
fn prelude_uploads(&self, batch: &mut Batch) -> Vec<(crate::texture::PreludeUpload, bool)> {
let waiting = self.deferred().prelude_uploads.clone();
if waiting.is_empty() {
return Vec::new();
}
batch.refresh_textures();
waiting
.into_iter()
.filter_map(|upload| upload.finish_refresh().map(|first| (upload, first)))
.collect()
}
/// A copy source owned exclusively by this list until reset after its
/// last execution. A different list can prepare its movie plane concurrently.
pub(crate) fn plane_upload(
@@ -9195,6 +9268,75 @@ impl Meter {
slots[9],
);
}
let shown = crate::draw::HEAP_TEXTURE_SHOWN.each_ref().map(|n| n.swap(0, Ordering::Relaxed));
let nothing = crate::draw::HEAP_TEXTURE_NOTHING.each_ref().map(|n| n.swap(0, Ordering::Relaxed));
let ahead_of = crate::draw::HEAP_TEXTURE_BEFORE.each_ref().map(|n| n.swap(0, Ordering::Relaxed) / 1_000_000);
if all > 0 || parts[7] > 0 {
let [made_ns, after_ns, flipped_ns, made, after, flipped] = shown;
let [due_by_memory, remade, due_list] = ahead_of;
tracing::info!(
"the pass over textures picked by index, its parts in the last 5 seconds: slots shown: {} ms made at \
once ({made}), {} ms shown after their upload ({after}), {} ms flipped ({flipped}); nothing to bring \
up to date: {} views of textures the host writes, {} without a texture, {} the host's own texture, {} of \
them made at once; before the loops: {due_by_memory} ms making slots due, {remade} ms views made again \
and slots flipped, {due_list} ms taking the slots due, {} ms the rest",
made_ns / 1_000_000,
after_ns / 1_000_000,
flipped_ns / 1_000_000,
nothing[0],
nothing[1],
nothing[2],
nothing[3],
parts[7].saturating_sub(due_by_memory + remade + due_list),
);
}
if crate::descriptor::host::show_new_later() {
tracing::info!(
"slots of textures made while lists sent before them ran, shown once those had run \
(VICTORY_SHOW_NEW_LATER=1), since the start: {}",
crate::descriptor::host::NEW_LATER.load(Ordering::Relaxed)
);
}
// The queue's lock by place (`crate::descriptor::queue_site`).
let lock = crate::descriptor::QUEUE_LOCK.each_ref().map(|row| row.each_ref().map(|n| n.swap(0, Ordering::Relaxed)));
let [taken, waited, held, skipped] = lock;
if taken.iter().sum::<u64>() + skipped.iter().sum::<u64>() > 0 {
let ms = |ns: u64| ns / 1_000_000;
tracing::info!(
"the texture queue's lock in the last 5 seconds: taken {} times ({} by the pass asking of or telling of a \
slot, {} taking the slots due, {} making slots due, {} noting a slot's record, {} by table reads, {} for \
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), {} records of textures \
the host writes left out of the queue (VICTORY_QUEUE_HOST_TEXTURES=0)",
taken.iter().sum::<u64>(),
taken[0],
taken[1],
taken[2],
taken[3],
taken[4],
taken[5],
taken[6],
ms(waited.iter().sum::<u64>()),
ms(waited[0]),
ms(waited[1]),
ms(waited[2]),
ms(waited[3]),
ms(waited[4]),
ms(waited[5]),
ms(waited[6]),
ms(held[1]),
ms(held[2]),
ms(held[5]),
skipped.iter().sum::<u64>(),
skipped[3],
skipped[4],
skipped[5],
crate::descriptor::host::TABLED_WRITES[2].load(Ordering::Relaxed),
crate::descriptor::host::HOST_TEXTURES_LEFT_OUT.load(Ordering::Relaxed),
);
}
}
if crate::resource::held_only() {
let [copies, bytes, grown, whole] = [0, 1, 2, 3].map(|i| crate::resource::HELD[i].load(Ordering::Relaxed));