Indirect executions joined (VICTORY_INDIRECT_MERGE=1, off) and counted

An execution of one record that follows another on the same host list is
recorded with it as one ExecuteIndirect of more records when nothing could
tell them apart: no title call that records into the list between, binding
calls between that set what was set (State::rebinds), no count buffer and
one record each, same kind and host pipeline, no clamp pass recorded for
it (batch slot or window hit), the run's last binding left the list's
epoch where it found it, and the record lies next to the run's last in the
same scratch buffer at the run's step (batch slot or window step; the run
is recorded with a signature of that stride).

The run's execution is held back on the HostList and recorded before
anything else: every title call that may record (list::host_list), the
clamp passes and bindings of later executions, and the list's close.
Calls that only change the binding (pipeline, heaps, tables, views,
constants, vertex and index buffers) no longer count as title calls and
record nothing; they count their real changes instead.

A release frame line counts every indirect execution by verdict, with the
switch off too: how many could join the one before them, how many were
joined, and what kept the others apart (first on the list, a title call
that records, count buffer or more records, kept alone, other kind or
pipeline, clamped, binding changed, root constants only changed, binding
that changed the list, record apart).

Tests: the merge rules (11), a HostList test that records held runs at a
title call and at close and runs each record once on the card, and two
new variants of the ignored bare_command_cost measurement (each draw an
indirect execution of one record; all records in one execution).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
readmet3xt-labandClaude Opus 5.5 committed 2026-11-26 19:42:52 +05:30
1 parent c0f627e4b5
commit 28f6e25210
5 files changed
+825 -68

No files matched your search

+49 -20
View File
@@ -150,7 +150,27 @@ const _: () = assert!(offset_of!(List, pipeline_shadow) + 32 == 0x560);
/// is a host GPU.
#[cfg(windows)]
fn with_state(this: This, f: impl FnOnce(&crate::host::HostList, &mut crate::draw::State)) {
let Some(list) = host_list(this) else { return };
with_state_on(host_list(this), this, f);
}
/// As [`with_state`], for a call that only changes what the next draw or
/// dispatch binds, which records nothing until then: not counted as a title
/// call ([`crate::host::HostList::title_call`]); an indirect execution held
/// back may still be joined if the binding stays as it was
/// ([`crate::indirect::merge`]).
#[cfg(windows)]
fn with_binding(this: This, f: impl FnOnce(&mut crate::draw::State)) {
with_state_on(host_list_held(this), this, |_, s| f(s));
}
/// As [`with_state`], with `list`, the host list of `this` as it was taken.
#[cfg(windows)]
fn with_state_on(
list: Option<&crate::host::HostList>,
this: This,
f: impl FnOnce(&crate::host::HostList, &mut crate::draw::State),
) {
let Some(list) = list else { return };
#[cfg(feature = "diagnostics")]
let started = std::time::Instant::now();
// SAFETY: the title passes one of our lists.
@@ -177,9 +197,22 @@ pub(crate) fn tables_done(lists: &[This]) {
}
}
/// The host list behind a title list, if there is a host GPU.
/// The host list behind a title list, if there is a host GPU, for a call
/// that records into it: counted as a title call, which records an
/// indirect execution held back first ([`crate::host::HostList::title_call`]).
#[cfg(windows)]
pub(crate) fn host_list<'a>(this: This) -> Option<&'a crate::host::HostList> {
let list = host_list_held(this)?;
list.title_call();
Some(list)
}
/// As [`host_list`], not counted as a title call and recording nothing:
/// for an indirect execution, which may join the one held back
/// ([`crate::indirect::merge`]), and for calls that only change the binding
/// ([`with_binding`]).
#[cfg(windows)]
fn host_list_held<'a>(this: This) -> Option<&'a crate::host::HostList> {
if this.is_null() {
return None;
}
@@ -1544,7 +1577,7 @@ static ALLOCATOR_FUNCTIONS: Table<24> = {
extern "system" fn set_pipeline(this: This, pipeline: This) {
crate::pipeline::bound(pipeline);
#[cfg(windows)]
with_state(this, |_, state| state.set_pipeline(pipeline));
with_binding(this, |state| state.set_pipeline(pipeline));
#[cfg(not(windows))]
let _ = this;
}
@@ -1646,7 +1679,7 @@ extern "system" fn ignored_state(_: This) {}
/// set on the host list at once. Without a host GPU these do nothing.
#[cfg(windows)]
mod state {
use super::{This, with_state};
use super::{This, with_binding, with_state};
use crate::draw::{IndexView, VertexView};
use windows::Win32::Foundation::RECT;
use windows::Win32::Graphics::Direct3D12::D3D12_VIEWPORT;
@@ -1688,16 +1721,16 @@ mod state {
with_state(this, |list, s| s.set_depth_bounds(list, min, max));
}
pub(super) extern "system" fn heaps(this: This, count: u32, heaps: *const This) {
with_state(this, |_, s| s.set_heaps(items(heaps, count)));
with_binding(this, |s| s.set_heaps(items(heaps, count)));
}
pub(super) extern "system" fn compute_table(this: This, slot: u32, handle: u64) {
with_state(this, |_, s| s.set_table(true, slot, handle));
with_binding(this, |s| s.set_table(true, slot, handle));
}
pub(super) extern "system" fn graphics_table(this: This, slot: u32, handle: u64) {
with_state(this, |_, s| s.set_table(false, slot, handle));
with_binding(this, |s| s.set_table(false, slot, handle));
}
pub(super) extern "system" fn compute_constant(this: This, slot: u32, value: u32, offset: u32) {
with_state(this, |_, s| s.set_constants(true, slot, &[value], offset));
with_binding(this, |s| s.set_constants(true, slot, &[value], offset));
}
pub(super) extern "system" fn graphics_constant(
this: This,
@@ -1705,7 +1738,7 @@ mod state {
value: u32,
offset: u32,
) {
with_state(this, |_, s| s.set_constants(false, slot, &[value], offset));
with_binding(this, |s| s.set_constants(false, slot, &[value], offset));
}
pub(super) extern "system" fn compute_constants(
this: This,
@@ -1714,9 +1747,7 @@ mod state {
values: *const u32,
offset: u32,
) {
with_state(this, |_, s| {
s.set_constants(true, slot, items(values, count), offset)
});
with_binding(this, |s| s.set_constants(true, slot, items(values, count), offset));
}
pub(super) extern "system" fn graphics_constants(
this: This,
@@ -1725,20 +1756,18 @@ mod state {
values: *const u32,
offset: u32,
) {
with_state(this, |_, s| {
s.set_constants(false, slot, items(values, count), offset)
});
with_binding(this, |s| s.set_constants(false, slot, items(values, count), offset));
}
/// Root constant buffer, shader resource and unordered access views.
pub(super) extern "system" fn compute_view(this: This, slot: u32, address: u64) {
with_state(this, |_, s| s.set_view(true, slot, address));
with_binding(this, |s| s.set_view(true, slot, address));
}
pub(super) extern "system" fn graphics_view(this: This, slot: u32, address: u64) {
with_state(this, |_, s| s.set_view(false, slot, address));
with_binding(this, |s| s.set_view(false, slot, address));
}
pub(super) extern "system" fn index_buffer(this: This, view: *const IndexView) {
// SAFETY: the title passes a view or null.
with_state(this, |_, s| s.set_index_buffer(unsafe { view.as_ref() }));
with_binding(this, |s| s.set_index_buffer(unsafe { view.as_ref() }));
}
pub(super) extern "system" fn vertex_buffers(
this: This,
@@ -1746,7 +1775,7 @@ mod state {
count: u32,
views: *const VertexView,
) {
with_state(this, |_, s| {
with_binding(this, |s| {
if views.is_null() {
s.clear_vertex_buffers(start, count);
} else {
@@ -1905,7 +1934,7 @@ extern "system" fn execute_indirect(
const DISPATCH: u32 = 2;
const DISPATCH_SINGLE: u32 = 105;
let kind = if *kind == DISPATCH_SINGLE { DISPATCH } else { *kind };
with_state(this, |list, s| {
with_state_on(host_list_held(this), this, |list, s| {
ran = s.execute_indirect(list, (kind, stride, max), address, counter);
});
} else {