On the consumer's XTX Launchpad walk ~59% of render encoders end keeping nothing though they would fit the next encoder (WorkCounts::encoders_none_kept_next_fits, RUNTIME 2229), and ~75 draws a present read their own color attachment through a snapshot (render/snapshot.rs), a draw that kept nothing and so took every step each time. A direct draw that reads through snapshots (not in place), pins nothing, and otherwise meets every plain-draw condition (records into its instance as it stood, a pipeline made ahead, one push, one Vulkan draw, whole draw state, its only push hole SnapshotPhase, no write but its snapshots' uses) now keeps a Kept with a reader part (slots, feedback colors, the phase hole, the pipeline's own write masks, its layout). A draw again records exactly what the first did, the snapshot draw (masks 0, phase 1) then the drawing draw (own masks, phase 0), with their barriers and query, re-deriving only what changes with no call (the reader's ordinal, its learned coverage and the area/coverage decision, peeked first; if it would no longer take the snapshot the draw takes every step). A rebind re-derives the reader decision through side-effect-free cores of the functions every step runs (in_place_wanted, snapshot_wanted, area/coverage, snapshot_holds, snapshot_apart), binding::rebind_into rewrites a changed slot's SnapshotTexels source, and record_rebound records the two recordings with their pairs. A carried reader's snapshot conditions are checked at its rebind beside carried_stale (WorkCounts::draws_carry_stopped_snapshot), begin_carried passes its feedback to inline_begin, and a carried draw retains its pipeline objects into its encoder. Set-aside kept readers are exempt from a reader's forget of its colors' readers: their reads go through their own pair, whose first barrier orders every earlier color write. In-place readers, pinning readers and readers recording into a new instance stay unkept. New WorkCounts: reading_draws_snapshotted_again, draws_rebind_stopped_snapshot, draws_carry_stopped_snapshot. A lane bench (runtime_lane reader_costs) measures the CPU per draw of encoders ending in a reader. Expected reach (keepdraws' read of the consumer's lp72-xtx counters): readers never sit in an unsplit inline pass, so this reaches the ~22 fitting encoders a present that are not inline. Verified (keepdraws): clippy plain / --cfg m2v_gpu / --cfg m2v_cpu_icd and rustdoc 0 at adaccf2367; lavapipe 43/43 (no snapshot path there: pixels only); XTX and 780M debug at e4961c98ee 91/92, the one miss (a carried draw's later draw again) fixed by 8e219f8bad. XTX/780M reruns at the tip, negative control and the release bench are queued and follow on development. RUNTIME_VERSION 2239 -> 2240.
86 lines
3.9 KiB
Rust
86 lines
3.9 KiB
Rust
//! The sizes of the draws that read their pass's texture through a snapshot or take the split by
|
|
//! the area rule (`render/snapshot.rs`'s `RenderCommandEncoder::weigh_snapshot`), counted for a
|
|
//! diagnostic line where `METAL2VULKAN_LOG_PIPELINES` is set: how many such draws weigh which share
|
|
//! of their colors' pixels, at which texel bytes, on which side of the rule. A device counts them
|
|
//! only while the log is on, writes the line after 64 of them and after each power of two past
|
|
//! it, and once more as it ends where it counted one since; the line changes nothing it records.
|
|
//!
|
|
//! A draw's share is its scissors' pixels for each color it reads so, over the pixels of those
|
|
//! colors' levels, in steps of 0.5% (one step at 100% and above); its texel bytes are those
|
|
//! colors' bytes over their pixels, rounded down: a color's own format's bytes for a draw that
|
|
//! reads one color, or colors of one width. The rule's bound on the share
|
|
//! (`render/snapshot.rs`'s area rule) turns on the texel bytes and on the colors' size, so the
|
|
//! line shows how many draws lie near it for each width.
|
|
|
|
use std::collections::BTreeMap;
|
|
use std::fmt::Write;
|
|
|
|
/// The steps of a share: 0.5% each, the last one 100% and above.
|
|
const STEPS: u64 = 200;
|
|
|
|
/// The fewest weighed draws a line is written after, and each power of two from it.
|
|
const FIRST_LINE: u64 = 64;
|
|
|
|
/// The draws a device weighed by the area rule, by texel bytes, side and share.
|
|
#[derive(Debug, Default)]
|
|
pub(crate) struct ReaderSizes {
|
|
weighed: u64,
|
|
/// The count of each texel bytes, side of the rule (`true` within, so the snapshot) and
|
|
/// share step.
|
|
counts: BTreeMap<(u64, bool, u64), u64>,
|
|
}
|
|
|
|
impl ReaderSizes {
|
|
/// Count a draw whose scissors bound `covered` pixels over all the colors it reads so
|
|
/// (the scissors' pixels times the colors), of colors of `pixels` pixels and `bytes` bytes in
|
|
/// all, `within` the rule or not; the diagnostic line, where the count of weighed draws
|
|
/// reaches [`FIRST_LINE`] or a power of two past it.
|
|
pub(crate) fn add(
|
|
&mut self,
|
|
covered: u64,
|
|
pixels: u64,
|
|
bytes: u64,
|
|
within: bool,
|
|
) -> Option<String> {
|
|
let step = match pixels {
|
|
0 => STEPS,
|
|
p => (covered.saturating_mul(STEPS) / p).min(STEPS),
|
|
};
|
|
let texel = bytes.checked_div(pixels).unwrap_or(0);
|
|
*self.counts.entry((texel, within, step)).or_default() += 1;
|
|
self.weighed += 1;
|
|
(self.weighed >= FIRST_LINE && self.weighed.is_power_of_two()).then(|| self.line())
|
|
}
|
|
|
|
/// The line a device writes as it ends, where it weighed a draw since its last line.
|
|
pub(crate) fn last_line(&self) -> Option<String> {
|
|
let written = self.weighed >= FIRST_LINE && self.weighed.is_power_of_two();
|
|
(self.weighed > 0 && !written).then(|| self.line())
|
|
}
|
|
|
|
/// The diagnostic line: the draws weighed, then for each texel bytes and side, each share
|
|
/// step's count.
|
|
pub(crate) fn line(&self) -> String {
|
|
let mut text = format!(
|
|
"{} draws that read their pass's texture weighed by the area rule (texel bytes, side, \
|
|
then share of the colors' pixels the scissors bound, from, in 0.5% steps: count):",
|
|
self.weighed
|
|
);
|
|
let mut group = None;
|
|
for (&(texel, within, step), &count) in &self.counts {
|
|
if group != Some((texel, within)) {
|
|
let side = if within { "snapshot" } else { "split" };
|
|
let gap = if group.is_some() { ";" } else { "" };
|
|
let _ = write!(text, "{gap} {texel} B {side}");
|
|
group = Some((texel, within));
|
|
}
|
|
let label = match step {
|
|
STEPS => "100%+".to_string(),
|
|
s => format!("{}.{}%", s / 2, (s % 2) * 5),
|
|
};
|
|
let _ = write!(text, " {label}:{count}");
|
|
}
|
|
text
|
|
}
|
|
}
|