RUNTIME 2338: Re-homed and carried kept draws restate by their scissor rectangles alone where nothing beyond them changed
Kept::rehomed_into and Kept::carried_into reset the kept draw's render-state stamps to fresh ones (Stated::default()), so the next draw of each derived again everything the encoder's render state decides (restated.rs's restate_kept: the route, the bind state's values, the draw state), though between the walk's draws the encoders set their scissor rectangles alone: on the RTX 5080 compositor walk (107 encoders of 5 draws a frame, abwalk-203314 at 5a4df749ec) 414 of the 428 rebound draws a frame took the full restate, about 0.26 us each, and 14 restated by scissors. A re-homed draw stays under its encoder's render state: rehomed_into now draws its `set` stamp afresh and keeps its stamp beyond the scissor rectangles, so its next draw restates by them alone where the encoder set nothing beyond them since (Stated::scissors_alone), and by everything where it did. A carried draw moves to another encoder, whose render state starts at Metal's defaults: the ending encoder records its pass's extent where it never set its render state beyond its scissor rectangles (DrawAgain::beyond_set, RenderLowering::again_defaults, Carried::defaults), and the opening one gives the carried draws its own stamp beyond them where its pass is of the same extent and it set nothing beyond them either (RenderLowering::carried_stated); else a fresh one, as before. Both encoders' render states are then Metal's defaults but for the scissor rectangles, and the default viewport is the attachment's extent, so restate_scissors answers what restate_kept would. The `set` stamp still differs from the encoder's, so record_rebound still adds the restated draw's pixels to its instance's drawn area and records its dynamic states afresh. Test: tests::split_keeps' two tests assert the re-homed draws (2) and, across two encoders, the re-homed and carried draws (6) restate by their scissor rectangles alone (WorkCounts::draws_restated_scissors), with the same commands, state commands and pixels as every draw taking every step; builds with debug assertions check every second rebound draw against every step. Verification: the jobs that compile and run it are reported with this sha. Compiled in m3-max-31357 (msi: clippy x3; 92 runtime render and kept-draw tests on lavapipe in debug, every second rebound draw checked against every step).
This commit is contained in:
1 parent
ebbaf7eff6
commit
33369d0e8e
4 files changed
+84
-24
No files matched your search
@@ -136,6 +136,9 @@ pub(crate) struct Carried {
|
||||
shape: PassShape,
|
||||
layers: Layers,
|
||||
residency: u64,
|
||||
/// The ended encoder's pass's extent where it never set its render state beyond its scissor
|
||||
/// rectangles (`RenderLowering::again_defaults`).
|
||||
defaults: Option<[u32; 2]>,
|
||||
/// Whether its command buffer was committed, and its queue holds it for a later command
|
||||
/// buffer's render encoder ([`across`](Carried::across)).
|
||||
across: bool,
|
||||
@@ -400,14 +403,15 @@ impl RenderLowering {
|
||||
&mut self,
|
||||
mut kept: Kept,
|
||||
live: &mut LiveBind,
|
||||
across: bool,
|
||||
(across, defaults): (bool, Option<[u32; 2]>),
|
||||
#[cfg(debug_assertions)] carries: u64,
|
||||
) {
|
||||
let (stamps, under) = (self.table_stamps(), self.under());
|
||||
let (epoch, draws) = (self.again_epoch(), (self.current.draws, across));
|
||||
kept.carried_into(epoch, stamps, under, draws);
|
||||
let at = (self.again_epoch(), stamps, self.carried_stated(defaults));
|
||||
let draws = (self.current.draws, across);
|
||||
kept.carried_into(at, under, draws);
|
||||
self.keep_carried(kept);
|
||||
let aside = live.carried_aside(|kept| kept.carried_into(epoch, stamps, under, draws));
|
||||
let aside = live.carried_aside(|kept| kept.carried_into(at, under, draws));
|
||||
#[cfg(debug_assertions)]
|
||||
self.set_carries(carries);
|
||||
let counts = &self.core.device().shared().counts;
|
||||
@@ -436,6 +440,7 @@ impl Lowering {
|
||||
shape: (*lowering.current.shape).clone(),
|
||||
layers: Layers::of(&lowering),
|
||||
residency: lowering.residency.generation(),
|
||||
defaults: lowering.again_defaults(),
|
||||
across: false,
|
||||
#[cfg(debug_assertions)]
|
||||
carries: lowering.carries(),
|
||||
@@ -452,6 +457,7 @@ impl Lowering {
|
||||
mut live,
|
||||
kept,
|
||||
across,
|
||||
defaults,
|
||||
#[cfg(debug_assertions)]
|
||||
carries,
|
||||
..
|
||||
@@ -460,9 +466,9 @@ impl Lowering {
|
||||
Start::Spare(live) => return Lowering { lowering, live },
|
||||
};
|
||||
#[cfg(debug_assertions)]
|
||||
lowering.carried_in(kept, &mut live, across, carries);
|
||||
lowering.carried_in(kept, &mut live, (across, defaults), carries);
|
||||
#[cfg(not(debug_assertions))]
|
||||
lowering.carried_in(kept, &mut live, across);
|
||||
lowering.carried_in(kept, &mut live, (across, defaults));
|
||||
Lowering { lowering, live }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,9 +172,11 @@
|
||||
//! readers through snapshots, the draws carried in and not drawn since, and those that read
|
||||
//! what changes with no call otherwise than it did, which it lets go. Each is kept there as a
|
||||
//! carried draw is kept in the instance its encoder opened with ([`Kept::rehomed`]): after
|
||||
//! draws of other states, recorded through no record, under another render state, so its
|
||||
//! next draw is rebound (`rebound.rs`), deriving again what the render state decides and
|
||||
//! adding the pixels it may write to the instance's drawn area (`restated.rs`), its uses
|
||||
//! draws of other states, recorded through no record, under a render state of another stamp
|
||||
//! but its stamp beyond the scissor rectangles, so its next draw is rebound (`rebound.rs`),
|
||||
//! deriving again what the render state decides (its scissor rectangles alone where the encoder
|
||||
//! set nothing beyond them since) and adding the pixels it may write to the instance's drawn
|
||||
//! area (`restated.rs`), its uses
|
||||
//! noted, added to the pass's reads and gathered whole into the new instance with its
|
||||
//! shadowed textures' (which the copies before it then take), where it uses those exactly as
|
||||
//! the kept draw did, and every state command it sets recorded against what that instance's
|
||||
@@ -186,11 +188,13 @@
|
||||
//! where nothing comes between, or past its commit into a render encoder of a later command
|
||||
//! buffer of its queue, where that encoder's pass is its pass's like (`render/carried.rs`): each
|
||||
//! draw is kept there as one after draws of other states, recorded through no record, under
|
||||
//! another render state ([`Kept::carried`]), in the instance that encoder opened with, so its
|
||||
//! state's first draw there is rebound (`rebound.rs`), bringing in every slot that encoder's
|
||||
//! calls bound and gathering its own shadowed textures' uses (a texture of that pass's color
|
||||
//! attachment it reads through the texture's copy among them) into that instance, as every step
|
||||
//! gathers them.
|
||||
//! another render state ([`Kept::carried`]; Metal's defaults but for the scissor rectangles
|
||||
//! where neither encoder set its render state beyond them and the passes are of one extent,
|
||||
//! which restates it by its scissor rectangles alone), in the instance that encoder opened
|
||||
//! with, so its state's first draw there is rebound (`rebound.rs`), bringing in every slot that
|
||||
//! encoder's calls bound and gathering its own shadowed textures' uses (a texture of that pass's
|
||||
//! color attachment it reads through the texture's copy among them) into that instance, as
|
||||
//! every step gathers them.
|
||||
//! - **What a kept draw left holds for the next.** Each of its steps adds to what the encoder
|
||||
//! holds, and adding the same again changes nothing: its drawn area and coverage (rectangles
|
||||
//! and boxes, `clear_reach::DrawnArea`, `linear_attachment::Coverage`), the pass's reads
|
||||
@@ -259,6 +263,10 @@ pub(super) struct DrawAgain {
|
||||
/// call that sets it ([`restate_again`](RenderLowering::restate_again)), so a kept draw that
|
||||
/// holds others is restated (the module docs).
|
||||
stated: Stated,
|
||||
/// Whether a call set the encoder's render state beyond its scissor rectangles: until one
|
||||
/// does, it is Metal's default but for them, which a kept draw carried into the next encoder
|
||||
/// of a pass of the same extent is drawn under too (`render/carried.rs`).
|
||||
beyond_set: bool,
|
||||
/// What another thread may change of what the encoder's current draw reads, as its steps
|
||||
/// began ([`Outside`], [`RenderLowering::draw_began`]).
|
||||
began: Outside,
|
||||
@@ -399,21 +407,21 @@ impl PartialEq for KeptPipeline {
|
||||
|
||||
impl Kept {
|
||||
/// Carry this draw into a render encoder of epoch `epoch` whose tables' stamps are `stamps`
|
||||
/// at its opening, whose `Under` is `under` there and whose first instance records into
|
||||
/// `draws` (`render/carried.rs`): of a later command buffer than the one it was kept in where
|
||||
/// at its opening, whose `Under` is `under` there, whose render state's stamps it holds as
|
||||
/// `stated` (`RenderLowering::carried_stated`) and whose first instance records into `draws`
|
||||
/// (`render/carried.rs`): of a later command buffer than the one it was kept in where
|
||||
/// `across` (a draw set aside, carried again before it is drawn, stays across).
|
||||
pub(super) fn carried_into(
|
||||
&mut self,
|
||||
epoch: Stamp,
|
||||
stamps: [Stamp; 4],
|
||||
(epoch, stamps, stated): (Stamp, [Stamp; 4], Stated),
|
||||
under: Under,
|
||||
(draws, across): (vk::CommandBuffer, bool),
|
||||
) {
|
||||
self.across |= across;
|
||||
self.epoch = epoch;
|
||||
// Stamps no render state had: its first draw derives again what the encoder's render
|
||||
// state decides (`restated.rs`).
|
||||
self.stated = Stated::default();
|
||||
// Its first draw derives again what the encoder's render state decides (`restated.rs`):
|
||||
// its scissor rectangles alone where `stated` holds the encoder's stamp beyond them.
|
||||
self.stated = stated;
|
||||
self.between = true;
|
||||
self.stamps = stamps;
|
||||
self.under = under;
|
||||
@@ -452,7 +460,12 @@ impl Kept {
|
||||
if read(&self.under) != read(&under) {
|
||||
return false;
|
||||
}
|
||||
self.stated = Stated::default();
|
||||
// Under the encoder's render state still, its next draw restated, by the scissor
|
||||
// rectangles alone where the encoder set nothing beyond them since (`restated.rs`).
|
||||
self.stated = Stated {
|
||||
set: Stamp::fresh(),
|
||||
beyond_scissors: self.stated.beyond_scissors,
|
||||
};
|
||||
self.between = true;
|
||||
self.under = under;
|
||||
self.command_buffer = draws;
|
||||
@@ -950,6 +963,31 @@ impl RenderLowering {
|
||||
self.again.stated.set = Stamp::fresh();
|
||||
if !scissors {
|
||||
self.again.stated.beyond_scissors = Stamp::fresh();
|
||||
self.again.beyond_set = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// The ended encoder's pass's extent where the encoder never set its render state beyond its
|
||||
/// scissor rectangles: its kept draws' settings are of Metal's defaults there but for them
|
||||
/// (`render/carried.rs`).
|
||||
pub(super) fn again_defaults(&self) -> Option<[u32; 2]> {
|
||||
(!self.again.beyond_set).then_some(self.layout.extent)
|
||||
}
|
||||
|
||||
/// The render state's stamps kept draws carried in from an encoder whose pass's extent was
|
||||
/// `defaults`, where it never set its render state beyond its scissor rectangles
|
||||
/// ([`again_defaults`](Self::again_defaults)), hold here (`render/carried.rs`): restated at
|
||||
/// their next draws, by the scissor rectangles alone where this encoder's pass is of the same
|
||||
/// extent and this encoder has set nothing beyond them either, as both encoders' render
|
||||
/// states are then Metal's defaults but for them; else by everything the state decides.
|
||||
pub(super) fn carried_stated(&self, defaults: Option<[u32; 2]>) -> Stated {
|
||||
let beyond = match defaults == Some(self.layout.extent) && !self.again.beyond_set {
|
||||
true => self.again.stated.beyond_scissors,
|
||||
false => Stamp::fresh(),
|
||||
};
|
||||
Stated {
|
||||
set: Stamp::fresh(),
|
||||
beyond_scissors: beyond,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -223,7 +223,8 @@ fn corners([x0, y0, x1, y1]: [u64; 4]) -> Vec<u8> {
|
||||
/// that changes nothing for them (`set_tessellation_factor_scale`, which no draw of their states
|
||||
/// reads), which forgets the kept draws. The reader splits the pass once in both runs, and no
|
||||
/// draw keeps nothing for another reason than its own (`WorkCounts::draws_unkept_other`): a draw
|
||||
/// into the instance after the split keeps itself.
|
||||
/// into the instance after the split keeps itself. The re-homed draws restate by their scissor
|
||||
/// rectangles alone (`WorkCounts::draws_restated_scissors`): the encoder set nothing beyond them.
|
||||
#[test]
|
||||
fn kept_draws_set_aside_are_rebound_past_a_split() {
|
||||
let scratch = Scratch::new("split-keeps");
|
||||
@@ -251,6 +252,12 @@ fn kept_draws_set_aside_are_rebound_past_a_split() {
|
||||
(2, 0),
|
||||
"the kept draws re-homed"
|
||||
);
|
||||
// Re-homed under the encoder's render state, which set its scissor rectangles alone since.
|
||||
assert_eq!(
|
||||
counted(|c| c.draws_restated_scissors),
|
||||
(2, 0),
|
||||
"the re-homed draws restated by their scissor rectangles alone"
|
||||
);
|
||||
assert_eq!(
|
||||
counted(|c| c.draws_unlike_kept + c.draws_rebind_stopped),
|
||||
(0, 0),
|
||||
@@ -295,6 +302,8 @@ fn kept_draws_set_aside_are_rebound_past_a_split() {
|
||||
/// in turn, with the same commands, state commands and pixels as every draw taking every step.
|
||||
/// Only the readers and the first encoder's first draw of each state take every step; no encoder
|
||||
/// ends uncarried for its split, and no draw is unlike its kept draw or stops its rebind or carry.
|
||||
/// The carried and re-homed draws restate by their scissor rectangles alone
|
||||
/// (`WorkCounts::draws_restated_scissors`): neither encoder set its render state beyond them.
|
||||
#[test]
|
||||
fn kept_draws_past_a_split_carry_into_the_next_encoder() {
|
||||
let scratch = Scratch::new("split-carries");
|
||||
@@ -324,6 +333,13 @@ fn kept_draws_past_a_split_carry_into_the_next_encoder() {
|
||||
(drawn_alone(2), 0),
|
||||
"the second encoder's first draws of A and B, rebound against the carried draws"
|
||||
);
|
||||
// Neither encoder set its render state beyond its scissor rectangles, over one target: the
|
||||
// carried draws restate by them alone, as the re-homed ones do.
|
||||
assert_eq!(
|
||||
counted(|c| c.draws_restated_scissors),
|
||||
(2 * encoders + 2, 0),
|
||||
"the re-homed and carried draws restated by their scissor rectangles alone"
|
||||
);
|
||||
// Each encoder's draws: A, B, the reader, A, B and B's draws again.
|
||||
let each = BOXES.len() as u64 + AGAIN;
|
||||
assert_eq!(
|
||||
|
||||
Vendored
+1
-1
@@ -94,7 +94,7 @@ pub const ARTIFACT_FORMAT_VERSION: u32 = 523;
|
||||
/// changes no behaviour, and then updates that hash alone with the commit saying why, or changes
|
||||
/// behaviour and also bumps this version. The commit that bumps it says what changed; this comment
|
||||
/// keeps no history.
|
||||
pub const RUNTIME_VERSION: u32 = 2337;
|
||||
pub const RUNTIME_VERSION: u32 = 2338;
|
||||
|
||||
/// The digest of the sources this build of the crate was compiled from: SHA-256, as lowercase hex,
|
||||
/// of the manifest, the build script, and exactly the files the crate roots' module tree compiles
|
||||
|
||||
Reference in new issue
Block a user