Record each command into the driver's command buffer at the call
Recording at the call replaces the deferred replay, with the pipeline-wait test settling the
device's in-place check that recording at the call made fall inside its run.
One work packet, landed as 2 commits on archive/development-linear-2026-10-29, in order:
* Record each command into the driver's command buffer at the call (6c9d1f4551)
An encoder's command buffers are the driver's VkCommandBuffers from the command
buffer's pool, recorded at each call on the program's thread. The deferral is
gone: the per-command log, the deferred handles, the replays and the recorder
thread, the scheduler's wake of it, the host pages' replay holds, and
WorkCounts::{command_buffers_deferred, command_buffers_replayed,
command_buffers_replayed_inline} (removed public fields; none is read by the
consumer). The slots' routed entry points stay as a counting door:
WorkCounts::commands_replayed counts each command at the call, across every
command buffer (the scheduler's barrier buffers and primaries begun ahead
included, so its totals rise: the drag frame's 1000 -> 1094). A shadow's copy in
over dirty-logged host pages becomes a segment its batch's submission records
(Deferred::GatedCopyIn), so its regions are still decided after the commit's
dirty-log stamp. Rebind re-encode (replay.rs, reencode.rs) is unchanged.
RUNTIME_VERSION 1692.
Verified on the Apple M3 Max (MoltenVK): runtime device suite 1392/1393 twice
(pipeline_wait_order's "a batch waiting for a pipeline holds only the batches
that share its resources" fails under suite load only, a known load flake that
now fails more often; 3/3 alone; the base passed 1395/1395 under the same
load); new recorded_at_the_call::a_fill_is_recorded_at_its_call; the three
dirty_pages_device tests through the gated segment; plain runtime 1145/1145;
conformance plain 1007/1007 (its racy-count test now reads wakes_spared and
command_buffers_submitted); clippy plain and --cfg m2v_gpu; rustdoc.
Release A/B on the M3 (5 interleaved pairs, host load 16-43): drag frame
commit-to-handler p50 3.416 -> 3.386 ms back to back, 4.185 -> 3.671 ms paced
at 60 Hz; encode per draw +7.9% back to back, +15.7% paced (the recording moved
onto the program's thread). Not run: the validation plain suite, the
validation lanes edited, lavapipe; conformance's MoltenVK cost records hold
begin/end/barrier bounds from the narrower count and need re-recording.
* Settle the device's in-place check before the pipeline-wait test frees its no-copy buffer (40c79d69e6)
The test's texture over a no-copy buffer starts the device's check of images
over host pages, whose rounds make internal submissions on the
m2v-in-place-check thread. On MoltenVK freed memory waits for every device-own
submission issued before it went (freed_memory.rs), so a check submission in
flight as the test drops the buffer delays its deallocator
(host_deallocators_delayed 1). That wait is the runtime's documented behaviour;
the unrelated batch holds no reference to the buffer (a temporary backtrace on
the device's internal submissions showed every one from the check thread, none
from barrier buffers, primaries begun ahead or gated copy segments). The test
assumed no other device work was in flight, and recording at the call made the
test about 2.5x faster, so the release fell inside the check's run. The test
now calls settle_in_place_checks (a condition-variable wait, no sleep) before
its work.
Verified on the Apple M3 Max (MoltenVK): with three heavy device tests beside
it, 10/10 pass (5/10 without the settle, each "the deallocator waited for the
import"); alone 5/5; the runtime device suite 1393/1393. Also run there, all
passing: the validation lane device tests record at the call edited
(commands_replayed, detach, hidden_depth, clear_reach, rate_mapped_passes,
frame_costs, and the row_copies/frame_costs_plain measurements).
This commit is contained in:
1 parent
5f2c69e087
commit
44d97aaa5e
49 files changed
+415
-3565
No files matched your search
@@ -54,9 +54,7 @@
|
||||
|
||||
use super::rebound_use::Unlogged;
|
||||
use super::{lock, CommandBuffer, CommandBufferShared, State};
|
||||
use crate::buffer::HostPages;
|
||||
use crate::deferred::{Deferred, StepInputs};
|
||||
use crate::device::functions::Vk;
|
||||
use crate::encoder::{RecordedSegment, Replayed, ReplayedPart, Segment};
|
||||
use crate::pipeline::budget::Urgency;
|
||||
use crate::replay::Replay;
|
||||
@@ -175,10 +173,9 @@ impl CommandBufferShared {
|
||||
}
|
||||
};
|
||||
// What a refused splice held goes after the lock.
|
||||
let vk = device.shared().vk();
|
||||
let spliced_now = {
|
||||
let mut state = lock(&self.state);
|
||||
let spliced = state.splice_replay(vk, at, replayed, residency);
|
||||
let spliced = state.splice_replay(at, replayed, residency);
|
||||
if let (Ok(()), Some(predication)) = (&spliced, predication) {
|
||||
state.predication.take_checks(predication);
|
||||
}
|
||||
@@ -264,8 +261,7 @@ impl CommandBufferShared {
|
||||
counts.reencode_refused();
|
||||
continue;
|
||||
};
|
||||
let vk = device.shared().vk();
|
||||
let put = lock(&self.state).splice_segment(vk, place, recorded, inputs);
|
||||
let put = lock(&self.state).splice_segment(place, recorded, inputs);
|
||||
match put {
|
||||
Ok(()) => counts.segment_recorded_again(),
|
||||
Err(unspliced) => {
|
||||
@@ -314,12 +310,9 @@ impl State {
|
||||
/// `replayed` back, where its place holds other parts than the encoding again's, or a segment
|
||||
/// but one whose pipelines are being made (which goes, the encoding again having left one of
|
||||
/// its own in its place) or work its commit recorded on the GPU alone, or its group was
|
||||
/// submitted, or the
|
||||
/// command buffer completed. Its replays hold what its commands took with `device`, the
|
||||
/// device's functions (`Replays::hold`).
|
||||
/// submitted, or the command buffer completed.
|
||||
pub(super) fn splice_replay(
|
||||
&mut self,
|
||||
device: &Vk,
|
||||
at: usize,
|
||||
replayed: Replayed,
|
||||
residency: Option<Residency>,
|
||||
@@ -358,21 +351,13 @@ impl State {
|
||||
heaps,
|
||||
} = replayed;
|
||||
// Held weakly until its group's submission, as the commit held what the first recording
|
||||
// and its segments took, and by its replays until they are replayed: what they held last
|
||||
// goes here, as it does without them (`Replays::hold`, with `device`, the device's
|
||||
// functions).
|
||||
let mut wait = |pages: &mut Vec<Arc<HostPages>>| {
|
||||
taken.wait(pages);
|
||||
let segments = (replayed_parts.iter_mut())
|
||||
.flat_map(|part| part.segments.iter_mut())
|
||||
.filter_map(|segment| segment.recorded.as_mut());
|
||||
for done in segments {
|
||||
done.taken.wait(pages);
|
||||
}
|
||||
};
|
||||
match self.replays.clone() {
|
||||
Some(replays) => drop(replays.hold(device, wait)),
|
||||
None => wait(&mut Vec::new()),
|
||||
// and its segments took.
|
||||
taken.wait();
|
||||
let segments = (replayed_parts.iter_mut())
|
||||
.flat_map(|part| part.segments.iter_mut())
|
||||
.filter_map(|segment| segment.recorded.as_mut());
|
||||
for done in segments {
|
||||
done.taken.wait();
|
||||
}
|
||||
let first = self.ended[at].executions.clone();
|
||||
for (&part, replayed) in parts.iter().zip(replayed_parts) {
|
||||
@@ -436,15 +421,13 @@ impl State {
|
||||
|
||||
/// Put `recorded`, segment `at` of part `part` recorded again on the GPU alone, in its place
|
||||
/// before the first submission, with `inputs`, what its host step needs now: what its
|
||||
/// commands took held weakly until the first submission, as the commit holds them (by its
|
||||
/// replays too, with `device`, the device's functions: `Replays::hold`). What the first
|
||||
/// commands took held weakly until the first submission, as the commit holds them. What the first
|
||||
/// recording retained, its executions and its host step's inputs stay retained; its
|
||||
/// `VkCommandBuffer`s go with the pool unsubmitted, and what its commands took, held weakly,
|
||||
/// goes. Refused, changing nothing and giving `recorded` and `inputs` back, where the place
|
||||
/// holds no such segment, or the command buffer was submitted.
|
||||
pub(super) fn splice_segment(
|
||||
&mut self,
|
||||
device: &Vk,
|
||||
(part, at): (usize, usize),
|
||||
mut recorded: RecordedSegment,
|
||||
inputs: StepInputs,
|
||||
@@ -456,10 +439,7 @@ impl State {
|
||||
if !fits {
|
||||
return Err(Box::new((recorded, inputs)));
|
||||
}
|
||||
match self.replays.clone() {
|
||||
Some(replays) => drop(replays.hold(device, |pages| recorded.taken.wait(pages))),
|
||||
None => recorded.taken.wait(&mut Vec::new()),
|
||||
}
|
||||
recorded.taken.wait();
|
||||
let segment = &mut self.recorded[part].segments[at];
|
||||
let first = segment.recorded.replace(recorded);
|
||||
let before = segment.inputs.replace(inputs);
|
||||
|
||||
Reference in new issue
Block a user