WorkCounts: why a render encoder ends carrying no kept draw
A Launchpad walk on RADV counted no kept draw carried and no carry let go: every encoder's carried_out declined silently, so each of its first draws per state took every step (draws_none_kept, 53% of its draws). The encoder now counts the first reason it carries none (encoders_uncarried_*): no draw, no kept draw at its end, an unsettled bind state, a split, colour groups or a rate map, a replay, executed commands or pending pipelines or tile dispatches, shader-side tests, imageblocks, a visibility result, an instance of reformats, views or storage, a kept draw that does not rebind, or a failing depth/stencil state. What carries is unchanged. Test: carried_draws::an_encoder_that_carries_nothing_counts_why.
This commit is contained in:
1 parent
312b1b2d78
commit
6499e2f7ce
4 files changed
+224
-27
No files matched your search
@@ -26,7 +26,10 @@
|
||||
//! (`LiveBind::end_carried`): they are the residency's, which is the encoder's. The carry names
|
||||
//! the program's objects by key and handle alone (the bind state's values, the kept draws'
|
||||
//! index buffers, their pipeline states held weakly), and holds only the runtime's own: the
|
||||
//! settles' variants, the kept draws' `VkPipeline`s (`Kept::made`) and settings.
|
||||
//! settles' variants, the kept draws' `VkPipeline`s (`Kept::made`) and settings. An encoder
|
||||
//! that ends carrying none counts the first reason ([`Uncarried`],
|
||||
//! `WorkCounts::encoders_uncarried_*`): no draw, no kept draw, or which of the above did not
|
||||
//! hold.
|
||||
//! - **Let go.** Any call of the command buffer but the commit that settles its last render
|
||||
//! encoder's end (`CommandBuffer::settle_end`: another encoder's opening, an event, a
|
||||
//! semaphore) lets it go to the device's spares, counted
|
||||
@@ -92,7 +95,7 @@ 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;
|
||||
use crate::work_counts::{CarryDropped, Uncarried};
|
||||
|
||||
/// The most pipeline states whose kept draws a render encoder carries into its command buffer's
|
||||
/// next render encoder: its last draw's and those of the three drawn most lately before it, of the
|
||||
@@ -176,32 +179,23 @@ impl RenderLowering {
|
||||
/// states of the [`CARRIED_STATES`] pipeline states drawn most lately that carry with it,
|
||||
/// every other set aside let go (the module docs).
|
||||
fn carried_out(&mut self, live: &mut LiveBind) -> Option<Kept> {
|
||||
let kept = self.again_kept()?;
|
||||
let ends = 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();
|
||||
let counts = &self.core.device().shared().counts;
|
||||
if !(ends && kept.carries()) {
|
||||
if ends && kept.carries_but_attached() {
|
||||
counts.kept_draws_uncarried_attached(1);
|
||||
let Some(kept) = self.again_kept() else {
|
||||
counts.encoder_uncarried(match self.draw_calls {
|
||||
0 => Uncarried::Drawless,
|
||||
_ => Uncarried::NoneKept,
|
||||
});
|
||||
return None;
|
||||
};
|
||||
if let Err(why) = self.carry_ends(live) {
|
||||
counts.encoder_uncarried(why);
|
||||
return None;
|
||||
}
|
||||
if !kept.carries() {
|
||||
match (kept.carries_but_attached(), kept.rebinds) {
|
||||
(true, _) => counts.kept_draws_uncarried_attached(1),
|
||||
(false, false) => counts.encoder_uncarried(Uncarried::Unrebound),
|
||||
(false, true) => counts.encoder_uncarried(Uncarried::FailingState),
|
||||
}
|
||||
return None;
|
||||
}
|
||||
@@ -215,6 +209,55 @@ impl RenderLowering {
|
||||
self.take_kept()
|
||||
}
|
||||
|
||||
/// Whether the encoder ends in a state its kept draw carries from (the module docs): its
|
||||
/// bind state holds the settle of its last draw's state, and its pass recorded no step a
|
||||
/// carried draw's first rebind does not repeat; else the first reason it does not
|
||||
/// (`WorkCounts::encoders_uncarried_*`).
|
||||
fn carry_ends(&self, live: &LiveBind) -> Result<(), Uncarried> {
|
||||
let current = &self.current;
|
||||
let checks = [
|
||||
(live.settled.is_some(), Uncarried::Unsettled),
|
||||
(
|
||||
self.earlier.is_empty() && current.pieces.is_empty(),
|
||||
Uncarried::Split,
|
||||
),
|
||||
(
|
||||
self.grouped.is_none() && self.rate_map.is_none(),
|
||||
Uncarried::Pass,
|
||||
),
|
||||
(!self.replaying && !self.rerouting, Uncarried::Replay),
|
||||
(
|
||||
self.executions.is_empty()
|
||||
&& self.pending.is_empty()
|
||||
&& self.dispatches.is_empty()
|
||||
&& !self.dispatched,
|
||||
Uncarried::Commands,
|
||||
),
|
||||
(
|
||||
self.shadow.is_none()
|
||||
&& self.depth_stand_in.is_none()
|
||||
&& !current.shadow
|
||||
&& !current.shader_tests,
|
||||
Uncarried::ShaderTests,
|
||||
),
|
||||
(
|
||||
self.imageblock.is_none() && !self.tile_imageblock,
|
||||
Uncarried::Imageblock,
|
||||
),
|
||||
(!self.visibility.active(), Uncarried::Visibility),
|
||||
(
|
||||
current.reformats.is_empty()
|
||||
&& current.views == ViewSetup::default()
|
||||
&& current.shape.storage.is_empty(),
|
||||
Uncarried::Instance,
|
||||
),
|
||||
];
|
||||
match checks.into_iter().find(|&(holds, _)| !holds) {
|
||||
Some((_, why)) => Err(why),
|
||||
None => Ok(()),
|
||||
}
|
||||
}
|
||||
|
||||
/// Start from `kept`, the kept draw the command buffer's last render encoder carried, or
|
||||
/// the last render encoder of a command buffer committed on its queue where `across`, and
|
||||
/// those `live`, its bind state, set aside with it, of `carries` kept draws carried in before
|
||||
|
||||
@@ -124,6 +124,29 @@ impl Frame {
|
||||
fn across(&self) -> u64 {
|
||||
self.counted(|c| c.kept_draws_carried_across)
|
||||
}
|
||||
|
||||
/// The render encoders that ended carrying nothing, by reason (`encoders_uncarried_*`, in
|
||||
/// their order): drawless, none kept, and the eleven others together.
|
||||
fn uncarried(&self) -> [u64; 3] {
|
||||
let others: [fn(&WorkCounts) -> u64; 11] = [
|
||||
|c| c.encoders_uncarried_unsettled,
|
||||
|c| c.encoders_uncarried_split,
|
||||
|c| c.encoders_uncarried_pass,
|
||||
|c| c.encoders_uncarried_replay,
|
||||
|c| c.encoders_uncarried_commands,
|
||||
|c| c.encoders_uncarried_shader_tests,
|
||||
|c| c.encoders_uncarried_imageblock,
|
||||
|c| c.encoders_uncarried_visibility,
|
||||
|c| c.encoders_uncarried_instance,
|
||||
|c| c.encoders_uncarried_unrebound,
|
||||
|c| c.encoders_uncarried_failing_state,
|
||||
];
|
||||
[
|
||||
self.counted(|c| c.encoders_uncarried_drawless),
|
||||
self.counted(|c| c.encoders_uncarried_none_kept),
|
||||
others.into_iter().map(|of| self.counted(of)).sum(),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
/// The carry's counts ([`Frame::carries`]) of a frame whose carried draws are `carried`, the
|
||||
@@ -304,6 +327,30 @@ fn passes_of_the_same_state_rebind_the_carried_draw() {
|
||||
);
|
||||
}
|
||||
|
||||
/// A render encoder that ends carrying nothing counts the first reason
|
||||
/// (`encoders_uncarried_*`): passes that each carry their kept draw into the next count none, and
|
||||
/// passes that draw nothing count each as drawless.
|
||||
#[test]
|
||||
fn an_encoder_that_carries_nothing_counts_why() {
|
||||
let scratch = Scratch::new("carried-uncarried");
|
||||
let heard = Heard::default();
|
||||
let device = device(&scratch.0, &[], &heard);
|
||||
let queue = device.new_command_queue().unwrap();
|
||||
let state = adding_state(&device);
|
||||
let color = colors(&device, &[[1.0 / 16.0; 4]]);
|
||||
let pass = |encoder: &mut RenderCommandEncoder| rectangle(encoder, &state, (&color, 0));
|
||||
let drawless = |_: &mut RenderCommandEncoder| {};
|
||||
warm(&device, pass);
|
||||
const PASSES: usize = 3;
|
||||
let passes: [Pass<'_>; PASSES] = [&pass; PASSES];
|
||||
let drawn = frame(&queue, &passes, Apart::Together);
|
||||
let passes: [Pass<'_>; PASSES] = [&drawless; PASSES];
|
||||
let cleared = frame(&queue, &passes, Apart::Together);
|
||||
assert_eq!(drawn.carries(), rebound(PASSES as u64 - 1), "drawn");
|
||||
assert_eq!(drawn.uncarried(), [0, 0, 0], "drawn");
|
||||
assert_eq!(cleared.uncarried(), [PASSES as u64, 0, 0], "drawless");
|
||||
}
|
||||
|
||||
/// Passes that each draw through three pipeline states, each pass after the first starting from a
|
||||
/// state its encoder's last draw did not draw: every state's kept draw carries with the encoder's
|
||||
/// last one (`kept_draws_carried_aside`), and the next encoder's first draw of each state is
|
||||
|
||||
@@ -340,6 +340,7 @@ pub(crate) struct Counters {
|
||||
kept_draws_carried_aside: AtomicU64,
|
||||
kept_draws_carry_capped: AtomicU64,
|
||||
kept_draws_uncarried_attached: AtomicU64,
|
||||
encoders_uncarried: [AtomicU64; Uncarried::COUNT],
|
||||
inline_split_instances: AtomicU64,
|
||||
inline_memoryless_write_splits: AtomicU64,
|
||||
passes_not_inline: [AtomicU64; NotInline::COUNT],
|
||||
@@ -875,6 +876,46 @@ impl CarryDropped {
|
||||
pub(crate) const COUNT: usize = 4;
|
||||
}
|
||||
|
||||
/// Why a render encoder that ended carried no kept draw into its command buffer's next render
|
||||
/// encoder (`render/carried.rs`, `WorkCounts::encoders_uncarried_*`): the first that held, in this
|
||||
/// order.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub(crate) enum Uncarried {
|
||||
/// It recorded no draw.
|
||||
Drawless,
|
||||
/// It drew, but kept no draw at its end: its last draw kept nothing, or a call after its
|
||||
/// last kept draw let every kept draw go.
|
||||
NoneKept,
|
||||
/// Its bind state held no settle of its last draw's state.
|
||||
Unsettled,
|
||||
/// Its pass split: an instance before the current one, or pieces of the current one.
|
||||
Split,
|
||||
/// Its pass is drawn in color groups or over a rasterization-rate map.
|
||||
Pass,
|
||||
/// It encoded an ended encoder again, or recorded a draw again into another instance.
|
||||
Replay,
|
||||
/// Executed render commands, a pipeline being made, or a tile dispatch in its pass.
|
||||
Commands,
|
||||
/// A shader-side stencil or depth test, or its stand-in, in its pass.
|
||||
ShaderTests,
|
||||
/// A fragment or tile imageblock in its pass.
|
||||
Imageblock,
|
||||
/// A visibility result active at its end.
|
||||
Visibility,
|
||||
/// Its current instance renders a color through a view of another format, draws views, or
|
||||
/// holds storage attachments.
|
||||
Instance,
|
||||
/// Its last kept draw does not rebind (`Kept::rebinds`).
|
||||
Unrebound,
|
||||
/// Its last kept draw holds a depth/stencil state that fails every fragment.
|
||||
FailingState,
|
||||
}
|
||||
|
||||
impl Uncarried {
|
||||
/// How many there are.
|
||||
pub(crate) const COUNT: usize = 13;
|
||||
}
|
||||
|
||||
/// 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)]
|
||||
@@ -3266,6 +3307,12 @@ impl Counters {
|
||||
}
|
||||
}
|
||||
|
||||
/// A render encoder ended carrying no kept draw, for `why`
|
||||
/// (`WorkCounts::encoders_uncarried_*`).
|
||||
pub(crate) fn encoder_uncarried(&self, why: Uncarried) {
|
||||
self.encoders_uncarried[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);
|
||||
@@ -6933,6 +6980,38 @@ pub struct WorkCounts {
|
||||
/// encoder's first draw of each one's state takes every step (`draws_none_kept`). One that
|
||||
/// reads it through its copy carries (`kept_draws_carried`).
|
||||
pub kept_draws_uncarried_attached: u64,
|
||||
/// Render encoders that ended carrying no kept draw into their command buffer's next render
|
||||
/// encoder (`render/carried.rs`), by the first reason that held, in this order: they recorded
|
||||
/// no draw.
|
||||
pub encoders_uncarried_drawless: u64,
|
||||
/// They drew but kept no draw at their end: the last draw kept nothing (`draws_unkept`), or
|
||||
/// a call after the last kept draw let every kept draw go.
|
||||
pub encoders_uncarried_none_kept: u64,
|
||||
/// Their bind state held no settle of the last draw's state.
|
||||
pub encoders_uncarried_unsettled: u64,
|
||||
/// Their pass split: an instance before the current one, or pieces of the current one.
|
||||
pub encoders_uncarried_split: u64,
|
||||
/// Their pass is drawn in color groups or over a rasterization-rate map.
|
||||
pub encoders_uncarried_pass: u64,
|
||||
/// They encoded an ended encoder again, or recorded a draw again into another instance.
|
||||
pub encoders_uncarried_replay: u64,
|
||||
/// Their pass executed render commands, drew through a pipeline still being made, or
|
||||
/// dispatched tiles.
|
||||
pub encoders_uncarried_commands: u64,
|
||||
/// Their pass tests the stencil or depth in the shader, or holds such a test's stand-in.
|
||||
pub encoders_uncarried_shader_tests: u64,
|
||||
/// Their pass holds a fragment or tile imageblock.
|
||||
pub encoders_uncarried_imageblock: u64,
|
||||
/// A visibility result was active at their end.
|
||||
pub encoders_uncarried_visibility: u64,
|
||||
/// Their current instance renders a color through a view of another format, draws views, or
|
||||
/// holds storage attachments.
|
||||
pub encoders_uncarried_instance: u64,
|
||||
/// Their last kept draw does not rebind: a visible-function table, a push hole, a use beyond
|
||||
/// its plan's, a set-0 write that holds a keeper, or a recording of more than one Vulkan draw.
|
||||
pub encoders_uncarried_unrebound: u64,
|
||||
/// Their last kept draw holds a depth/stencil state that fails every fragment.
|
||||
pub encoders_uncarried_failing_state: 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
|
||||
@@ -9570,6 +9649,8 @@ impl Device {
|
||||
let carry_dropped = |why: CarryDropped| {
|
||||
counters.kept_draws_carry_dropped[why as usize].load(Ordering::Relaxed)
|
||||
};
|
||||
let uncarried =
|
||||
|why: Uncarried| counters.encoders_uncarried[why as usize].load(Ordering::Relaxed);
|
||||
let group_end = |end: GroupEnd| counters.group_ends[end as usize].load(Ordering::Relaxed);
|
||||
let unswapped = |cause: Unturned| {
|
||||
let at = cause as usize;
|
||||
@@ -10141,6 +10222,19 @@ impl Device {
|
||||
kept_draws_carry_capped: counters.kept_draws_carry_capped.load(Ordering::Relaxed),
|
||||
kept_draws_uncarried_attached: (counters.kept_draws_uncarried_attached)
|
||||
.load(Ordering::Relaxed),
|
||||
encoders_uncarried_drawless: uncarried(Uncarried::Drawless),
|
||||
encoders_uncarried_none_kept: uncarried(Uncarried::NoneKept),
|
||||
encoders_uncarried_unsettled: uncarried(Uncarried::Unsettled),
|
||||
encoders_uncarried_split: uncarried(Uncarried::Split),
|
||||
encoders_uncarried_pass: uncarried(Uncarried::Pass),
|
||||
encoders_uncarried_replay: uncarried(Uncarried::Replay),
|
||||
encoders_uncarried_commands: uncarried(Uncarried::Commands),
|
||||
encoders_uncarried_shader_tests: uncarried(Uncarried::ShaderTests),
|
||||
encoders_uncarried_imageblock: uncarried(Uncarried::Imageblock),
|
||||
encoders_uncarried_visibility: uncarried(Uncarried::Visibility),
|
||||
encoders_uncarried_instance: uncarried(Uncarried::Instance),
|
||||
encoders_uncarried_unrebound: uncarried(Uncarried::Unrebound),
|
||||
encoders_uncarried_failing_state: uncarried(Uncarried::FailingState),
|
||||
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)
|
||||
|
||||
@@ -2891,6 +2891,19 @@ field metal2vulkan-runtime::WorkCounts.encoder_command_buffers_begun pub encoder
|
||||
field metal2vulkan-runtime::WorkCounts.encoder_primaries_begun_ahead pub encoder_primaries_begun_ahead: u64
|
||||
field metal2vulkan-runtime::WorkCounts.encoders_barriered_at_open pub encoders_barriered_at_open: u64
|
||||
field metal2vulkan-runtime::WorkCounts.encoders_reencoded pub encoders_reencoded: u64
|
||||
field metal2vulkan-runtime::WorkCounts.encoders_uncarried_commands pub encoders_uncarried_commands: u64
|
||||
field metal2vulkan-runtime::WorkCounts.encoders_uncarried_drawless pub encoders_uncarried_drawless: u64
|
||||
field metal2vulkan-runtime::WorkCounts.encoders_uncarried_failing_state pub encoders_uncarried_failing_state: u64
|
||||
field metal2vulkan-runtime::WorkCounts.encoders_uncarried_imageblock pub encoders_uncarried_imageblock: u64
|
||||
field metal2vulkan-runtime::WorkCounts.encoders_uncarried_instance pub encoders_uncarried_instance: u64
|
||||
field metal2vulkan-runtime::WorkCounts.encoders_uncarried_none_kept pub encoders_uncarried_none_kept: u64
|
||||
field metal2vulkan-runtime::WorkCounts.encoders_uncarried_pass pub encoders_uncarried_pass: u64
|
||||
field metal2vulkan-runtime::WorkCounts.encoders_uncarried_replay pub encoders_uncarried_replay: u64
|
||||
field metal2vulkan-runtime::WorkCounts.encoders_uncarried_shader_tests pub encoders_uncarried_shader_tests: u64
|
||||
field metal2vulkan-runtime::WorkCounts.encoders_uncarried_split pub encoders_uncarried_split: u64
|
||||
field metal2vulkan-runtime::WorkCounts.encoders_uncarried_unrebound pub encoders_uncarried_unrebound: u64
|
||||
field metal2vulkan-runtime::WorkCounts.encoders_uncarried_unsettled pub encoders_uncarried_unsettled: u64
|
||||
field metal2vulkan-runtime::WorkCounts.encoders_uncarried_visibility pub encoders_uncarried_visibility: u64
|
||||
field metal2vulkan-runtime::WorkCounts.event_signals_behind_merge pub event_signals_behind_merge: u64
|
||||
field metal2vulkan-runtime::WorkCounts.event_waits_met pub event_waits_met: u64
|
||||
field metal2vulkan-runtime::WorkCounts.exported_dma_buf_images pub exported_dma_buf_images: u64
|
||||
|
||||
|
Can't render this file because it is too large.
|
Reference in new issue
Block a user