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<MTLHeap>, not a
resource).
This commit is contained in:
1 parent
060482f654
commit
a5d498d99c
2 files changed
+18
-8
No files matched your search
@@ -231,6 +231,11 @@ fn sampler(index: Option<u64>) -> 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<f3
|
||||
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 (buffer, heap) = (resource("Buffer", 8), Value::Object(16));
|
||||
let buffers = Value::List(vec![resource("Buffer", 8), resource("Buffer", 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()],
|
||||
vec![resource("Buffer", 9), read.clone(), vertex.clone()],
|
||||
),
|
||||
(
|
||||
"useResources:count:usage:",
|
||||
@@ -1321,10 +1326,10 @@ fn a_compute_encoder_s_residency_declarations_play_through_the_runtime() {
|
||||
w.call("setBuffer:offset:atIndex:", 9, 0, &bind(7, 1), &[])?;
|
||||
// MTLResourceUsageRead and Write.
|
||||
let (read, write) = (Value::Uint(1), Value::Uint(2));
|
||||
let buffers = Value::List(vec![Value::Object(6), Value::Object(7)]);
|
||||
let buffers = Value::List(vec![resource("Buffer", 6), resource("Buffer", 7)]);
|
||||
let heaps = Value::List(vec![Value::Object(10)]);
|
||||
let uses = [
|
||||
("useResource:usage:", vec![Value::Object(6), read]),
|
||||
("useResource:usage:", vec![resource("Buffer", 6), read]),
|
||||
("useResources:count:usage:", vec![buffers, write]),
|
||||
("useHeap:", vec![Value::Object(10)]),
|
||||
("useHeaps:count:", vec![heaps]),
|
||||
|
||||
@@ -1936,6 +1936,11 @@ fn encoder_call(selector: &str, receiver: u64, args: Vec<Value>) -> 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.
|
||||
|
||||
Reference in new issue
Block a user