diff --git a/crates/metal2vulkan-validation/src/replay/new_runtime/encoders.rs b/crates/metal2vulkan-validation/src/replay/new_runtime/encoders.rs index b5630c422..7f7533b2f 100644 --- a/crates/metal2vulkan-validation/src/replay/new_runtime/encoders.rs +++ b/crates/metal2vulkan-validation/src/replay/new_runtime/encoders.rs @@ -370,6 +370,11 @@ impl NewRuntime { Ok(()) } }, + "setStageInRegion:" => { + let region = region(call, arg(call, 0)?)?; + self.compute(id).encoder.set_stage_in_region(region); + Ok(()) + } _ => return Err(refuse(call, "not played on a compute encoder")), }; result.map_err(failed(call)) diff --git a/crates/metal2vulkan-validation/src/runtime_lane/rt_replay.rs b/crates/metal2vulkan-validation/src/runtime_lane/rt_replay.rs index f212462fb..b6380c213 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/rt_replay.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/rt_replay.rs @@ -9,6 +9,7 @@ //! report says the play is no verdict past it: its gap, frame and call. //! - A compute pipeline state the runtime answers with a typed gap is skipped and counted by the //! gap, and a dispatch of it is skipped, and the play goes on. +//! - A compute encoder's `setStageInRegion:` plays: the runtime takes it. //! - The host's library from source is made of its display library where the backend has it, a //! function of it with it; without it both are skipped. //! - A Managed buffer of a stream recorded with two copies keeps both on any device (the player's @@ -446,6 +447,32 @@ fn a_compute_state_the_runtime_does_not_build_is_counted_and_its_dispatch_skippe assert!(lines.iter().any(|l| l.starts_with(line)), "{lines:?}"); } +#[test] +fn a_stage_in_region_plays_on_a_compute_encoder() { + let dir = ScratchDir::new("rt-replay-stage-in").unwrap(); + let path = written(&dir, |w| { + w.call("MTLCreateSystemDefaultDevice", 0, 1, &[], &[])?; + w.call("newCommandQueue", 1, 2, &[], &[])?; + w.call("commandBuffer", 2, 3, &[], &[])?; + w.call("computeCommandEncoder", 3, 4, &[], &[])?; + let region = Value::Map(vec![ + ("origin".into(), uints(&[("x", 0), ("y", 0), ("z", 0)])), + ( + "size".into(), + uints(&[("width", 64), ("height", 1), ("depth", 1)]), + ), + ]); + w.call("setStageInRegion:", 4, 0, &[region], &[])?; + w.call("endEncoding", 4, 0, &[], &[])?; + w.call("commit", 3, 0, &[], &[])?; + w.call(WAIT_COMPLETED, 3, 0, &[], &[]) + }); + let (report, _) = play("stage-in", &path); + let executed = &report.total.executed; + assert_eq!(executed["skipped_calls"], 0, "{executed:?}"); + assert_eq!(report.first_skip, None); +} + #[test] fn a_two_copy_stream_s_managed_buffer_keeps_both_copies() { let dir = ScratchDir::new("rt-replay-two-copies").unwrap(); diff --git a/docs/REPLAY-STREAM.md b/docs/REPLAY-STREAM.md index c7b31bab8..bf83077fd 100644 --- a/docs/REPLAY-STREAM.md +++ b/docs/REPLAY-STREAM.md @@ -669,7 +669,9 @@ counted from 0), completes the work committed so far, reports as at the stream's 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). + order). Compute encoders on the new runtime 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); the old runtime refuses it. `report.txt` holds one line per item: the line `recorded before the recorder's completion fix: the stream may differ from what the program did` first where the stream's header lacks bit 1 (section