Replay: a render encoder's residency declarations play as nothing

What: the runtime player plays a render encoder's useResource:usage:, useResource:usage:stages:,
useResources:count:usage:, useResources:count:usage:stages:, useHeap:, useHeap:stages:,
useHeaps:count: and useHeaps:count:stages: with no runtime call. Until now each was refused
("not played on a render encoder"), which ended the play. What these calls name is still
noted before the call plays, as for any encoder call (tiled-texture takes, index reads,
covers, place users). docs/REPLAY-STREAM.md lists the eight among what render encoders play.

Why: a recorded consumer stream (run 62101 of the 3090 Xid 13 investigation) stopped at frame
239 on its first render encoder's useHeaps:count:stages:, before any heap-pass draw. The
consumer's runtime backend makes no rt call for these either (reims-vgpu 14c00263ef,
crates/reims-vgpu-vulkan/src/rt_platform/render.rs:310-312 puts UseHeaps and UseHeapsStages in
the arm that does nothing; :301-309 notes a useResources texture's tiled take and
own-index read, and makes no rt call). The runtime's render encoder has no residency call, and
every object of a play is resident.

Test: rt_replay's a_render_encoder_s_residency_declarations_play_as_nothing (device tests,
--cfg m2v_gpu or m2v_cpu_icd). After a triangle, a stream makes a heap and declares all eight
forms on the render encoder, naming the heap and the vertex buffers, then draws again. The play
ends, nothing is skipped and the target checks green. Before this change the first declaration
was refused.

Verified: cargo fmt --all. Build, clippy and the lavapipe device tests run in the job named in
the lane's report.
This commit is contained in:
Anees Iqbal committed 2026-11-21 00:56:28 -08:00
1 parent 6b1367b6c5
commit 5ea6b63f01
3 files changed
+71 -3

No files matched your search

@@ -950,6 +950,17 @@ impl NewRuntime {
self.render(id).encoder.set_line_width(width);
Ok(())
}
// A render encoder's residency declarations: no runtime call, as the runtime's render
// encoder has none and every object of the play is resident. What they name is noted
// before the call plays, as any encoder call's names are.
"useResource:usage:"
| "useResource:usage:stages:"
| "useResources:count:usage:"
| "useResources:count:usage:stages:"
| "useHeap:"
| "useHeap:stages:"
| "useHeaps:count:"
| "useHeaps:count:stages:" => Ok(()),
_ => return Err(refuse(call, "not played on a render encoder")),
};
match result {
@@ -6,6 +6,9 @@
//! a pass's target that its setter records clear to red: a blit copies the target to a buffer,
//! which the stream checks green, and nothing is skipped.
//! - A draw of points after it plays, nothing skipped.
//! - A render encoder's residency declarations play as nothing: after each of its eight
//! `useResource`, `useResources`, `useHeap` and `useHeaps` forms, with stages and without, a
//! draw plays, nothing refused or skipped.
//! - `setLineWidth:` plays: at width 1 a draw of lines after it plays; at width 2 a draw of
//! triangles plays and one of lines is the runtime's gap, skipped and counted, and the report
//! says the play is no verdict past it: its gap, frame and call.
@@ -289,6 +292,9 @@ enum Then {
Nothing,
/// The triangle's vertices as points: call 19.
Points,
/// A heap (#16, call 19), the eight residency declarations of a render encoder naming it and
/// the vertex buffers (calls 20 to 27), and the triangle again (call 28).
Uses,
/// `setLineWidth:` of the width (call 19), the triangle again (call 20), and its first two
/// vertices as a line (call 21).
Lines(f32),
@@ -394,6 +400,38 @@ fn draw_with_clamps(dir: &ScratchDir, green: &[u8], then: Then, clamp: Option<f3
let draw = [Value::Uint(0), Value::Uint(0), Value::Uint(3)];
w.call("drawPrimitives:vertexStart:vertexCount:", 13, 0, &draw, &[])?;
}
Then::Uses => {
let block = [Value::Uint(0x1_0000), Value::Uint(0)];
w.call("m2v.newBlockWithLength:storageMode:", 1, 16, &block, &[])?;
// MTLResourceUsageRead; MTLRenderStageVertex, Fragment and both.
let [read, vertex, fragment, both] = [1, 1, 2, 3].map(Value::Uint);
let (buffer, heap) = (Value::Object(8), Value::Object(16));
let buffers = Value::List(vec![Value::Object(8), Value::Object(9)]);
let heaps = Value::List(vec![Value::Object(16)]);
let uses = [
("useResource:usage:", vec![buffer.clone(), read.clone()]),
(
"useResource:usage:stages:",
vec![Value::Object(9), read.clone(), vertex.clone()],
),
(
"useResources:count:usage:",
vec![buffers.clone(), Value::Uint(2), read.clone()],
),
(
"useResources:count:usage:stages:",
vec![buffers, Value::Uint(2), read, both.clone()],
),
("useHeap:", vec![heap.clone()]),
("useHeap:stages:", vec![heap, fragment]),
("useHeaps:count:", vec![heaps.clone(), Value::Uint(1)]),
("useHeaps:count:stages:", vec![heaps, Value::Uint(1), both]),
];
for (selector, args) in uses {
w.call(selector, 13, 0, &args, &[])?;
}
w.call("drawPrimitives:vertexStart:vertexCount:", 13, 0, &draw, &[])?;
}
Then::Lines(width) => {
w.call("setLineWidth:", 13, 0, &[Value::F32(width)], &[])?;
w.call("drawPrimitives:vertexStart:vertexCount:", 13, 0, &draw, &[])?;
@@ -554,6 +592,23 @@ fn a_draw_of_points_plays_on_the_new_runtime() {
assert_eq!(report.first_skip, None);
}
/// A render encoder's eight residency declarations (calls 20 to 27) play as nothing: the play
/// ends, no call refused, nothing skipped, and the triangle drawn after them (call 28) leaves the
/// target green.
#[test]
fn a_render_encoder_s_residency_declarations_play_as_nothing() {
let dir = ScratchDir::new("rt-replay-render-uses").unwrap();
let green: Vec<u8> = [0u8, 255, 0, 255].repeat(16);
let path = draw_into_a_pass(&dir, &green, Then::Uses);
let (report, _) = play("render-uses", &path);
assert_eq!(Some(report.checks[0].sha256), report.checks[0].recorded);
let executed = &report.total.executed;
for skipped in ["skipped_render_commands", "skipped_draws", "skipped_calls"] {
assert_eq!(executed[skipped], 0, "{skipped}: {executed:?}");
}
assert_eq!(report.first_skip, None);
}
/// `setLineWidth:` plays: at width 1 the triangle and the line after it play, nothing skipped; at
/// width 2 the triangle draws and the line is the runtime's gap, skipped and counted, and the
/// report says the play is no verdict past it.
+5 -3
View File
@@ -887,9 +887,11 @@ records as text, and
buffers, offsets, bytes, textures and sampler states, the viewport, scissor, cull mode, winding,
blend color and stencil references, the draws (indexed or not, with instance counts, base
vertex and base instance), fences and memory barriers (their stages are the runtime's to
order). A bind of a range (`withRange:`) of buffers, textures or sampler
states plays as the single-slot bind of each, from the range's location, on render and compute
encoders alike.
order). Their residency declarations (`useResource:usage:`, `useResources:count:usage:`,
`useHeap:` and `useHeaps:count:`, each with `stages:` or without) play as nothing: the
runtime's render encoder has no such call, and every object of the play is resident. A bind
of a range (`withRange:`) of buffers, textures or sampler states plays as the single-slot bind
of each, from the range's location, on render and compute encoders alike.
Compute encoders play `setStageInRegion:` (the runtime takes it and it changes nothing a
dispatch of a kernel without a stage-in argument does, the only kernel it builds).