replay: skipped render pipeline states are counted by the runtime's gap

The report gave one line for every skipped render pipeline state, its
total and the first one's answer, so a stream's states refused for a
depth attachment, for framebuffer fetch or by the translator read as one
number. The planner's census of what the new runtime refuses needs the
count of each kind per stream.

The backend now keeps the skipped states by the gap as Rust prints it
for debugging (Translation where the translator refused), with the
first one's object and answer, and the report gives a
"skipped render states GAP N, the first #ID: WHY" line for each, as it
does for render commands; skipped_render_states is their sum.
docs/REPLAY-STREAM.md describes the line.

Verified: see the check job (a new rt_replay device test: a state with
a Depth32Float depth attachment is counted under
RenderPipeline { kind: DepthAttachment }).
This commit is contained in:
Anees Iqbal committed 2026-11-18 16:57:09 -08:00
1 parent 749c939440
commit c027cc2cfa
4 files changed
+55 -17

No files matched your search

@@ -40,10 +40,10 @@ struct Skips {
encoders: u64,
/// Objects it does not build: libraries from source.
objects: u64,
/// Render pipeline states the runtime answers with a typed gap or the translator refuses.
render_states: u64,
/// The first such state's object id and the runtime's answer, for the report's lines.
first_render_state: Option<(u64, String)>,
/// Render pipeline states the runtime answers with a typed gap or the translator refuses, by
/// the gap (`Translation` for the translator's refusals): how many, and the first one's object
/// id and the runtime's answer.
render_states: BTreeMap<String, (u64, u64, String)>,
/// Dispatches that bind a skipped object.
dispatches: u64,
/// Draws whose pipeline state, or a buffer or texture bound to either stage, is a skipped
@@ -77,13 +77,17 @@ impl Skips {
.sum()
}
/// The render pipeline states skipped, of every gap.
fn render_state_count(&self) -> u64 {
self.render_states.values().map(|&(count, ..)| count).sum()
}
/// Everything skipped, in one count (`Backend::skips`).
fn total(&self) -> u64 {
let Skips {
encoders,
objects,
render_states,
first_render_state: _,
render_states: _,
dispatches,
draws,
render_commands: _,
@@ -97,7 +101,6 @@ impl Skips {
let counted = [
encoders,
objects,
render_states,
dispatches,
draws,
blits,
@@ -107,7 +110,7 @@ impl Skips {
calls,
resource_ids,
];
counted.into_iter().sum::<u64>() + self.render_command_count()
counted.into_iter().sum::<u64>() + self.render_state_count() + self.render_command_count()
}
}
@@ -2139,7 +2142,7 @@ impl Backend for NewRuntime {
("stamps_not_available", metrics.stamps_not_available),
("skipped_encoders", self.skips.encoders),
("skipped_objects", self.skips.objects),
("skipped_render_states", self.skips.render_states),
("skipped_render_states", self.skips.render_state_count()),
("skipped_dispatches", self.skips.dispatches),
("skipped_draws", self.skips.draws),
("skipped_render_commands", self.skips.render_command_count()),
@@ -2223,10 +2226,9 @@ impl Backend for NewRuntime {
}
lines.push(line);
}
if let Some((at, why)) = &self.skips.first_render_state {
for (gap, (count, at, why)) in &self.skips.render_states {
lines.push(format!(
"skipped render states {}, the first #{at}: {why}",
self.skips.render_states
"skipped render states {gap} {count}, the first #{at}: {why}"
));
}
for (gap, (count, frame, at)) in &self.skips.render_commands {
@@ -1,7 +1,8 @@
//! Render pipeline states, render pass descriptors and render encoders on the new runtime.
//!
//! What the runtime does not build yet is skipped and counted: a render pipeline state it answers
//! with a typed gap or the translator refuses (`render_states`); a render encoder whose pass the
//! with a typed gap or the translator refuses (`render_states`, by the gap, with the first state
//! and the runtime's answer of each); a render encoder whose pass the
//! runtime's descriptor cannot hold (a resolve texture, a depth plane, store action options, a
//! visibility result buffer, layered or tile rendering, a skipped texture) or that it answers with
//! a typed gap (`encoders`); a draw whose pipeline state, or a buffer or texture bound to either
@@ -133,8 +134,12 @@ impl NewRuntime {
match made {
Ok(state) => unaddressed(Object::RenderPipeline(state)),
Err(error @ (rt::Error::Unsupported(_) | rt::Error::Translation(_))) => {
self.skips.render_states += 1;
(self.skips.first_render_state).get_or_insert((call.result, error.to_string()));
let gap = match &error {
rt::Error::Unsupported(gap) => format!("{gap:?}"),
_ => "Translation".to_owned(),
};
let kind = self.skips.render_states.entry(gap);
kind.or_insert((0, call.result, error.to_string())).0 += 1;
unaddressed(Object::Skipped)
}
Err(error) => Err(failed(call)(error)),
@@ -330,6 +330,35 @@ fn a_draw_the_runtime_does_not_build_is_skipped_and_ends_the_verdict() {
assert!(lines.iter().any(|l| l == line), "{lines:?}");
}
#[test]
fn a_render_state_the_runtime_does_not_build_is_counted_by_its_gap() {
let dir = ScratchDir::new("rt-replay-state-gap").unwrap();
let path = written(&dir, |w| {
let library = w.blob(&render_library(&dir))?;
w.call("MTLCreateSystemDefaultDevice", 0, 1, &[], &[])?;
let library = [Value::Blob(library)];
w.call("newLibraryWithData:error:", 1, 3, &library, &[])?;
let vertex = [Value::Str("colored_vertex".into())];
w.call("newFunctionWithName:", 3, 4, &vertex, &[])?;
let fragment = [Value::Str("colored_fragment".into())];
w.call("newFunctionWithName:", 3, 5, &fragment, &[])?;
// Colour 0 RGBA8Unorm and a Depth32Float depth attachment, which the runtime refuses.
let color = Value::List(vec![Value::Uint(0), uints(&[("pixelFormat", 70)])]);
let pipeline = Value::Map(vec![
("vertex".into(), Value::Object(4)),
("fragment".into(), Value::Object(5)),
("colors".into(), Value::List(vec![color])),
("depthPixelFormat".into(), Value::Uint(252)),
]);
let made = "newRenderPipelineStateWithDescriptor:error:";
w.call(made, 1, 6, &[pipeline], &[])
});
let (report, lines) = play("state-gap", &path);
assert_eq!(report.total.executed["skipped_render_states"], 1);
let line = "skipped render states RenderPipeline { kind: DepthAttachment } 1, the first #6: ";
assert!(lines.iter().any(|l| l.starts_with(line)), "{lines:?}");
}
#[test]
fn a_two_copy_stream_s_managed_buffer_keeps_both_copies() {
let dir = ScratchDir::new("rt-replay-two-copies").unwrap();
+4 -2
View File
@@ -692,8 +692,10 @@ calls played: where
the play stopped, the stopping call is the next), the new runtime's backend's
`pipeline I wall_nanos=N kernel=new|again` for each compute pipeline state it made, in order (the
making's wall time, and whether no state of another specialization of the kernel, a library's
function by name, was made before), its `skipped render states N, the first #ID: WHY` where it
skipped any (`ID` the first one's object and `WHY` the runtime's answer), its
function by name, was made before), its `skipped render states GAP N, the first #ID: WHY` for each
typed gap a render pipeline state met (`GAP` the runtime's gap as Rust prints it for debugging, such
as `RenderPipeline { kind: DepthAttachment }`, or `Translation` where the translator refused it, `N`
the states skipped, `ID` the first one's object and `WHY` the runtime's answer), its
`skipped render commands GAP N, the first at frame F, call C` for each typed gap a render command
met, a draw the runtime does not build among them (`GAP` the runtime's gap as Rust prints it for
debugging, such as `Draw { kind: Points }`, `N` the commands skipped, `F`