From a5d498d99c0f97d5216e0611cd8deff853fff5ed Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Mon, 23 Nov 2026 08:19:27 -0800 Subject: [PATCH] Tests: residency declarations name their resources as the stream records them (red) docs/REPLAY-STREAM.md records a resource argument as the map {Buffer: object} or {Texture: object}, and a C array of them with its count as one list of such maps. The residency tests passed bare objects: the unwritten test's useResource:usage:, the render residency test's four resource forms, and the new compute and covers tests. The compute encoder reads its useResource:usage: argument as the map already. The covers rule and the unwritten count read it with as_object, which takes only a bare object, so a real recording's useResource:usage: wrote and uncovered nothing in them. On the format, the unwritten test's useResource:usage: is red too, beside the plural tests. Heaps stay bare objects (useHeap: takes an id, not a resource). --- .../src/replay/rt_replay.rs | 15 ++++++++++----- .../metal2vulkan-validation/src/replay/tests.rs | 11 ++++++++--- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/crates/metal2vulkan-validation/src/replay/rt_replay.rs b/crates/metal2vulkan-validation/src/replay/rt_replay.rs index 2cd695e82..84a5cf489 100644 --- a/crates/metal2vulkan-validation/src/replay/rt_replay.rs +++ b/crates/metal2vulkan-validation/src/replay/rt_replay.rs @@ -231,6 +231,11 @@ fn sampler(index: Option) -> Value { } /// A recorder struct's map of unsigned fields. +/// A resource argument, `{Buffer: object}` or `{Texture: object}`. +fn resource(kind: &str, id: u64) -> Value { + Value::Map(vec![(kind.into(), Value::Object(id))]) +} + fn uints(fields: &[(&str, u64)]) -> Value { Value::Map( fields @@ -421,14 +426,14 @@ fn draw_with_clamps(dir: &ScratchDir, green: &[u8], then: Then, clamp: Option) -> Call { } } +/// Buffer `id` as a resource argument: `{Buffer: object}`. +fn buffer_resource(id: u64) -> Value { + map(&[("Buffer", Value::Object(id))]) +} + /// `setBuffer:offset:atIndex:` of buffer `id` at slot `slot` of encoder `encoder`. fn bind_at(encoder: u64, id: u64, slot: u64) -> Call { let args = vec![Value::Object(id), Value::Uint(0), Value::Uint(slot)]; @@ -2045,7 +2050,7 @@ fn a_dispatch_reads_a_buffer_only_where_its_state_or_its_usage_reads_it() { encoder_call( "useResource:usage:", 17, - vec![Value::Object(id), Value::Uint(usage)], + vec![buffer_resource(id), Value::Uint(usage)], ) }; unwritten.encoded(&used(8, 2), 18, true); @@ -2088,7 +2093,7 @@ fn a_dispatch_reads_or_writes_each_buffer_a_plural_use_names_by_its_usage() { } unwritten.state(12, Some(Vec::new())); let used = |ids: &[u64], usage: u64| { - let list = Value::List(ids.iter().map(|&id| Value::Object(id)).collect()); + let list = Value::List(ids.iter().map(|&id| buffer_resource(id)).collect()); encoder_call( "useResources:count:usage:", 12, @@ -2772,7 +2777,7 @@ fn a_compute_encoder_s_plural_uses_take_covers_off_as_the_single_forms_do() { w.call(made, 1, 9, &[], &[])?; // Covered by the write of #5, then written by the plural use with write usage (2). encoded(w, 20)?; - let list = Value::List(vec![Value::Object(3)]); + let list = Value::List(vec![buffer_resource(3)]); used(w, 30, "useResources:count:usage:", &[list, Value::Uint(2)])?; w.call("m2v.check", 0, 0, &[Value::Object(3)], &[])?; // Covered again, then bound by the plural use of its heap.