Two host queues: a plan for the title's compute queues (VICTORY_ASYNC_QUEUE=plan, off by default)

The gameplay frame is about 45 ms with the card busy most of it on about
11,000 small commands at 130-140 W of 220; a timeline (tl.190) had the
submission the title waited for stand 7.2 ms sent and not begun behind
other work on the one direct queue. The title runs part of its work on
compute queues of its own, which on the console overlaps its drawing.

The queue itself is not built: a D3D12 list runs only on a queue of its
own type, the type is fixed when the list is made, every host list is a
direct list, and what the layer records into the title's compute lists is
not all something a compute list may hold (textures shaders read are put
in both read states, 0x40|0x80; depth twins are copied through a drawn
pass). A submission cannot fall back to the direct queue once its lists
are compute lists. This is the half that can be had without that:

- host/two_queues.rs: Plan::place, the order between a direct and a
  compute queue: the queue each host submission would go to, the value
  signalled behind it, and the one wait put before it (left out where the
  queue waits behind that value already, or the submission has finished),
  for copies in the card's memory (sends and compares in one order), steps
  on the card, textures named on both queues, memory values a flight of
  the other queue writes (late_met_by), tile mappings, a texture's drawing
  state moved on the direct queue first, and submissions of ours.
- With VICTORY_ASYNC_QUEUE=plan (or =1, which says it is not built) the
  frame line "two host queues, planned per frame" counts submissions by
  the title queue's type, what keeps compute submissions on the direct
  queue, those that would go to a compute queue (with and without a wait)
  and the waits by reason. Nothing runs differently.
- The title queue's type reaches Host::submit (two_queues::for_title from
  the line's thread and the older paths; the queues' types by address,
  queue::kind_of); a value job in the line knows its queue.
- Diagnostics: the timeline's summary says how much of the card's running
  time was the title's compute queues' submissions (the most a queue of
  their own could run beside the rest).

Tests: the plan's order (eight cases). The two failures in indirect::tests
are as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
readmet3xt-labandClaude Opus 5.5 committed 2026-11-26 20:00:25 +05:30
1 parent c0f627e4b5
commit fa88dc7c84
7 files changed
+758 -29

No files matched your search

+29 -19
View File
@@ -378,8 +378,9 @@ type Recordings = std::sync::Arc<[std::sync::Arc<crate::list::thin::Recording>]>
enum Job {
/// The queue waits for the fence (its address) to reach the value.
Wait(usize, u64),
/// A part of a submission waits for a memory value.
Value(crate::list::ValueWait),
/// A part of a submission to the queue (its address) waits for a memory
/// value.
Value(usize, crate::list::ValueWait),
/// A submission, or a part of one: the lists' host sides and the order
/// they run in.
Run(usize, Vec<crate::list::Detached>, Vec<usize>),
@@ -416,7 +417,7 @@ impl Work for Job {
fn ask(&self) -> Option<Ask> {
match self {
&Job::Wait(fence, value) => Some(Ask::Wait(fence, value)),
Job::Value(wait) => Some(Ask::Value(*wait)),
Job::Value(_, wait) => Some(Ask::Value(*wait)),
Job::Lists(_, lists) => Some(Ask::Lists(lists.clone())),
_ => None,
}
@@ -468,20 +469,24 @@ impl Work for Job {
return Err(next);
}
// Nothing but waits and signals that a submission may follow.
let (count, lists, signals) = match self {
Job::Run(_, lists, order) => (1, (&*lists, &*order), &[][..]),
Job::Joined(_, lists, order, parts, signals) => (1 + parts.len(), (&*lists, &*order), &signals[..]),
let (queue, count, lists, signals) = match self {
Job::Run(queue, lists, order) => (*queue, 1, (&*lists, &*order), &[][..]),
Job::Joined(queue, lists, order, parts, signals) => (*queue, 1 + parts.len(), (&*lists, &*order), &signals[..]),
_ => return Err(next),
};
let hosts = || lists.1.iter().map(|&i| lists.0[i].host());
match &next {
Job::Value(wait) => {
let met = wait.met()
|| crate::host::late_met_known(wait) == Some(true)
|| hosts().any(|list| crate::host::will_meet(list, wait));
if !met {
Job::Value(_, wait) => {
let met = wait.met();
let ahead = !met && crate::host::late_met_known(wait) == Some(true);
if !met && !ahead && !hosts().any(|list| crate::host::will_meet(list, wait)) {
return Err(next);
}
// Met by a flight in the air: on a queue of its own the
// submission would wait for it.
if ahead && crate::host::two_queues::on() && !hosts().any(|list| crate::host::will_meet(list, wait)) {
crate::host::two_queues::value_passed(queue, wait);
}
}
&Job::Wait(fence, value) => {
if crate::fence::completed(fence as This) < value && !signals.iter().any(|&(f, v)| f == fence && v >= value) {
@@ -539,27 +544,32 @@ impl Work for Job {
}
match self {
// (A folded one is unfolded, never done.)
Job::Wait(..) | Job::Value(..) | Job::Lists(..) => {}
Job::Wait(..) | Job::Lists(..) => {}
Job::Value(queue, wait) => {
if !forced {
crate::host::two_queues::value_passed(queue, &wait);
}
}
Job::Run(queue, lists, order) => {
let _ = queue;
#[cfg(feature = "diagnostics")]
crate::capture::op(queue, || format!("RUN submission of {} lists (its thread's)", order.len()));
match crate::host::host() {
let after = crate::host::two_queues::take_after(queue);
crate::host::two_queues::for_title(super::kind_of(queue), after, || match crate::host::host() {
Some(host) => host.execute_late(lists, order),
None => drop(lists),
}
});
QUEUED.fetch_sub(1, Relaxed);
}
Job::Joined(queue, lists, order, parts, signals) => {
let _ = queue;
#[cfg(feature = "diagnostics")]
crate::capture::op(queue, || {
format!("RUN {} parts of submissions in one, {} lists (its thread's)", 1 + parts.len(), order.len())
});
match crate::host::host() {
let after = crate::host::two_queues::take_after(queue);
crate::host::two_queues::for_title(super::kind_of(queue), after, || match crate::host::host() {
Some(host) => host.execute_parts(lists, order, &parts),
None => drop(lists),
}
});
// (A part that had no list is one all the same.)
QUEUED.fetch_sub(1 + parts.len() as u64, Relaxed);
for (fence, value) in signals {
@@ -792,7 +802,7 @@ fn jobs_of(this: This, lists: &[This]) -> Vec<Job> {
}
if first < lists.len() {
for (waits, taken, order) in crate::list::detach_parts(&lists[first..]) {
jobs.extend(waits.into_iter().map(Job::Value));
jobs.extend(waits.into_iter().map(|wait| Job::Value(queue, wait)));
jobs.push(Job::Run(queue, taken, order));
}
}