Carry a render encoder's kept draw into the next render encoder of its command buffer
A pass of a composite costs its first draw every step in a fresh encoder: about 12 us of the 35 us a pass takes on the 780M's encoding thread, where each later draw of the same state is rebound for about 2.3 us. An encoder that ends with a kept draw that rebinds now leaves its bind state, with its settle, and the kept draw in its command buffer (render/carried.rs) in place of the device's spares. The next render encoder of that command buffer takes them where its pass is the ended one's in everything the settle and the recording read (the same PassShape and layers, no memoryless color, visibility buffer, sample positions, extended-range color, rate map or color groups) and where what the kept draw read that changes with no call is as it was (no no-copy buffer moved, the sampler IDs' slots, the residency's generation). Any other call of the command buffer that settles the end lets it go. The new encoder keeps the carried draw under its own epoch, between, of another render-state stamp and through no record, and its tables' stamps are the encoder's first ones. Its first draw of the same state is then rebound: it brings in every slot the new encoder's calls bound since the opening, stops where the bind state holds a slot none of them bound (stale: a new encoder inherits no binding), makes its uses whole, stops where it samples an attachment of its pass, begins the pass's first instance as every step's first draw does, and records every state command into the new command buffer, whose record holds none. Counted: WorkCounts::kept_draws_carried, kept_draws_carry_dropped_between, _layout and _under; draws_rebound_carried, draws_carry_stopped and draws_carry_stopped_stale, _attached and _other. In builds with debug assertions the first carried draw of a command buffer and every second one after it takes every step and is compared with the rebound (DrawAgain::carries). Verified: cargo fmt; api_signatures blessed. Build, clippy and the device tests follow in their own jobs. (cherry picked from commit 13e996baeb5286d9fe5aa561cd5adc92695d5bf6)
This commit is contained in:
1 parent
a1b2bb1907
commit
fa7bb25dd2
10 files changed
+679
-44
No files matched your search
@@ -1415,7 +1415,7 @@ impl ArgumentTable {
|
||||
pub(super) fn changed_since(
|
||||
&self,
|
||||
read: Stamp,
|
||||
) -> Option<impl Iterator<Item = (SlotClass, u32, bool)> + '_> {
|
||||
) -> Option<impl Iterator<Item = (SlotClass, u32, bool)> + Clone + '_> {
|
||||
Some(
|
||||
self.changes
|
||||
.since(read)?
|
||||
|
||||
@@ -93,7 +93,7 @@ use super::predication::{Event, Predication};
|
||||
use super::program_objects;
|
||||
use super::queue::{QueueGen, Slot};
|
||||
use super::rebind::{Holds, SubmittedHolds, Taken};
|
||||
use super::render::EndInFlight;
|
||||
use super::render::{Carried, EndInFlight};
|
||||
use super::replay::Replay;
|
||||
use super::residency::Residency;
|
||||
use super::resource::{ObjectId, ResourceKey};
|
||||
@@ -109,7 +109,7 @@ use super::unique_identifier::ScheduledWork;
|
||||
use super::upload::{Upload, Uploads};
|
||||
use super::used_resources::{names_any, EncoderKind, EncoderRecord, Reached, ReadRecord};
|
||||
use super::values::CommandBufferStatus;
|
||||
use super::work_counts::Counters;
|
||||
use super::work_counts::{CarryDropped, Counters};
|
||||
use super::write_routes::{AtCommit, Routes};
|
||||
use super::{Buffer, CommandQueue, Device};
|
||||
use crate::release;
|
||||
@@ -680,6 +680,10 @@ pub(super) struct State {
|
||||
ending: Option<EndInFlight>,
|
||||
/// The device's lowering thread lowered the end it holds (`ending`).
|
||||
end_lowered: bool,
|
||||
/// The kept draw its last render encoder carried for its next render encoder, with that
|
||||
/// encoder's bind state (`render/carried.rs`): let go by every call that settles the end
|
||||
/// ([`CommandBuffer::settle_end`]) but a render encoder's opening, which takes it.
|
||||
carried: Option<Box<Carried>>,
|
||||
/// The commits' own work fails this many more times (a device test's injection of an out of
|
||||
/// memory, `tests::deferred_calls`).
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
@@ -2118,6 +2122,7 @@ impl CommandBuffer {
|
||||
abandoned: false,
|
||||
ending: None,
|
||||
end_lowered: false,
|
||||
carried: None,
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
failures_injected: 0,
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
@@ -2456,13 +2461,58 @@ impl CommandBuffer {
|
||||
/// of its calls the thread has not lowered): first in each call that follows an encoder's end
|
||||
/// in the command buffer (another encoder's opening, an event or a semaphore, the commit, a
|
||||
/// read of what its encoders left), as if the end had been lowered inside its call.
|
||||
///
|
||||
/// A kept draw the last render encoder carried for the next is let go (`render/carried.rs`),
|
||||
/// counted as one another call came before (`WorkCounts::kept_draws_carry_dropped_between`).
|
||||
pub(crate) fn settle_end(&self) {
|
||||
self.settle_ended();
|
||||
self.let_go_carried(Some(CarryDropped::Between));
|
||||
}
|
||||
|
||||
/// [`settle_end`](Self::settle_end) at a commit: a kept draw carried is let go uncounted, as
|
||||
/// no render encoder of the command buffer comes after it.
|
||||
fn settle_end_committing(&self) {
|
||||
self.settle_ended();
|
||||
self.let_go_carried(None);
|
||||
}
|
||||
|
||||
/// [`settle_end`](Self::settle_end), but a kept draw the last render encoder carried stays
|
||||
/// (`render/carried.rs`): for a render encoder's opening, which takes it, and a read of what
|
||||
/// the encoders left, which records nothing between them.
|
||||
pub(crate) fn settle_ended(&self) {
|
||||
let ending = self.state().ending.take();
|
||||
if let Some(ending) = ending {
|
||||
ending.finish();
|
||||
}
|
||||
}
|
||||
|
||||
/// The kept draw the last render encoder carried for the next, taken (`render/carried.rs`).
|
||||
pub(crate) fn take_carried(&self) -> Option<Box<Carried>> {
|
||||
self.state().carried.take()
|
||||
}
|
||||
|
||||
/// Hold `carried`, the kept draw of a render encoder ending, for the next render encoder
|
||||
/// (`render/carried.rs`).
|
||||
pub(crate) fn carry(&self, carried: Box<Carried>) {
|
||||
let earlier = self.state().carried.replace(carried);
|
||||
// None is held: the opening of the encoder ending took the one before.
|
||||
if let Some(earlier) = earlier {
|
||||
earlier.let_go(&self.0.device);
|
||||
}
|
||||
}
|
||||
|
||||
/// Let go of the kept draw the last render encoder carried, where it holds one, to the
|
||||
/// device's spares, counted as `why` says where it says (`render/carried.rs`).
|
||||
fn let_go_carried(&self, why: Option<CarryDropped>) {
|
||||
let carried = self.state().carried.take();
|
||||
if let Some(carried) = carried {
|
||||
if let Some(why) = why {
|
||||
self.0.device.shared().counts.kept_draw_carry_dropped(why);
|
||||
}
|
||||
carried.let_go(&self.0.device);
|
||||
}
|
||||
}
|
||||
|
||||
/// The residency a new compute or render (`render`) encoder starts with
|
||||
/// (`Residency::shadows`): the shadowed textures its ended encoders made resident, those in
|
||||
/// the heaps they used made since included.
|
||||
@@ -3002,7 +3052,7 @@ impl CommandBuffer {
|
||||
return Ok(());
|
||||
}
|
||||
// The last render encoder's end, where its call left it to the device's lowering thread.
|
||||
self.settle_end();
|
||||
self.settle_end_committing();
|
||||
self.commit_settled(call, failure, CommitRun::AtCall, hand)
|
||||
}
|
||||
|
||||
@@ -3064,7 +3114,7 @@ impl CommandBuffer {
|
||||
true => Hand::Wake,
|
||||
false => self.state().queued_commit.unwrap_or(Hand::Wake),
|
||||
};
|
||||
self.settle_end();
|
||||
self.settle_end_committing();
|
||||
if let Err(error) = self.commit_settled("commit", None, CommitRun::Queued, hand) {
|
||||
self.state().refuse_commit(error);
|
||||
let committed = self.commit_settled("commit", None, CommitRun::Refused, hand);
|
||||
@@ -3089,7 +3139,7 @@ impl CommandBuffer {
|
||||
return;
|
||||
};
|
||||
for command_buffer in commits.unready_through(self) {
|
||||
command_buffer.settle_end();
|
||||
command_buffer.settle_end_committing();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3639,7 +3689,7 @@ impl CommandBuffer {
|
||||
/// encoder's call refused as it was lowered would have returned at the call. No Metal
|
||||
/// counterpart.
|
||||
pub fn refusal(&self) -> Option<Error> {
|
||||
self.settle_end();
|
||||
self.settle_ended();
|
||||
self.state().refusal.clone()
|
||||
}
|
||||
|
||||
@@ -3650,7 +3700,7 @@ impl CommandBuffer {
|
||||
/// dispatch, in encoding order: Metal reports one error per command buffer. No Metal
|
||||
/// counterpart.
|
||||
pub fn failed_pipeline(&self) -> Option<FailedPipeline> {
|
||||
self.settle_end();
|
||||
self.settle_ended();
|
||||
self.state().failed_pipeline.clone()
|
||||
}
|
||||
|
||||
@@ -3665,7 +3715,7 @@ impl CommandBuffer {
|
||||
/// `dispatches_dropped_still_making`. No Metal counterpart: Metal makes a state's pipelines as
|
||||
/// it makes the state.
|
||||
pub fn dropped_draw(&self) -> Option<FailedPipeline> {
|
||||
self.settle_end();
|
||||
self.settle_ended();
|
||||
self.state().dropped_draw.clone()
|
||||
}
|
||||
|
||||
@@ -3809,7 +3859,7 @@ impl CommandBuffer {
|
||||
/// encoders build no record otherwise.
|
||||
#[doc(hidden)]
|
||||
pub fn executions(&self) -> Vec<Execution> {
|
||||
self.settle_end();
|
||||
self.settle_ended();
|
||||
self.state().executions.clone()
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,9 @@
|
||||
//! lock of its program's (`GraphicsState::settle_shape`, whose answer is a function of the
|
||||
//! shape and forms alone). Only a draw that recorded keeps it, so its encoder holds its pipeline
|
||||
//! state (and the command buffer the variant's objects); it goes as the encoder ends
|
||||
//! ([`SpareLiveBinds::give`]), so a spare state holds nothing alive.
|
||||
//! ([`SpareLiveBinds::give`]), so a spare state holds nothing alive, but where the encoder
|
||||
//! carries its kept draw into its command buffer's next render encoder, which takes the state
|
||||
//! with its settle (`render/carried.rs`, [`LiveBind::end_carried`]).
|
||||
//! - **Kept from one encoder to the next.** An encoder that ends gives its state, with its shape,
|
||||
//! to its device ([`SpareLiveBinds`]), and the next render encoder opened starts from it, as a
|
||||
//! draw starts from the draw before it: its first draw brings it in place, so a pass that binds
|
||||
@@ -546,6 +548,14 @@ impl LiveBind {
|
||||
/// kept go with the encoder (the module docs), so the next encoder may start from it.
|
||||
pub(super) fn end_encoder(&mut self) {
|
||||
self.end_chunk();
|
||||
self.end_carried();
|
||||
}
|
||||
|
||||
/// Its encoder ended, carrying its kept draw into its command buffer's next render encoder
|
||||
/// (`render/carried.rs`): as [`end_encoder`](Self::end_encoder), but what its draws settled
|
||||
/// stays, which the command buffer holds the variants' objects of. The shadows' copies listed
|
||||
/// and the heap parts kept go: they are its residency's, which is the encoder's.
|
||||
pub(super) fn end_carried(&mut self) {
|
||||
self.shadows.let_go();
|
||||
self.heap.let_go();
|
||||
}
|
||||
|
||||
@@ -399,6 +399,7 @@ mod arguments;
|
||||
mod attached_levels;
|
||||
mod bound;
|
||||
mod call_checks;
|
||||
mod carried;
|
||||
mod color_groups;
|
||||
pub(crate) mod coverage;
|
||||
mod deferral;
|
||||
@@ -440,6 +441,7 @@ mod vertex_strides;
|
||||
#[cfg(all(test, debug_assertions, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
pub(crate) use bound::dynamic_compares;
|
||||
use bound::{Bound, EqualShapes, Now, Recorded};
|
||||
pub(crate) use carried::Carried;
|
||||
pub(crate) use deferral::{lowering, DeferredEncoders, EndInFlight};
|
||||
use deferral::{Logged, OwnLowering};
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
@@ -1951,10 +1953,12 @@ impl Lowering {
|
||||
lowering
|
||||
}
|
||||
|
||||
/// The lowering of [`RenderCommandEncoder::end_encoding`] (`RenderLowering::end_encoding`).
|
||||
/// The lowering of [`RenderCommandEncoder::end_encoding`] (`RenderLowering::end_encoding`),
|
||||
/// its kept draw carried into its command buffer's next render encoder where it carries
|
||||
/// (`render/carried.rs`).
|
||||
pub(crate) fn end_encoding(self) -> Result<(), Error> {
|
||||
let _for = self.core.notices_for();
|
||||
self.ending().end_encoding()
|
||||
self.ending_carried().end_encoding()
|
||||
}
|
||||
|
||||
/// `RenderLowering::finish_replay`, its bind state given back first.
|
||||
@@ -1978,11 +1982,13 @@ impl CommandBuffer {
|
||||
descriptor: &RenderPassDescriptor,
|
||||
) -> Result<RenderCommandEncoder, Error> {
|
||||
let _for = self.notices_for();
|
||||
// The last render encoder's end, where its call left it to the device's lowering thread.
|
||||
self.settle_end();
|
||||
// The last render encoder's end, where its call left it to the device's lowering thread,
|
||||
// and the kept draw it carried (`render/carried.rs`), which nothing came between.
|
||||
self.settle_ended();
|
||||
let carried = self.take_carried();
|
||||
// Metal's process ends here under some protection options (`command_buffer/protection.rs`).
|
||||
self.refuse_protected_encoder("render_command_encoder")?;
|
||||
self.open_render(descriptor, None, None)
|
||||
self.open_render(descriptor, None, None, carried)
|
||||
.map(RenderCommandEncoder::new)
|
||||
}
|
||||
|
||||
@@ -1999,6 +2005,7 @@ impl CommandBuffer {
|
||||
given: &RenderPassDescriptor,
|
||||
again: Option<Residency>,
|
||||
screen: Option<[u32; 2]>,
|
||||
carried: Option<Box<carried::Carried>>,
|
||||
) -> Result<Lowering, Error> {
|
||||
const CALL: &str = "render_command_encoder";
|
||||
let device = self.device();
|
||||
@@ -2113,7 +2120,7 @@ impl CommandBuffer {
|
||||
log,
|
||||
grouped,
|
||||
);
|
||||
Ok(RenderLowering::assemble(core, draws, opening))
|
||||
Ok(RenderLowering::assemble(core, draws, opening, carried))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2177,8 +2184,17 @@ impl RenderLowering {
|
||||
/// An encoder over `core` of the pass `opening` describes, its first instance's draws
|
||||
/// recording into `draws` (null where it records inline), made in its box: the box is
|
||||
/// allocated first and the lowering written into it, where `Box::new` of a lowering makes it
|
||||
/// on the stack and copies its thousands of bytes in.
|
||||
fn assemble(core: Box<EncoderCore>, draws: vk::CommandBuffer, opening: Opening) -> Lowering {
|
||||
/// on the stack and copies its thousands of bytes in. It starts from `carried`, the kept draw
|
||||
/// its command buffer's last render encoder carried, where that fits its pass
|
||||
/// (`render/carried.rs`).
|
||||
fn assemble(
|
||||
core: Box<EncoderCore>,
|
||||
draws: vk::CommandBuffer,
|
||||
opening: Opening,
|
||||
carried: Option<Box<carried::Carried>>,
|
||||
) -> Lowering {
|
||||
let samplers = core.generation().sampler_slots_changed();
|
||||
let carried = carried::fitting(carried, &opening, (core.device(), samplers));
|
||||
let Opening {
|
||||
layout,
|
||||
render_target_array_length,
|
||||
@@ -2193,8 +2209,12 @@ impl RenderLowering {
|
||||
grouped,
|
||||
} = opening;
|
||||
let rerecord = extended.keeps_draws();
|
||||
// The bind state the device's last ended render encoder left (`live_bind.rs`).
|
||||
let live = core.device().shared().live_binds.take();
|
||||
// The bind state the device's last ended render encoder left (`live_bind.rs`), where it
|
||||
// starts from no carried one.
|
||||
let start = match carried {
|
||||
Some(carried) => carried::Start::Carried(carried),
|
||||
None => carried::Start::Spare(core.device().shared().live_binds.take()),
|
||||
};
|
||||
// The views and sampler descriptions its binds made or found (`binding::BindMemo`).
|
||||
let bind_memo = core.device().shared().bind_memos.take();
|
||||
// What its draws gather into, with the room an ended encoder's left
|
||||
@@ -2327,7 +2347,7 @@ impl RenderLowering {
|
||||
pins_frozen: false,
|
||||
},
|
||||
);
|
||||
Lowering { lowering, live }
|
||||
Lowering::starting_from(lowering, start)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4251,7 +4271,7 @@ impl RenderLowering {
|
||||
residency: Residency,
|
||||
screen: Option<[u32; 2]>,
|
||||
) -> Result<Lowering, Error> {
|
||||
command_buffer.open_render(descriptor, Some(residency), screen)
|
||||
command_buffer.open_render(descriptor, Some(residency), screen, None)
|
||||
}
|
||||
|
||||
/// Refuse `call` as its lowering refused it, after it returned, for `error`
|
||||
@@ -10949,6 +10969,7 @@ impl RenderLowering {
|
||||
stamps: self.table_stamps(),
|
||||
rebinds,
|
||||
settled: through_record,
|
||||
carried: false,
|
||||
};
|
||||
self.again.keep(kept);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,220 @@
|
||||
//! A render encoder's kept draw carried into the next render encoder of its command buffer
|
||||
//! (`WorkCounts::kept_draws_carried`): that encoder starts from the ended encoder's bind state, its
|
||||
//! settle and its kept draw (`render/draw_again.rs`), so that its first draw of the same pipeline
|
||||
//! state is rebound (`render/draw_again/rebound.rs`, `WorkCounts::draws_rebound_carried`) instead
|
||||
//! of taking every step.
|
||||
//!
|
||||
//! - **What carries.** Where an encoder ends with a kept draw that rebinds (`Kept::rebinds`),
|
||||
//! recorded into its pass's first instance (no split, no executed commands or tile dispatches,
|
||||
//! no stand-in, shadow or reformat of its own, the instance's views the default) through a bind
|
||||
//! state whose settle it holds (`LiveBind::settled`), that read no texture an attachment of its
|
||||
//! pass renders, in a pass of no color groups, rasterization-rate map or replay, its command
|
||||
//! buffer holds the bind state, with the settle, and the kept draw ([`Carried`]) in place of
|
||||
//! giving the state to its device's spares (`live_bind::SpareLiveBinds`). The shadows' copies it
|
||||
//! listed and the heap parts it kept go as they go at any end (`LiveBind::end_carried`): they
|
||||
//! are the residency's, which is the encoder's. The settle holds its variant's objects, which
|
||||
//! the command buffer holds already, so the carry keeps nothing alive past the command buffer.
|
||||
//! - **Let go.** Any call of the command buffer that settles its last render encoder's end
|
||||
//! (`CommandBuffer::settle_end`: another encoder's opening, an event, a semaphore, the commit)
|
||||
//! lets it go to the device's spares, counted where it comes between
|
||||
//! (`WorkCounts::kept_draws_carry_dropped_between`): only the opening of a render encoder takes
|
||||
//! it. That encoder takes it ([`carried_fits`]) where its pass is the ended one's in everything
|
||||
//! the kept draw's settle and recording read: the same [`PassShape`] (formats, samples,
|
||||
//! resolves, input attachments, view mask) and layers, no memoryless color, visibility buffer,
|
||||
//! custom sample positions, extended-range color, rasterization-rate map, color groups or
|
||||
//! encoding of an ended encoder again (`kept_draws_carry_dropped_layout`); and where what the
|
||||
//! kept draw read that changes with no call is as it was: no no-copy buffer moved, the device's
|
||||
//! sampler IDs' slots as they were, and its residency of the generation the ended encoder's
|
||||
//! had (`kept_draws_carry_dropped_under`). Else it lets it go, counted, and starts from a
|
||||
//! spare, as any encoder.
|
||||
//! - **Taken.** The encoder starts from the carried bind state, and keeps the carried draw under
|
||||
//! its own epoch ([`Kept::carried`]): after draws of no other state (`Kept::between`), recorded
|
||||
//! through no record (`Kept::settled`), under a render state of another stamp (`Kept::stated`),
|
||||
//! so its first draw of it derives again what the encoder's render state decides
|
||||
//! (`restated.rs`) and records every state command it sets into the encoder's command buffer,
|
||||
//! which holds none. Its tables' stamps are the encoder's tables' first ones: a new encoder
|
||||
//! inherits no binding, so its first draw brings in every slot its calls bound since the
|
||||
//! opening (`argument_table::Changes`), and its rebind stops where the bind state holds a slot
|
||||
//! bound that none of them bound (`WorkCounts::draws_carry_stopped_stale`): the state is the
|
||||
//! ended encoder's there, not this one's. Its uses are made again whole, and it stops where it
|
||||
//! samples a texture an attachment of its pass renders (`draws_carry_stopped_attached`). It
|
||||
//! begins its pass's first instance as every step's first draw begins it
|
||||
//! (`render/inline_first.rs`). What it compares at a draw again is the encoder's: the command
|
||||
//! buffer its instance records into, and what it read that changes with no call (`Under`), as
|
||||
//! of the opening.
|
||||
//! - **Checked in builds with debug assertions.** As a draw rebound is: the first carried draw of a
|
||||
//! command buffer's encoders and every second one after it takes every step instead, which must
|
||||
//! keep the same draw, with the same commands, writes, offsets, push bytes, vertex buffers, uses
|
||||
//! and draw state; the count of carried draws carries with the draw (`DrawAgain::carries`).
|
||||
|
||||
use super::draw_again::Kept;
|
||||
use super::{Lowering, Opening, RenderLowering, ViewSetup};
|
||||
use crate::device::Device;
|
||||
use crate::live_bind::LiveBind;
|
||||
use crate::render_target::PassShape;
|
||||
use crate::work_counts::CarryDropped;
|
||||
|
||||
/// A render encoder's bind state, its settle and its kept draw, carried by its command buffer for
|
||||
/// the next render encoder of it (the module docs).
|
||||
pub(crate) struct Carried {
|
||||
live: Box<LiveBind>,
|
||||
kept: Kept,
|
||||
/// The ended encoder's pass's shape and layers, and its residency's generation.
|
||||
shape: PassShape,
|
||||
layers: u32,
|
||||
residency: u64,
|
||||
/// The kept draws carried in since the command buffer's first render encoder
|
||||
/// (`DrawAgain::carries`).
|
||||
#[cfg(debug_assertions)]
|
||||
carries: u64,
|
||||
}
|
||||
|
||||
impl Carried {
|
||||
/// Let it go: its bind state to `device`'s spares, as any ended encoder's.
|
||||
pub(crate) fn let_go(self: Box<Self>, device: &Device) {
|
||||
device.shared().live_binds.give(self.live);
|
||||
}
|
||||
}
|
||||
|
||||
/// What a render encoder starts from: the bind state and kept draw its command buffer's last
|
||||
/// render encoder carried, where it fits the encoder's pass ([`fitting`]), else the bind state of
|
||||
/// its device's last ended render encoder (`live_bind::SpareLiveBinds`).
|
||||
pub(super) enum Start {
|
||||
Carried(Box<Carried>),
|
||||
Spare(Box<LiveBind>),
|
||||
}
|
||||
|
||||
/// Whether `carried` fits the render encoder `opening` opens, its device's sampler IDs' slots
|
||||
/// changed `samplers` times (the module docs); else why it is let go.
|
||||
fn carried_fits(carried: &Carried, opening: &Opening, samplers: u64) -> Result<(), CarryDropped> {
|
||||
let layout = &opening.layout;
|
||||
let colors = layout.colors.iter().flatten();
|
||||
let same_pass = opening.shape == carried.shape
|
||||
&& layout.layers == carried.layers
|
||||
&& opening.rate_map.is_none()
|
||||
&& opening.grouped.is_none()
|
||||
&& layout.visibility.is_none()
|
||||
&& layout.sample_positions.is_empty()
|
||||
&& !opening.extended.any()
|
||||
&& colors.clone().all(|color| !color.memoryless);
|
||||
if !same_pass {
|
||||
return Err(CarryDropped::Layout);
|
||||
}
|
||||
let moved = crate::buffer::host_cells_moved();
|
||||
if !carried
|
||||
.kept
|
||||
.carried_under(moved, opening.residency.generation(), samplers)
|
||||
|| carried.residency != opening.residency.generation()
|
||||
{
|
||||
return Err(CarryDropped::Under);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
impl RenderLowering {
|
||||
/// The kept draw this encoder, ending with its bind state `live`, carries into its command
|
||||
/// buffer's next render encoder, taken from it where it does (the module docs).
|
||||
fn carried_out(&mut self, live: &LiveBind) -> Option<Kept> {
|
||||
let kept = self.again_kept()?;
|
||||
let carries = kept.rebinds
|
||||
&& kept.through_copies == (false, false)
|
||||
&& kept.narrowed.is_empty()
|
||||
&& live.settled.is_some()
|
||||
&& self.earlier.is_empty()
|
||||
&& self.grouped.is_none()
|
||||
&& self.rate_map.is_none()
|
||||
&& !self.replaying
|
||||
&& !self.rerouting
|
||||
&& self.executions.is_empty()
|
||||
&& self.pending.is_empty()
|
||||
&& self.dispatches.is_empty()
|
||||
&& !self.dispatched
|
||||
&& self.shadow.is_none()
|
||||
&& self.depth_stand_in.is_none()
|
||||
&& self.imageblock.is_none()
|
||||
&& !self.tile_imageblock
|
||||
&& !self.visibility.active()
|
||||
&& self.current.pieces.is_empty()
|
||||
&& self.current.reformats.is_empty()
|
||||
&& self.current.views == ViewSetup::default()
|
||||
&& !self.current.shadow
|
||||
&& !self.current.shader_tests
|
||||
&& self.current.shape.storage.is_empty();
|
||||
carries.then(|| self.take_kept()).flatten()
|
||||
}
|
||||
|
||||
/// Start from `kept`, the kept draw the command buffer's last render encoder carried, of
|
||||
/// `carries` kept draws carried in before it (the module docs).
|
||||
fn carried_in(&mut self, kept: Kept, #[cfg(debug_assertions)] carries: u64) {
|
||||
let (stamps, under, draws) = (self.table_stamps(), self.under(), self.current.draws);
|
||||
let epoch = self.again_epoch();
|
||||
self.keep_carried(kept.carried_into(epoch, stamps, under, draws));
|
||||
#[cfg(debug_assertions)]
|
||||
self.set_carries(carries);
|
||||
self.core.device().shared().counts.kept_draw_carried();
|
||||
}
|
||||
}
|
||||
|
||||
impl Lowering {
|
||||
/// The lowering at [`RenderCommandEncoder::end_encoding`](super::RenderCommandEncoder), its
|
||||
/// bind state and kept draw carried into its command buffer's next render encoder where they
|
||||
/// carry (the module docs), else its bind state given to its device, as at every end.
|
||||
pub(super) fn ending_carried(self) -> Box<RenderLowering> {
|
||||
let Lowering {
|
||||
mut lowering,
|
||||
mut live,
|
||||
} = self;
|
||||
let Some(kept) = lowering.carried_out(&live) else {
|
||||
lowering.core.device().shared().live_binds.give(live);
|
||||
return lowering;
|
||||
};
|
||||
live.end_carried();
|
||||
let carried = Box::new(Carried {
|
||||
live,
|
||||
kept,
|
||||
shape: (*lowering.current.shape).clone(),
|
||||
layers: lowering.layout.layers,
|
||||
residency: lowering.residency.generation(),
|
||||
#[cfg(debug_assertions)]
|
||||
carries: lowering.carries(),
|
||||
});
|
||||
let command_buffer = lowering.core.command_buffer();
|
||||
command_buffer.carry(carried);
|
||||
lowering
|
||||
}
|
||||
|
||||
/// The lowering of an encoder, `lowering`, starting from `start` (the module docs): a
|
||||
/// carried bind state, and its kept draw, or a spare one.
|
||||
pub(super) fn starting_from(mut lowering: Box<RenderLowering>, start: Start) -> Lowering {
|
||||
let carried = match start {
|
||||
Start::Carried(carried) => *carried,
|
||||
Start::Spare(live) => return Lowering { lowering, live },
|
||||
};
|
||||
#[cfg(debug_assertions)]
|
||||
lowering.carried_in(carried.kept, carried.carries);
|
||||
#[cfg(not(debug_assertions))]
|
||||
lowering.carried_in(carried.kept);
|
||||
Lowering {
|
||||
lowering,
|
||||
live: carried.live,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// `carried` where it fits the encoder `opening` opens (`carried_fits`), its device's sampler
|
||||
/// IDs' slots changed `samplers` times, else `None`, let go to `device` and counted.
|
||||
pub(super) fn fitting(
|
||||
carried: Option<Box<Carried>>,
|
||||
opening: &Opening,
|
||||
(device, samplers): (&Device, u64),
|
||||
) -> Option<Box<Carried>> {
|
||||
let carried = carried?;
|
||||
match carried_fits(&carried, opening, samplers) {
|
||||
Ok(()) => Some(carried),
|
||||
Err(why) => {
|
||||
device.shared().counts.kept_draw_carry_dropped(why);
|
||||
carried.let_go(device);
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -77,6 +77,12 @@
|
||||
//! state decides of it (`restated.rs`). It is then rebound (`rebound.rs`), recording its new
|
||||
//! draw state's dynamic states against what its record holds, where what it derived leaves
|
||||
//! its pipeline, plan, shape and push bytes the kept draw's; else it takes every step.
|
||||
//! - **Carried to the next encoder.** An encoder that ends with a kept draw of its pass's first
|
||||
//! instance carries it, with its bind state and settle, into its command buffer's next render
|
||||
//! encoder where nothing comes between and that encoder's pass is its pass's like
|
||||
//! (`render/carried.rs`): the draw is kept there as one after draws of other states, recorded
|
||||
//! through no record, under another render state ([`Kept::carried`]), so its first draw there
|
||||
//! is rebound (`rebound.rs`), bringing in every slot that encoder's calls bound.
|
||||
//! - **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
|
||||
@@ -143,6 +149,11 @@ pub(super) struct DrawAgain {
|
||||
/// second one after it take every step instead (the module docs).
|
||||
#[cfg(debug_assertions)]
|
||||
hits: u64,
|
||||
/// Kept draws carried in and rebound since the command buffer's first render encoder: in
|
||||
/// builds with debug assertions, the first and every second one after it take every step
|
||||
/// instead (`render/carried.rs`).
|
||||
#[cfg(debug_assertions)]
|
||||
carries: u64,
|
||||
}
|
||||
|
||||
/// What a kept draw was, what it read, and what a draw again repeats of it (the module docs).
|
||||
@@ -205,6 +216,45 @@ pub(crate) struct Kept {
|
||||
/// this, the record holds the pipeline and dynamic states it set, which a draw rebound then
|
||||
/// compares with none. `None` where it recorded through none.
|
||||
pub(super) settled: Option<u64>,
|
||||
/// Whether its command buffer's last render encoder carried it into this one, which has not
|
||||
/// drawn it since (`render/carried.rs`): its tables' stamps are the encoder's tables' first
|
||||
/// ones, and its next draw is rebound as a carried draw is.
|
||||
pub(super) carried: bool,
|
||||
}
|
||||
|
||||
impl Kept {
|
||||
/// This draw, carried 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`).
|
||||
pub(super) fn carried_into(
|
||||
self,
|
||||
epoch: Stamp,
|
||||
stamps: [Stamp; 4],
|
||||
under: Under,
|
||||
draws: vk::CommandBuffer,
|
||||
) -> Kept {
|
||||
Kept {
|
||||
epoch,
|
||||
// A stamp no render state had: its first draw derives again what the encoder's
|
||||
// render state decides (`restated.rs`).
|
||||
stated: Stamp::fresh(),
|
||||
between: true,
|
||||
stamps,
|
||||
under,
|
||||
command_buffer: draws,
|
||||
settled: None,
|
||||
carried: true,
|
||||
..self
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether what the draw read that changes with no call is as it was, but what it was noted
|
||||
/// into: `moved` no-copy buffers' moves, a residency of `residency`'s generation, and the
|
||||
/// device's sampler IDs' slots changed `samplers` times (`render/carried.rs`).
|
||||
pub(super) fn carried_under(&self, moved: u64, residency: u64, samplers: u64) -> bool {
|
||||
let under = &self.under;
|
||||
(under.moved, under.residency, under.samplers) == (moved, residency, samplers)
|
||||
}
|
||||
}
|
||||
|
||||
/// An index source as a kept draw read it in place: the Metal buffer, by key, and offset, and
|
||||
@@ -388,6 +438,32 @@ impl RenderLowering {
|
||||
self.again.kept = None;
|
||||
}
|
||||
|
||||
/// The last direct draw's kept draw, taken: an ended encoder's, carried into its command
|
||||
/// buffer's next render encoder (`render/carried.rs`).
|
||||
pub(super) fn take_kept(&mut self) -> Option<Kept> {
|
||||
self.again.kept.take()
|
||||
}
|
||||
|
||||
/// Keep `kept`, a draw carried in from the command buffer's last render encoder
|
||||
/// (`render/carried.rs`), as the last direct draw's.
|
||||
pub(super) fn keep_carried(&mut self, kept: Kept) {
|
||||
self.again.kept = Some(kept);
|
||||
}
|
||||
|
||||
/// The kept draws carried in since the command buffer's first render encoder
|
||||
/// ([`DrawAgain`]), which a carried draw carries on (`render/carried.rs`).
|
||||
#[cfg(debug_assertions)]
|
||||
pub(super) fn carries(&self) -> u64 {
|
||||
self.again.carries
|
||||
}
|
||||
|
||||
/// Take `carries` kept draws carried in since the command buffer's first render encoder: a
|
||||
/// carried draw's.
|
||||
#[cfg(debug_assertions)]
|
||||
pub(super) fn set_carries(&mut self, carries: u64) {
|
||||
self.again.carries = carries;
|
||||
}
|
||||
|
||||
/// Bring in the kept draw of the pipeline state the encoder draws through, where its last draw
|
||||
/// drew through another: the last draw's kept draw set aside with the bind state `live` holds
|
||||
/// for that state, and the bind state of this one selected (`LiveBind::select`), with the
|
||||
@@ -824,6 +900,9 @@ impl Checked {
|
||||
again.between,
|
||||
again.stated,
|
||||
);
|
||||
// A carried draw's every step began the pass's first instance, which its kept draw named
|
||||
// before any did, and keeps a draw carried no more (`render/carried.rs`).
|
||||
let (command_buffer, carried) = (again.command_buffer, again.carried);
|
||||
assert!(
|
||||
draw_alone || rebound,
|
||||
"a draw again recorded a state command"
|
||||
@@ -838,9 +917,13 @@ impl Checked {
|
||||
// (`Kept::stated`).
|
||||
(again.draw_alone, again.stamps, again.under) = (kept.draw_alone, kept.stamps, kept.under);
|
||||
(again.settled, again.between, again.stated) = (kept.settled, kept.between, kept.stated);
|
||||
if kept.carried {
|
||||
(again.command_buffer, again.carried) = (kept.command_buffer, kept.carried);
|
||||
}
|
||||
assert!(*again == kept, "a draw again kept another draw");
|
||||
(again.draw_alone, again.stamps, again.under) = (draw_alone, stamps, under);
|
||||
(again.settled, again.between, again.stated) = (settled, between, stated);
|
||||
(again.command_buffer, again.carried) = (command_buffer, carried);
|
||||
encoder.again.hits = hits;
|
||||
}
|
||||
}
|
||||
@@ -125,11 +125,12 @@ use crate::error::Error;
|
||||
use crate::live_bind::{LiveBind, Reshape};
|
||||
use crate::pipeline::{RenderStateKind, Settled};
|
||||
use crate::render::{line_width, Assembly, Bound, DrawBuffers, DrawState, Recording};
|
||||
use crate::render_target::Feedback;
|
||||
use crate::resource::ResourceKey;
|
||||
use crate::shadow::{ShadowUse, UsedAs};
|
||||
use crate::texture::Texture;
|
||||
use crate::tracker::Use;
|
||||
use crate::work_counts::ArgumentsStop;
|
||||
use crate::work_counts::{ArgumentsStop, CarryStop};
|
||||
|
||||
/// The most slots a draw rebound takes changed: a draw after more takes every step.
|
||||
const SLOTS: usize = 8;
|
||||
@@ -336,29 +337,40 @@ impl RenderLowering {
|
||||
) -> Again {
|
||||
// A notice met at each occurrence forgets the draw once recorded, as its every step does.
|
||||
let watch = crate::degradation::EachWatch::start();
|
||||
// A draw of other arguments whose rebind stops is counted by where.
|
||||
let stopped = |encoder: &Self, why| {
|
||||
// Carried in from the command buffer's last render encoder (`render/carried.rs`).
|
||||
let carried = (self.again.kept.as_ref()).is_some_and(|kept| kept.carried);
|
||||
// A draw of other arguments, or a carried one, whose rebind stops is counted by where.
|
||||
let stopped = |encoder: &Self, (why, carry): (ArgumentsStop, CarryStop)| {
|
||||
if reargued {
|
||||
encoder.core.counts().draw_rebind_stopped_arguments(why);
|
||||
}
|
||||
if carried {
|
||||
encoder.core.counts().draw_carry_stopped(carry);
|
||||
}
|
||||
encoder.rebind_stopped()
|
||||
};
|
||||
let other = (ArgumentsStop::Other, CarryStop::Other);
|
||||
// Of other arguments, routed as the kept draw.
|
||||
if reargued && !self.routed_as_kept(assembly, draw) {
|
||||
return stopped(self, ArgumentsStop::Route);
|
||||
return stopped(self, (ArgumentsStop::Route, CarryStop::Other));
|
||||
}
|
||||
// After a call set the encoder's render state, what it decides derived again
|
||||
// (`restated.rs`).
|
||||
let restated =
|
||||
(self.again.kept.as_ref()).is_some_and(|kept| kept.stated != self.again.stated);
|
||||
if restated && !self.restate_kept(live, call, assembly, draw) {
|
||||
return stopped(self, ArgumentsStop::Other);
|
||||
return stopped(self, other);
|
||||
}
|
||||
let Some(changed) = self.bring_in(live, stamps) else {
|
||||
return stopped(self, ArgumentsStop::Other);
|
||||
// A carried draw: every slot its bind state holds bound, the encoder's calls bound
|
||||
// (`render/carried.rs`).
|
||||
if carried && self.carried_stale(live) {
|
||||
return stopped(self, (ArgumentsStop::Other, CarryStop::Stale));
|
||||
}
|
||||
let Some(changed) = self.bring_in(live, stamps, carried) else {
|
||||
return stopped(self, other);
|
||||
};
|
||||
let mut stop = ArgumentsStop::Other;
|
||||
let drawn = (draw, buffers, reargued);
|
||||
let mut stop = other;
|
||||
let drawn = (draw, buffers, (reargued, carried));
|
||||
let Some(rebinding) = self.rebind(call, live, &changed, drawn, &mut stop) else {
|
||||
return stopped(self, stop);
|
||||
};
|
||||
@@ -367,8 +379,14 @@ impl RenderLowering {
|
||||
}
|
||||
#[cfg(debug_assertions)]
|
||||
{
|
||||
let hits = self.again.hits;
|
||||
self.again.hits += 1;
|
||||
// The first and every second draw rebound since the draw was kept, or carried in since
|
||||
// the command buffer's first render encoder (`render/carried.rs`), takes every step.
|
||||
let count = match carried {
|
||||
true => &mut self.again.carries,
|
||||
false => &mut self.again.hits,
|
||||
};
|
||||
let hits = *count;
|
||||
*count += 1;
|
||||
if hits.is_multiple_of(2) {
|
||||
let rebound = super::Expected::Rebound(super::Rebound::of(live));
|
||||
*checked = Some(super::Checked::of(self, rebound));
|
||||
@@ -398,6 +416,12 @@ impl RenderLowering {
|
||||
if let Err(refused) = attached {
|
||||
return Again::Refused(refused);
|
||||
}
|
||||
// A carried draw begins its pass's first instance (`render/carried.rs`).
|
||||
if carried {
|
||||
if let Err(refused) = self.begin_carried() {
|
||||
return Again::Refused(refused);
|
||||
}
|
||||
}
|
||||
let counted = (stamps, changed.images());
|
||||
let recorded =
|
||||
self.record_rebound(live, (call, assembly, draw), buffers, (counted, rebinding));
|
||||
@@ -420,6 +444,76 @@ impl RenderLowering {
|
||||
Again::Drawn
|
||||
}
|
||||
|
||||
/// Whether the bind state `live` holds a slot bound that no call of the encoder bound since
|
||||
/// its opening: of the kept draw carried into it, whose tables' stamps are the encoder's
|
||||
/// tables' first ones (`render/carried.rs`). A new encoder inherits no binding, so such a slot
|
||||
/// is stale; and a threadgroup memory length or an acceleration structure, which no stage
|
||||
/// table's change lists, is told stale too. A table whose changes since its opening it no
|
||||
/// longer lists is not told here: [`bring_in`](Self::bring_in) stops at it.
|
||||
fn carried_stale(&self, live: &LiveBind) -> bool {
|
||||
let Some(kept) = self.again.kept.as_ref() else {
|
||||
return true;
|
||||
};
|
||||
let tables = [&self.vertex, &self.fragment, &self.object, &self.mesh];
|
||||
let stages = [Stage::Vertex, Stage::Fragment, Stage::Object, Stage::Mesh];
|
||||
for (at, (stage, table)) in stages.into_iter().zip(tables).enumerate() {
|
||||
let Some(state) = live.state.stages.get(&stage) else {
|
||||
continue;
|
||||
};
|
||||
if !state.threadgroup_lengths.is_empty() || !state.acceleration_structures.is_empty() {
|
||||
return true;
|
||||
}
|
||||
let mut bound = (state
|
||||
.buffers
|
||||
.keys()
|
||||
.map(|&index| (SlotClass::Buffer, index)))
|
||||
.chain(
|
||||
state
|
||||
.textures
|
||||
.keys()
|
||||
.map(|&index| (SlotClass::Texture, index)),
|
||||
)
|
||||
.chain(
|
||||
state
|
||||
.samplers
|
||||
.keys()
|
||||
.map(|&index| (SlotClass::Sampler, index)),
|
||||
);
|
||||
// A table no call changed binds nothing.
|
||||
let opened = kept.stamps[at];
|
||||
if table.stamp() == opened {
|
||||
if bound.next().is_some() {
|
||||
return true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
let Some(since) = table.changed_since(opened) else {
|
||||
continue;
|
||||
};
|
||||
let stale = bound.any(|slot| {
|
||||
let mut changed = since.clone();
|
||||
!changed.any(|(class, index, _)| (class, index) == slot)
|
||||
});
|
||||
if stale {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
/// Begin the pass's first instance for the kept draw carried into the encoder, as every
|
||||
/// step's first draw that records begins it (`render/inline_first.rs`): inline where the pass
|
||||
/// opened so and its instance allows it, else its secondary. Refused only where an object
|
||||
/// cannot be made, as every step's is.
|
||||
fn begin_carried(&mut self) -> Result<(), Error> {
|
||||
let next = super::super::Next::Current;
|
||||
let begin = self.inline_begin(&next, None, (true, true, false), Feedback::NONE)?;
|
||||
if let Some(begin) = begin {
|
||||
self.begin_inline(begin);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Whether `draw` of `assembly`, of other arguments than the kept draw's alone, is routed as
|
||||
/// the kept draw: a draw's route (`RenderLowering::routed_draw`) reads its arguments only
|
||||
/// through whether it may draw a primitive (`line_width::draws_primitives`, and the provoking
|
||||
@@ -452,8 +546,11 @@ impl RenderLowering {
|
||||
/// stamp is no longer the kept draw's, each table so read counted read in part
|
||||
/// (`WorkCounts::stage_tables_read_in_part`): the changed slots; `None` where one is not a
|
||||
/// buffer, texture or sampler slot, a table keeps no list of them, or the shape changed (then
|
||||
/// the kept state makes its shape again, as any draw's does).
|
||||
fn bring_in(&self, live: &mut LiveBind, stamps: [Stamp; 4]) -> Option<Changed> {
|
||||
/// the kept state makes its shape again, as any draw's does). A `carried` draw's stamps are
|
||||
/// its encoder's tables' first ones, under which its state holds the slots the calls since
|
||||
/// bound, each a slot of the state ([`carried_stale`](Self::carried_stale)), whatever
|
||||
/// table the state was read from.
|
||||
fn bring_in(&self, live: &mut LiveBind, stamps: [Stamp; 4], carried: bool) -> Option<Changed> {
|
||||
let RenderStateKind::Graphics(pipeline) = self.pipeline.as_ref()?.kind() else {
|
||||
return None;
|
||||
};
|
||||
@@ -478,7 +575,7 @@ impl RenderLowering {
|
||||
continue;
|
||||
}
|
||||
let state = live.state.stages.get(&stage)?;
|
||||
let read = live.read_from.read_under(at) == Some(under);
|
||||
let read = carried || live.read_from.read_under(at) == Some(under);
|
||||
if !read || !views.holds(stage, state.at_bind_views) {
|
||||
return None;
|
||||
}
|
||||
@@ -563,8 +660,8 @@ impl RenderLowering {
|
||||
call: &'static str,
|
||||
live: &mut LiveBind,
|
||||
changed: &Changed,
|
||||
(draw, buffers, reargued): (&DrawCall, &DrawBuffers<'_>, bool),
|
||||
stop: &mut ArgumentsStop,
|
||||
(draw, buffers, (reargued, carried)): (&DrawCall, &DrawBuffers<'_>, (bool, bool)),
|
||||
stop: &mut (ArgumentsStop, CarryStop),
|
||||
) -> Option<Rebinding> {
|
||||
let slots = changed.list();
|
||||
let kept = settles_kept(self, live)
|
||||
@@ -594,7 +691,7 @@ impl RenderLowering {
|
||||
None => Ok(false),
|
||||
};
|
||||
if rebound != Ok(true) {
|
||||
*stop = ArgumentsStop::Tables;
|
||||
stop.0 = ArgumentsStop::Tables;
|
||||
return None;
|
||||
}
|
||||
// A draw of other arguments: what they decide of its commands, its Vulkan draw, push
|
||||
@@ -608,7 +705,7 @@ impl RenderLowering {
|
||||
Ok(true) => {}
|
||||
Ok(false) => {
|
||||
if !plan.vertex_buffers.is_empty() {
|
||||
*stop = ArgumentsStop::FetchWindow;
|
||||
stop.0 = ArgumentsStop::FetchWindow;
|
||||
}
|
||||
return None;
|
||||
}
|
||||
@@ -634,7 +731,7 @@ impl RenderLowering {
|
||||
);
|
||||
let reached = (self.check_vertex_reach(&compiled.vertex_input.pulled, draw)).is_ok();
|
||||
if !reached {
|
||||
*stop = ArgumentsStop::Reach;
|
||||
stop.0 = ArgumentsStop::Reach;
|
||||
}
|
||||
let checked = reached && (moved || tables_checked());
|
||||
// The pass's fragment writes, a copy of which a stage before the fragments may read
|
||||
@@ -653,6 +750,11 @@ impl RenderLowering {
|
||||
if attached && self.loads_ordered && self.samples_attachment(facts, Texture::cleared_in) {
|
||||
return None;
|
||||
}
|
||||
// A carried draw reads no texture its pass's attachments render (`render/carried.rs`).
|
||||
if attached && carried {
|
||||
stop.1 = CarryStop::Attached;
|
||||
return None;
|
||||
}
|
||||
let images = changed.images();
|
||||
if images && (self.storage_colors(facts) != 0 || !live.state.extended_shadows.is_empty()) {
|
||||
return None;
|
||||
@@ -695,10 +797,11 @@ impl RenderLowering {
|
||||
let writes_kept = moved && commands.descriptor_ranges == live.kept.ranges;
|
||||
// Its uses: where only buffer slots changed, the kept draw's with those slots' patched in
|
||||
// place, which reads the stages' tables alone, else made again whole, those of what the
|
||||
// encoder made resident kept (`binding::command_uses_into`).
|
||||
// encoder made resident kept (`binding::command_uses_into`); a carried draw's whole, as its
|
||||
// kept draw's are another encoder's (`render/carried.rs`).
|
||||
// A draw of other arguments patches its index buffer's use too, as a moved slot's.
|
||||
let patch = (&**plan, &command, &stages[..]);
|
||||
let inside = match images {
|
||||
let inside = match images || carried {
|
||||
true => None,
|
||||
false => {
|
||||
let moved_uses = (&mut live.kept.moved_at, &mut live.kept.moved);
|
||||
@@ -1120,6 +1223,10 @@ impl RenderLowering {
|
||||
kept.settled = Some(settled);
|
||||
kept.between = false;
|
||||
kept.stated = stated;
|
||||
// A carried draw is the encoder's own from here, recorded into the instance it began.
|
||||
let carried = kept.carried;
|
||||
kept.carried = false;
|
||||
kept.command_buffer = self.current.draws;
|
||||
// Whether its uses read an image: what its drawing again notes (`Kept::reads_images`).
|
||||
if images {
|
||||
kept.reads_images = live.uses.iter().any(super::reads_image);
|
||||
@@ -1133,6 +1240,9 @@ impl RenderLowering {
|
||||
if restated {
|
||||
counts.draw_restated();
|
||||
}
|
||||
if carried {
|
||||
counts.draw_rebound_carried();
|
||||
}
|
||||
recorded.count_equal_shapes(counts);
|
||||
self.current.recorded = true;
|
||||
let again = kept.again;
|
||||
|
||||
@@ -175,6 +175,12 @@ impl ExtendedShadows {
|
||||
self.holds
|
||||
}
|
||||
|
||||
/// Whether the pass has a color of an extended-range form, or holds shadows: a draw kept in
|
||||
/// another pass is not carried into it (`render/carried.rs`).
|
||||
pub(super) fn any(&self) -> bool {
|
||||
self.holds || !self.colors.is_empty()
|
||||
}
|
||||
|
||||
/// Whether the pass made `color`'s shadow, whose draws took a view of the color.
|
||||
pub(super) fn made(&self, color: u32) -> bool {
|
||||
self.made.contains_key(&color)
|
||||
|
||||
@@ -255,6 +255,8 @@ pub(crate) struct Counters {
|
||||
untouched_passes_skipped: AtomicU64,
|
||||
inline_passes: AtomicU64,
|
||||
inline_passes_split: AtomicU64,
|
||||
kept_draws_carried: AtomicU64,
|
||||
kept_draws_carry_dropped: [AtomicU64; CarryDropped::COUNT],
|
||||
inline_split_instances: AtomicU64,
|
||||
inline_memoryless_write_splits: AtomicU64,
|
||||
passes_not_inline: [AtomicU64; NotInline::COUNT],
|
||||
@@ -646,6 +648,9 @@ struct CommandCounters {
|
||||
draws_rebind_stopped_arguments_fetch_window: AtomicU64,
|
||||
draws_rebind_stopped_arguments_reach: AtomicU64,
|
||||
draws_rebind_stopped_arguments_other: AtomicU64,
|
||||
draws_rebound_carried: AtomicU64,
|
||||
draws_carry_stopped: AtomicU64,
|
||||
draws_carry_stopped_by: [AtomicU64; CarryStop::COUNT],
|
||||
attached_read_slots: AtomicU64,
|
||||
attached_read_slots_by: [AtomicU64; AttachedLevels::COUNT],
|
||||
}
|
||||
@@ -683,6 +688,46 @@ impl AttachedLevels {
|
||||
pub(crate) const COUNT: usize = 7;
|
||||
}
|
||||
|
||||
/// Why a render encoder's kept draw carried into its command buffer's next render encoder
|
||||
/// (`render/carried.rs`) was let go before that encoder started from it
|
||||
/// (`WorkCounts::kept_draws_carry_dropped_*`): the first that held.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub(crate) enum CarryDropped {
|
||||
/// Another call of the command buffer came first: another encoder's opening, an event, a
|
||||
/// commit, or any other that settles its last render encoder's end.
|
||||
Between,
|
||||
/// The next render encoder's pass is another's: another shape or compatible render pass, a
|
||||
/// color, depth or stencil attachment of another kind, memoryless colors, a visibility
|
||||
/// buffer, a rasterization-rate map, color groups, or an encoder that encodes an ended one
|
||||
/// again.
|
||||
Layout,
|
||||
/// What the kept draw read that changes with no call: a no-copy buffer moved, the device's
|
||||
/// sampler IDs' slots changed, or the next encoder's residency is of another generation.
|
||||
Under,
|
||||
}
|
||||
|
||||
impl CarryDropped {
|
||||
/// How many there are.
|
||||
pub(crate) const COUNT: usize = 3;
|
||||
}
|
||||
|
||||
/// Where the rebind of a render encoder's first draw of the kept draw its command buffer's last
|
||||
/// render encoder carried into it stopped (`WorkCounts::draws_carry_stopped_*`).
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub(crate) enum CarryStop {
|
||||
/// A slot its bind state holds bound that no call of the encoder bound (`render/carried.rs`).
|
||||
Stale,
|
||||
/// It samples a texture an attachment of the encoder's pass renders.
|
||||
Attached,
|
||||
/// Any other step of a rebind.
|
||||
Other,
|
||||
}
|
||||
|
||||
impl CarryStop {
|
||||
/// How many there are.
|
||||
pub(crate) const COUNT: usize = 3;
|
||||
}
|
||||
|
||||
/// What kept a direct draw that recorded from being kept to draw again
|
||||
/// (`WorkCounts::draws_unkept`): each a group of the conditions a kept draw meets
|
||||
/// (`render/draw_again.rs`), any number of them at once.
|
||||
@@ -1301,6 +1346,25 @@ impl Counting<'_> {
|
||||
counts.add(count, 1);
|
||||
}
|
||||
|
||||
/// A render draw rebound from the kept draw its command buffer's last render encoder carried
|
||||
/// into its encoder (`WorkCounts::draws_rebound_carried`).
|
||||
pub(crate) fn draw_rebound_carried(&self) {
|
||||
self.0.add(|counts| &counts.draws_rebound_carried, 1);
|
||||
}
|
||||
|
||||
/// A render draw of the kept draw carried into its encoder whose rebind stopped where `why`
|
||||
/// says (`WorkCounts::draws_carry_stopped`).
|
||||
pub(crate) fn draw_carry_stopped(&self, why: CarryStop) {
|
||||
let counts = self.0;
|
||||
counts.add(|counts| &counts.draws_carry_stopped, 1);
|
||||
let count: fn(&CommandCounters) -> &AtomicU64 = match why {
|
||||
CarryStop::Stale => |c| &c.draws_carry_stopped_by[CarryStop::Stale as usize],
|
||||
CarryStop::Attached => |c| &c.draws_carry_stopped_by[CarryStop::Attached as usize],
|
||||
CarryStop::Other => |c| &c.draws_carry_stopped_by[CarryStop::Other as usize],
|
||||
};
|
||||
counts.add(count, 1);
|
||||
}
|
||||
|
||||
/// A render draw rebound that was moved (`WorkCounts::draws_moved`).
|
||||
pub(crate) fn draw_moved(&self) {
|
||||
self.0.add(|counts| &counts.draws_moved, 1);
|
||||
@@ -2700,6 +2764,18 @@ impl Counters {
|
||||
self.inline_passes.fetch_add(1, Ordering::Relaxed);
|
||||
}
|
||||
|
||||
/// A render encoder opened from the kept draw its command buffer's last render encoder
|
||||
/// carried (`render/carried.rs`, `WorkCounts::kept_draws_carried`).
|
||||
pub(crate) fn kept_draw_carried(&self) {
|
||||
self.kept_draws_carried.fetch_add(1, Ordering::Relaxed);
|
||||
}
|
||||
|
||||
/// A kept draw carried into its command buffer's next render encoder was let go for `why`
|
||||
/// (`WorkCounts::kept_draws_carry_dropped_*`).
|
||||
pub(crate) fn kept_draw_carry_dropped(&self, why: CarryDropped) {
|
||||
self.kept_draws_carry_dropped[why as usize].fetch_add(1, Ordering::Relaxed);
|
||||
}
|
||||
|
||||
/// A render pass's first instance did not record inline, for `why` (`NotInline`).
|
||||
pub(crate) fn pass_not_inline(&self, why: NotInline) {
|
||||
self.passes_not_inline[why.index()].fetch_add(1, Ordering::Relaxed);
|
||||
@@ -5704,6 +5780,24 @@ pub struct WorkCounts {
|
||||
/// command buffer of its encoder's, begun at its first draw, in place of a secondary
|
||||
/// (`render/inline_first.rs`).
|
||||
pub inline_passes: u64,
|
||||
/// Render encoders that opened from the kept draw their command buffer's last render encoder
|
||||
/// carried into them, with that encoder's bind state and settle (`render/carried.rs`): the
|
||||
/// encoder's first draw of it is rebound (`draws_rebound_carried`). An encoder ended with a
|
||||
/// kept draw of its pass's first instance that read no attachment of its pass carries it.
|
||||
pub kept_draws_carried: u64,
|
||||
/// Kept draws carried that were let go before a render encoder started from them because
|
||||
/// another call of the command buffer came first: another encoder's opening, an event, a
|
||||
/// commit, or any other call that settles the last render encoder's end.
|
||||
pub kept_draws_carry_dropped_between: u64,
|
||||
/// Kept draws carried that were let go because the next render encoder's pass is another's:
|
||||
/// another shape or compatible render pass, another kind of attachment, memoryless colors, a
|
||||
/// visibility buffer, a rasterization-rate map, color groups, or an encoder that encodes an
|
||||
/// ended one again.
|
||||
pub kept_draws_carry_dropped_layout: u64,
|
||||
/// Kept draws carried that were let go because what they read that changes with no call
|
||||
/// changed: a no-copy buffer moved, the device's sampler IDs' slots changed, or the next
|
||||
/// encoder's residency is of another generation.
|
||||
pub kept_draws_carry_dropped_under: u64,
|
||||
/// Those of them that ended with more than one instance.
|
||||
pub inline_passes_split: u64,
|
||||
/// The instances after a split of such passes that recorded their draws inline too, in the
|
||||
@@ -6286,6 +6380,23 @@ pub struct WorkCounts {
|
||||
/// (`BindingPlan::redraw_apart_into`), its pulled attributes' reach and its index buffer's
|
||||
/// bind, which it records with its draw (`render/draw_again/rebound.rs`).
|
||||
pub draws_rebound_arguments: u64,
|
||||
/// Of `draws_rebound`, render encoders' first draws of the kept draw their command buffer's
|
||||
/// last render encoder carried into them (`kept_draws_carried`, `render/carried.rs`): each
|
||||
/// derived again what the encoder's render state decides of it, brought in every slot the
|
||||
/// encoder's calls bound, made its uses whole, began its pass's first instance as every step
|
||||
/// begins it, and recorded every state command it sets into the encoder's command buffer.
|
||||
pub draws_rebound_carried: u64,
|
||||
/// Render encoders' first draws of a carried kept draw whose rebind stopped, so that they took
|
||||
/// every step: each counted in one of the counts below.
|
||||
pub draws_carry_stopped: u64,
|
||||
/// Of `draws_carry_stopped`, those whose bind state held a slot bound that no call of their
|
||||
/// encoder bound: a new encoder inherits no binding, so the state is stale there.
|
||||
pub draws_carry_stopped_stale: u64,
|
||||
/// Of `draws_carry_stopped`, those that sample a texture an attachment of their pass renders.
|
||||
pub draws_carry_stopped_attached: u64,
|
||||
/// Of `draws_carry_stopped`, those that stopped at another step of a rebind
|
||||
/// (`draws_rebind_stopped`'s).
|
||||
pub draws_carry_stopped_other: u64,
|
||||
/// Render encoders' direct draws that recorded a Vulkan draw and kept nothing to draw again
|
||||
/// or rebind (`render/draw_again.rs`), so their encoder's next draw takes every step; with,
|
||||
/// in the counts below, what kept each from being kept, a draw counted in every group it met
|
||||
@@ -7757,6 +7868,12 @@ impl Device {
|
||||
let attached = |levels: AttachedLevels| {
|
||||
(counters.commands).sum(|counts| &counts.attached_read_slots_by[levels as usize])
|
||||
};
|
||||
let carry_stopped = |why: CarryStop| {
|
||||
(counters.commands).sum(|counts| &counts.draws_carry_stopped_by[why as usize])
|
||||
};
|
||||
let carry_dropped = |why: CarryDropped| {
|
||||
counters.kept_draws_carry_dropped[why as usize].load(Ordering::Relaxed)
|
||||
};
|
||||
let group_end = |end: GroupEnd| counters.group_ends[end as usize].load(Ordering::Relaxed);
|
||||
let first_work_order = self.shared().textures.first_moves.submissions_waited();
|
||||
let held_for =
|
||||
@@ -8234,6 +8351,10 @@ impl Device {
|
||||
unrun_instances_ended: counters.unrun_instances_ended.load(Ordering::Relaxed),
|
||||
untouched_passes_skipped: counters.untouched_passes_skipped.load(Ordering::Relaxed),
|
||||
inline_passes: counters.inline_passes.load(Ordering::Relaxed),
|
||||
kept_draws_carried: counters.kept_draws_carried.load(Ordering::Relaxed),
|
||||
kept_draws_carry_dropped_between: carry_dropped(CarryDropped::Between),
|
||||
kept_draws_carry_dropped_layout: carry_dropped(CarryDropped::Layout),
|
||||
kept_draws_carry_dropped_under: carry_dropped(CarryDropped::Under),
|
||||
inline_passes_split: counters.inline_passes_split.load(Ordering::Relaxed),
|
||||
inline_split_instances: counters.inline_split_instances.load(Ordering::Relaxed),
|
||||
inline_memoryless_write_splits: (counters.inline_memoryless_write_splits)
|
||||
@@ -8403,6 +8524,11 @@ impl Device {
|
||||
draws_moved_inside: commands(|counts| &counts.draws_moved_inside),
|
||||
draws_restated: commands(|counts| &counts.draws_restated),
|
||||
draws_rebound_arguments: commands(|counts| &counts.draws_rebound_arguments),
|
||||
draws_rebound_carried: commands(|counts| &counts.draws_rebound_carried),
|
||||
draws_carry_stopped: commands(|counts| &counts.draws_carry_stopped),
|
||||
draws_carry_stopped_stale: carry_stopped(CarryStop::Stale),
|
||||
draws_carry_stopped_attached: carry_stopped(CarryStop::Attached),
|
||||
draws_carry_stopped_other: carry_stopped(CarryStop::Other),
|
||||
draws_unkept: commands(|counts| &counts.draws_unkept),
|
||||
draws_unkept_instance: commands(|counts| &counts.draws_unkept_instance),
|
||||
draws_unkept_instance_later: commands(|counts| &counts.draws_unkept_instance_later),
|
||||
|
||||
@@ -2707,6 +2707,10 @@ field metal2vulkan-runtime::WorkCounts.draw_shapes_made pub draw_shapes_made: u6
|
||||
field metal2vulkan-runtime::WorkCounts.draw_shapes_reused pub draw_shapes_reused: u64
|
||||
field metal2vulkan-runtime::WorkCounts.draw_states_recorded pub draw_states_recorded: u64
|
||||
field metal2vulkan-runtime::WorkCounts.draws_as_before pub draws_as_before: u64
|
||||
field metal2vulkan-runtime::WorkCounts.draws_carry_stopped pub draws_carry_stopped: u64
|
||||
field metal2vulkan-runtime::WorkCounts.draws_carry_stopped_attached pub draws_carry_stopped_attached: u64
|
||||
field metal2vulkan-runtime::WorkCounts.draws_carry_stopped_other pub draws_carry_stopped_other: u64
|
||||
field metal2vulkan-runtime::WorkCounts.draws_carry_stopped_stale pub draws_carry_stopped_stale: u64
|
||||
field metal2vulkan-runtime::WorkCounts.draws_counted_past_early_masks pub draws_counted_past_early_masks: u64
|
||||
field metal2vulkan-runtime::WorkCounts.draws_dropped_still_making pub draws_dropped_still_making: u64
|
||||
field metal2vulkan-runtime::WorkCounts.draws_dropped_unmade pub draws_dropped_unmade: u64
|
||||
@@ -2722,6 +2726,7 @@ field metal2vulkan-runtime::WorkCounts.draws_rebind_stopped_arguments_route pub
|
||||
field metal2vulkan-runtime::WorkCounts.draws_rebind_stopped_arguments_tables pub draws_rebind_stopped_arguments_tables: u64
|
||||
field metal2vulkan-runtime::WorkCounts.draws_rebound pub draws_rebound: u64
|
||||
field metal2vulkan-runtime::WorkCounts.draws_rebound_arguments pub draws_rebound_arguments: u64
|
||||
field metal2vulkan-runtime::WorkCounts.draws_rebound_carried pub draws_rebound_carried: u64
|
||||
field metal2vulkan-runtime::WorkCounts.draws_restated pub draws_restated: u64
|
||||
field metal2vulkan-runtime::WorkCounts.draws_settled pub draws_settled: u64
|
||||
field metal2vulkan-runtime::WorkCounts.draws_unkept pub draws_unkept: u64
|
||||
@@ -2948,6 +2953,10 @@ field metal2vulkan-runtime::WorkCounts.joins_withheld_from_unshared pub joins_wi
|
||||
field metal2vulkan-runtime::WorkCounts.kept_backings_made pub kept_backings_made: u64
|
||||
field metal2vulkan-runtime::WorkCounts.kept_bytes_passes pub kept_bytes_passes: u64
|
||||
field metal2vulkan-runtime::WorkCounts.kept_contexts_made pub kept_contexts_made: u64
|
||||
field metal2vulkan-runtime::WorkCounts.kept_draws_carried pub kept_draws_carried: u64
|
||||
field metal2vulkan-runtime::WorkCounts.kept_draws_carry_dropped_between pub kept_draws_carry_dropped_between: u64
|
||||
field metal2vulkan-runtime::WorkCounts.kept_draws_carry_dropped_layout pub kept_draws_carry_dropped_layout: u64
|
||||
field metal2vulkan-runtime::WorkCounts.kept_draws_carry_dropped_under pub kept_draws_carry_dropped_under: u64
|
||||
field metal2vulkan-runtime::WorkCounts.kept_resident_keys_compared pub kept_resident_keys_compared: u64
|
||||
field metal2vulkan-runtime::WorkCounts.kept_texels_passes pub kept_texels_passes: u64
|
||||
field metal2vulkan-runtime::WorkCounts.line_band_draws pub line_band_draws: u64
|
||||
|
||||
|
Can't render this file because it is too large.
|
Reference in new issue
Block a user