Files
metal2vulkan/crates/metal2vulkan-harness/tests/rt.rs
T
Anees Iqbal 92ce7950fc Docs: "the runtime", not "the new runtime"
There is one runtime, so the prose of the harness, validation, devtools,
the translator's lockstep module, .config/nextest.toml and the refusal
surface and conformance coverage generators says "the runtime"
(scratch newrt.py: a word replacement, identifiers such as new_runtime
and NewRuntime untouched). docs/REFUSALS.md and
docs/CONFORMANCE-COVERAGE.md are regenerated from the edited scripts.

Four harness passages said the runtime makes no heap and no texture
over a buffer, and has no Managed mode. The runtime has all three
(Device::new_heap_buffer and heap textures, Buffer::new_texture,
Device::new_managed_buffer); the harness's own backend refuses the two
texture sources. They now say the harness makes neither on the runtime,
and the Managed note names Device::new_managed_buffer. The refusal
strings keep the words the harness's described test matches ("makes no
heap", "makes no texture over a buffer").

Left: three fixture comments (.metal under validation's public
fixtures, whose text keys the golden tables and the committed AIR) and
scripts/matrix, whose keys (harness-new) carry the same naming.

Verified locally: the refusal surface, Metal coverage, conformance
coverage and API signature checks pass.
2026-11-20 11:52:56 -08:00

30 lines
1.4 KiB
Rust

//! The runtime's buffers through the harness, on the device the cfg names
//! (docs/VALIDATION.md): a range given back is the next one taken, buffers alive at once lie
//! apart, and a buffer longer than a pooled block takes a block of its own.
#![cfg(any(m2v_gpu, m2v_cpu_icd))]
use metal2vulkan_harness::{rt, Buffer, Device, Storage};
#[test]
fn a_range_given_back_is_the_next_taken_and_live_buffers_lie_apart() {
let device = rt::system_default(None).unwrap();
let at = |buffer: &rt::Buffer| buffer.contents().unwrap().as_ptr() as usize;
let first = device.new_buffer(4096, Storage::Shared).unwrap();
let second = device.new_buffer(4096, Storage::Shared).unwrap();
let (first_at, second_at) = (at(&first), at(&second));
assert!(
second_at >= first_at + 4096 || second_at + 4096 <= first_at,
"{first_at:#x} and {second_at:#x} overlap"
);
drop(first);
let third = device.new_buffer(4096, Storage::Shared).unwrap();
assert_eq!(at(&third), first_at, "the range given back is taken again");
let private = device.new_buffer(4096, Storage::Private).unwrap();
assert!(private.contents().is_none());
// Past a pooled block: a dedicated block, released when the buffer is dropped.
let long = (device.new_buffer(256 << 20 | 4096, Storage::Shared)).unwrap();
metal2vulkan_harness::run::zeroed(&long, 256 << 20 | 4096, 4096).unwrap();
drop(long);
drop((second, third, private));
}