Files
metal2vulkan/crates/metal2vulkan-runtime/src/tests/shared_pointers.rs
T
Anees Iqbal 787d92fdc2 Answer a heap texture's allocatedSize from the place that holds it
The steps this packet landed as, in order:
- Answer a kept heap texture requirement before asking the device's limits
- Answer whether a command buffer or submission uses given objects, cloning nothing
- List devices' registry IDs without making devices, and open one by its ID
- Give a made pipeline state's reflection from its compile, after its creation
- Enable optional device extensions where each device can, and say which it enabled
- Let a caller vouch for its host pages' write permission, skipping the kernel's answer
- Import read-only host pages from the caller's dma-buf source, and say whether a device takes shared pointers
- Hold a texture of Apple's private usage 0x8 alone to what Metal does with it
- Measure RADV 26.2.4 on the RX 7900 XTX: its pointer imports follow their address
- Free a no-copy buffer's dma-buf imports before its keep-alive goes
- Measure a file's pages mapped under a live RADV pointer import, a known gap
- Let what waits for a dma-buf import's free go as its fields drop

Content: the tree of `development` at 0a38130573, unchanged.
2026-10-26 13:19:05 +02:00

48 lines
2.1 KiB
Rust

//! `Device::imports_shared_host_pointers`: found once per device by importing one page of shared
//! memory, and answered from that after. MoltenVK (anonymous shared memory, handed to Metal) and
//! lavapipe (a `memfd`) import it; RADV refuses it (the 780M and the 7900 XTX, Mesa 26.2.4).
//! NVIDIA is expected to import it, as it imported such memory for no-copy buffers. Another
//! driver's answer is printed.
//!
//! A device test: compiled only under the validation crate's GPU safety cfgs (`m2v_gpu`,
//! `m2v_cpu_icd`), on the kind of device the cfg selects. Nothing runs on the GPU.
use crate::{Device, DeviceKind, DeviceOptions, MessageSink};
use metal2vulkan::vk::DriverId;
#[test]
fn a_device_says_once_whether_it_imports_shared_memory_pointers() {
let options = DeviceOptions {
kinds: match cfg!(m2v_cpu_icd) {
true => vec![DeviceKind::Cpu],
false => vec![
DeviceKind::Discrete,
DeviceKind::Integrated,
DeviceKind::Virtual,
],
},
// A group of devices no other test makes.
messages: Some(MessageSink::new(|_| {})),
..DeviceOptions::default()
};
let device = Device::system_default_with(&options).unwrap();
let expected = match device.properties().description.driver_id {
Some(DriverId::MESA_RADV) => Some(false),
Some(DriverId::MOLTENVK | DriverId::MESA_LLVMPIPE | DriverId::NVIDIA_PROPRIETARY) => {
Some(true)
}
_ => None,
};
let imports = || device.work_counts().host_pointer_imports_made;
let before = imports();
let answer = device.imports_shared_host_pointers().unwrap();
if let Some(expected) = expected {
assert_eq!(answer, expected, "{}", device.name());
}
// The page's import, counted where the device took it.
assert_eq!(imports() - before, u64::from(answer));
assert_eq!(device.imports_shared_host_pointers().unwrap(), answer);
assert_eq!(imports() - before, u64::from(answer), "asked again");
eprintln!("shared host pointers on {}: {answer}", device.name());
}