diff --git a/crates/metal2vulkan-validation/src/replay/new_runtime/render.rs b/crates/metal2vulkan-validation/src/replay/new_runtime/render.rs index c5ef7b3b2..69c43dd25 100644 --- a/crates/metal2vulkan-validation/src/replay/new_runtime/render.rs +++ b/crates/metal2vulkan-validation/src/replay/new_runtime/render.rs @@ -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 { diff --git a/crates/metal2vulkan-validation/src/replay/rt_replay.rs b/crates/metal2vulkan-validation/src/replay/rt_replay.rs index 080a526db..aa2879c5f 100644 --- a/crates/metal2vulkan-validation/src/replay/rt_replay.rs +++ b/crates/metal2vulkan-validation/src/replay/rt_replay.rs @@ -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 { + 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 = [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. diff --git a/docs/REPLAY-STREAM.md b/docs/REPLAY-STREAM.md index 3bb2566d4..03a620995 100644 --- a/docs/REPLAY-STREAM.md +++ b/docs/REPLAY-STREAM.md @@ -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).