diff --git a/crates/metal2vulkan-validation/src/replay/player.rs b/crates/metal2vulkan-validation/src/replay/player.rs index 4c6f3098c..d2044bee5 100644 --- a/crates/metal2vulkan-validation/src/replay/player.rs +++ b/crates/metal2vulkan-validation/src/replay/player.rs @@ -821,6 +821,11 @@ impl<'b, B: Backend> Player<'b, B> { call: Call, left_out: &mut Counters, ) -> Result<(), PlayError> { + // A message to nil does nothing: a call of receiver 0 that makes nothing and names no + // class (a class's call is `MTLX.selector`, the host's `m2v.selector`). + if call.receiver == 0 && call.result == 0 && !call.selector.contains('.') { + return Ok(()); + } match &*call.selector { "m2v.write" => self.write(stream, &call), "m2v.check" => { diff --git a/crates/metal2vulkan-validation/src/replay/tests.rs b/crates/metal2vulkan-validation/src/replay/tests.rs index 512ac06b2..c3f21add8 100644 --- a/crates/metal2vulkan-validation/src/replay/tests.rs +++ b/crates/metal2vulkan-validation/src/replay/tests.rs @@ -1063,6 +1063,37 @@ fn a_dispatch_plays_between_its_private_bytes() { assert!(total.values().all(|&value| value == 0), "{total:?}"); } +/// A message to nil (receiver 0, no result, no class named) plays nothing and does not stop the +/// play; the stream still counts it as a call. +#[test] +fn a_message_to_nil_does_nothing() { + let mut kept = Kept::default(); + let (report, ended) = played(&mut kept, |w| { + w.call("MTLCreateSystemDefaultDevice", 0, 1, &[], &[])?; + let region = map(&[ + ("origin", map(&[("x", Value::Uint(0))])), + ("size", map(&[("width", Value::Uint(1))])), + ]); + let args = [ + region, + Value::Uint(0), + Value::Bytes(vec![0; 4]), + Value::Uint(4), + ]; + w.call( + "replaceRegion:mipmapLevel:withBytes:bytesPerRow:", + 0, + 0, + &args, + &[], + )?; + Ok(()) + }); + ended.unwrap(); + assert_eq!(kept.calls, ["#1 = MTLCreateSystemDefaultDevice"]); + assert_eq!(report.total.stream["calls"], 2); +} + /// On a backend that takes no snapshots, a dispatch an `m2v.privateBytes` record names plays as it /// is, with none of the player's own calls, and the report counts it. #[test] diff --git a/docs/REPLAY-STREAM.md b/docs/REPLAY-STREAM.md index 8b613452b..4f88bb672 100644 --- a/docs/REPLAY-STREAM.md +++ b/docs/REPLAY-STREAM.md @@ -83,6 +83,8 @@ and the (name id, value) answer pairs. (`MTLRenderPassDescriptor.new`), or an `m2v.` name for what Metal has no call for. Where two classes share a selector, the receiver's kind tells them apart. - **Receiver 0** is the host's platform: the device, descriptor and drawable records it makes. + A call of receiver 0 that makes nothing and whose selector names no class (no `.`) is a message + the program sent to nil: it does nothing, and a player plays nothing for it. - **Arguments:** one value per argument of the selector, in order; an encoder command's are its fields. Error out-parameters, blocks and handlers are left out: their effects reach the stream as later calls and writes.