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

+43 -2
View File
@@ -3233,6 +3233,38 @@ pub(crate) fn late_met_known(wait: &crate::list::ValueWait) -> Option<bool> {
None
}
/// The number of the flight in the air whose bottom-of-pipe write meets
/// `wait` ([`late_met_known`]), for `two_queues`: the part behind the wait
/// goes to the card behind that flight, on the one queue; on a queue of its
/// own it would have to wait for it. `None`: memory meets it now, the
/// flight is being landed (the card has run it), or no flight's write does.
pub(crate) fn late_met_by(wait: &crate::list::ValueWait) -> Option<u64> {
if !late() || wait.met() {
return None;
}
let (address, bytes) = wait.place();
let line = line();
let mut flight = None;
for item in &line.line {
match item {
Late::Run(f) => flight = Some(f.number),
Late::Write(at, crate::queue::Written::Value(v), n) if *at == address && *n >= bytes && wait.holds_for(*v) => {
return flight;
}
_ => {}
}
}
None
}
/// Tiles were mapped on `queue`: counted for `two_queues` if it is the
/// host's direct queue.
pub(crate) fn tiles_mapped_on(queue: &ID3D12CommandQueue) {
if two_queues::on() && host().is_some_and(|h| h.queue.as_raw() == queue.as_raw()) {
two_queues::tiles_mapped();
}
}
/// Settles the flights in the air, if any ([`Host::settle`]), for reason
/// `why` (one of the `WHY_` places). Not from inside a submission.
pub(crate) fn settle_now(why: usize) {
@@ -3703,6 +3735,7 @@ pub(crate) mod spans;
mod torn;
#[cfg(feature = "diagnostics")]
mod traffic;
pub(crate) mod two_queues;
pub(crate) mod upcheck;
#[cfg(feature = "diagnostics")]
mod stamps;
@@ -5536,6 +5569,9 @@ impl Host {
None => runs,
};
let parts: Vec<usize> = parts.iter().map(|&n| n + usize::from(own.is_some())).collect();
// The plan for two queues: the textures' states before the preludes
// move them.
let probe = two_queues::on().then(|| two_queues::probe(runs));
stage.next("submit: the sweep");
let behind = late && flying();
// Before this submission counts as started: what the sweep lets go
@@ -5682,6 +5718,10 @@ impl Host {
}
let declared = declared_writes(runs);
let card = self.card_before(&declared, &picked, flown);
if let Some(probe) = probe {
let finished = FINISHED.load(Ordering::Acquire);
two_queues::place(probe, this_submission, card.is_some(), own.is_some(), runs.len(), finished);
}
// The sends are taken: from here on the references hold what the
// copies in the lists put.
for (shadow, at, bytes) in batch.placed.drain(..) {
@@ -5732,7 +5772,7 @@ impl Host {
};
awake::sent(&self.device);
#[cfg(feature = "diagnostics")]
crate::timeline::sent(sending, *submitted, stamp);
crate::timeline::sent(sending, *submitted, stamp, two_queues::title_kind() == Some(two_queues::COMPUTE));
self.card_sent();
stage.next("submit: noting what is in the air");
if let Err(e) = signalled {
@@ -5787,7 +5827,7 @@ impl Host {
.Signal(&self.fence, *submitted)
.and_then(|()| self.fence.SetEventOnCompletion(*submitted, self.event));
#[cfg(feature = "diagnostics")]
crate::timeline::sent(sending, *submitted, stamp);
crate::timeline::sent(sending, *submitted, stamp, two_queues::title_kind() == Some(two_queues::COMPUTE));
match waited {
Ok(()) => {
working(false);
@@ -8759,6 +8799,7 @@ impl Meter {
late_line(frames);
crate::queue::behind_line(frames);
card_clock_line(frames, ms);
two_queues::line(frames);
#[cfg(feature = "diagnostics")]
spans::line(frames);
crate::shadow::back_line(frames);