GPU: the indirect scratch buffer stays readable between executions

Every indirect execution was followed by a move of the list's clamped
arguments back to the common state, and the next clamp moved them from
common to unordered access. Drivers may treat a barrier into or out of
the common state as a full wait, so even the window path
(VICTORY_INDIRECT_WINDOW=1), whose draws skip the clamp, still recorded
one barrier between every two draws.

The list now remembers that its scratch buffer was left readable as
indirect arguments: executions read it with no barrier of their own, the
next clamp moves it straight back to unordered access, and it returns to
common once, when the list closes or a bigger buffer replaces it. The
waits for earlier shader writes around the clamp are unchanged.

Tests: two windows of executions with no barrier between them, on WARP
and through a host list; the tracked state across clamps, growth and
reset; the existing clamp tests follow the new states. With
VICTORY_D3D12_DEBUG=1 in a diagnostics build, the host-list tests also
check that the debug layer reports nothing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Vyacheslav VenglovskyandClaude Opus 5.5 committed 2026-11-24 23:34:30 +01:00
1 parent 43ebd22d7d
commit 2136b81420
3 files changed
+336 -76

No files matched your search

+6 -3
View File
@@ -117,7 +117,9 @@ const WINDOW_MOST: u64 = 64;
/// apart after it (16, then twice as many each time, [`WINDOW_MOST`] at
/// most, never past the buffer) into
/// the list's scratch buffer in one pass, and the draws that follow read
/// their record there with no pass of ours, until one of these: a compute
/// their record there with no pass of ours and no barrier (the scratch
/// buffer stays readable as arguments until the next clamp), until one of
/// these: a compute
/// dispatch, a direct draw, an indirect call with a count buffer or more
/// than one record, a draw whose shaders can store to buffers, a record
/// outside the window, another host list.
@@ -2435,7 +2437,6 @@ impl State {
_ => false,
};
if !ran {
crate::indirect::done(list, &bounded);
why("prepare failed");
return false;
}
@@ -2461,7 +2462,9 @@ impl State {
if kind == MESH {
self.mesh_scissor(list, false);
}
crate::indirect::done(list, &bounded);
// The scratch buffer stays readable as arguments: the next draw of
// the window reads it with no barrier, and the next clamp moves it
// back (`crate::indirect`).
if kind == DISPATCH {
DISPATCHED.fetch_add(1, Ordering::Relaxed);
} else {