diff --git a/crates/metal2vulkan-runtime/src/tests/command.rs b/crates/metal2vulkan-runtime/src/tests/command.rs index 2b828bc8f..15ed7a064 100644 --- a/crates/metal2vulkan-runtime/src/tests/command.rs +++ b/crates/metal2vulkan-runtime/src/tests/command.rs @@ -232,16 +232,23 @@ pub(crate) mod on_device { /// through the two-copy view (`DeviceOptions::two_copies`), where it keeps a device copy as /// a discrete GPU does and `has_unified_memory` answers false. The second run's name is the /// device's with ", two copies" after it. - pub(crate) fn each_device_in_both_forms( + pub(crate) fn each_device_in_both_forms(test: &str, body: impl FnMut(&str, &Instance, Device)) { + each_device_in_both_forms_with(test, DeviceOptions::default, body); + } + + /// [`each_device_in_both_forms`] with `options` for each device, the two-copy view's run + /// opened with them too. + pub(crate) fn each_device_in_both_forms_with( test: &str, + options: impl Fn() -> DeviceOptions, mut body: impl FnMut(&str, &Instance, Device), ) { let instance = crate::tests::validation::instance(&[]); let devices = devices_of_the_cfgs_kind(&instance); assert!(!devices.is_empty(), "no device of this cfg's kind"); for (name, physical) in &devices { - let device = Device::new(physical, DeviceOptions::default()) - .unwrap_or_else(|error| panic!("{name}: {error}")); + let device = + Device::new(physical, options()).unwrap_or_else(|error| panic!("{name}: {error}")); let unified = device.has_unified_memory(); run_settled(test, &instance, name, device, &mut body); if !unified { @@ -249,7 +256,7 @@ pub(crate) mod on_device { } let view = DeviceOptions { two_copies: true, - ..DeviceOptions::default() + ..options() }; let device = Device::new(physical, view).unwrap_or_else(|error| panic!("{name}: {error}")); diff --git a/crates/metal2vulkan-runtime/src/tests/gpu_span.rs b/crates/metal2vulkan-runtime/src/tests/gpu_span.rs index 97fe4fdf6..e2ee50b9d 100644 --- a/crates/metal2vulkan-runtime/src/tests/gpu_span.rs +++ b/crates/metal2vulkan-runtime/src/tests/gpu_span.rs @@ -5,7 +5,9 @@ #[cfg(any(m2v_gpu, m2v_cpu_icd))] pub(crate) mod on_device { - use crate::tests::command::on_device::{each_device, finished, Arena}; + use crate::tests::command::on_device::{ + each_device, each_device_in_both_forms, finished, Arena, + }; use crate::tests::compute::on_device::step; use crate::tests::managed::on_device::new_managed; use crate::{ @@ -93,7 +95,7 @@ pub(crate) mod on_device { /// puts the upload inside it. Only where the Managed buffer has a device copy. #[test] fn every_device_leaves_a_copy_in_out_of_the_gpu_span_it_goes_ahead_of() { - each_device("copy-in outside the span", |name, _, device| { + each_device_in_both_forms("copy-in outside the span", |name, _, device| { if device.has_unified_memory() { println!("copy-in outside the span: {name}: unified, no copy-in"); return; diff --git a/crates/metal2vulkan-runtime/src/tests/import.rs b/crates/metal2vulkan-runtime/src/tests/import.rs index 920f1563a..7790a7f09 100644 --- a/crates/metal2vulkan-runtime/src/tests/import.rs +++ b/crates/metal2vulkan-runtime/src/tests/import.rs @@ -156,7 +156,9 @@ fn host_memory_takes_the_first_coherent_listed_type_offered() { #[cfg(any(m2v_gpu, m2v_cpu_icd))] pub(crate) mod on_device { use crate::memory::Release; - use crate::tests::command::on_device::{each_device, finished, within, Busy}; + use crate::tests::command::on_device::{ + each_device, each_device_in_both_forms, finished, within, Busy, + }; use crate::tests::devices_of_the_cfgs_kind; use crate::texture::TextureObject; use crate::{ @@ -528,7 +530,7 @@ pub(crate) mod on_device { /// import host memory has nothing to show. #[test] fn every_device_releases_an_import_under_a_managed_buffer_dropped_before_any_commit() { - each_device("import_managed_drop", |name, _, device| { + each_device_in_both_forms("import_managed_drop", |name, _, device| { let counters = device.counters(); let Some((_, alignment)) = device.core().imports.host.as_ref() else { println!("import: {name}: imports no host memory"); diff --git a/crates/metal2vulkan-runtime/src/tests/resolve.rs b/crates/metal2vulkan-runtime/src/tests/resolve.rs index 2360d6257..307fc94de 100644 --- a/crates/metal2vulkan-runtime/src/tests/resolve.rs +++ b/crates/metal2vulkan-runtime/src/tests/resolve.rs @@ -84,7 +84,7 @@ fn a_resolving_action_needs_a_resolve_texture_and_unknown_resolves_where_one_is_ #[cfg(any(m2v_gpu, m2v_cpu_icd))] mod on_device { - use crate::tests::command::on_device::each_device; + use crate::tests::command::on_device::{each_device, each_device_in_both_forms}; use crate::tests::draw::on_device::{ descriptor, examples, floats, pass, run, state, target, Buffers, SIDE, }; @@ -747,7 +747,7 @@ mod on_device { let Some(library) = examples() else { return; }; - each_device("resolve_over", |name, _, device| { + each_device_in_both_forms("resolve_over", |name, _, device| { let format = PixelFormat::BGRA8UnormSRGB; let color = four_of(name, &device, format, WALK) .unwrap_or_else(|error| panic!("{name}: Vulkan requires 4 samples: {error}")); diff --git a/crates/metal2vulkan-runtime/src/tests/sites.rs b/crates/metal2vulkan-runtime/src/tests/sites.rs index fc674c0a7..84e8a5e57 100644 --- a/crates/metal2vulkan-runtime/src/tests/sites.rs +++ b/crates/metal2vulkan-runtime/src/tests/sites.rs @@ -10,7 +10,7 @@ mod on_device { use crate::fill::ZEROS; use crate::memory::MakerTest; use crate::ring::{Writes, CHUNK}; - use crate::tests::command::on_device::{each_device_with, within}; + use crate::tests::command::on_device::{each_device_in_both_forms_with, within}; use crate::{ Device, DeviceOptions, HostBytes, MemoryClass, Metrics, PixelFormat, Region, SiteAllocations, StorageMode, Texture, TextureDescriptor, TextureType, TextureUsage, @@ -106,7 +106,7 @@ mod on_device { maker: MakerTest::Fail, ..DeviceOptions::default() }; - each_device_with("allocation_sites", options, |name, _, device| { + each_device_in_both_forms_with("allocation_sites", options, |name, _, device| { count_each_site(name, &device); }); } diff --git a/crates/metal2vulkan-runtime/src/tests/spill.rs b/crates/metal2vulkan-runtime/src/tests/spill.rs index 95458541a..1e7f092bc 100644 --- a/crates/metal2vulkan-runtime/src/tests/spill.rs +++ b/crates/metal2vulkan-runtime/src/tests/spill.rs @@ -12,7 +12,7 @@ #[cfg(any(m2v_gpu, m2v_cpu_icd))] mod on_device { - use crate::tests::command::on_device::each_device; + use crate::tests::command::on_device::each_device_in_both_forms; use crate::tests::compute::on_device::WORDS; use crate::tests::managed::on_device::two_copy_rule; use crate::{MemoryClass, PixelFormat, TextureDescriptor, TextureType, TextureUsage}; @@ -30,7 +30,7 @@ mod on_device { #[test] fn every_device_spills_private_memory_out_of_device_memory() { - each_device("spill", |name, _, device| { + each_device_in_both_forms("spill", |name, _, device| { let core = device.core(); let counters = device.counters(); wait_until("a wholly free unit in each class", || { diff --git a/crates/metal2vulkan-runtime/src/tests/upload.rs b/crates/metal2vulkan-runtime/src/tests/upload.rs index f0bfa1e5a..014bdf43d 100644 --- a/crates/metal2vulkan-runtime/src/tests/upload.rs +++ b/crates/metal2vulkan-runtime/src/tests/upload.rs @@ -30,7 +30,7 @@ mod on_device { use crate::staging::REGION_LEN; use crate::submit::{HOMES_PRUNE, UPLOAD_BYTES, UPLOAD_ENTRIES}; use crate::tests::command::on_device::{ - behind_busy, each_device, finished, within, Busy, PATIENCE, + behind_busy, each_device, each_device_in_both_forms, finished, within, Busy, PATIENCE, }; use crate::tests::devices_of_the_cfgs_kind; use crate::{ @@ -703,7 +703,7 @@ mod on_device { #[test] fn every_device_counts_and_times_its_own_command_buffers() { use crate::tests::managed::on_device::new_managed; - each_device("own command buffers", |name, _, device| { + each_device_in_both_forms("own command buffers", |name, _, device| { let counters = device.counters(); let copies = !device.has_unified_memory(); let timed = cfg!(m2v_cpu_icd); diff --git a/docs/VALIDATION.md b/docs/VALIDATION.md index a4f83242a..f4ab29e3d 100644 --- a/docs/VALIDATION.md +++ b/docs/VALIDATION.md @@ -65,9 +65,10 @@ it with the import families filtered. A Managed buffer's two copies need no cfg. Under `m2v_cpu_icd` and `m2v_gpu` alike, the device tests of `metal2vulkan-runtime` whose work a Managed buffer's form decides (those of -`tests::managed` that make a Managed buffer, and those of `tests::copy_over`, `tests::blit` and -`tests::over` that read the device's form) run each device in its own form and, on a device that -keeps one copy (`Device::has_unified_memory` true: an integrated GPU, or lavapipe), once more +`tests::managed` that make a Managed buffer, and those of `tests::copy_over`, `tests::blit`, +`tests::over`, `tests::upload`, `tests::import`, `tests::spill`, `tests::sites`, `tests::gpu_span` +and `tests::resolve` that read the device's form) run each device in its own form and, on a device +that keeps one copy (`Device::has_unified_memory` true: an integrated GPU, or lavapipe), once more through the two-copy view (`DeviceOptions`'s test-only `two_copies`, read where the device decides its form; `tests::command::on_device::each_device_in_both_forms`). Through the view the device keeps a Private device copy of every Managed buffer, as a discrete GPU does, and