diff --git a/crates/metal2vulkan-runtime/src/tests/layer_claim.rs b/crates/metal2vulkan-runtime/src/tests/layer_claim.rs new file mode 100644 index 000000000..fa5afac2c --- /dev/null +++ b/crates/metal2vulkan-runtime/src/tests/layer_claim.rs @@ -0,0 +1,258 @@ +//! What a device test's claim that the validation layer reported nothing holds, from what the +//! device's instance enabled of the layers it asked for. +//! +//! A device opens although a layer its caller asked for is one the loader cannot provide +//! (`device/create.rs`, `tests/missing_layer.rs`): the creation drops the whole layer list, creates +//! the instance with none, and the device says as it is made which layers it was made without +//! ([`LAYERS_DROPPED`]). That is right for a caller that asked for a device and wrong for a claim: +//! a test that requires the validation layer to have reported nothing passes by reporting nothing +//! at all, on every host the loader can give it no layer. +//! +//! So a test states the claim against the instance's own answer ([`Watched::layer_reported_nothing`]): +//! where the layer was enabled the claim holds over everything the layer checks, and where it was +//! not the test says so in its own output (`LAYER-ABSENT `) rather than passing on an empty +//! list. The decision is the instance's alone -- never the loader's listing, which a layer it lists +//! and cannot load passes alike, and never the host or the driver's name. +//! +//! A device test: compiled only under the validation crate's GPU safety cfgs. + +use crate::device::create::LAYERS_DROPPED; +use crate::{DebugMessage, MessageSeverity, MessageSink}; +use std::ffi::{CStr, CString}; +use std::sync::{Arc, Mutex}; + +/// The validation layer, which this host may or may not provide. +pub(super) const VALIDATION: &CStr = c"VK_LAYER_KHRONOS_validation"; + +/// The id name the Vulkan loader gives the messages it reports itself. +const LOADER_MESSAGE: &str = "Loader Message"; + +/// What the loader's message about a layer it cannot provide names: the check it failed, and what +/// it found (`loader_validate_layers`, Vulkan-Loader `loader/loader.c`). +const VALIDATE_LAYERS: &str = "loader_validate_layers"; + +/// The rest of that message: the layer is none the loader lists. +const NOT_AVAILABLE: &str = "does not exist in the list of available layers"; + +/// Whether a message with this id name and text is the loader's own complaint about an instance +/// layer it cannot provide, and nothing wider. The loader reports it through the messenger chained +/// at `vkCreateInstance`, before the call answers `VK_ERROR_LAYER_NOT_PRESENT`. +fn loader_layer_message(id_name: &str, text: &str) -> bool { + id_name == LOADER_MESSAGE && text.contains(VALIDATE_LAYERS) && text.contains(NOT_AVAILABLE) +} + +/// What one message list holds. +#[derive(Default)] +struct Seen { + /// The messages that fail a run, bounded so a flood cannot grow without limit. + failing: Vec, + /// Whether a device reporting here announced it was made without the layers it asked for. + dropped: bool, + /// Whether a device reporting here asked for the validation layer. + asked: bool, +} + +/// The most messages kept of one list. +const MAX: usize = 64; + +/// The messages the devices of one test report, and what their instance enabled of the validation +/// layer they asked for. +#[derive(Clone, Default)] +pub(super) struct Watched(Arc>); + +impl Watched { + /// The instance layers a device reporting here asks for: the validation layer alone. The + /// loader may be unable to provide it, which the device itself says + /// ([`Watched::layer_reported_nothing`] reads that answer, not this list). + pub(super) fn layers(&self) -> Vec { + self.0.lock().unwrap_or_else(|p| p.into_inner()).asked = true; + vec![VALIDATION.to_owned()] + } + + /// A sink reporting here, which calls `also` with each message first: a test's own work on the + /// messages it watches for (a sentinel the sink owns, a line it prints). + pub(super) fn sink(&self, also: impl Fn(&DebugMessage) + Send + Sync + 'static) -> MessageSink { + let seen = Arc::clone(&self.0); + MessageSink::new(move |message: &DebugMessage| { + also(message); + let mut seen = seen.lock().unwrap_or_else(|p| p.into_inner()); + // What the instance enabled of the layers the device asked for: informational, so it + // fails nothing, and kept rather than dropped with the rest, since a claim of what the + // validation layer reported holds nothing without it. + if message.id_name == LAYERS_DROPPED { + seen.dropped = true; + return; + } + let fails = message.severity == MessageSeverity::Error + || (message.severity == MessageSeverity::Warning && message.kind.validation); + if fails && message.degradation.is_none() && seen.failing.len() < MAX { + seen.failing.push(message.clone()); + } + }) + } + + /// Require that the validation layer reported nothing of `claim` on the devices reporting + /// here, and say what that holds. + /// + /// Every message the layer reported fails here, as `assert!(failures.is_empty())` did. What + /// the claim then stands on is the instance's answer alone: where a device announced it was + /// made without the layer it asked for, there was nothing to report, so the claim was not + /// exercised and the test says so; the loader's own complaint about that same layer passes + /// with it, and nothing else does. + /// + /// # Panics + /// + /// Where the layer reported anything that fails a run. + pub(super) fn layer_reported_nothing(&self, claim: &str) { + let mut seen = self.0.lock().unwrap_or_else(|p| p.into_inner()); + let dropped = seen.dropped; + let asked = seen.asked; + let failing: Vec = seen + .failing + .split_off(0) + .into_iter() + // The device said it was made without the layer, which is what the loader complained + // about first and all it complained about. + .filter(|message| !(dropped && loader_layer_message(&message.id_name, &message.text))) + .collect(); + drop(seen); + assert!( + failing.is_empty(), + "{claim}: the validation layer reported\n{failing:#?}" + ); + if dropped || !asked { + eprintln!( + "LAYER-ABSENT {claim}: the device's instance enabled no validation layer, so it \ + reported nothing at all; the claim was not exercised here" + ); + } + } +} + +#[cfg(test)] +mod tests { + use super::{loader_layer_message, Watched, VALIDATION}; + use crate::device::create::LAYERS_DROPPED; + use crate::{DebugMessage, MessageKind, MessageSeverity}; + + /// A message of the layer's or the loader's, as the sink hears it. + fn message(severity: MessageSeverity, id_name: &str, text: &str) -> DebugMessage { + DebugMessage { + severity, + kind: MessageKind { + general: severity == MessageSeverity::Error, + validation: false, + performance: false, + }, + id_name: id_name.to_owned(), + id: 0, + text: text.to_owned(), + degradation: None, + } + } + + /// The loader's own complaint about the layer it cannot provide, and nothing wider. + #[test] + fn the_loader_s_message_about_a_layer_it_cannot_provide_is_matched_and_nothing_wider() { + assert!(loader_layer_message( + "Loader Message", + "loader_validate_layers: Layer 0 does not exist in the list of available layers" + )); + for (id_name, text) in [ + ( + "Loader Message", + "terminator_CreateInstance: Failed to CreateInstance in ICD 0", + ), + ( + "VUID-vkCreateInstance-ppEnabledLayerNames-01727", + "loader_validate_layers: Layer 0 does not exist in the list of available layers", + ), + ("Loader Message", "loader_validate_layers: Layer 0 is fine"), + ] { + assert!(!loader_layer_message(id_name, text), "{id_name}: {text}"); + } + } + + /// The message the loader sends about the layer it cannot provide. + fn loader_complaint() -> DebugMessage { + message( + MessageSeverity::Error, + "Loader Message", + "loader_validate_layers: Layer 0 does not exist in the list of available layers", + ) + } + + /// The message a device sends as it is made without the layers it asked for. + fn made_without() -> DebugMessage { + message( + MessageSeverity::Info, + LAYERS_DROPPED, + "metal2vulkan: the device was made without the instance layer(s) \ + VK_LAYER_KHRONOS_validation", + ) + } + + /// A list whose device asked for the validation layer and was made without it states no claim + /// of the layer's: the loader's own complaint about that layer passes, and the claim prints + /// that it was not exercised rather than passing on an empty list. Its own input: no device, + /// no loader, no host. + #[test] + fn a_claim_on_a_device_made_without_the_layer_is_not_exercised() { + let watched = Watched::default(); + assert_eq!(watched.layers(), [VALIDATION.to_owned()]); + let sink = watched.sink(|_| {}); + sink.deliver(&loader_complaint()); + sink.deliver(&made_without()); + watched.layer_reported_nothing("nothing of the layer's"); + } + + /// The loader's complaint fails where no device says it was made without the layer: a loader + /// that refused a layer nothing accounts for is not a clean run. + #[test] + #[should_panic(expected = "the validation layer reported")] + fn the_loader_s_complaint_fails_where_no_device_explains_it() { + let watched = Watched::default(); + let sink = watched.sink(|_| {}); + sink.deliver(&loader_complaint()); + watched.layer_reported_nothing("nothing of the layer's"); + } + + /// A list whose device enabled the layer it asked for and had it report nothing holds the + /// claim, and anything the layer did report fails it: the check is not vacuous either way. + #[test] + fn a_claim_holds_where_the_layer_was_enabled_and_fails_on_what_it_reported() { + let watched = Watched::default(); + assert_eq!(watched.layers(), [VALIDATION.to_owned()]); + let sink = watched.sink(|_| {}); + watched.layer_reported_nothing("every command was valid"); + sink.deliver(&message( + MessageSeverity::Error, + "VUID-vkCmdDraw-None-08600", + "a bound descriptor set was not valid", + )); + let failed = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + watched.layer_reported_nothing("every command was valid") + })); + assert!( + failed.is_err(), + "the claim held over a message the layer reported" + ); + } + + /// The test's own work on each message runs too, beside the list's. + #[test] + fn a_test_s_own_receiver_hears_every_message() { + use std::sync::atomic::{AtomicUsize, Ordering}; + use std::sync::Arc; + let heard = Arc::new(AtomicUsize::new(0)); + let counted = Arc::clone(&heard); + let watched = Watched::default(); + let sink = watched.sink(move |_| { + counted.fetch_add(1, Ordering::Relaxed); + }); + sink.deliver(&made_without()); + sink.deliver(&loader_complaint()); + assert_eq!(heard.load(Ordering::Relaxed), 2); + watched.layer_reported_nothing("nothing of the layer's"); + } +} diff --git a/crates/metal2vulkan-runtime/src/tests/mod.rs b/crates/metal2vulkan-runtime/src/tests/mod.rs index 1c4a24bba..c00755eee 100644 --- a/crates/metal2vulkan-runtime/src/tests/mod.rs +++ b/crates/metal2vulkan-runtime/src/tests/mod.rs @@ -127,6 +127,8 @@ mod keeper; mod kept_barriers; #[cfg(any(m2v_gpu, m2v_cpu_icd))] mod kept_images; +#[cfg(any(m2v_gpu, m2v_cpu_icd))] +mod layer_claim; mod left; mod linear_attachment; mod linear_plan; diff --git a/crates/metal2vulkan-runtime/src/tests/srgb_fetch_images.rs b/crates/metal2vulkan-runtime/src/tests/srgb_fetch_images.rs index 118919396..217aad91b 100644 --- a/crates/metal2vulkan-runtime/src/tests/srgb_fetch_images.rs +++ b/crates/metal2vulkan-runtime/src/tests/srgb_fetch_images.rs @@ -13,12 +13,14 @@ //! which the fetching draws' storage view of them takes. //! //! 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, under the validation layer where the -//! loader lists it: a view the image does not take, or a view whose usage its format lacks, is a -//! failing message. +//! `m2v_cpu_icd`), on the kind of device the cfg selects, asking for the validation layer: a view +//! the image does not take, or a view whose usage its format lacks, is a failing message. What the +//! claim of the layer's silence holds is what the device's instance enabled of the layer it asked +//! for (`tests/layer_claim.rs`), so a host the loader can give it no layer says so rather than +//! passing on an empty message list. +use super::layer_claim::Watched; use crate::attachment_stand_in::stand_in; -use crate::device::lock; use crate::framebuffer_fetch::{ storage_view_format, stores_samples, through_multisampled_storage, through_planes, views_in, }; @@ -27,15 +29,13 @@ use crate::render_pass::Target; use crate::render_target::{color_view, storage_view_in}; use crate::sample_planes::Planes; use crate::{ - DebugMessage, Device, DeviceKind, DeviceOptions, MessageSeverity, MessageSink, ResourceOptions, - ShaderCacheOptions, Texture, TextureDescriptor, + Device, DeviceKind, DeviceOptions, ResourceOptions, ShaderCacheOptions, Texture, + TextureDescriptor, }; use metal2vulkan::device::FormatUsage; use metal2vulkan::metal::{PixelFormat, TextureType, TextureUsage}; use metal2vulkan::vk::{Format, ImageCreateFlags, ImageUsageFlags}; -use std::ffi::CString; use std::path::{Path, PathBuf}; -use std::sync::{Arc, Mutex}; /// The attachments' side, and the multisampled one's samples. const SIDE: u32 = 16; @@ -65,30 +65,12 @@ impl Drop for Scratch { } } -/// The validation layer's name, where the loader lists it. -fn validation_layer() -> Option { - let name = c"VK_LAYER_KHRONOS_validation"; - let entry = crate::device::create::open_loader(None).ok()?; - // SAFETY: the loader is open; listing its layers needs nothing else. - let layers = unsafe { entry.enumerate_instance_layer_properties() }.ok()?; - layers - .iter() - .any(|layer| layer.layer_name_as_c_str().is_ok_and(|n| n == name)) - .then(|| name.to_owned()) -} - -/// The device the cfg selects, its shader cache in `cache`, under the validation layer where the -/// loader lists it, and the failing messages it reports. -fn watched(cache: &Path) -> (Device, Arc>>) { - let failures = Arc::new(Mutex::new(Vec::new())); - let reported = Arc::clone(&failures); - let sink = MessageSink::new(move |message: &DebugMessage| { - let fails = message.severity == MessageSeverity::Error - || (message.severity == MessageSeverity::Warning && message.kind.validation); - if fails && message.degradation.is_none() { - lock(&reported).push(format!("{}: {}", message.id_name, message.text)); - } - }); +/// The device the cfg selects, its shader cache in `cache`, asking for the validation layer, and +/// what its instance had the layer report ([`Watched::layer_reported_nothing`] says what a claim +/// of its silence holds; the instance's own answer, never the loader's listing). +fn watched(cache: &Path) -> (Device, Watched) { + let watched = Watched::default(); + let sink = watched.sink(|_| {}); let options = DeviceOptions { kinds: match cfg!(m2v_cpu_icd) { true => vec![DeviceKind::Cpu], @@ -102,12 +84,12 @@ fn watched(cache: &Path) -> (Device, Arc>>) { directory: Some(cache.to_owned()), ..ShaderCacheOptions::default() }, - layers: validation_layer().into_iter().collect(), + layers: watched.layers(), messages: Some(sink), ..DeviceOptions::default() }; let device = Device::system_default_with(&options).unwrap(); - (device, failures) + (device, watched) } /// A private 2D texture of `pf`, `SIDE` square, of `samples` and `usage`. @@ -155,7 +137,7 @@ fn mutable_to(plan: &ImagePlan, format: Format, view: Format) -> bool { #[test] fn an_srgb_attachment_is_fetched_through_its_unsigned_integer_view() { let cache = Scratch::new(); - let (device, failures) = watched(&cache.0); + let (device, watched) = watched(&cache.0); // The command buffer whose encoder would make the scratch images. let queue = device.new_command_queue().unwrap(); let maker = queue.command_buffer().unwrap(); @@ -236,6 +218,5 @@ fn an_srgb_attachment_is_fetched_through_its_unsigned_integer_view() { {planes} sample planes" ); drop((maker, queue, device)); - let failures = lock(&failures); - assert!(failures.is_empty(), "failing messages: {:#?}", *failures); + watched.layer_reported_nothing("every fetch image's commands were valid and nothing leaked"); } diff --git a/crates/metal2vulkan-runtime/src/tests/teardown_threads.rs b/crates/metal2vulkan-runtime/src/tests/teardown_threads.rs index 9fb1d362f..ad9cf5a36 100644 --- a/crates/metal2vulkan-runtime/src/tests/teardown_threads.rs +++ b/crates/metal2vulkan-runtime/src/tests/teardown_threads.rs @@ -5,8 +5,9 @@ //! gates the test opens, never a timing: the program drops every handle while the runtime holds the //! device through one path, the device is checked to be still alive, the gate opens, and the //! teardown must end, on the thread the path lets go on, with no message (the validation layer, -//! where the loader lists it, reports a destroyed object used, an object destroyed twice, or one -//! the teardown left). +//! which the device asks for, reports a destroyed object used, an object destroyed twice, or one +//! the teardown left; what the claim of its silence holds is what the instance enabled of it, +//! `tests/layer_claim.rs`). //! //! - **Not a pool thread**: a draw's making held waiting in the pool (`pool::held`) holds nothing //! of the device, whose last handle goes on the program's thread; one held while it runs @@ -52,6 +53,7 @@ use super::dispatch_pending as pending; use super::freed_memory::{unused, Host, Runs}; +use super::layer_claim::Watched; use crate::device::lock; use crate::device::prime::SHADER; use crate::exit_guard; @@ -59,14 +61,12 @@ use crate::pipeline::objects::{shader_module, words_digest}; use crate::pipeline::pool::held; use crate::trails::blocked; use crate::{ - Buffer, ClearColor, CommandBufferStatus, DebugMessage, Device, DeviceKind, DeviceOptions, - LoadAction, MessageSeverity, MessageSink, PipelineOptions, RenderPassDescriptor, - RenderPipelineState, ResourceOptions, ShaderCacheOptions, Size, StoreAction, Submission, - TextureDescriptor, + Buffer, ClearColor, CommandBufferStatus, Device, DeviceKind, DeviceOptions, LoadAction, + PipelineOptions, RenderPassDescriptor, RenderPipelineState, ResourceOptions, + ShaderCacheOptions, Size, StoreAction, Submission, TextureDescriptor, }; use metal2vulkan::metal::{PixelFormat, PrimitiveType, TextureUsage}; use metal2vulkan::pipeline::{ColorAttachmentDescriptor, RenderPipelineDescriptor, StageSource}; -use std::ffi::CString; use std::path::{Path, PathBuf}; use std::sync::atomic::Ordering; use std::sync::mpsc::{self, TryRecvError}; @@ -119,10 +119,11 @@ impl Drop for Ended { } } -/// A watched device's teardown: the thread it ends on, and the failing messages it reported. +/// A watched device's teardown: the thread it ends on, and what its instance had the validation +/// layer report ([`Watched`], which says what a claim of its silence holds). struct Ending { thread: mpsc::Receiver, - failures: Arc>>, + watched: Watched, } impl Ending { @@ -143,8 +144,8 @@ impl Ending { Ok(program_thread()), "the device was not torn down on this thread before its last drop returned" ); - let failures = lock(&self.failures); - assert!(failures.is_empty(), "failing messages: {:#?}", *failures); + self.watched + .layer_reported_nothing("the teardown that ended here left no object and used none"); } /// The teardown ends, on one of `threads`, and nothing failed meanwhile. @@ -157,38 +158,22 @@ impl Ending { threads.contains(&thread.as_str()), "the device's teardown ended on {thread}, not on one of {threads:?}" ); - let failures = lock(&self.failures); - assert!(failures.is_empty(), "failing messages: {:#?}", *failures); + self.watched.layer_reported_nothing(&format!( + "the teardown that ended on {thread} left no object and used none" + )); } } -/// The validation layer's name, where the loader lists it. -fn validation_layer() -> Option { - let name = c"VK_LAYER_KHRONOS_validation"; - let entry = crate::device::create::open_loader(None).ok()?; - // SAFETY: the loader is open; listing its layers needs nothing else. - let layers = unsafe { entry.enumerate_instance_layer_properties() }.ok()?; - layers - .iter() - .any(|layer| layer.layer_name_as_c_str().is_ok_and(|n| n == name)) - .then(|| name.to_owned()) -} - -/// The device the cfg selects, its shader cache in `cache`, under the validation layer where the -/// loader lists it, reporting to a sink that sees its teardown end. +/// The device the cfg selects, its shader cache in `cache`, asking for the validation layer, and +/// reporting to a sink that sees its teardown end. What a claim of the layer's silence holds is +/// the instance's own answer ([`Watched::layer_reported_nothing`]), never the loader's listing. fn watched(cache: &Path) -> (Device, Ending) { let (sender, thread) = mpsc::channel(); let ended = Ended(sender); - let failures = Arc::new(Mutex::new(Vec::new())); - let reported = Arc::clone(&failures); - let sink = MessageSink::new(move |message: &DebugMessage| { + let watched = Watched::default(); + let sink = watched.sink(move |_| { // The sink owns the sentinel, which goes with its last share, the instance's. let _ = &ended; - let fails = message.severity == MessageSeverity::Error - || (message.severity == MessageSeverity::Warning && message.kind.validation); - if fails && message.degradation.is_none() { - lock(&reported).push(format!("{}: {}", message.id_name, message.text)); - } }); let options = DeviceOptions { kinds: match cfg!(m2v_cpu_icd) { @@ -203,13 +188,13 @@ fn watched(cache: &Path) -> (Device, Ending) { directory: Some(cache.to_owned()), ..ShaderCacheOptions::default() }, - layers: validation_layer().into_iter().collect(), + layers: watched.layers(), messages: Some(sink), ..DeviceOptions::default() }; // The options' share of the sink goes as this returns: the instance's is the last. let device = Device::system_default_with(&options).unwrap(); - (device, Ending { thread, failures }) + (device, Ending { thread, watched }) } /// The fixture's render pipeline state: `colored_vertex` and `colored_fragment`, one @@ -513,8 +498,9 @@ fn the_watch_of_the_program_s_marks_leaves_the_device_to_the_program_s_thread() Ok(program_thread()), "the device was not torn down on this thread before its last drop returned" ); - let failures = lock(&ending.failures); - assert!(failures.is_empty(), "failing messages: {:#?}", *failures); + ending + .watched + .layer_reported_nothing("the teardown that ended here left no object and used none"); } /// A released host import's block waits for the program's mark, which only the held watch sees; @@ -564,7 +550,8 @@ fn a_release_of_freed_memory_leaves_the_device_to_the_program_s_thread() { 1, "the teardown freed the block and ran its deallocator" ); - let failures = lock(&ending.failures); - assert!(failures.is_empty(), "failing messages: {:#?}", *failures); + ending + .watched + .layer_reported_nothing("the teardown that freed the block left no object and used none"); drop(host); } diff --git a/crates/metal2vulkan-validation/src/candidate/engine/runtime_run/tests.rs b/crates/metal2vulkan-validation/src/candidate/engine/runtime_run/tests.rs index 0aca89e17..847702c0d 100644 --- a/crates/metal2vulkan-validation/src/candidate/engine/runtime_run/tests.rs +++ b/crates/metal2vulkan-validation/src/candidate/engine/runtime_run/tests.rs @@ -1,6 +1,8 @@ //! The runtime path's routing, device-free, over the committed public cases. use super::*; +#[cfg(any(m2v_gpu, m2v_cpu_icd))] +use crate::candidate::runtime_case::layer_reported_nothing_at_all; use crate::check::admission::{admit, ExecutionRequest}; use crate::gpu::DeviceType; use crate::store::CorpusStore; @@ -966,11 +968,7 @@ fn the_runtime_path_calls_the_functions_its_tables_hold() { }; assert!(matches!(unlinked, CaseError::Case(_)), "{unlinked}"); } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// The engine's candidate draws each owned object and mesh case through the runtime's mesh path diff --git a/crates/metal2vulkan-validation/src/candidate/runtime_case.rs b/crates/metal2vulkan-validation/src/candidate/runtime_case.rs index f5403264d..c6380b2b3 100644 --- a/crates/metal2vulkan-validation/src/candidate/runtime_case.rs +++ b/crates/metal2vulkan-validation/src/candidate/runtime_case.rs @@ -95,7 +95,10 @@ pub use commands::{encoded_execution, pipeline_states, CaseCommands, TemplateSta /// (`runtime_lane::creation_heard_checked`). #[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))] pub(crate) use layer_claim::loader_layer_message; -pub use layer_claim::{layer_reported_nothing, EnabledLayers, LayerClaim, LAYERS_DROPPED}; +pub use layer_claim::{ + layer_reported_nothing, layer_reported_nothing_at_all, nothing_reported_without_the_layer, + EnabledLayers, LayerClaim, LAYERS_DROPPED, +}; pub use render::{ commit_render, encoded_mesh, encoded_render, mesh_pipeline_state, render_pipeline_descriptor, render_pipeline_state, CommittedRender, EncodedRender, MeshInputs, RenderInputs, diff --git a/crates/metal2vulkan-validation/src/candidate/runtime_case/layer_claim.rs b/crates/metal2vulkan-validation/src/candidate/runtime_case/layer_claim.rs index 27998ed3a..524e2d0e8 100644 --- a/crates/metal2vulkan-validation/src/candidate/runtime_case/layer_claim.rs +++ b/crates/metal2vulkan-validation/src/candidate/runtime_case/layer_claim.rs @@ -126,15 +126,70 @@ impl LayerClaim { /// alone ([`EnabledLayers`]): [`LayerClaim::Held`] where the layer was enabled, else a claim that /// was not exercised, printed on stderr with the test's name. /// +/// For a claim no narrower than the layer's own silence, [`layer_reported_nothing_at_all`]. +/// /// # Panics /// /// Where the layer reported anything that fails a run. pub fn layer_reported_nothing(messages: &Messages, claim: &str) -> LayerClaim { + stated(messages, claim, &format!("{claim}: "), LAYER) +} + +/// What a lane states where it names no claim narrower than the layer's own silence: that the +/// validation layer reported nothing at all of the work the test did up to here. Named in the line +/// a layerless device prints, where the test's own name says the rest ([`LayerFacts::claim`]). +const NOTHING_AT_ALL: &str = "the validation layer reported nothing of the work so far"; + +/// Require that the validation layer reported nothing at all of the work the devices reporting to +/// `messages` did, and say what that holds ([`layer_reported_nothing`] of the lane's widest +/// claim). +/// +/// The claim the lane states oftenest, and exactly what `assert!(messages.take().is_empty())` +/// stated: whatever the layer checked of the work so far, it reported nothing of it. A test that +/// holds something narrower names it ([`layer_reported_nothing`]); the claim's words change +/// nothing of what fails, every message failing either way, and say which claim a layerless +/// device could not exercise. +/// +/// # Panics +/// +/// Where the layer reported anything that fails a run. +pub fn layer_reported_nothing_at_all(messages: &Messages) -> LayerClaim { + stated(messages, NOTHING_AT_ALL, "", LAYER) +} + +/// Require that the devices reporting to `messages` reported nothing of `claim` that fails, where +/// they asked for no validation layer: a device a test makes without it, so that what reaches the +/// list is the driver's own and the runtime's. The layer's absence takes nothing from such a +/// claim, and the claim is [`LayerClaim::NoLayerAsked`]. +/// +/// # Panics +/// +/// Where anything reported fails a run, and where such a device did ask for the validation layer: +/// then the claim is the layer's after all, and [`layer_reported_nothing`] is how it is stated. +pub fn nothing_reported_without_the_layer(messages: &Messages, claim: &str) -> LayerClaim { + let asked = messages.enabled_layers(); + assert!( + !asked + .asked() + .iter() + .any(|name| name.as_c_str() == super::VALIDATION_LAYER), + "{claim}: the device asked for the validation layer, so the claim is the layer's" + ); + stated(messages, claim, &format!("{claim}: "), "the device") +} + +/// What a claim names as having reported nothing, where the validation layer is what would have. +const LAYER: &str = "the validation layer"; + +/// Take what the devices reporting to `messages` reported, state `claim` against what their +/// instance enabled, and fail on anything reported, the failure led by `lead` and naming +/// `reporter` as what reported. +fn stated(messages: &Messages, claim: &str, lead: &str, reporter: &str) -> LayerClaim { let reported = messages.take(); let stated = messages.state_layer_claim(claim); assert!( reported.is_empty(), - "{claim}: the validation layer reported\n{reported:#?}" + "{lead}{reporter} reported\n{reported:#?}" ); stated } @@ -291,7 +346,10 @@ impl LayerFacts { #[cfg(test)] mod tests { - use super::{layer_reported_nothing, LayerClaim, LAYERS_DROPPED}; + use super::{ + layer_reported_nothing, layer_reported_nothing_at_all, nothing_reported_without_the_layer, + LayerClaim, LAYERS_DROPPED, + }; use crate::candidate::runtime_case::{Messages, VALIDATION_LAYER}; use std::ffi::CString; @@ -364,6 +422,63 @@ mod tests { assert!(claim.exercised()); } + /// The widest claim, which no test names ([`layer_reported_nothing_at_all`], the one the lane + /// states oftenest), is not exercised either where the layer was dropped: so the 300-odd lane + /// sites that asserted `messages.take()` was empty and said no more now say so instead of + /// passing on a list that could report nothing at all. + #[test] + fn the_widest_claim_is_not_exercised_where_the_layer_was_dropped() { + let messages = layerless(); + assert_eq!( + messages.take(), + Vec::new(), + "the layerless list reports nothing at all" + ); + assert_eq!( + layer_reported_nothing_at_all(&messages), + LayerClaim::NotExercised { + dropped: vec![VALIDATION_LAYER.to_string_lossy().into_owned()], + }, + "the widest claim with no layer present must say it was not exercised" + ); + assert!(!layer_reported_nothing_at_all(&messages).exercised()); + } + + /// The same claim on a list whose device enabled the layer holds. + #[test] + fn the_widest_claim_holds_where_the_layer_was_enabled() { + let messages = Messages::default(); + messages.device_asked_layers(&[VALIDATION_LAYER.to_owned()]); + let claim = layer_reported_nothing_at_all(&messages); + assert_eq!(claim, LayerClaim::Held); + assert!(claim.exercised()); + } + + /// A claim a test states of a device it made without the validation layer + /// ([`nothing_reported_without_the_layer`]: the driver's own messages and the runtime's) is + /// none of the layer's, and the layer's absence takes nothing from it. + #[test] + fn a_claim_of_what_a_layerless_device_reported_is_none_of_the_layer_s() { + let messages = Messages::default(); + messages.device_asked_layers(&[]); + assert_eq!( + nothing_reported_without_the_layer(&messages, "nothing the driver said fails"), + LayerClaim::NoLayerAsked + ); + } + + /// The same claim on a device that did ask for the validation layer fails: then what reaches + /// the list is the layer's, and the claim is the layer's to state + /// ([`layer_reported_nothing`]), so a test that stops clearing its device's layers cannot + /// keep the weaker statement. + #[test] + #[should_panic(expected = "the device asked for the validation layer")] + fn a_layerless_claim_on_a_device_that_asked_for_the_layer_fails() { + let messages = Messages::default(); + messages.device_asked_layers(&[VALIDATION_LAYER.to_owned()]); + nothing_reported_without_the_layer(&messages, "nothing the driver said fails"); + } + /// A device a test makes with no layer at all, to time it, states no claim of the layer's. #[test] fn a_device_that_asked_for_no_layer_states_no_claim_of_the_layer_s() { diff --git a/crates/metal2vulkan-validation/src/parity/lane.rs b/crates/metal2vulkan-validation/src/parity/lane.rs index 976dfa232..38947b6b8 100644 --- a/crates/metal2vulkan-validation/src/parity/lane.rs +++ b/crates/metal2vulkan-validation/src/parity/lane.rs @@ -8,6 +8,7 @@ use super::api::Observation; use super::record::{compare, read_lines, Value}; use super::runtime::RuntimeApi; use super::{fingerprint, records_path, scenarios, Scenario, SCENARIOS}; +use crate::candidate::runtime_case::layer_reported_nothing; use crate::runtime_lane::METAL_ENVIRONMENT; /// Run every case of `scenario` on the runtime, each on a device of its own, and compare the @@ -34,7 +35,9 @@ fn matches_metal(name: &str) { ); } -/// One case's records on a runtime device, which reported no validation message. +/// One case's records on a runtime device, which reported no validation message +/// ([`layer_reported_nothing`], so a device the loader could not give the layer to says in the +/// test's output that the claim was not exercised there). fn run_on_runtime(scenario: &Scenario, case: &'static str) -> Result, String> { let api = RuntimeApi::open()?; let mut observation = Observation::new(case, false); @@ -42,15 +45,8 @@ fn run_on_runtime(scenario: &Scenario, case: &'static str) -> Result = counts(&messages.take_notices()).into_keys().collect(); println!("ANISOTROPIC {name}: announced {announced:?}"); let mut wrong = Vec::new(); diff --git a/crates/metal2vulkan-validation/src/runtime_lane/argument_buffers.rs b/crates/metal2vulkan-validation/src/runtime_lane/argument_buffers.rs index aaad23a74..12b33d14a 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/argument_buffers.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/argument_buffers.rs @@ -15,8 +15,9 @@ use super::kernel_textures::{absent_read_only, fresh_candidate, refusal}; use super::{ - bound_buffers, buffer_with, encode_case, pipeline_state, public_case, public_cases, - read_buffer, run_case, validated_device, CaseResources, Messages, ScratchCache, + bound_buffers, buffer_with, encode_case, layer_reported_nothing, layer_reported_nothing_at_all, + pipeline_state, public_case, public_cases, read_buffer, run_case, validated_device, + CaseResources, Messages, ScratchCache, }; use crate::candidate::engine::ComputeOutput; use crate::case::{AuthoredCase, Stage}; @@ -49,11 +50,7 @@ fn on_device(test: impl FnOnce(&Device)) { let device = validated_device(TEST_DEVICE, &messages, cache.path()).unwrap(); test(&device); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// Every committed public kernel case whose argument buffers hold buffers runs through the @@ -160,6 +157,10 @@ fn census(what: &str, select: impl Fn(&AuthoredCase) -> bool) -> Census { "failed:\n{}\nat device destruction: {leaked:#?}", failed.join("\n") ); + layer_reported_nothing( + &messages, + "every case's commands were valid and left nothing behind", + ); Census { matched: matched.len(), } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/argument_linear_samples.rs b/crates/metal2vulkan-validation/src/runtime_lane/argument_linear_samples.rs index ed456e099..a6d66b7f3 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/argument_linear_samples.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/argument_linear_samples.rs @@ -24,7 +24,7 @@ //! by its class and a heap texture's not. use super::depth_compares::{pipeline_of, run_held, Held, Through}; -use super::{validated_device, Messages, ScratchCache}; +use super::{layer_reported_nothing_at_all, validated_device, Messages, ScratchCache}; use crate::gpu::TEST_DEVICE; use metal2vulkan::bind::SamplerDescriptor; use metal2vulkan::error::DriverDeviation; @@ -510,5 +510,5 @@ fn heap_linear_samples_answer_as_slot_samples() { groups.join("\n") ); } - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/attachmentless.rs b/crates/metal2vulkan-validation/src/runtime_lane/attachmentless.rs index bff924902..b98f366eb 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/attachmentless.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/attachmentless.rs @@ -7,7 +7,10 @@ //! device keeps for its sample count (`runtime/attachmentless.rs`); MoltenVK rasterized one sample //! in a pass made per encoder. -use super::{buffer_with, read_buffer, validated_device, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, layer_reported_nothing_at_all, read_buffer, validated_device, Messages, + ScratchCache, WAIT, +}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::metal::PrimitiveType; @@ -121,11 +124,7 @@ fn a_pass_without_attachments_rasterizes_its_default_sample_count() { } eprintln!("attachmentless passes on {name}: {}", answers.join("; ")); } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// What one command buffer on `queue` leaves: a blit filling mark 0 with `0x11`, a signal of @@ -270,11 +269,7 @@ fn a_pass_without_attachments_past_16384_fails_its_command_buffer() { assert_eq!(events, [1, 0], "{size:?}: the signal before the pass alone"); } } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// A pass without attachments at a default raster sample count other than 1, 2 and 4 is Metal's @@ -352,9 +347,5 @@ fn a_pass_without_attachments_takes_metal_s_default_sample_counts() { device.name() ); } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/barycentric_weights.rs b/crates/metal2vulkan-validation/src/runtime_lane/barycentric_weights.rs index 0fc8722da..c3f055de5 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/barycentric_weights.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/barycentric_weights.rs @@ -25,7 +25,9 @@ //! with neither way, such as the `vk12-floor` profile's, refuses the functions as needing either //! `fragmentShaderBarycentric` or `geometryShader`. -use super::{buffer_with, validated_device_with, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, layer_reported_nothing_at_all, validated_device_with, Messages, ScratchCache, WAIT, +}; use crate::air_library::AirLibrary; use crate::candidate::LaneRestriction; use crate::gpu::TEST_DEVICE; @@ -377,11 +379,7 @@ fn on_lane(adjust: impl FnOnce(&mut DeviceOptions), check: impl FnOnce(&Lane)) { let lane = Lane::with(&messages, &cache, adjust); check(&lane); drop(lane); - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// `check` on the lane device of `path`. @@ -667,11 +665,7 @@ fn a_pipeline_with_a_geometry_stage_announces_it_and_one_without_does_not() { } ); drop(lane); - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/binary_archives.rs b/crates/metal2vulkan-validation/src/runtime_lane/binary_archives.rs index 4fc7cfec4..76ee5b562 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/binary_archives.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/binary_archives.rs @@ -17,7 +17,8 @@ use super::degrade_notices::assert_once; use super::render_state::{library, Probe, PASS}; use super::{ - compute_descriptor, pipeline_state, public_case, validated_device, Messages, ScratchCache, + compute_descriptor, layer_reported_nothing_at_all, pipeline_state, public_case, + validated_device, Messages, ScratchCache, }; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; @@ -257,9 +258,5 @@ fn an_archive_serves_a_fresh_device_and_fails_where_metal_misses() { ))) ); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/blits.rs b/crates/metal2vulkan-validation/src/runtime_lane/blits.rs index c8200b5d5..0666b866a 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/blits.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/blits.rs @@ -7,8 +7,9 @@ use super::degrade_notices::{assert_once, counts}; use super::{ - buffer_with, buffer_with_options, encode_case, pipeline_state, public_case, read_buffer, - validated_device, CaseResources, Messages, ScratchCache, + buffer_with, buffer_with_options, encode_case, layer_reported_nothing, + layer_reported_nothing_at_all, pipeline_state, public_case, read_buffer, validated_device, + CaseResources, Messages, ScratchCache, }; use crate::gpu::TEST_DEVICE; use metal2vulkan_runtime::{ @@ -102,11 +103,7 @@ fn on_device_with(test: impl FnOnce(&Device, &Messages)) { let device = validated_device(TEST_DEVICE, &messages, cache.path()).unwrap(); test(&device, &messages); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// Copies and fills of any offsets and sizes land exactly where Metal puts them, within one @@ -743,11 +740,7 @@ fn compute_blit_compute_chains_read_what_was_written() { command_buffer.wait_until_completed_for(WAIT).unwrap(); assert_eq!(command_buffer.error(), None, "{leg}"); } - let reported = messages.take(); - assert!( - reported.is_empty(), - "{leg}: the validation layer reported: {reported:#?}" - ); + layer_reported_nothing(messages, &leg); for (chain, (first, second)) in chains.iter().enumerate() { let written = read_buffer(&first[&1], 0, output).unwrap(); assert_eq!(written, case.metal_output, "{leg}, chain {chain}: first"); diff --git a/crates/metal2vulkan-validation/src/runtime_lane/buffer_depth_samples.rs b/crates/metal2vulkan-validation/src/runtime_lane/buffer_depth_samples.rs index c65435cb6..1ea37d7ea 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/buffer_depth_samples.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/buffer_depth_samples.rs @@ -41,7 +41,10 @@ use super::degrade_notices::{assert_made_once, forced, loses_depth_denormals, signs_depth_tests}; use super::degrade_notices::{made_compute_kinds, shared_in_system_memory}; -use super::{buffer_with, read_buffer, validated_device, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, layer_reported_nothing_at_all, read_buffer, validated_device, Messages, + ScratchCache, WAIT, +}; use crate::candidate::runtime_samples::{encode, read_function}; use crate::executor_contract::multisample::SampleRead; use crate::gpu::TEST_DEVICE; @@ -542,9 +545,5 @@ fn a_buffer_copies_every_sample_of_a_multisampled_depth_or_stencil_both_ways() { {announced:?}" ); } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/buffer_texture_blits.rs b/crates/metal2vulkan-validation/src/runtime_lane/buffer_texture_blits.rs index 8e20249fb..7dc8a14c0 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/buffer_texture_blits.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/buffer_texture_blits.rs @@ -11,7 +11,10 @@ use super::degrade_notices::{assert_made_once, forced, shared_in_system_memory}; use super::host_memory::{no_copy, not_importable, Mapping}; -use super::{buffer_with, read_buffer, validated_device, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, layer_reported_nothing_at_all, read_buffer, validated_device, Messages, + ScratchCache, WAIT, +}; use crate::gpu::TEST_DEVICE; use ash::vk; use metal2vulkan::metal::{PixelFormat, TextureType, TextureUsage}; @@ -376,11 +379,7 @@ fn on_device(test: impl FnOnce(&Device)) { let device = validated_device(TEST_DEVICE, &messages, cache.path()).unwrap(); test(&device); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// The rows a Metal probe recorded (M4 and M3 Max alike) for its overlapping copies at 32-byte @@ -909,11 +908,7 @@ fn an_overlapping_texel_copy_is_announced_once() { ]); assert_made_once(&messages, &OVERLAPS, &first); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// The kind [`iosurface_planes_lie_where_metal_puts_them`] takes: a texture of an IOSurface plane @@ -1002,11 +997,7 @@ fn iosurface_planes_lie_where_metal_puts_them() { ]); assert_made_once(&messages, &NARROW_ROWS, &first); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// A depth or stencil texture over a plane of a surface with planes, which Metal makes and @@ -1143,11 +1134,7 @@ fn a_planar_surface_s_depth_or_stencil_texture_reads_and_stores_the_plane() { } } } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// Where Metal's pass puts element `(x, y)` of a `w`x`h` depth or stencil texture of `unit`-byte @@ -1402,11 +1389,7 @@ fn a_planar_surface_s_depth_or_stencil_texture_s_passes_write_metal_s_elements_a } } } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// The rows of a `w`x`h` plane `row` bytes wide, from `offset`, `pitch` bytes apart. @@ -1621,11 +1604,7 @@ fn four_two_two_iosurface_planes_move_the_surface_s_rows() { } } } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// The consumer's '420v' backing over a new buffer of `kind` ([`iosurface_planes_lie_where_metal_puts_them`]): diff --git a/crates/metal2vulkan-validation/src/runtime_lane/buffer_texture_order.rs b/crates/metal2vulkan-validation/src/runtime_lane/buffer_texture_order.rs index af788938e..d770bc1c5 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/buffer_texture_order.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/buffer_texture_order.rs @@ -11,8 +11,9 @@ use super::degrade_notices::counts; use super::{ - buffer_with, encode_case, pipeline_state, public_case, read_buffer, run_case, - texture_descriptor, validated_device, CaseResources, Messages, PublicCase, ScratchCache, WAIT, + buffer_with, encode_case, layer_reported_nothing_at_all, pipeline_state, public_case, + read_buffer, run_case, texture_descriptor, validated_device, CaseResources, Messages, + PublicCase, ScratchCache, WAIT, }; use crate::candidate::engine::ComputeOutput; use crate::case::TextureType; @@ -51,11 +52,7 @@ fn on_device(test: impl FnOnce(&Device)) { let device = validated_device(TEST_DEVICE, &messages, cache.path()).unwrap(); test(&device); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// A binding of a case: its texture or buffer at a slot. @@ -462,11 +459,7 @@ fn textures_over_buffers_alias_where_the_device_lays_them_as_metal_does() { } let shadowed = counts(&messages.take_notices()).contains_key(&Degradation::ShadowedTexture); forms.push((width, row, if shadowed { "shadowed" } else { "aliased" })); - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } eprintln!("textures over buffers on {name}: {forms:?}"); assert_eq!( @@ -547,11 +540,7 @@ fn with_undeclared_usage(name: &str, usage: TextureUsage, width: u64, pad: u64) let notices = counts(&messages.take_notices()); let shadowed = notices.contains_key(&Degradation::ShadowedTexture) || notices.contains_key(&Degradation::UndeclaredUsageShadow); - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); shadowed } @@ -682,11 +671,7 @@ fn beyond_usage(name: &str, usage: TextureUsage) -> (Vec, Vec, bool) { }; let shadowed = counts(&messages.take_notices()).contains_key(&Degradation::UndeclaredUsageShadow); - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); (ran.0, ran.1, shadowed) } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/buffer_texture_renders.rs b/crates/metal2vulkan-validation/src/runtime_lane/buffer_texture_renders.rs index de0228e99..9885da042 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/buffer_texture_renders.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/buffer_texture_renders.rs @@ -29,7 +29,10 @@ use super::buffer_texture_blits::{hex_rows, texel, texels, Held, Kind, OFF}; use super::degrade_notices::counts; -use super::{buffer_with, read_buffer, validated_device, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, layer_reported_nothing_at_all, read_buffer, validated_device, Messages, + ScratchCache, WAIT, +}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::bind::SamplerDescriptor; @@ -341,11 +344,7 @@ fn on_device(test: impl FnOnce(&Device)) { let device = validated_device(TEST_DEVICE, &messages, cache.path()).unwrap(); test(&device); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// Run `cases` over each kind of buffer the device makes. @@ -940,11 +939,7 @@ fn a_command_writing_a_buffers_bytes_two_ways_keeps_both_writes() { device.name() ); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } fn two_ways(lane: &Lane, kind: Kind) { diff --git a/crates/metal2vulkan-validation/src/runtime_lane/buffer_textures.rs b/crates/metal2vulkan-validation/src/runtime_lane/buffer_textures.rs index e59eea840..047389f66 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/buffer_textures.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/buffer_textures.rs @@ -6,8 +6,9 @@ //! ordering against other uses of the bytes is `buffer_texture_order.rs`'s. use super::{ - bound_buffers, buffer_with, encode_case, pipeline_state, public_case, read_buffer, run_case, - texture_descriptor, validated_device, CaseResources, Messages, ScratchCache, WAIT, + bound_buffers, buffer_with, encode_case, layer_reported_nothing_at_all, pipeline_state, + public_case, read_buffer, run_case, texture_descriptor, validated_device, CaseResources, + Messages, ScratchCache, WAIT, }; use crate::candidate::engine::ComputeOutput; use crate::gpu::TEST_DEVICE; @@ -34,11 +35,7 @@ fn on_device(test: impl FnOnce(&Device)) { let device = validated_device(TEST_DEVICE, &messages, cache.path()).unwrap(); test(&device); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } fn invalid(call: &'static str, problem: BufferTextureProblem) -> Error { diff --git a/crates/metal2vulkan-validation/src/runtime_lane/cache.rs b/crates/metal2vulkan-validation/src/runtime_lane/cache.rs index 742676303..1a48fa383 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/cache.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/cache.rs @@ -22,8 +22,9 @@ //! cache data"): every making's data is read, nothing fails, and nothing is reported. use super::{ - needs_later_steps, pipeline_state, public_case, public_case_names, public_cases, run_case, - run_with, validated_device, validated_device_with, Messages, PublicCase, ScratchCache, + layer_reported_nothing_at_all, needs_later_steps, pipeline_state, public_case, + public_case_names, public_cases, run_case, run_with, validated_device, validated_device_with, + Messages, PublicCase, ScratchCache, }; use crate::air_library::AirLibrary; use crate::case::ExecutionSafety; @@ -112,11 +113,7 @@ fn cache_run(cache: &Path, case: &str) -> CacheRun { run, } }; - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); run } @@ -405,11 +402,7 @@ fn a_state_made_again_takes_the_memos_translations() { ); assert_eq!(run_with(&device, &case, &again).unwrap().output, output); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } } @@ -468,11 +461,7 @@ fn a_cancelled_or_late_creation_refuses_until_its_translation_is_cached() { "nothing compiled again" ); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// The makings a device's statistics count by what became of the driver's pipeline cache data: @@ -540,11 +529,7 @@ fn makings_on_several_threads_each_read_their_own_cache() { }); (device.shader_cache_statistics(), failed) }; - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); let made = cases.len() - failed.len(); assert_eq!( (statistics.write_failures, statistics.read_failures), diff --git a/crates/metal2vulkan-validation/src/runtime_lane/capabilities.rs b/crates/metal2vulkan-validation/src/runtime_lane/capabilities.rs index f26009113..845144265 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/capabilities.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/capabilities.rs @@ -3,7 +3,7 @@ //! and the Apple-only calls answered typed on a live command buffer and its compute and blit //! encoders. -use super::{validated_device, Messages, ScratchCache}; +use super::{layer_reported_nothing_at_all, validated_device, Messages, ScratchCache}; use crate::gpu::TEST_DEVICE; use metal2vulkan::device::{VkFeature, VkProperty}; use metal2vulkan::error::{Capability, Feature, Unsupported}; @@ -212,11 +212,7 @@ fn a_runtime_device_answers_its_queries_and_the_apple_only_calls() { assert_eq!(command_buffer.status(), CommandBufferStatus::Completed); assert_eq!(command_buffer.error(), None); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// A private 4ยฒ texture of `pf` with `samples` samples, a render target read by shaders: 2D for @@ -429,11 +425,7 @@ fn textures_are_made_as_the_texture_queries_answer() { assert_eq!(command_buffer.status(), CommandBufferStatus::Completed); assert_eq!(command_buffer.error(), None); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// The device's own numbers, printed per venue (`GPU-CORES`): `gpuCoreCount` is the count its diff --git a/crates/metal2vulkan-validation/src/runtime_lane/clear_reach.rs b/crates/metal2vulkan-validation/src/runtime_lane/clear_reach.rs index 95b0a1d3c..e6bb2cbfb 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/clear_reach.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/clear_reach.rs @@ -19,7 +19,10 @@ use super::degrade_notices::{assert_made_once, forced, made_render_kinds}; use super::degrade_notices::{shared_in_system_memory, twins_depth}; use super::hidden_depth::replayed_but_unrun; -use super::{buffer_with, read_buffer, validated_device, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, layer_reported_nothing_at_all, read_buffer, validated_device, Messages, + ScratchCache, WAIT, +}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::metal::state::{DepthStencilDescriptor, StencilDescriptor}; @@ -380,11 +383,7 @@ pub(super) fn lane() -> (Messages, ScratchCache, Lane) { pub(super) fn quiet(lane: Lane, messages: &Messages) { drop(lane); - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(messages); } /// A case of `a_clear_reaches_past_the_render_area_as_metal_s`: its name, the render area, the diff --git a/crates/metal2vulkan-validation/src/runtime_lane/color_groups.rs b/crates/metal2vulkan-validation/src/runtime_lane/color_groups.rs index da4d8f265..917961fbf 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/color_groups.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/color_groups.rs @@ -33,7 +33,7 @@ //! color of another group. A pipeline of four colors in the five-color pass, which the device //! draws in groups, is refused `NotImplemented(ColorAttachmentGroups)`. -use super::{validated_device_with, Messages, ScratchCache, WAIT}; +use super::{layer_reported_nothing_at_all, validated_device_with, Messages, ScratchCache, WAIT}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use crate::observation::PROFILES_LAYER; @@ -487,11 +487,7 @@ fn scenes(width: Width) { } assert_eq!(announced, expected, "on {}", lane.device.name()); drop(lane); - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// The depth scene (the module docs). diff --git a/crates/metal2vulkan-validation/src/runtime_lane/command_queues.rs b/crates/metal2vulkan-validation/src/runtime_lane/command_queues.rs index 9729951da..3f6975550 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/command_queues.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/command_queues.rs @@ -12,7 +12,7 @@ //! [`WAIT`]. use super::host_memory::Mapping; -use super::{validated_device, Messages, ScratchCache}; +use super::{layer_reported_nothing_at_all, validated_device, Messages, ScratchCache}; use crate::gpu::TEST_DEVICE; use metal2vulkan_runtime::{ BufferContents, BufferDescriptor, CommandBuffer, CommandQueue, DeadlockCause, Deallocator, @@ -47,11 +47,7 @@ fn on_device(test: impl FnOnce(&Device)) { let device = validated_device(TEST_DEVICE, &messages, cache.path()).unwrap(); test(&device); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// A make of `queue`'s next command buffer on a thread of its own; its answer comes on the @@ -437,9 +433,5 @@ fn a_presenting_queue_s_lock_holds_no_other_queue_where_the_device_reserved_one( release.send(()).unwrap(); holder.join().unwrap(); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/compressed_blits.rs b/crates/metal2vulkan-validation/src/runtime_lane/compressed_blits.rs index 9fd984be1..689a500cf 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/compressed_blits.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/compressed_blits.rs @@ -15,7 +15,7 @@ //! the image of a texture a CPU copy reaches is uncompressed, in the space of Metal's compressed //! size). -use super::{validated_device_with, Messages, ScratchCache}; +use super::{layer_reported_nothing_at_all, validated_device_with, Messages, ScratchCache}; use crate::gpu::TEST_DEVICE; use metal2vulkan::bind::CompressedBlit; use metal2vulkan::metal::{PixelFormat, TextureUsage}; @@ -389,5 +389,5 @@ fn blits_through_a_compressed_texture_write_metal_s_texels() { } } } - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/compressed_moves.rs b/crates/metal2vulkan-validation/src/runtime_lane/compressed_moves.rs index 818c920b1..fc2d0efef 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/compressed_moves.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/compressed_moves.rs @@ -33,7 +33,7 @@ //! through the view; and an interior `replaceRegion` to the edges. Plain Metal answered the same //! 336 steps as the model ([`METAL_TRANSCRIPT_2`]). -use super::{validated_device_with, Messages, ScratchCache}; +use super::{layer_reported_nothing, validated_device_with, Messages, ScratchCache}; use crate::gpu::TEST_DEVICE; use metal2vulkan::metal::{PixelFormat, TextureType, TextureUsage}; use metal2vulkan_runtime::{ @@ -686,11 +686,7 @@ fn compressed_blocks_move_as_metal_moves_them() { transcript, METAL_TRANSCRIPT, "the model no longer moves blocks as plain Metal on an Apple M4 moved them" ); - assert_eq!( - messages.take(), - Vec::new(), - "the validation layer reported on {name}" - ); + layer_reported_nothing(&messages, &format!("on {name}")); } // ---- The second lane: views, interior regions and a large texture ---- @@ -938,9 +934,5 @@ fn views_regions_and_large_levels_move_as_metal_s() { transcript, METAL_TRANSCRIPT_2, "the model no longer moves blocks as plain Metal on an Apple M4 moved them" ); - assert_eq!( - messages.take(), - Vec::new(), - "the validation layer reported on {name}" - ); + layer_reported_nothing(&messages, &format!("on {name}")); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/coverage_alpha_rounding.rs b/crates/metal2vulkan-validation/src/runtime_lane/coverage_alpha_rounding.rs index 965a560dd..07ac1d98d 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/coverage_alpha_rounding.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/coverage_alpha_rounding.rs @@ -17,7 +17,7 @@ use super::degrade_notices::counts; use super::extended_range_targets::half_value; -use super::{validated_device_with, Messages, ScratchCache, WAIT}; +use super::{layer_reported_nothing_at_all, validated_device_with, Messages, ScratchCache, WAIT}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::metal::{ @@ -209,11 +209,7 @@ fn coverage_alpha_stores_the_nearest_even_half_under_mode_two() { "{name}: {noted:?}" ); drop(lane); - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// Alphas whose rounding to the nearest-even half crosses a coverage level's edge: for each edge @@ -295,9 +291,5 @@ fn an_unstored_coverage_alpha_keeps_metal_s_coverage_under_mode_two() { "{name}: {noted:?}" ); drop(lane); - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/coverage_loop.rs b/crates/metal2vulkan-validation/src/runtime_lane/coverage_loop.rs index 95fe16d40..3ff545c42 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/coverage_loop.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/coverage_loop.rs @@ -23,7 +23,10 @@ //! Metal's error on every device. use super::raster_sample_counts::refusal; -use super::{buffer_with, read_buffer, validated_device, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, layer_reported_nothing_at_all, read_buffer, validated_device, Messages, + ScratchCache, WAIT, +}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::device::DriverWorkaround; @@ -196,11 +199,7 @@ fn the_loop_runs_what_fits_and_refuses_the_rest_by_its_reason() { } eprintln!("coverage loop on {name}: {}", answers.join("; ")); } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// The standard sample positions at 2 and 4 samples (Vulkan's "Standard sample locations", @@ -320,9 +319,5 @@ fn the_loop_reads_each_sample_qualified_varying_at_its_sample() { } eprintln!("sample-qualified varying on {name}: {}", answers.join("; ")); } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/coverage_outputs.rs b/crates/metal2vulkan-validation/src/runtime_lane/coverage_outputs.rs index 67aa1442a..161e45da9 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/coverage_outputs.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/coverage_outputs.rs @@ -18,7 +18,10 @@ //! triangle's fragments (lavapipe), says so and draws nothing. use super::degrade_notices::counts; -use super::{buffer_with, read_buffer, validated_device_with, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, layer_reported_nothing_at_all, read_buffer, validated_device_with, Messages, + ScratchCache, WAIT, +}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::error::Feature; @@ -258,9 +261,5 @@ fn coverage_reading_color_writers_write_the_samples_metal_writes() { assert!(whole > 0 && partial > 0, "{whole} whole, {partial} partial"); } drop(lane); - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/degrade_notices.rs b/crates/metal2vulkan-validation/src/runtime_lane/degrade_notices.rs index 322d8f389..6f32dc6f7 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/degrade_notices.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/degrade_notices.rs @@ -223,8 +223,9 @@ use super::wide_points::POINT_GUARD_BAND; use super::ycbcr_passes::YCBCR_PASSES; use super::ycbcr_textures::YCBCR_FILTERS; use super::{ - case_making_kinds, creation_heard_checked, made_lane_device, pipeline_state, public_case, - run_case, run_with, shared_kinds, validated_device_with, Messages, PublicCase, ScratchCache, + case_making_kinds, creation_heard_checked, layer_reported_nothing_at_all, made_lane_device, + pipeline_state, public_case, run_case, run_with, shared_kinds, validated_device_with, Messages, + PublicCase, ScratchCache, }; use crate::air_library::AirLibrary; use crate::candidate::engine::compute_shape; @@ -452,7 +453,7 @@ pub(super) fn on_device_with( let device = validated_device_with(TEST_DEVICE, &messages, cache.path(), adjust).unwrap(); test(&device, &messages); } - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } /// Every kind is taken by a lane test's site: listed above, or a stage's precision note or @@ -639,7 +640,7 @@ fn moltenvk_argument_buffers_are_announced_where_unread_and_refused_off() { } moltenvk }; - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); if !moltenvk { return; } @@ -819,7 +820,7 @@ fn a_metal_level_below_the_host_release_is_announced_once() { } assert!(made.is_empty(), "announced past the creation: {made:?}"); } - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } /// The kind an anisotropy past the device's largest takes diff --git a/crates/metal2vulkan-validation/src/runtime_lane/denormal_word_fetches.rs b/crates/metal2vulkan-validation/src/runtime_lane/denormal_word_fetches.rs index 39061d150..fa4cd3250 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/denormal_word_fetches.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/denormal_word_fetches.rs @@ -15,7 +15,7 @@ use super::argument_linear_samples::kernel; use super::depth_compares::{pipeline_of, run_held, Held, Through}; -use super::{validated_device, Messages, ScratchCache}; +use super::{layer_reported_nothing_at_all, validated_device, Messages, ScratchCache}; use crate::gpu::TEST_DEVICE; use metal2vulkan::bind::SamplerDescriptor; use metal2vulkan::metal::PixelFormat; @@ -187,5 +187,5 @@ fn denormal_texels_read_through_words_and_heaps_keep_their_bits() { wrong.join("\n") ); } - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/depth_as_color.rs b/crates/metal2vulkan-validation/src/runtime_lane/depth_as_color.rs index 98b88955c..be5fb5279 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/depth_as_color.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/depth_as_color.rs @@ -14,7 +14,10 @@ //! `RGBA32Float` target, where the linear filter weighs one texel). use super::depth_compares::pipeline_of; -use super::{buffer_with, read_buffer, validated_device, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, layer_reported_nothing_at_all, read_buffer, validated_device, Messages, + ScratchCache, WAIT, +}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::bind::SamplerDescriptor; @@ -398,9 +401,5 @@ fn a_depth_texture_read_as_a_color_reads_metals_texel() { ); assert!(wrong.is_empty(), "{name}: {wrong:#?}"); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/depth_compare_clamps.rs b/crates/metal2vulkan-validation/src/runtime_lane/depth_compare_clamps.rs index 255d86bf6..34790e80a 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/depth_compare_clamps.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/depth_compare_clamps.rs @@ -15,7 +15,9 @@ //! `[0, 1]` (`degrade_notices::clamps_depth_uploads`). use super::degrade_notices::{clamps_depth_uploads, counts}; -use super::{buffer_with, validated_device_with, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, layer_reported_nothing_at_all, validated_device_with, Messages, ScratchCache, WAIT, +}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::bind::SamplerDescriptor; @@ -252,9 +254,5 @@ fn the_depth_compare_clamp_mask_clamps_metal_s_references() { "{name}: restricted-depth-range announced" ); drop(lane); - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/depth_compare_levels.rs b/crates/metal2vulkan-validation/src/runtime_lane/depth_compare_levels.rs index 6daa01dad..6883dd891 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/depth_compare_levels.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/depth_compare_levels.rs @@ -20,7 +20,7 @@ //! filter's two levels' comparisons (`compared::blended`). use super::depth_compares::{argument_kernel, pipeline_of, run_held, Held, Through}; -use super::{validated_device, Messages, ScratchCache}; +use super::{layer_reported_nothing_at_all, validated_device, Messages, ScratchCache}; use crate::gpu::TEST_DEVICE; use metal2vulkan::bind::SamplerDescriptor; use metal2vulkan::metal::{CompareFunction, PixelFormat, SamplerMipFilter}; @@ -375,5 +375,5 @@ fn comparisons_read_the_level_metal_reads() { .join("\n") ); } - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/depth_compares.rs b/crates/metal2vulkan-validation/src/runtime_lane/depth_compares.rs index 7e5805c59..4d1daac0c 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/depth_compares.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/depth_compares.rs @@ -31,7 +31,10 @@ //! the eight functions. (A sampler that filters leaves a heap texture's comparison to the device, //! which the module records, so it is not asked here.) -use super::{buffer_with, read_buffer, validated_device, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, layer_reported_nothing_at_all, read_buffer, validated_device, Messages, + ScratchCache, WAIT, +}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::bind::SamplerDescriptor; @@ -809,5 +812,5 @@ fn depth_comparisons_compare_as_metal_does() { wrong.join("\n") ); } - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/depth_denormals.rs b/crates/metal2vulkan-validation/src/runtime_lane/depth_denormals.rs index c0c0f089b..e573229cf 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/depth_denormals.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/depth_denormals.rs @@ -79,7 +79,10 @@ use super::degrade_notices::{counts, signs_depth_tests}; use super::degrade_notices::{made_compute_kinds, made_render_kinds, shared_in_system_memory}; use super::depth_compares::run; use super::render_state::library; -use super::{buffer_with, read_buffer, validated_device, validated_device_with}; +use super::{ + buffer_with, layer_reported_nothing_at_all, read_buffer, validated_device, + validated_device_with, +}; use super::{Messages, ScratchCache, WAIT}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; @@ -696,11 +699,7 @@ fn depth_images_hold_denormals_as_their_drivers_claim() { tests {tests})" ); } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// Whether Metal's depth test passes a fragment at depth `z` under `compare` against the stored @@ -1145,11 +1144,7 @@ fn a_stored_depth_tests_reads_samples_and_compares_as_metal_s() { "{name}: signed-depth-test for the merge where the target takes the stand-in" ); } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// A target that takes no magnitude stand-in, or whose pass renders it through another image, @@ -1254,11 +1249,7 @@ fn a_target_without_a_stand_in_stores_its_words_without_their_signs() { "{name}: signed-depth-test for the tests of the targets without a stand-in" ); } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// A NaN clear depth stores and tests as Metal's (our probe `nanclear`, the M3 Max under macOS @@ -1352,11 +1343,7 @@ fn a_nan_clear_depth_stores_and_tests_as_metal_s() { } messages.take_notices(); } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// The side of [`fresh_target`]'s textures, which Metal compresses: each texel reads its pattern. @@ -1628,11 +1615,7 @@ fn a_new_target_s_pattern_loaded_unwritten_tests_and_stores_as_metal_s() { "{name}: a cleared target announces nothing: {announced:?}" ); } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// The depth of an ordinary pass, which never stores a value whose stand-in is not itself, loads @@ -1679,9 +1662,5 @@ fn an_ordinary_depth_loads_in_place() { assert_eq!(strips, 0, "{name}: sign strips"); messages.take_notices(); } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/depth_never.rs b/crates/metal2vulkan-validation/src/runtime_lane/depth_never.rs index 46a7c5a2c..655774c08 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/depth_never.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/depth_never.rs @@ -27,7 +27,10 @@ //! `NotImplemented(DepthNeverWithoutAttachment)` (printed). use super::render_state::{texels, texture}; -use super::{buffer_with, read_buffer, validated_device, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, layer_reported_nothing_at_all, read_buffer, validated_device, Messages, + ScratchCache, WAIT, +}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::error::Feature; @@ -249,11 +252,7 @@ impl Lane { /// The lane dropped, nothing the validation layer reported. fn quiet(lane: Lane, messages: &Messages) { drop(lane); - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(messages); } /// `color` 16 times. diff --git a/crates/metal2vulkan-validation/src/runtime_lane/depth_texel_reads.rs b/crates/metal2vulkan-validation/src/runtime_lane/depth_texel_reads.rs index 2ee1576ae..de6817813 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/depth_texel_reads.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/depth_texel_reads.rs @@ -11,7 +11,10 @@ //! texture at a slot, and the module converts a heap depth texture's texel by the class its //! handle carries. -use super::{buffer_with, read_buffer, validated_device, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, layer_reported_nothing_at_all, read_buffer, validated_device, Messages, + ScratchCache, WAIT, +}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use crate::hash::sha256_bytes; @@ -255,9 +258,5 @@ fn a_depth16_texel_reads_and_samples_as_metal_s_code_over_65535() { assert_eq!(sha256_bytes(got), METAL, "{what}: Metal's digest"); } } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/device_commands.rs b/crates/metal2vulkan-validation/src/runtime_lane/device_commands.rs index ddc68a715..940d36f0f 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/device_commands.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/device_commands.rs @@ -9,7 +9,10 @@ //! itself, as MoltenVK would. A swapchain needs a headless surface that the device's primary //! queue family presents to; a venue without one prints its gap and only loads. -use super::{validated_device, validated_device_with, Messages, ScratchCache}; +use super::{ + layer_reported_nothing_at_all, nothing_reported_without_the_layer, validated_device, + validated_device_with, Messages, ScratchCache, +}; use crate::gpu::wait::{self, SubmissionBackend}; use crate::gpu::TEST_DEVICE; use ash::vk::{self, Handle}; @@ -206,8 +209,7 @@ fn a_device_is_made_and_used_while_moltenvk_names_it_in_each_message() { overwrite(&device, true); overwrite(&device, true); } - let messages = messages.take(); - assert!(messages.is_empty(), "the device reported: {messages:#?}"); + nothing_reported_without_the_layer(&messages, "nothing MoltenVK said fails"); } /// The caller's swapchain commands load through `Device::device_proc_addr` after the device's @@ -234,11 +236,7 @@ fn the_caller_s_commands_load_and_make_a_swapchain_after_moltenvk_overwrote_the_ ); caller_s_commands(&device, moltenvk, headless, layered); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/dispatch_executions.rs b/crates/metal2vulkan-validation/src/runtime_lane/dispatch_executions.rs index 8747eb0a2..c27e667c7 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/dispatch_executions.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/dispatch_executions.rs @@ -44,7 +44,7 @@ use super::indirect_host_steps::{self, HOST_STEPS}; use super::rebind_reach::{buffer_len, buffer_over, pages}; use super::rebinds::rebind; use super::shared_kinds; -use super::{validated_device_with, Messages, ScratchCache, WAIT}; +use super::{layer_reported_nothing_at_all, validated_device_with, Messages, ScratchCache, WAIT}; use crate::air_library::AirLibrary; use crate::candidate::runtime_case::{buffer_with, read_buffer}; use crate::gpu::TEST_DEVICE; @@ -343,7 +343,7 @@ fn on_device(test: impl FnOnce(&Device, &Messages)) { assert!(device.compile_device().generated_commands().is_none()); test(&device, &messages); } - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } /// The indirect dispatches `device` replayed so far. diff --git a/crates/metal2vulkan-validation/src/runtime_lane/dma_buf_imports.rs b/crates/metal2vulkan-validation/src/runtime_lane/dma_buf_imports.rs index 63bd3ba10..66ffac2c8 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/dma_buf_imports.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/dma_buf_imports.rs @@ -1791,11 +1791,7 @@ fn a_heap_texture_over_dma_buf_pages_takes_its_shadow_where_the_source_fails() { ); drop((texture, heap)); } - let failing = messages.take(); - assert!( - failing.is_empty(), - "{TEST}: the validation layer reported: {failing:#?}" - ); + layer_reported_nothing(&messages, TEST); } /// A placement heap of `view`'s length over its pages of `ram`, with `ram`'s source noting in diff --git a/crates/metal2vulkan-validation/src/runtime_lane/driver_deviations.rs b/crates/metal2vulkan-validation/src/runtime_lane/driver_deviations.rs index 364cafa72..063b8b504 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/driver_deviations.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/driver_deviations.rs @@ -104,8 +104,9 @@ use super::degrade_notices::{counts as notice_counts, on_device}; use super::{ - buffer_with, public_case, read_buffer, run_case, validated_device, validated_device_with, - CaseResources, Messages, PublicCase, ScratchCache, METAL_ENVIRONMENT, WAIT, + buffer_with, layer_reported_nothing_at_all, public_case, read_buffer, run_case, + validated_device, validated_device_with, CaseResources, Messages, PublicCase, ScratchCache, + METAL_ENVIRONMENT, WAIT, }; use crate::air_library::AirLibrary; use crate::case::{AuthoredCase, OutputSelection, Primitive}; @@ -314,11 +315,7 @@ fn threadgroup_words_only_lockstep_orders_answer_as_metal() { ); } } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } // --------------------------------------------------------------------------------------------- @@ -422,11 +419,7 @@ fn float_functions_the_device_answers_are_metals() { } } } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } // --------------------------------------------------------------------------------------------- @@ -616,11 +609,7 @@ fn cube_gradients_through_an_anisotropic_sampler_answer_as_metal() { } } assert!(failures.is_empty(), "{failures:#?}"); - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } // --------------------------------------------------------------------------------------------- @@ -702,11 +691,7 @@ fn half_fused_multiply_adds_the_device_answers_are_metals() { } } } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } // --------------------------------------------------------------------------------------------- @@ -836,11 +821,7 @@ fn float_denormals_read_as_metal_reads_them() { } assert!(failures.is_empty(), "{failures:#?}"); } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// a probe cases ([`HALF_FMA_CASES`]): every word, `fma(a, b, c)`, `a * b + c`, the two `half` @@ -875,11 +856,7 @@ fn fused_pairs_answer_metals_nans_and_denormals() { } assert!(failures.is_empty(), "{failures:#?}"); } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// The NaN model's cases whose words round a `float` near 65520 to `half`: the narrowing, the @@ -968,11 +945,7 @@ fn half_quantize_rounds_as_metal_at_the_edge() { } assert!(failures.is_empty(), "{failures:#?}"); } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// The owned denormal fixtures (`dfl_float_denormals`, `dfl_float_denormals_fast`): 256 threads of @@ -1141,11 +1114,7 @@ fn owned_float_fixtures_answer_metal() { } assert!(failures.is_empty(), "{failures:#?}"); } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } // --------------------------------------------------------------------------------------------- @@ -1202,11 +1171,7 @@ fn owned_dot_fixtures_answer_metal() { } assert!(failures.is_empty(), "{failures:#?}"); } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } // --------------------------------------------------------------------------------------------- @@ -1268,11 +1233,7 @@ fn minimums_and_maximums_answer_as_metal() { } assert!(failures.is_empty(), "{failures:#?}"); } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } // --------------------------------------------------------------------------------------------- @@ -1333,11 +1294,7 @@ fn half_arithmetic_answers_as_metal() { } assert!(failures.is_empty(), "{failures:#?}"); } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } // --------------------------------------------------------------------------------------------- @@ -1531,11 +1488,7 @@ fn half_loads_the_device_widens_answer_as_metal() { } assert!(failures.is_empty(), "{failures:#?}"); } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } // --------------------------------------------------------------------------------------------- @@ -1926,11 +1879,7 @@ fn fragment_simdgroup_lanes_are_metal_s() { } } assert!(failures.is_empty(), "{failures:#?}"); - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } // --------------------------------------------------------------------------------------------- diff --git a/crates/metal2vulkan-validation/src/runtime_lane/event_round_trips.rs b/crates/metal2vulkan-validation/src/runtime_lane/event_round_trips.rs index 4a5a27d91..8ae100a85 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/event_round_trips.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/event_round_trips.rs @@ -24,7 +24,10 @@ //! event it waits for there or of another head's (no head waits for the GPU's signal once the //! host met its wait). -use super::{loader, open_device, validated_device_with, Messages, ScratchCache, WAIT}; +use super::{ + layer_reported_nothing_at_all, loader, open_device, validated_device_with, Messages, + ScratchCache, WAIT, +}; use crate::gpu::TEST_DEVICE; use metal2vulkan::device::CompletionPolicy; use metal2vulkan::vk::DriverId; @@ -290,11 +293,7 @@ fn a_checked_head_waits_for_another_queue_s_signal_on_the_gpu() { ); } } - let failing = messages.take(); - assert!( - failing.is_empty(), - "the validation layer reported: {failing:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// Where the scheduler's thread waits on the GPU for a signal a long command buffer gives at its @@ -430,9 +429,5 @@ fn a_host_signal_wakes_the_scheduler_from_its_wait_on_the_gpu() { } } } - let failing = messages.take(); - assert!( - failing.is_empty(), - "the validation layer reported: {failing:#?}" - ); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/events.rs b/crates/metal2vulkan-validation/src/runtime_lane/events.rs index e7bb18e7f..963c8fbdc 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/events.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/events.rs @@ -10,8 +10,8 @@ //! last handle returns. use super::{ - open_device, open_devices, pipeline_state, public_case, run_with, validated_device, - validated_options, Messages, ScratchCache, + layer_reported_nothing_at_all, open_device, open_devices, pipeline_state, public_case, + run_with, validated_device, validated_options, Messages, ScratchCache, }; use crate::gpu::TEST_DEVICE; use metal2vulkan::metal::{PixelFormat, TextureUsage}; @@ -55,11 +55,7 @@ fn on_device(test: impl FnOnce(&Device)) { let device = validated_device(TEST_DEVICE, &messages, cache.path()).unwrap(); test(&device); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// Wait for `command_buffer` and check it completed without error. @@ -669,7 +665,7 @@ fn shared_event_handles_open_the_same_event() { Err(invalid("encode_signal_event", Problem::ForeignObject)) ); } - assert!(messages.take().is_empty()); + layer_reported_nothing_at_all(&messages); }); } @@ -728,11 +724,7 @@ fn equal_options_make_one_device() { completed(&command_buffer); assert_eq!(event.signaled_value(), 2); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// Event waits and signals are refused where Metal stops them: with an encoder open (Metal @@ -1028,11 +1020,7 @@ fn a_device_dropped_after_a_wait_is_gone_when_the_drop_returns() { } let next = validated_device(TEST_DEVICE, &messages, cache.path()).unwrap(); drop(next); - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } after_handler.sort_by(f64::total_cmp); eprintln!( diff --git a/crates/metal2vulkan-validation/src/runtime_lane/executions.rs b/crates/metal2vulkan-validation/src/runtime_lane/executions.rs index 0f442baf1..122e4694b 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/executions.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/executions.rs @@ -4,8 +4,8 @@ use super::renders::{is_public_render, render_cases_where, run_render}; use super::{ - bound_buffers, encode_case, in_shard, pipeline_state, public_case, run_case, - validated_device_with, CaseResources, Messages, ScratchCache, WAIT, + bound_buffers, encode_case, in_shard, layer_reported_nothing_at_all, pipeline_state, + public_case, run_case, validated_device_with, CaseResources, Messages, ScratchCache, WAIT, }; use crate::budgets::creation_within_ceiling; use crate::candidate::engine::compute_shape; @@ -30,11 +30,7 @@ pub(super) fn on_device_with(adjust: impl FnOnce(&mut DeviceOptions), test: impl let device = validated_device_with(TEST_DEVICE, &messages, cache.path(), adjust).unwrap(); test(&device); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// The kernel case's run records one execution: the compiled compute pipeline its dispatch ran, diff --git a/crates/metal2vulkan-validation/src/runtime_lane/exits.rs b/crates/metal2vulkan-validation/src/runtime_lane/exits.rs index 787d6b741..988995975 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/exits.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/exits.rs @@ -33,7 +33,9 @@ //! waited. use super::indirect_host_steps::Setup; -use super::{run_queue_waits, validated_device, Messages, ScratchCache}; +use super::{ + layer_reported_nothing_at_all, run_queue_waits, validated_device, Messages, ScratchCache, +}; use crate::gpu::{DeviceType, TEST_DEVICE}; use metal2vulkan_runtime::{ Buffer, CommandBuffer, CommandBufferStatus, CommandQueue, Deallocator, Device, DeviceKind, @@ -1155,11 +1157,7 @@ fn a_dropped_command_buffer_completes_once_its_event_is_signalled() { std::thread::sleep(Duration::from_millis(10)); } } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// Devices made again in a long-lived process register the exit hook no more while what they @@ -1197,9 +1195,5 @@ fn devices_made_again_register_the_exit_hook_no_more() { ); drop(held); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/extended_range_resolve.rs b/crates/metal2vulkan-validation/src/runtime_lane/extended_range_resolve.rs index 51d4a8791..f205e0d13 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/extended_range_resolve.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/extended_range_resolve.rs @@ -16,7 +16,10 @@ //! `Feature::RasterSampleCount`, is skipped with a printed line, and the other counts are checked. use super::degrade_notices::{assert_once, forced, shared_in_system_memory}; -use super::{buffer_with, read_buffer, validated_device_with, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, layer_reported_nothing_at_all, read_buffer, validated_device_with, Messages, + ScratchCache, WAIT, +}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::error::Feature; @@ -422,9 +425,5 @@ fn extended_range_resolves_are_metals_or_within_a_code() { )])); assert_once(&messages.take_notices(), &kinds); drop(lane); - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/families.rs b/crates/metal2vulkan-validation/src/runtime_lane/families.rs index bdc7d88cf..2ef873c02 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/families.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/families.rs @@ -1,7 +1,7 @@ //! Device test of the GPU-family audit on the device the cfg selects: every family's //! `supportsFamily:` answer and the rows that block it, printed as the venue's burn-down. -use super::{validated_device, Messages, ScratchCache}; +use super::{layer_reported_nothing_at_all, validated_device, Messages, ScratchCache}; use crate::gpu::TEST_DEVICE; use metal2vulkan::metal::TextureUsage; use metal2vulkan_runtime::{ @@ -88,9 +88,5 @@ fn every_family_answers_with_its_blocking_rows() { .and_then(|heap| heap.new_texture(&texture)); assert_eq!(sparse, made.is_ok(), "{made:?}"); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/fence_stages.rs b/crates/metal2vulkan-validation/src/runtime_lane/fence_stages.rs index 6504024a4..20f9058b7 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/fence_stages.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/fence_stages.rs @@ -16,7 +16,10 @@ //! one of the two. The validation layer is off there: the vertex function's read races the fill //! by Metal's rule, which synchronization validation reports as a hazard. -use super::{buffer_with, read_buffer, validated_device_with, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, layer_reported_nothing, read_buffer, validated_device_with, Messages, + ScratchCache, WAIT, +}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::metal::state::DepthStencilDescriptor; @@ -166,11 +169,7 @@ fn a_wait_before_the_vertex_stage_orders_the_vertex_function() { "texels after the fill and before it on {name}" ); drop(device); - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported on {name}: {reported:#?}" - ); + layer_reported_nothing(&messages, &format!("on {name}")); } /// The module docs' wait before the fragment stage: either answer, counted. diff --git a/crates/metal2vulkan-validation/src/runtime_lane/first_use_writes.rs b/crates/metal2vulkan-validation/src/runtime_lane/first_use_writes.rs index f847cb956..b7a1f5e15 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/first_use_writes.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/first_use_writes.rs @@ -20,7 +20,7 @@ use super::host_memory::{counting, no_copy, not_importable, Mapping, GUEST_PAGE}; use super::no_copy_textures::{floats, staged}; use super::pitched_surfaces::reading; -use super::{validated_device, Messages, ScratchCache, WAIT}; +use super::{layer_reported_nothing_at_all, validated_device, Messages, ScratchCache, WAIT}; use crate::gpu::TEST_DEVICE; use metal2vulkan::metal::{PixelFormat, PrimitiveType, TextureUsage}; use metal2vulkan_runtime::{ @@ -239,11 +239,7 @@ fn a_cpu_write_to_bytes_a_first_use_does_not_read_stays() { } } } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); assert!( lapses.is_empty(), "a first use undid a CPU write, or changed or misread bytes:\n{}", diff --git a/crates/metal2vulkan-validation/src/runtime_lane/format_copies.rs b/crates/metal2vulkan-validation/src/runtime_lane/format_copies.rs index 477e03053..f10d88a84 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/format_copies.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/format_copies.rs @@ -27,7 +27,7 @@ //! (`texture_blits` measures that). use super::degrade_notices::assert_once; -use super::{validated_device, Messages, ScratchCache}; +use super::{layer_reported_nothing_at_all, validated_device, Messages, ScratchCache}; use crate::gpu::TEST_DEVICE; use metal2vulkan::metal::{PixelFormat, TextureUsage}; use metal2vulkan_runtime::{ @@ -260,7 +260,7 @@ fn depth_and_stencil_copy_their_bytes_with_colour_formats_of_their_unit() { ); } } - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } /// Probes 8, 8b and 8c: the stencil view `X32Stencil8` of a `Depth32FloatStencil8` texture copies @@ -396,7 +396,7 @@ fn the_stencil_view_of_a_combined_texture_copies_its_stencil() { "a combined texture into another on {name}" ); } - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } /// The CPU's copies through the stencil view `X32Stencil8` of a `Shared` `Depth32FloatStencil8` @@ -470,7 +470,7 @@ fn the_cpu_copies_through_the_stencil_view_move_the_stencil() { texture.get_bytes(&mut held, 16, 32, region, 0, 0).unwrap(); assert_eq!(held.to_vec(), depth, "the depth kept again on {name}"); } - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } /// Probes 7, 7b and 8b: a region copied onto itself keeps its texels, the whole texture or a @@ -613,7 +613,7 @@ fn a_copy_onto_its_own_texels_keeps_them_and_another_overlap_moves_as_memmove() let notices = assert_once(&messages.take_notices(), &MEMMOVES); assert_eq!(notices.len(), 1, "{notices:?} on {name}"); } - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } /// A unit's bytes: `tag`, its index `i`, then bytes that count up, `n` in all. @@ -741,5 +741,5 @@ fn compressed_blocks_copy_into_texels_of_their_bytes_and_back() { ); } } - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/fragment_imageblocks.rs b/crates/metal2vulkan-validation/src/runtime_lane/fragment_imageblocks.rs index a3c85d251..996b5986a 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/fragment_imageblocks.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/fragment_imageblocks.rs @@ -24,7 +24,9 @@ use super::degrade_notices::assert_once; use super::shared_kinds; use super::tile_states::descriptor as tile_descriptor; -use super::{buffer_with, validated_device, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, layer_reported_nothing_at_all, validated_device, Messages, ScratchCache, WAIT, +}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::metal::{PixelFormat, PrimitiveType, TextureUsage}; @@ -260,7 +262,7 @@ fn a_pass_keeps_its_imageblock_across_draws_and_a_split() { } } } - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); assert_once(&messages.take_notices(), &kinds); } @@ -333,7 +335,7 @@ fn imageblock_draws_are_refused_where_metal_or_the_runtime_refuses_them() { ); }); } - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } /// What a step of [`commands_reach_the_pass_s_imageblock`] draws: the encoder's own draw of a @@ -450,7 +452,7 @@ fn commands_reach_the_pass_s_imageblock() { } drop(held); } - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); let notices = messages.take_notices(); let storage = notices .iter() diff --git a/crates/metal2vulkan-validation/src/runtime_lane/fresh_writes.rs b/crates/metal2vulkan-validation/src/runtime_lane/fresh_writes.rs index 03cd841f7..c45f5a187 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/fresh_writes.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/fresh_writes.rs @@ -24,7 +24,10 @@ use super::degrade_notices::{assert_made_once, assert_once, clamps_depth_uploads use super::degrade_notices::{ draws_depth_copies, forced, loses_depth_denormals, signs_depth_tests, }; -use super::{buffer_with, read_buffer, validated_device, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, layer_reported_nothing_at_all, read_buffer, validated_device, Messages, + ScratchCache, WAIT, +}; use crate::gpu::TEST_DEVICE; use metal2vulkan::metal::{PixelFormat, TextureType, TextureUsage}; use metal2vulkan_runtime::{ @@ -267,11 +270,7 @@ fn a_new_texture_a_blit_wrote_whole_reads_its_texels_unannounced() { let control = assert_once(&messages.take_notices(), &[Degradation::FreshPatternZeroed]); println!("FRESH-WRITE {name} control, read unwritten: announced {control:?}"); } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// Writes of parts, a resolve, separate attachments and a view's write, each of a new texture @@ -445,11 +444,7 @@ fn a_new_texture_written_in_parts_or_by_a_pass_reads_its_texels_unannounced() { let noted = counts.contains_key(&Degradation::FreshPatternZeroed); println!("FRESH-WRITE {name} a new single-sample Depth32Float is noted: {noted}"); } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// A clear the pass renders through a scratch and does not store writes nothing of the texture: @@ -503,9 +498,5 @@ fn a_clear_through_a_scratch_the_pass_does_not_store_writes_nothing() { ); } } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/generated_executions.rs b/crates/metal2vulkan-validation/src/runtime_lane/generated_executions.rs index 8cdc93560..b6857002f 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/generated_executions.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/generated_executions.rs @@ -28,7 +28,7 @@ use super::indirect_host_steps::{ complete, param, state, wait, Setup, COMMANDS, HOST_STEPS, THREADS, }; use super::shared_kinds; -use super::{validated_device_with, Messages, ScratchCache}; +use super::{layer_reported_nothing_at_all, validated_device_with, Messages, ScratchCache}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::bind::ReplayFaults; @@ -89,7 +89,7 @@ fn on_device(withheld: bool, test: impl FnOnce(&Device, &Messages, bool)) { } test(&device, &messages, generated); } - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } /// Whether `command_buffer` ran the flat kernel's flat variant: the GPU-alone path's execution diff --git a/crates/metal2vulkan-validation/src/runtime_lane/gpu_times.rs b/crates/metal2vulkan-validation/src/runtime_lane/gpu_times.rs index 64e3577c0..4b7d8f84d 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/gpu_times.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/gpu_times.rs @@ -62,7 +62,9 @@ use super::commit_work::orders_by_ends; use super::degrade_notices::{assert_once, counts, FROM_HOST, GPU_TIMES, UNTIMED}; use super::presenting::Adopted; -use super::{validated_device, validated_device_with, Messages, ScratchCache}; +use super::{ + layer_reported_nothing_at_all, validated_device, validated_device_with, Messages, ScratchCache, +}; use crate::gpu::TEST_DEVICE; use ash::vk; use metal2vulkan::device::{BatchOrderPolicy, DriverFact}; @@ -390,11 +392,7 @@ fn command_buffers_are_timed_in_the_hosts_time_base() { assert_once(¬ices, &GPU_TIMES); } } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// On a `device` that calibrates: the calibration pairs that placed its command buffers' times, @@ -513,11 +511,7 @@ fn command_buffers_one_after_another_are_each_timed_on_their_own() { assert!(reused > 0, "no kept stamped command buffer taken again"); } } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// [`BEHIND_ROUNDS`] pairs of fills of the same [`BEHIND_LENGTH`] bytes on one queue, the first @@ -648,11 +642,7 @@ fn start_behind_work(batch_order: BatchOrderPolicy) { ), } } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// On a device the test made and the runtime adopts without calibrated timestamps: the three @@ -720,11 +710,7 @@ fn more_command_buffers_in_flight_than_metal_keeps_sample_buffers_are_timed() { ); } } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// Command buffers each waiting for one shared event are committed before it is signaled, so all @@ -856,11 +842,7 @@ fn command_buffers_past_a_pool_s_slots_are_timed_by_pools_made_as_needed() { ); } } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// Command buffers with no encoder answer where their queue reached them as both GPU times and @@ -944,11 +926,7 @@ fn a_command_buffer_with_no_encoder_answers_where_its_queue_reached_it() { ); } } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// On a device made with `gpu_times_from_host`: the three command buffers' times hold the module @@ -1025,11 +1003,7 @@ fn a_device_answering_gpu_times_from_the_host_writes_no_timestamps() { "runtime gpu times: {IN_FLIGHT} command buffers on one queue, answered from the host" ); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// The command buffers each queue of [`host_clock_gpu_times_keep_metal_s_rules`] commits, in a @@ -1357,9 +1331,5 @@ fn host_clock_gpu_times_keep_metal_s_rules() { } ); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/grouped_submissions.rs b/crates/metal2vulkan-validation/src/runtime_lane/grouped_submissions.rs index a42931e6a..580e7bb01 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/grouped_submissions.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/grouped_submissions.rs @@ -42,7 +42,10 @@ //! handler's start on the host's clock, over [`DELAY_ROUNDS`] rounds after [`DELAY_WARM`]. use super::degrade_notices::counts; -use super::{loader, open_device, validated_device_with, Messages, ScratchCache, WAIT}; +use super::{ + layer_reported_nothing_at_all, loader, open_device, validated_device_with, Messages, + ScratchCache, WAIT, +}; use crate::gpu::TEST_DEVICE; use metal2vulkan::device::{CompletionPolicy, DeviceDescription, DriverFact}; use metal2vulkan_runtime::{ @@ -184,11 +187,7 @@ fn run(completion: CompletionPolicy, checked: bool) -> (u64, u64, u64, usize, bo }; let notices = counts(&messages.take_notices()); let [heard] = GROUPED.map(|kind| notices.get(&kind).copied().unwrap_or(0)); - let failing = messages.take(); - assert!( - failing.is_empty(), - "the validation layer reported: {failing:#?}" - ); + layer_reported_nothing_at_all(&messages); eprintln!( "GROUPED {completion:?}, checked {checked}: {grouped} vkQueueSubmit calls held {batches} batches together, \ of {submissions} calls in all; groups by what sent them {ends:?}; {heard} \ @@ -322,11 +321,7 @@ fn completions_wake_the_scheduler_only_once_a_head_may_go() { after.scheduler_wakes_completion - before.scheduler_wakes_completion, ) }; - let failing = messages.take(); - assert!( - failing.is_empty(), - "the validation layer reported: {failing:#?}" - ); + layer_reported_nothing_at_all(&messages); eprintln!("GROUPED-COMPLETION-WAKES: the check saw {seen:?}; {wakes} wakings by completions"); assert_eq!(seen, Some(1), "the event's value the check saw"); assert!(wakes <= 1, "{wakes} wakings by completions"); @@ -474,11 +469,7 @@ fn event_scenario(completion: CompletionPolicy, steps: &[Step], last: u64) -> Sc met: after.event_waits_met - before.event_waits_met, } }; - let failing = messages.take(); - assert!( - failing.is_empty(), - "the validation layer reported: {failing:#?}" - ); + layer_reported_nothing_at_all(&messages); eprintln!( "GROUPED-EVENTS {completion:?}: {} vkQueueSubmit calls held {} batches together; groups \ by what sent them {:?}; event waits met as taken {}; the driver merges: {}", @@ -981,11 +972,7 @@ fn behind_running_work(completion: CompletionPolicy, stretch: usize, carried: Ca checks: checks.load(std::sync::atomic::Ordering::SeqCst), } }; - let failing = messages.take(); - assert!( - failing.is_empty(), - "the validation layer reported: {failing:#?}" - ); + layer_reported_nothing_at_all(&messages); eprintln!("GROUPED-BEHIND {completion:?} {carried:?}: {seen:#?}"); seen } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/half_slice_nans.rs b/crates/metal2vulkan-validation/src/runtime_lane/half_slice_nans.rs index 6fb1d4e3e..596c089bd 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/half_slice_nans.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/half_slice_nans.rs @@ -29,7 +29,7 @@ //! alpha 1. use super::degrade_notices::{counts, on_device_with}; -use super::{buffer_with_options, read_buffer, WAIT}; +use super::{buffer_with_options, layer_reported_nothing, read_buffer, WAIT}; use crate::air_library::AirLibrary; use metal2vulkan::metal::{PixelFormat, TextureUsage}; use metal2vulkan::pipeline::{ComputePipelineDescriptor, StageSource}; @@ -534,11 +534,7 @@ fn half_nans_written_through_the_blur_keep_their_bits() { if read_announced { " (announced)" } else { "" } )); } - assert_eq!( - messages.take(), - Vec::new(), - "{what}: the validation layer reported" - ); + layer_reported_nothing(messages, &what); } } } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/half_storage_writes.rs b/crates/metal2vulkan-validation/src/runtime_lane/half_storage_writes.rs index ff002a784..152116210 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/half_storage_writes.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/half_storage_writes.rs @@ -29,7 +29,7 @@ use super::color_writes::{ half, half_toward_zero, specials, unsigned_float, unsigned_float_toward_zero, }; use super::degrade_notices::{on_device, on_device_with}; -use super::{buffer_with, read_buffer, Messages, WAIT}; +use super::{buffer_with, layer_reported_nothing, read_buffer, Messages, WAIT}; use crate::air_library::AirLibrary; use metal2vulkan::metal::{PixelFormat, ResourceUsage, TextureUsage}; use metal2vulkan::pipeline::{ComputePipelineDescriptor, StageSource}; @@ -260,12 +260,7 @@ fn kernel_writes_store_metals_halves() { if let Some(d) = judge(device, messages, (form, pf, channels), &values) { differ.push(d); } - assert_eq!( - messages.take(), - Vec::new(), - "{pf:?} by {}: the validation layer reported", - form.kernel() - ); + layer_reported_nothing(messages, &format!("{pf:?} by {}", form.kernel())); } } }, diff --git a/crates/metal2vulkan-validation/src/runtime_lane/half_write_nans.rs b/crates/metal2vulkan-validation/src/runtime_lane/half_write_nans.rs index b2a19b935..c8e24341d 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/half_write_nans.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/half_write_nans.rs @@ -19,7 +19,7 @@ //! `device-nan-encoding`. use super::degrade_notices::{counts, on_device_with}; -use super::{buffer_with, read_buffer, WAIT}; +use super::{buffer_with, layer_reported_nothing, read_buffer, WAIT}; use crate::air_library::AirLibrary; use metal2vulkan::device::VkProperty; use metal2vulkan::metal::{PixelFormat, ResourceUsage, TextureUsage}; @@ -397,12 +397,7 @@ fn half_writes_store_their_nans_as_metal_or_announce() { if noted { "announced" } else { "not announced" } )); } - assert_eq!( - messages.take(), - Vec::new(), - "{access} {}: the validation layer reported", - f.name - ); + layer_reported_nothing(messages, &format!("{access} {}", f.name)); } } }, diff --git a/crates/metal2vulkan-validation/src/runtime_lane/handler_waits.rs b/crates/metal2vulkan-validation/src/runtime_lane/handler_waits.rs index 2aa9ffcaa..e832939ec 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/handler_waits.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/handler_waits.rs @@ -11,7 +11,7 @@ //! one that would leave the device's handler threads with none free (`HandlerThreadCap`). No wait here can hang: every wait in a handler is answered at once or //! is for work that other threads do, and every wait of the test's own thread is bounded. -use super::{validated_device, Messages, ScratchCache}; +use super::{layer_reported_nothing_at_all, validated_device, Messages, ScratchCache}; use crate::gpu::TEST_DEVICE; use metal2vulkan_runtime::{ Buffer, CommandBuffer, CommandBufferStatus, CommandQueue, DeadlockCause, Device, Error, @@ -51,11 +51,7 @@ fn on_device(test: impl FnOnce(&Device)) { let device = validated_device(TEST_DEVICE, &messages, cache.path()).unwrap(); test(&device); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// A command buffer of `queue` filling the first 64 bytes of `buffer` with `value`, not diff --git a/crates/metal2vulkan-validation/src/runtime_lane/handles.rs b/crates/metal2vulkan-validation/src/runtime_lane/handles.rs index 641f7b277..b20913ee9 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/handles.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/handles.rs @@ -1,7 +1,7 @@ //! Device tests of the raw-handle accessors on the device the cfg selects: each handle the runtime //! lends names the object it says, read back through Vulkan itself. -use super::{validated_device, Messages, ScratchCache}; +use super::{layer_reported_nothing_at_all, validated_device, Messages, ScratchCache}; use crate::gpu::wait::{self, SubmissionBackend}; use crate::gpu::TEST_DEVICE; use ash::vk; @@ -133,9 +133,5 @@ fn the_raw_handles_name_the_runtimes_objects() { // SAFETY: the test's fence; its submission completed. unsafe { vk_device.destroy_fence(fence, None) }; } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/heap_device_samples.rs b/crates/metal2vulkan-validation/src/runtime_lane/heap_device_samples.rs index 7dba61e26..eab99be0a 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/heap_device_samples.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/heap_device_samples.rs @@ -4,7 +4,7 @@ use super::heap_textures::{sample_round_trip, SampleAspect}; use super::host_memory::{gpu_fill, gpu_read, run}; -use super::{buffer_with, validated_device, Messages, ScratchCache}; +use super::{buffer_with, layer_reported_nothing_at_all, validated_device, Messages, ScratchCache}; use crate::gpu::TEST_DEVICE; use metal2vulkan::device::DriverFact; use metal2vulkan::error::Feature; @@ -159,9 +159,5 @@ fn device_heap_multisample_colour_textures_lie_where_announced() { reasons[0] ); drop((texture, heap)); - let failing = messages.take(); - assert!( - failing.is_empty(), - "the validation layer reported: {failing:#?}" - ); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/heap_sample_moves.rs b/crates/metal2vulkan-validation/src/runtime_lane/heap_sample_moves.rs index 2355b425a..520bf356d 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/heap_sample_moves.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/heap_sample_moves.rs @@ -4,7 +4,7 @@ //! holds, and the consumer's surface, whose it may not. use super::host_memory::run; -use super::{validated_device, Messages, ScratchCache}; +use super::{layer_reported_nothing_at_all, validated_device, Messages, ScratchCache}; use crate::gpu::TEST_DEVICE; use metal2vulkan::error::Feature; use metal2vulkan::metal::{PixelFormat, TextureType, TextureUsage}; @@ -179,9 +179,5 @@ fn a_large_heap_multisample_texture_s_moves() { drop(kept); print(&format!("{shape}: both gone")); } - let failing = messages.take(); - assert!( - failing.is_empty(), - "the validation layer reported: {failing:#?}" - ); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/heap_textures.rs b/crates/metal2vulkan-validation/src/runtime_lane/heap_textures.rs index 5e98f128e..752643716 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/heap_textures.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/heap_textures.rs @@ -31,9 +31,9 @@ use super::host_memory::{gpu_fill, gpu_read, on_device, run}; use super::presenting::Adopted; use super::textures::{no_texture_alone, pattern, texel_bytes}; use super::{ - bound_buffers, buffer_with, encode_case, pipeline_state, public_case, read_buffer, run_case, - texture_descriptor, validated_device, validated_device_with, CaseResources, Messages, - PublicCase, ScratchCache, + bound_buffers, buffer_with, encode_case, layer_reported_nothing_at_all, pipeline_state, + public_case, read_buffer, run_case, texture_descriptor, validated_device, + validated_device_with, CaseResources, Messages, PublicCase, ScratchCache, }; use crate::air_library::AirLibrary; use crate::candidate::engine::ComputeOutput; @@ -445,7 +445,7 @@ fn heap_textures_answer_and_place_as_metal_s_do() { placement_rules(device); automatic_rules(device); } - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } /// A placement heap's textures: at every multiple of the alignment, refused off it and past the @@ -790,11 +790,7 @@ fn a_buffer_write_shows_in_an_overlapping_texture() { ); assert_eq!(hidden, 0); assert_eq!(transfer + linear, usize::from(hides && made)); - let failing = messages.take(); - assert!( - failing.is_empty(), - "the validation layer reported: {failing:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// Under the default `HeapCompressionPolicy::Compressed`, where the device's driver may keep a @@ -872,11 +868,7 @@ fn a_heap_texture_metal_compresses_keeps_the_driver_s_compression_by_default() { assert_eq!(compressed, usize::from(hides && compressed_made)); assert_eq!(hidden, 0); assert_eq!(transfer + linear, usize::from(hides && uncompressed_made)); - let failing = messages.take(); - assert!( - failing.is_empty(), - "the validation layer reported: {failing:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// What a 2048x2048 `RGBA8Unorm` render target in a `Private` placement heap costs the GPU under @@ -1112,11 +1104,7 @@ fn a_multisample_depth_texture_without_optimized_contents_is_announced_where_it_ let notices = counts(&messages.take_notices()); let announced = notices.get(&OPTIMIZED[0]).copied().unwrap_or(0); assert_eq!(announced, usize::from(optimized)); - let failing = messages.take(); - assert!( - failing.is_empty(), - "the validation layer reported: {failing:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// The kinds a heap's colour texture announces on a driver whose compressed images hide writes @@ -1716,11 +1704,7 @@ fn heap_depth_textures_keep_their_bytes_with_their_twins() { eprintln!("HEAPTEX depth: the Shared heap's texture is a shadow of the heap's bytes"); } assert_eq!(shadowed, usize::from((apart && made) || shared_shadow)); - let failing = messages.take(); - assert!( - failing.is_empty(), - "the validation layer reported: {failing:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// A heap's single-sample depth and stencil textures keep their texels where Metal's tiles place @@ -1982,11 +1966,7 @@ fn heap_depth_textures_keep_their_texels_in_metal_s_tiles() { assert_eq!(count(OPTIMIZED[0]), 0); assert_eq!(count(APART[0]), 0); } - let failing = messages.take(); - assert!( - failing.is_empty(), - "the validation layer reported: {failing:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// One aspect of one slice of a multisample texture a lane moves ([`sample_round_trip`]): its @@ -2299,11 +2279,7 @@ fn heap_multisample_textures_keep_their_samples_in_metal_s_tiles() { assert_eq!(count(Degradation::HeapTextureLosslessLayout), 1); assert_eq!(count(APART[0]), 0); } - let failing = messages.take(); - assert!( - failing.is_empty(), - "the validation layer reported: {failing:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// A heap's colour textures that Metal keeps uncompressed, in a `Private` placement heap over the @@ -2417,11 +2393,7 @@ fn device_heap_textures_lie_in_metal_s_tiles() { true => assert_eq!((layouts.len(), counted), (0, 0)), false => assert_eq!((layouts, counted), (vec![(&untiled, &1)], 7)), } - let failing = messages.take(); - assert!( - failing.is_empty(), - "the validation layer reported: {failing:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// One aspect of a `side`-square depth or stencil texture, read back through a blit with diff --git a/crates/metal2vulkan-validation/src/runtime_lane/heaps.rs b/crates/metal2vulkan-validation/src/runtime_lane/heaps.rs index a51e5da80..1a30d48e1 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/heaps.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/heaps.rs @@ -12,8 +12,9 @@ use super::host_memory::{ }; use super::no_copy_heaps::{no_copy_heap, HEAP}; use super::{ - bound_buffers, encode_case, pipeline_state, public_case, read_buffer, run_case, - validated_device, CaseResources, Messages, PublicCase, ScratchCache, WAIT, + bound_buffers, encode_case, layer_reported_nothing_at_all, pipeline_state, public_case, + read_buffer, run_case, validated_device, CaseResources, Messages, PublicCase, ScratchCache, + WAIT, }; use crate::candidate::device_facts::DeviceFacts; use crate::candidate::engine::guards::{GuardCount, GuardReach}; @@ -1187,7 +1188,7 @@ fn a_kernel_reaches_buffers_placed_in_heaps_it_uses() { ); encoder.end_encoding().unwrap(); } - assert!(messages.take().is_empty()); + layer_reported_nothing_at_all(&messages); }); } @@ -1657,7 +1658,7 @@ fn a_resident_set_past_the_old_search_reaches_every_live_buffer() { ); drop(live); } - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } /// The counts of buffers of their own [`the_resident_set_s_cost`] adds, in turn. diff --git a/crates/metal2vulkan-validation/src/runtime_lane/host_memory.rs b/crates/metal2vulkan-validation/src/runtime_lane/host_memory.rs index 184dba3b8..af7ce8411 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/host_memory.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/host_memory.rs @@ -10,8 +10,8 @@ //! are Metal's, as measured on an Apple M3 Max and an M4. use super::{ - buffer_with, encode_case, pipeline_state, public_case, read_buffer, validated_device, - validated_device_with, CaseResources, Messages, ScratchCache, + buffer_with, encode_case, layer_reported_nothing, pipeline_state, public_case, read_buffer, + validated_device, validated_device_with, CaseResources, Messages, ScratchCache, }; use crate::candidate::engine::ComputeOutput; use crate::gpu::TEST_DEVICE; @@ -1709,8 +1709,7 @@ fn a_lost_device_s_command_buffers_let_go_of_their_pools_after_the_driver_s_comp ); drop((read_only, texture, filled, queue, device)); drop(memory); - let left = messages.take(); - assert!(left.is_empty(), "round {round}: {left:#?}"); + layer_reported_nothing(&messages, &format!("round {round}, after the teardown")); } } @@ -1893,8 +1892,7 @@ fn a_gpu_fault_fails_its_command_buffer_and_the_queue_runs_on() { faulting, victim, read_only, texture, after, beside, queue, device, )); drop(memory); - let left = messages.take(); - assert!(left.is_empty(), "{resume:?}: {left:#?}"); + layer_reported_nothing(&messages, &format!("{resume:?}, after the teardown")); } } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/index_fetches.rs b/crates/metal2vulkan-validation/src/runtime_lane/index_fetches.rs index 79ba69304..e1f2159ba 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/index_fetches.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/index_fetches.rs @@ -47,7 +47,10 @@ use super::degrade_notices::{assert_made_once, assert_once}; use super::shared_kinds; -use super::{buffer_with, read_buffer, validated_device_with, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, layer_reported_nothing_at_all, read_buffer, validated_device_with, Messages, + ScratchCache, WAIT, +}; use crate::air_library::AirLibrary; use crate::candidate::engine::guards::GuardReach; use crate::candidate::runtime_case::guarded_buffer; @@ -336,7 +339,7 @@ fn index_positions_past_the_buffer_draw_index_zero_plus_the_base_vertex() { ); } } - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } } @@ -440,7 +443,7 @@ fn a_run_of_bounded_indirect_draws_draws_each_draws_metal_vertices() { RUN.len() ); } - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } /// The positions of [`an_indirect_draw_past_the_old_index_pool_draws_metals_vertices`]'s draw: @@ -493,5 +496,5 @@ fn an_indirect_draw_past_the_old_index_pool_draws_metals_vertices() { u64::from(PAST_OLD_POOL) * 4 ); } - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/index_pools.rs b/crates/metal2vulkan-validation/src/runtime_lane/index_pools.rs index 52c65387b..4cb8027dd 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/index_pools.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/index_pools.rs @@ -19,7 +19,9 @@ //! `vkDestroyBuffer` waited for the lock that making holds, so the handler ran as the making //! ended, 20 to 27 ms after the command buffer completed. -use super::{buffer_with, validated_device_with, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, layer_reported_nothing_at_all, validated_device_with, Messages, ScratchCache, WAIT, +}; use crate::air_library::AirLibrary; use crate::coverage::ROBUSTNESS_FEATURES; use crate::gpu::TEST_DEVICE; @@ -167,7 +169,7 @@ fn command_buffers_of_one_queue_share_one_pool_block() { "two command buffers held the block at once at most" ); } - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } /// A second queue's command buffer makes a block of its own, which goes as the queue goes; the @@ -199,7 +201,7 @@ fn a_second_queue_takes_its_own_pool_block() { "the second queue's block went with it" ); } - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } /// A queue's block that no command buffer held for the quiet period goes as another queue's @@ -223,7 +225,7 @@ fn a_pool_block_no_command_buffer_held_goes_after_the_quiet_period() { lane.drawn(&idle); assert_eq!(lane.blocks(), (3, 1), "the idle queue makes one again"); } - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } /// A command buffer's completed handler runs while another queue's first command buffer makes @@ -281,5 +283,5 @@ fn a_completed_handler_waits_for_no_pool_block_made_meanwhile() { ); } } - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/indirect_dispatches.rs b/crates/metal2vulkan-validation/src/runtime_lane/indirect_dispatches.rs index 0d4a38d06..403185c59 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/indirect_dispatches.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/indirect_dispatches.rs @@ -40,7 +40,7 @@ use super::degrade_notices::{ assert_made_once, counts, forced, on_device, shared_in_system_memory, }; use super::indirect_host_steps::state; -use super::{buffer_with, read_buffer, WAIT}; +use super::{buffer_with, layer_reported_nothing_at_all, read_buffer, WAIT}; use crate::air_library::AirLibrary; use metal2vulkan::bind::StatusReport; use metal2vulkan::pipeline::{ComputePipelineDescriptor, RuntimeFact, StageSource}; @@ -348,7 +348,7 @@ fn indirect_dispatches_are_refused_where_metal_refuses_them() { complete(&command_buffer, "refused dispatches"); assert_eq!(fixture.out(), vec![0; SLOTS as usize]); } - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } /// An offset that is not a multiple of 4 reads the arguments at the multiple below, as plain diff --git a/crates/metal2vulkan-validation/src/runtime_lane/indirect_executions.rs b/crates/metal2vulkan-validation/src/runtime_lane/indirect_executions.rs index 5d503e016..c138c1629 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/indirect_executions.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/indirect_executions.rs @@ -21,9 +21,10 @@ use super::degrade_notices::counts; use super::host_memory::{host_page, no_copy, not_importable, Mapping}; use super::{ - bound_buffers, compute_descriptor, encode_case, in_shard, public_case, public_cases, - read_buffer, validated_device, validated_device_with, wait_for_device, CaseResources, - DeviceWait, Messages, PublicCase, ScratchCache, WAIT, + bound_buffers, compute_descriptor, encode_case, in_shard, layer_reported_nothing, + layer_reported_nothing_at_all, public_case, public_cases, read_buffer, validated_device, + validated_device_with, wait_for_device, CaseResources, DeviceWait, Messages, PublicCase, + ScratchCache, WAIT, }; use crate::air_library::AirLibrary; use crate::candidate::engine::{ComputeCase, ComputeOutput}; @@ -79,11 +80,7 @@ fn on_device_with(adjust: impl FnOnce(&mut DeviceOptions), test: impl FnOnce(&De let device = validated_device_with(TEST_DEVICE, &messages, cache.path(), adjust).unwrap(); test(&device, &messages); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// `case`'s pipeline state, made with `supportIndirectCommandBuffers` (as the oracle's @@ -634,6 +631,10 @@ fn every_case_of_buffers_alone_runs_from_a_command_as_its_dispatch(shard: usize) failed.join("\n"), timed_out.join("\n") ); + layer_reported_nothing( + &messages, + "every case's commands were valid and left nothing behind", + ); assert!(!alike.is_empty(), "no case ran alike"); } @@ -1709,11 +1710,7 @@ fn a_segment_runs_between_the_encoder_s_commands() { encoder.end_encoding().unwrap(); assert_eq!(command_buffer.executions().len(), 2); complete(&command_buffer); - let reported = messages.take(); - assert!( - reported.is_empty(), - "{dispatch_type:?}: the validation layer reported: {reported:#?}" - ); + layer_reported_nothing(messages, &format!("{dispatch_type:?}")); for (step, expected) in expected.iter().enumerate() { let written = read_buffer(&chain[step + 1], 0, length).unwrap(); assert_eq!(&written, expected, "{dispatch_type:?} step {step}"); diff --git a/crates/metal2vulkan-validation/src/runtime_lane/inline_bytes.rs b/crates/metal2vulkan-validation/src/runtime_lane/inline_bytes.rs index 077e26e68..ed30f41fe 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/inline_bytes.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/inline_bytes.rs @@ -20,7 +20,10 @@ //! The object stage's form runs `mesh_draws`' object cases (`mesh_draws.rs`). use super::vertex_strides::{drawn, pipeline, read_at}; -use super::{buffer_with, read_buffer, validated_device, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, layer_reported_nothing_at_all, read_buffer, validated_device, Messages, + ScratchCache, WAIT, +}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::error::BindError; @@ -173,7 +176,7 @@ fn kernels_read_each_calls_inline_bytes() { } } } - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } /// A vertex attribute reads inline bytes as its vertex buffer: at the layout's stride, and under @@ -222,7 +225,7 @@ fn vertex_attributes_read_inline_bytes() { "MTLAttributeStrideStatic" ); } - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } /// A fragment function reads inline bytes through a `const device` pointer and a `constant` @@ -283,5 +286,5 @@ fn fragments_read_inline_bytes() { .collect(); assert_eq!(read_buffer(&o, 0, 64).unwrap(), want); } - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/int_attributes.rs b/crates/metal2vulkan-validation/src/runtime_lane/int_attributes.rs index f30d8d70c..4917c80ec 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/int_attributes.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/int_attributes.rs @@ -20,7 +20,10 @@ //! - A 32-bit integer format read into a float attribute refuses the pipeline, //! `InvalidDescriptor(VertexAttribute)`, where Metal refuses it too. -use super::{buffer_with, read_buffer, validated_device, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, layer_reported_nothing_at_all, read_buffer, validated_device, Messages, + ScratchCache, WAIT, +}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::bind::SamplerDescriptor; @@ -297,7 +300,7 @@ fn integer_formats_read_into_float_attributes_take_metal_s_values() { ); assert!(wrong.is_empty(), "{} rows differ", wrong.len()); } - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } /// A 32-bit integer format read into a float attribute refuses the pipeline, as on Metal. @@ -333,7 +336,7 @@ fn a_32_bit_integer_format_into_a_float_attribute_is_refused() { } } } - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } /// The label pipeline, its `UShort2` attribute read as `float2`, draws Metal's pixels. @@ -508,5 +511,5 @@ fn the_label_pipeline_draws_metal_s_pixels() { "the label's pixels" ); } - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/interlocked_draw_order.rs b/crates/metal2vulkan-validation/src/runtime_lane/interlocked_draw_order.rs index 9792ca26e..e98066773 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/interlocked_draw_order.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/interlocked_draw_order.rs @@ -24,7 +24,10 @@ //! hold its band's composition; the wrong ones are counted and printed per pass, with the GPU time //! of each pass and whether the device records the barrier. -use super::{buffer_with, read_buffer, validated_device, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, layer_reported_nothing_at_all, read_buffer, validated_device, Messages, + ScratchCache, WAIT, +}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::device::DriverFact; @@ -270,9 +273,5 @@ fn consecutive_fetching_draws_read_each_others_writes() { device.name() ); drop(device); - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/kept_images.rs b/crates/metal2vulkan-validation/src/runtime_lane/kept_images.rs index 1caa1afe2..2ec7f30e9 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/kept_images.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/kept_images.rs @@ -19,7 +19,10 @@ //! and the bytes are the same. use super::no_copy_textures::{blending, floats, staged}; -use super::{validated_device, validated_device_with, Messages, ScratchCache, WAIT}; +use super::{ + layer_reported_nothing_at_all, validated_device, validated_device_with, Messages, ScratchCache, + WAIT, +}; use crate::gpu::TEST_DEVICE; use metal2vulkan::device::{CompletionPolicy, DriverFact}; use metal2vulkan::metal::{PixelFormat, PrimitiveType, TextureUsage}; @@ -278,11 +281,7 @@ fn on_device(completion: Option, test: impl FnOnce(&Device)) { .unwrap(); test(&device); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// The module docs' first case: [`COMMAND_BUFFERS`] passes into one texture a round, each in a diff --git a/crates/metal2vulkan-validation/src/runtime_lane/kernel_imageblocks.rs b/crates/metal2vulkan-validation/src/runtime_lane/kernel_imageblocks.rs index 9f5c1f4f0..acdc10406 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/kernel_imageblocks.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/kernel_imageblocks.rs @@ -12,8 +12,8 @@ use super::kernel_textures::census; use super::{ - bound_buffers, encode_case, pipeline_state, public_case, public_cases, validated_device, - CaseResources, Messages, PublicCase, ScratchCache, WAIT, + bound_buffers, encode_case, layer_reported_nothing_at_all, pipeline_state, public_case, + public_cases, validated_device, CaseResources, Messages, PublicCase, ScratchCache, WAIT, }; use crate::candidate::runtime_case::Committed; use crate::case::Stage; @@ -39,11 +39,7 @@ fn on_device(test: impl FnOnce(&Device)) { let device = validated_device(TEST_DEVICE, &messages, cache.path()).unwrap(); test(&device); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// Every committed public kernel case with an explicit imageblock, and no tile pass, passes the diff --git a/crates/metal2vulkan-validation/src/runtime_lane/kernel_lod.rs b/crates/metal2vulkan-validation/src/runtime_lane/kernel_lod.rs index 1f87700dc..2b5d3c7ce 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/kernel_lod.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/kernel_lod.rs @@ -18,7 +18,10 @@ //! 64 coordinates per query. use super::mip_levels::{half, texture, LEVELS, SIDE}; -use super::{buffer_with, read_buffer, validated_device, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, layer_reported_nothing_at_all, read_buffer, validated_device, Messages, + ScratchCache, WAIT, +}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::bind::SamplerDescriptor; @@ -279,7 +282,7 @@ fn kernel_lod_queries_answer_metals_level() { } assert!(wrong.is_empty(), "{name}: {} queries differ", wrong.len()); } - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } /// The rule's own arithmetic at the measured points: a nearest mip filter's half-way point, the diff --git a/crates/metal2vulkan-validation/src/runtime_lane/kernel_textures.rs b/crates/metal2vulkan-validation/src/runtime_lane/kernel_textures.rs index 289ef690d..db24a7ce9 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/kernel_textures.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/kernel_textures.rs @@ -18,8 +18,9 @@ //! of their cases' own formats. use super::{ - buffer_with, encode_case, in_shard, pipeline_state, public_case, public_cases, read_buffer, - run_case, validated_device, CaseResources, Messages, NamedCase, PublicCase, ScratchCache, WAIT, + buffer_with, encode_case, in_shard, layer_reported_nothing, layer_reported_nothing_at_all, + pipeline_state, public_case, public_cases, read_buffer, run_case, validated_device, + CaseResources, Messages, NamedCase, PublicCase, ScratchCache, WAIT, }; use crate::candidate::engine::variants::compile_compute_for_shape; use crate::candidate::engine::{compute_shape, ENGINE_EXECUTOR_ABI}; @@ -231,6 +232,10 @@ pub(super) fn census(label: &str, cases: &[NamedCase]) { "failed:\n{}\nat device destruction: {leaked:#?}", failed.join("\n") ); + layer_reported_nothing( + &messages, + "every case's commands were valid and left nothing behind", + ); assert!(matched > 0, "no case ran"); } @@ -341,11 +346,7 @@ fn on_device(test: impl FnOnce(&Device, &Messages)) { let device = validated_device(TEST_DEVICE, &messages, cache.path()).unwrap(); test(&device, &messages); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// A state the device can make is made, those Metal's validation stops among them, as plain diff --git a/crates/metal2vulkan-validation/src/runtime_lane/layered_passes.rs b/crates/metal2vulkan-validation/src/runtime_lane/layered_passes.rs index 87f655156..67a70683e 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/layered_passes.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/layered_passes.rs @@ -27,7 +27,8 @@ //! 27.0.1 for its texels). use super::{ - buffer_with, read_buffer, validated_device, validated_device_with, Messages, ScratchCache, WAIT, + buffer_with, layer_reported_nothing_at_all, read_buffer, validated_device, + validated_device_with, Messages, ScratchCache, WAIT, }; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; @@ -607,11 +608,7 @@ fn layered_passes(withheld: &[VkFeature]) { lane.geometry_stages(2) ); } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// An index at or past the pass's length renders the pass's first layer, and the fragment function @@ -829,11 +826,7 @@ fn index_past_the_length(withheld: &[VkFeature]) { lane.geometry_stages(2) ); } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// `rt6_layered_weights` reads the slice and the tag, the primitive ID and the barycentric weights @@ -976,11 +969,7 @@ fn weights_passes(withheld: &[VkFeature]) { lane.geometry_stages(1) ); } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// What Metal's validation stops in a layered pass is refused typed before anything runs (Metal @@ -1050,11 +1039,7 @@ fn a_layered_pass_is_refused_as_metal_refuses_it() { ); } } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// A resolve lane texel (RGBA8): white where a draw covered the pixel, the clear (zero) where none @@ -1909,11 +1894,7 @@ fn a_layered_pass_resolves_each_layer_as_metal() { } } } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// One separate depth and stencil case: its name, the arrays' slices, the attachments' slice, @@ -1992,11 +1973,7 @@ fn separate_depth_and_stencil_render_each_layer_as_metal() { assert_eq!(stencils, stencil, "{case} on {name}"); } } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// A layered pass over separate multisampled depth and stencil textures tests and stores each @@ -2146,11 +2123,7 @@ fn separate_multisampled_depth_and_stencil_render_each_layer_as_metal() { } differ }; - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); assert!(differ.is_empty(), "{differ:#?}"); } @@ -2209,11 +2182,7 @@ fn a_depth_and_stencil_resolve_reads_and_writes_their_own_slices() { } } } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// A layered pass resolves its depth and stencil from its first layer alone, into slice @@ -2270,9 +2239,5 @@ fn a_layered_pass_resolves_its_depth_and_stencil_from_its_first_layer() { } } } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/level_sizes.rs b/crates/metal2vulkan-validation/src/runtime_lane/level_sizes.rs index c4c2abd19..33900e444 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/level_sizes.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/level_sizes.rs @@ -3,7 +3,10 @@ //! (`lower::texture::emit::level_extent`). use super::host_memory::run; -use super::{buffer_with, read_buffer, validated_device, Messages, ScratchCache}; +use super::{ + buffer_with, layer_reported_nothing_at_all, read_buffer, validated_device, Messages, + ScratchCache, +}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::metal::{PixelFormat, TextureUsage}; @@ -130,9 +133,5 @@ fn size_queries_at_a_level_answer_metal_s_extent() { eprintln!("LEVELSIZES storage 100x40/3 level {l}: {got:?}, Metal's {want:?}"); assert_eq!(got, want, "storage, level {l}"); } - let failing = messages.take(); - assert!( - failing.is_empty(), - "the validation layer reported: {failing:#?}" - ); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/level_writes_by_usage.rs b/crates/metal2vulkan-validation/src/runtime_lane/level_writes_by_usage.rs index 79af39edd..0525ac59b 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/level_writes_by_usage.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/level_writes_by_usage.rs @@ -21,7 +21,7 @@ //! their `0x11` bytes. use super::degrade_notices::{counts, on_device_with}; -use super::{buffer_with, read_buffer, WAIT}; +use super::{buffer_with, layer_reported_nothing, read_buffer, WAIT}; use crate::air_library::AirLibrary; use metal2vulkan::metal::{PixelFormat, TextureUsage}; use metal2vulkan::pipeline::{ComputePipelineDescriptor, StageSource}; @@ -269,11 +269,7 @@ fn writes_at_every_level_store_whatever_the_usage() { if shadowed { "shadowed" } else { "own image" }, )); } - assert_eq!( - messages.take(), - Vec::new(), - "{what}: the validation layer reported" - ); + layer_reported_nothing(messages, &what); } } }, diff --git a/crates/metal2vulkan-validation/src/runtime_lane/logic_ops.rs b/crates/metal2vulkan-validation/src/runtime_lane/logic_ops.rs index 72c77fc4d..cd528fb3c 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/logic_ops.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/logic_ops.rs @@ -13,7 +13,9 @@ //! operation. Copy and no-op draw on every device; the others where the device has `logicOp`, //! and are refused naming it elsewhere (MoltenVK). -use super::{buffer_with, validated_device_with, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, layer_reported_nothing_at_all, validated_device_with, Messages, ScratchCache, WAIT, +}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::device::VkFeature; @@ -305,9 +307,5 @@ fn the_logic_operation_stores_metal_s_codes() { ); eprintln!("{name}: {checked} logic-operated draws store Metal's texels, {refused} refused"); drop(lane); - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/made_at_creation.rs b/crates/metal2vulkan-validation/src/runtime_lane/made_at_creation.rs index e4e906c30..3ace3134f 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/made_at_creation.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/made_at_creation.rs @@ -9,7 +9,10 @@ //! vertices through a vertex descriptor (`LAYOUT_FUNCTIONS`). use super::degrade_notices::{counts, on_device}; -use super::{dynamic_input_assembly, validated_device_with, Messages, ScratchCache, WAIT}; +use super::{ + dynamic_input_assembly, layer_reported_nothing_at_all, validated_device_with, Messages, + ScratchCache, WAIT, +}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::bind::SamplerDescriptor; @@ -320,7 +323,7 @@ fn a_pipeline_made_at_creation_announces_at_its_first_draw() { "a second draw announced again" ); } - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } /// A state's creation predicts the draw that binds no texture: nothing it sees names a texture a diff --git a/crates/metal2vulkan-validation/src/runtime_lane/math_routines.rs b/crates/metal2vulkan-validation/src/runtime_lane/math_routines.rs index 2021c078b..9a340f632 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/math_routines.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/math_routines.rs @@ -10,7 +10,10 @@ //! and `INT_MIN`; an infinity `(x, 0)` and `INT_MAX`; a NaN `(x, 0)` and `INT_MIN`; anything else //! `((u & 0x807fffff) | 0x3f000000, E - 126)` and `E - 127`. -use super::{buffer_with, read_buffer, validated_device, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, layer_reported_nothing_at_all, read_buffer, validated_device, Messages, + ScratchCache, WAIT, +}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::pipeline::{ComputePipelineDescriptor, StageSource}; @@ -194,9 +197,5 @@ fn frexp_and_ilogb_answer_as_metals_routines() { ); } } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/mesh_barriers.rs b/crates/metal2vulkan-validation/src/runtime_lane/mesh_barriers.rs index 2b1d31e5d..e0f794c3c 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/mesh_barriers.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/mesh_barriers.rs @@ -30,7 +30,10 @@ //! and each is compared with Metal's lines. use super::render_state::{texels, texture}; -use super::{buffer_with, read_buffer, validated_device, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, layer_reported_nothing_at_all, read_buffer, validated_device, Messages, + ScratchCache, WAIT, +}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::metal::{BarrierScope, PixelFormat, RenderStages}; @@ -342,9 +345,5 @@ fn readers_behind_a_barrier_read_the_writers_words() { } } } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/mesh_draws.rs b/crates/metal2vulkan-validation/src/runtime_lane/mesh_draws.rs index 6ecf08388..215fe244e 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/mesh_draws.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/mesh_draws.rs @@ -50,7 +50,10 @@ use super::degrade_notices::{assert_made_once, made_mesh_kinds}; use super::gpu_times::read_kinds; use super::render_state::{texels, texture}; use super::shared_kinds; -use super::{buffer_with, read_buffer, validated_device, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, layer_reported_nothing_at_all, read_buffer, validated_device, Messages, + ScratchCache, WAIT, +}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::device::{VkExtension, VkFeature}; @@ -486,11 +489,7 @@ fn mesh_draws_store_metals_words() { } } } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// Each object case draws the words Metal drew (the module docs), but those that leave a partial @@ -564,11 +563,7 @@ fn object_draws_store_metals_words() { }; assert_made_once(&messages, emulated, &made); } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// One case of Metal probe 5 over the owned fixture `mesh_object_grid`: the draw's object @@ -928,11 +923,7 @@ fn object_grids_run_as_metal_runs_them() { assert_eq!(tail, !direct, "{what}: the encoder after the draw's"); } } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// The pixels Metal draws for `cases` drawn in order in one pass, as case `name`: each case's @@ -1003,11 +994,7 @@ fn draws_of_both_pipelines_in_one_pass_store_metals_words() { ); assert_eq!(lines, metals, "on {name}"); } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// What Metal's validation stops draws as plain Metal does (a probe): more than 1024 threads in a @@ -1062,9 +1049,5 @@ fn mesh_draws_answer_as_plain_metal_and_refuse_the_rest() { .unwrap(); assert_eq!(lines, ["RESULT refused drawn=0"], "on {name}"); } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/mip_levels.rs b/crates/metal2vulkan-validation/src/runtime_lane/mip_levels.rs index 84ad5d60b..f3135ac10 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/mip_levels.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/mip_levels.rs @@ -26,7 +26,10 @@ //! `L + 1/2` in steps of `1/4096`, every `1/1024` from 1 to 2, the `half` ties around `L + k/64` //! with their `f32` neighbours, and past the last level, the infinities and a NaN. -use super::{buffer_with, read_buffer, validated_device, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, layer_reported_nothing_at_all, read_buffer, validated_device, Messages, + ScratchCache, WAIT, +}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::metal::{PixelFormat, TextureType}; @@ -380,5 +383,5 @@ fn explicit_levels_read_metals_levels() { wrong.join("\n") ); } - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/mipmaps_exact.rs b/crates/metal2vulkan-validation/src/runtime_lane/mipmaps_exact.rs index cfe76daee..b7d94f71e 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/mipmaps_exact.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/mipmaps_exact.rs @@ -20,7 +20,10 @@ //! compared with its bytes. use super::degrade_notices::assert_once; -use super::{validated_device, validated_device_with, Messages, ScratchCache, WAIT}; +use super::{ + layer_reported_nothing_at_all, validated_device, validated_device_with, Messages, ScratchCache, + WAIT, +}; use crate::gpu::TEST_DEVICE; use metal2vulkan::bind::{MipmapFilterChain, MipmapRule}; use metal2vulkan::metal::{PixelFormat, TextureType, TextureUsage}; @@ -303,11 +306,7 @@ fn mipmaps_of_the_16_bit_fixed_formats_on_halving_chains_are_metal_s() { "the M3 Max's passes, no blit chain: {announced:?}" ); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// The boxes an Apple M4 measured (probe 10), each the first level of a texture of the box: exact @@ -375,11 +374,7 @@ fn the_boxes_metal_measured_mipmap_as_it_measured_them() { "{announced:?}" ); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// At macOS 26.7 (`MetalLevel::MacOS26_7`, the M3 Max's passes), `mipmaps-as-apple-m4` is @@ -471,11 +466,7 @@ fn the_m3_note_is_announced_exactly_where_an_m3_differs() { generate(&queue, &t); assert_once(&messages.take_notices(), &M3_MIPMAPS); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// Every format the filter computes, from random bytes (every bit pattern: NaNs, infinities, @@ -577,11 +568,7 @@ fn every_format_the_filter_computes_is_its_filter_level_by_level() { "no blit chain: {announced:?}" ); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// At macOS 26.7 (`MetalLevel::MacOS26_7`), the Apple M3 Max's passes past its tail's extent, from @@ -656,11 +643,7 @@ fn mipmaps_past_65_texels_take_the_m3_max_s_passes() { assert!(unknown, "a compressed pass past PASS_ASPECT"); assert_once(&messages.take_notices(), &M3_MIPMAPS); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// The kind a chain takes where a level may take a rounding the chain does not fit, every venue, @@ -736,11 +719,7 @@ fn mipmaps_near_ties_are_announced_where_the_rounding_is_not_fit() { &[(PixelFormat::RGBA16Float, [16, 16, 1], 3)], Some("RGBA16Float"), ); - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// At macOS 27.0.1 (`MetalLevel::MacOS27_0_1`), where the Apple M3 Max makes every level by its @@ -808,11 +787,7 @@ fn mipmaps_at_macos_27_0_1_are_the_m3_max_s_filter() { assert_eq!(ties, (false, true), "an 8-bit sRGB chain"); assert_once(&messages.take_notices(), &TIE_MIPMAPS); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// Plain Metal's integer mipmap of a level from the level above (`above`, of `above_extent`), @@ -1017,11 +992,7 @@ fn integer_mipmaps_pick_the_texels_plain_metal_picks() { let announced = assert_once(&messages.take_notices(), &[]); assert!(announced.is_empty(), "{announced:?}"); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// The first level read in place recovers every code: for every format the filter computes, a 2D @@ -1122,9 +1093,5 @@ fn a_first_level_read_in_place_recovers_every_code() { "the extended-range formats' integer carriers are read in place on every device" ); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/msaa_depth_moves.rs b/crates/metal2vulkan-validation/src/runtime_lane/msaa_depth_moves.rs index 80b484f44..6c2b9e3da 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/msaa_depth_moves.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/msaa_depth_moves.rs @@ -17,7 +17,10 @@ //! argument buffer the encoder makes resident with `use_resource` ([`READ_DMS`]), or through a //! blit's copy into a buffer. -use super::{buffer_with, read_buffer, validated_device_with, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, layer_reported_nothing, read_buffer, validated_device_with, Messages, + ScratchCache, WAIT, +}; use crate::air_library::AirLibrary; use crate::candidate::runtime_samples::encode; use crate::executor_contract::multisample::SampleRead; @@ -355,11 +358,7 @@ fn run(name: &str, expected: Expect, case: impl FnOnce(&Device, &Kit)) { } drop(kit); drop(device); - let reported = messages.take(); - assert!( - reported.is_empty(), - "{name}: the validation layer reported on {device_name}: {reported:#?}" - ); + layer_reported_nothing(&messages, &format!("{name} on {device_name}")); } /// Three passes, each its own command buffer and each read back by a compute function after it: diff --git a/crates/metal2vulkan-validation/src/runtime_lane/narrow_clamps.rs b/crates/metal2vulkan-validation/src/runtime_lane/narrow_clamps.rs index 99e2ef253..28a6f698d 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/narrow_clamps.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/narrow_clamps.rs @@ -14,7 +14,10 @@ //! difference clamped by `air.clamp.s.i32`, each truncated to its width and zero-extended. Every //! device answers each word zero-extended. -use super::{buffer_with, read_buffer, validated_device, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, layer_reported_nothing_at_all, read_buffer, validated_device, Messages, + ScratchCache, WAIT, +}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::pipeline::{ComputePipelineDescriptor, StageSource}; @@ -196,5 +199,5 @@ fn a_narrow_sum_clamped_signed_and_truncated_is_zero_extended() { wrong.join("\n") ); } - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/no_copy_heaps.rs b/crates/metal2vulkan-validation/src/runtime_lane/no_copy_heaps.rs index 2da7a3ab9..75103838c 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/no_copy_heaps.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/no_copy_heaps.rs @@ -26,7 +26,7 @@ use super::heap_layouts::tiled_offset; use super::host_memory::{gpu_fill, gpu_read, host_page, not_importable, run, Mapping}; -use super::{read_buffer, validated_device, Messages, ScratchCache}; +use super::{layer_reported_nothing_at_all, read_buffer, validated_device, Messages, ScratchCache}; use crate::gpu::TEST_DEVICE; use metal2vulkan::metal::format::is_depth_stencil; use metal2vulkan::metal::{PixelFormat, TextureUsage}; @@ -156,11 +156,7 @@ fn on_device(kind: Degradation, test: impl FnOnce(&Device)) -> usize { .is_some_and(|notice| notice.degradation == kind) }) .count(); - let failing = messages.take(); - assert!( - failing.is_empty(), - "the validation layer reported: {failing:#?}" - ); + layer_reported_nothing_at_all(&messages); notices } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/no_copy_textures.rs b/crates/metal2vulkan-validation/src/runtime_lane/no_copy_textures.rs index 739b21db7..d08fc7fca 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/no_copy_textures.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/no_copy_textures.rs @@ -40,7 +40,10 @@ use super::degrade_notices::counts; use super::host_memory::{counting, no_copy, not_importable, Mapping, GUEST_PAGE}; -use super::{validated_device, validated_device_with, Messages, ScratchCache, WAIT}; +use super::{ + layer_reported_nothing_at_all, validated_device, validated_device_with, Messages, ScratchCache, + WAIT, +}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::metal::{ @@ -423,11 +426,7 @@ fn read_and_write_the_caller_s_pages(pf: PixelFormat, texel: u64, pad: u64) { drop(mapping); } } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } per_format! { @@ -600,11 +599,7 @@ fn two_slice_arrays_over_no_copy_buffers_read_and_write_the_caller_s_pages() { drop((texture, buffer, queue, device)); drop(mapping); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// The `shadowed-texture` notice's reason among the notices delivered so far (removed), as @@ -1031,11 +1026,7 @@ fn passes_blend_load_and_store_as_private_textures(pf: PixelFormat, texel: u64, drop((texture, private, buffer)); drop(mapping); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } per_format! { diff --git a/crates/metal2vulkan-validation/src/runtime_lane/norm_storage_writes.rs b/crates/metal2vulkan-validation/src/runtime_lane/norm_storage_writes.rs index a080095ff..6e8074a95 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/norm_storage_writes.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/norm_storage_writes.rs @@ -25,6 +25,7 @@ use super::color_writes::{field, metal, round_product, Channel, Output, CASES}; use super::degrade_notices::on_device; use super::half_storage_writes::{written, written_texels, Form}; +use super::layer_reported_nothing; use metal2vulkan::metal::PixelFormat; /// Metal's stored code of `x` in `channel` (the module docs); `None` for a channel of another @@ -63,11 +64,7 @@ fn kernel_writes_store_metals_normalized_codes() { for form in Form::ALL { let label = format!("{:?} by {}", case.pf, form.kernel()); let stored = written(device, form, case.pf, case.bytes, &values); - assert_eq!( - messages.take(), - Vec::new(), - "{label}: the validation layer reported" - ); + layer_reported_nothing(messages, &label); let Some(stored) = stored else { eprintln!("NORM-STORAGE-WRITE {label} on {name}: refused"); continue; @@ -141,11 +138,7 @@ fn kernel_writes_store_each_channel_in_its_field() { for form in Form::ALL { let label = format!("{pf:?} by {}", form.kernel()); let stored = written_texels(device, form, pf, 4, &texels); - assert_eq!( - messages.take(), - Vec::new(), - "{label}: the validation layer reported" - ); + layer_reported_nothing(messages, &label); let Some(stored) = stored else { eprintln!("NORM-STORAGE-FIELDS {label} on {name}: refused"); continue; diff --git a/crates/metal2vulkan-validation/src/runtime_lane/numbered_samplers.rs b/crates/metal2vulkan-validation/src/runtime_lane/numbered_samplers.rs index 3615b46fd..90704db3e 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/numbered_samplers.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/numbered_samplers.rs @@ -6,7 +6,7 @@ //! `label=ID` between steps that make and drop the objects, each state kept to the test's end //! (plain allocation hands each the lowest free ID). -use super::{validated_device, Messages, ScratchCache}; +use super::{layer_reported_nothing_at_all, validated_device, Messages, ScratchCache}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::bind::SamplerDescriptor; @@ -185,11 +185,7 @@ fn on_device(row: impl FnOnce(&mut Row)) -> String { row(&mut r); r.answers() }; - let failing = messages.take(); - assert!( - failing.is_empty(), - "the validation layer reported: {failing:#?}" - ); + layer_reported_nothing_at_all(&messages); answers } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/patches.rs b/crates/metal2vulkan-validation/src/runtime_lane/patches.rs index adc46e969..3cea9f418 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/patches.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/patches.rs @@ -15,7 +15,10 @@ //! (`render/tessellation_scan.rs`): the same marks, and the emulation announced once //! ([`EMULATED_TESSELLATION`]). -use super::{buffer_with, read_buffer, validated_device_with, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, layer_reported_nothing_at_all, read_buffer, validated_device_with, Messages, + ScratchCache, WAIT, +}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::device::VkFeature; @@ -103,11 +106,7 @@ pub(super) fn on_path(path: Path, check: impl FnOnce(Device, &str)) { } else { assert!(order <= 1, "the triangle order announced {order} times"); } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// `error`, a refusal of the fixture's pipeline, which only the native path may answer (on a diff --git a/crates/metal2vulkan-validation/src/runtime_lane/pipeline_creation.rs b/crates/metal2vulkan-validation/src/runtime_lane/pipeline_creation.rs index 1f0fcbcf6..3e7fe9457 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/pipeline_creation.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/pipeline_creation.rs @@ -46,8 +46,8 @@ use super::executions::KERNEL; use super::{ - buffer_with, pipeline_state, public_case, read_buffer, validated_device, validated_device_with, - Messages, ScratchCache, WAIT, + buffer_with, layer_reported_nothing_at_all, pipeline_state, public_case, read_buffer, + validated_device, validated_device_with, Messages, ScratchCache, WAIT, }; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; @@ -965,8 +965,7 @@ fn draws_made_on_the_pool_draw_as_made_ones() { assert!(pooled.1 > 0, "the draws counted samples"); assert_eq!(pooled.1, made.1, "the same samples counted"); assert!(pooled.0 == made.0, "the same bytes rendered"); - let reported = messages.take(); - assert!(reported.is_empty(), "{reported:#?}"); + layer_reported_nothing_at_all(&messages); } /// Pipeline states compare by identity, as Metal's objects do, so a program finds the state a @@ -996,6 +995,5 @@ fn pipeline_states_equal_only_their_own_clones() { ); assert!(first == first.clone()); assert!(first != second, "two states of one kernel are two states"); - let reported = messages.take(); - assert!(reported.is_empty(), "{reported:#?}"); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/pipeline_records.rs b/crates/metal2vulkan-validation/src/runtime_lane/pipeline_records.rs index b80238c64..f980e7190 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/pipeline_records.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/pipeline_records.rs @@ -65,7 +65,7 @@ //! `validation/fixtures/public/examples/runtime_examples.ll`. The tests print the driver's data and //! each device's counts (`PIPELINE-RECORDS`). -use super::{validated_device_with, Messages, ScratchCache, WAIT}; +use super::{layer_reported_nothing_at_all, validated_device_with, Messages, ScratchCache, WAIT}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use ash::vk; @@ -733,7 +733,7 @@ fn a_later_device_makes_every_pipeline_an_earlier_one_made_from_its_records() { assert!(now.is_empty(), "a record of a driver that keeps nothing"); } } - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } /// A state's line pipeline, made at its first line draw after the state's creation made its @@ -799,7 +799,7 @@ fn a_line_pipeline_is_made_from_its_triangle_sibling_s_record() { } } } - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } #[test] @@ -826,7 +826,7 @@ fn a_record_holding_another_pipeline_s_data_is_written_again() { "a record of a driver that keeps nothing" ); println!("PIPELINE-RECORDS: the driver's data is not whole; nothing to write again"); - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); return; } let foreign: Vec> = foreign.into_values().collect(); @@ -948,7 +948,7 @@ fn a_record_holding_another_pipeline_s_data_is_written_again() { target ); } - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } /// The processes [`two_processes_making_one_pipeline_leave_one_whole_record`] runs at once. @@ -1032,7 +1032,7 @@ fn two_processes_making_one_pipeline_leave_one_whole_record() { "the draw took the creation's pipeline" ); assert_eq!(records(cache.path()), before_draw, "the draw wrote nothing"); - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } /// One of [`two_processes_making_one_pipeline_leave_one_whole_record`]'s processes: the @@ -1051,5 +1051,5 @@ fn record_maker_process() { "\n{MAKER_REPORT} loads={} saves={} truncated={}", made.driver_loads, made.driver_saves, made.driver_data_truncated ); - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/pitched_surfaces.rs b/crates/metal2vulkan-validation/src/runtime_lane/pitched_surfaces.rs index c04525a51..19eebd9f3 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/pitched_surfaces.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/pitched_surfaces.rs @@ -70,7 +70,10 @@ use super::draw_work::pushes; use super::host_memory::{counting, no_copy, not_importable, Mapping, GUEST_PAGE}; use super::memoryless::memoryless_options; use super::no_copy_textures::{blending, blending_beside_scratch, floats, rects_beside, staged}; -use super::{validated_device, validated_device_with, Messages, ScratchCache, WAIT}; +use super::{ + layer_reported_nothing, layer_reported_nothing_at_all, validated_device, validated_device_with, + Messages, ScratchCache, WAIT, +}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::bind::SamplerDescriptor; @@ -730,11 +733,7 @@ fn reads_writes_and_renders_as_metal(layout: Layout) { check("the last blit", &expected); surface.report(&device, &messages); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// A texture of `layout` over a no-copy buffer whose first use reads it (a fragment function's @@ -760,12 +759,7 @@ fn first_use_reads_the_bytes(device: &Device, messages: &Messages, layout: Layou surface.check(&layout, "its first use", &surface.pages); surface.report(device, messages); } - assert_eq!( - messages.take(), - Vec::new(), - "{}: the validation layer reported", - layout.name - ); + layer_reported_nothing(messages, layout.name); } /// [`first_use_reads_the_bytes`] over each of [`LAYOUTS`], on one device. @@ -869,11 +863,7 @@ fn first_use_over_read_only_pages( "{what}: the read-only pages changed: {}", padding_changes(&layout, &now, &pages) ); - assert_eq!( - messages.take(), - Vec::new(), - "{what}: the validation layer reported" - ); + layer_reported_nothing(messages, &what); drop((texture, buffer)); drop(mapping); Some(()) @@ -977,11 +967,7 @@ fn a_padded_texture_s_shadow_names_what_may_write_its_padding() { ); drop((texture, buffer)); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } } @@ -1041,11 +1027,7 @@ fn a_pass_that_draws_nothing_copies_no_shadow() { ); drop((texture, buffer)); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// A pass that loads a shadowed texture (the browser's padded tile over an ordinary buffer, a @@ -1258,11 +1240,7 @@ fn a_pass_copies_in_and_back_only_the_texels_its_scissors_reach() { ); drop((texture, buffer, private)); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// A pass that loads a shadowed texture (the browser's padded tile over an ordinary buffer) over @@ -1340,11 +1318,7 @@ fn a_shadowed_color_beside_a_memoryless_scratch_blends_over_part_of_it() { assert!(now == expected, "the bytes between the rows changed"); drop((texture, buffer, private, scratch)); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// A pass's copies in share their barriers (`encoder.rs`'s `ShadowRun`): a pass that loads a @@ -1453,11 +1427,7 @@ fn a_pass_s_copies_in_share_their_barriers() { ); drop((read, loaded, buffer)); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// A pass that loads a shadowed texture and draws under a scissor beside a depth attachment it @@ -1572,11 +1542,7 @@ fn a_loaded_color_beside_a_cleared_depth_copies_inside_its_scissor(past: u64) { assert!(now == expected, "the bytes between the rows changed"); drop((texture, buffer, private, depth)); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// [`a_loaded_color_beside_a_cleared_depth_copies_inside_its_scissor`] beside a depth of the @@ -1812,11 +1778,7 @@ fn merged_writes_match_metal(layout: Layout) { surface.report(&device, &messages); } } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } #[test] @@ -1865,11 +1827,7 @@ fn writes_as_metal(layout: Layout) { surface.check(&layout, "a fragment function's writes", &expected); surface.report(&device, &messages); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// One test a layout, each its own process: `$name` runs [`LAYOUTS`]`[$index]`. @@ -1983,11 +1941,7 @@ fn on_shared_device(test: impl FnOnce(&Device, &Messages)) { .unwrap(); test(&device, &messages); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// `boxed` (rows of `bw` texels) laid into `expected` at texel (`bx`, `by`) of `layout`'s rows. @@ -2141,12 +2095,7 @@ fn reads_and_blits_as_metal(device: &Device, messages: &Messages, layout: Layout check("the last read", &expected); surface.report(device, messages); } - assert_eq!( - messages.take(), - Vec::new(), - "{}: the validation layer reported", - layout.name - ); + layer_reported_nothing(messages, layout.name); Some(()) } @@ -2202,11 +2151,7 @@ fn a_padded_texture_that_only_reads_is_a_shadow() { assert!(copied > 0, "{what}: a shadow its uses copied nothing into"); surface.check(&layout, "its uses", &surface.pages); surface.report(device, messages); - assert_eq!( - messages.take(), - Vec::new(), - "{what}: the validation layer reported" - ); + layer_reported_nothing(messages, &what); } }); } @@ -2246,12 +2191,7 @@ fn a_padded_texture_that_renders_or_writes_is_a_shadow() { ); messages.take_notices(); drop((texture, buffer)); - assert_eq!( - messages.take(), - Vec::new(), - "{} ({usage:?}): the validation layer reported", - layout.name - ); + layer_reported_nothing(messages, &format!("{} ({usage:?})", layout.name)); } }); } @@ -2329,11 +2269,7 @@ fn a_padded_texture_that_only_reads_over_an_ordinary_buffer_keeps_its_bytes() { device.name(), ); drop((texture, buffer)); - assert_eq!( - messages.take(), - Vec::new(), - "{what}: the validation layer reported" - ); + layer_reported_nothing(messages, &what); } }); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/pixel_downscales.rs b/crates/metal2vulkan-validation/src/runtime_lane/pixel_downscales.rs index 0d5cba3cd..291d38845 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/pixel_downscales.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/pixel_downscales.rs @@ -33,7 +33,9 @@ use super::argument_linear_samples::kernel; use super::degrade_notices::counts; use super::depth_compares::{pipeline_of, run_held, Held, Through}; -use super::{buffer_with, validated_device, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, layer_reported_nothing_at_all, validated_device, Messages, ScratchCache, WAIT, +}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::bind::SamplerDescriptor; @@ -626,11 +628,7 @@ fn a_pixel_sampler_downscale_answers_metal_s_texels() { .collect(); (outcomes, metal_sampler(&device)) }; - let failing = messages.take(); - assert!( - failing.is_empty(), - "the validation layer reported: {failing:#?}" - ); + layer_reported_nothing_at_all(&messages); let announced: BTreeSet = counts(&messages.take_notices()).into_keys().collect(); eprintln!("announced: {announced:?}"); let mut wrong = Vec::new(); diff --git a/crates/metal2vulkan-validation/src/runtime_lane/pixel_samplers.rs b/crates/metal2vulkan-validation/src/runtime_lane/pixel_samplers.rs index 565544a33..bbc82efa8 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/pixel_samplers.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/pixel_samplers.rs @@ -28,7 +28,7 @@ use super::argument_linear_samples::kernel; use super::degrade_notices::counts; use super::depth_compares::{pipeline_of, run_held, Held, Through}; use super::extended_range_targets::half_bits; -use super::{validated_device, Messages, ScratchCache}; +use super::{layer_reported_nothing_at_all, validated_device, Messages, ScratchCache}; use crate::gpu::TEST_DEVICE; use metal2vulkan::bind::SamplerDescriptor; use metal2vulkan::device::VkProperty; @@ -578,11 +578,7 @@ fn pixel_samplers_answer_metal_s_texels() { eprintln!("pixel samplers on {}", device.name()); (compare(&device), metal_sampler(&device)) }; - let failing = messages.take(); - assert!( - failing.is_empty(), - "the validation layer reported: {failing:#?}" - ); + layer_reported_nothing_at_all(&messages); let announced: BTreeSet = counts(&messages.take_notices()).into_keys().collect(); eprintln!("announced: {announced:?}"); let converted = announced.contains(&Degradation::FloatSampleFilter); @@ -699,9 +695,5 @@ fn the_argument_buffer_note_waits_for_a_filtering_pixel_state() { ); drop(linear); } - let failing = messages.take(); - assert!( - failing.is_empty(), - "the validation layer reported: {failing:#?}" - ); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/post_depth_coverage.rs b/crates/metal2vulkan-validation/src/runtime_lane/post_depth_coverage.rs index 43ff127ee..9bdd58596 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/post_depth_coverage.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/post_depth_coverage.rs @@ -11,7 +11,9 @@ //! `VK_EXT_post_depth_coverage` refuses `pdc_after` by that need; a device whose driver splits a //! clipped triangle's pixel-rate fragments (lavapipe) may refuse it for that first. -use super::{buffer_with, validated_device, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, layer_reported_nothing_at_all, validated_device, Messages, ScratchCache, WAIT, +}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::device::{DriverWorkaround, VkExtension}; @@ -201,9 +203,5 @@ fn the_coverage_after_the_depth_test_reads_as_metal_s() { ); eprintln!("post-depth coverage on {name}: Metal's, {partial} pixels partly covered"); } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/predication.rs b/crates/metal2vulkan-validation/src/runtime_lane/predication.rs index b441565f1..18cf605df 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/predication.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/predication.rs @@ -28,7 +28,8 @@ //! Metal reads memory unrelated to the buffer. use super::{ - buffer_with, read_buffer, validated_device, validated_device_with, Messages, ScratchCache, WAIT, + buffer_with, layer_reported_nothing_at_all, read_buffer, validated_device, + validated_device_with, Messages, ScratchCache, WAIT, }; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; @@ -233,7 +234,7 @@ fn on_device_at(level: MetalLevel, test: impl FnOnce(&Device)) { println!("PRD device {} at {level}", device.name()); test(&device); } - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } /// Run `test` on a validated device, then, where it has device addresses, on one made without @@ -254,7 +255,7 @@ fn on_device_noted(test: impl Fn(&Device, &Messages)) { test(&device, &messages); form == PredicationStepForm::Addressed }; - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); if !addressed { return; } @@ -269,7 +270,7 @@ fn on_device_noted(test: impl Fn(&Device, &Messages)) { println!("PRD device {} {form:?}", device.name()); test(&device, &messages); } - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } /// What [`run`] runs streams with: the marking kernel's state, the log, the condition words diff --git a/crates/metal2vulkan-validation/src/runtime_lane/presenting.rs b/crates/metal2vulkan-validation/src/runtime_lane/presenting.rs index 1cefbd181..ceaaf1375 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/presenting.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/presenting.rs @@ -12,8 +12,8 @@ use super::degrade_notices::{assert_made_once, WRAPPED}; use super::shared_kinds; use super::{ - loader, read_buffer, validated_device, validated_device_with, Messages, ScratchCache, - VALIDATION_LAYER, + layer_reported_nothing_at_all, loader, read_buffer, validated_device, validated_device_with, + Messages, ScratchCache, VALIDATION_LAYER, }; use crate::candidate::LoaderWord; use crate::gpu::wait::{self, SubmissionBackend}; @@ -1160,11 +1160,7 @@ fn wrapped_images_order_across_queues() { raw.device.free_memory(image_memory, None); } } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } fn invalid(call: &'static str, problem: Problem) -> Error { @@ -1387,11 +1383,7 @@ fn interop_refusals_and_shared_textures() { invalid("new_shared_texture_with_handle", Problem::ForeignObject) ); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// A device made with the presenting extensions whose feature structures the runtime knows @@ -1519,9 +1511,5 @@ fn listed_presenting_extensions_are_made_with_their_features() { } } } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/primitive_ids.rs b/crates/metal2vulkan-validation/src/runtime_lane/primitive_ids.rs index a4b00bdae..43fe836dd 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/primitive_ids.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/primitive_ids.rs @@ -24,7 +24,9 @@ //! each read at its address. Its strip and a vertex function that writes memory are refused //! (`NotImplemented(PrimitiveId)`). -use super::{buffer_with, validated_device_with, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, layer_reported_nothing_at_all, validated_device_with, Messages, ScratchCache, WAIT, +}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::device::VkFeature; @@ -417,11 +419,7 @@ fn on_path(path: Path, check: impl FnOnce(&Lane)) { }; check(&lane); drop(lane); - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } fn withhold(path: Path, options: &mut DeviceOptions) { diff --git a/crates/metal2vulkan-validation/src/runtime_lane/private_primitives.rs b/crates/metal2vulkan-validation/src/runtime_lane/private_primitives.rs index 639c10d7d..f6201c40a 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/private_primitives.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/private_primitives.rs @@ -35,7 +35,10 @@ //! //! Type 9's draws, which fail their command buffers as Metal's GPU does: [`type_nine`]. -use super::{buffer_with, validated_device, validated_device_with, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, layer_reported_nothing_at_all, validated_device, validated_device_with, Messages, + ScratchCache, WAIT, +}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::device::VkFeature; @@ -776,11 +779,7 @@ fn draws_metal_s_lists(cases: &[Case], weights: Weights) { cases.len() ); } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// Every direct draw without indices draws Metal's list, from the CPU's. @@ -851,11 +850,7 @@ fn other_fragments_draw_metal_s_lists_and_strips_differ() { } } } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// Quads and a quad strip count one `[[primitive_id]]` a quad, read by a fragment function with @@ -900,11 +895,7 @@ fn quads_count_one_primitive_id_a_quad() { } } } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// With `geometryShader` and `tessellationShader` withheld, a fragment function reads @@ -967,9 +958,5 @@ fn with_the_primitive_id_varying_private_draws_are_metal_s_lists() { "{name}: {drawn} private draws through the primitive ID's varying equal Metal's lists" ); } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/private_primitives/type_nine.rs b/crates/metal2vulkan-validation/src/runtime_lane/private_primitives/type_nine.rs index c5a14d50f..d1bb7cbcf 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/private_primitives/type_nine.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/private_primitives/type_nine.rs @@ -44,7 +44,10 @@ //! the second's, and the host the third's only once the others completed. Last, it commits one //! more that marks. -use super::super::{buffer_with, read_buffer, validated_device, Messages, ScratchCache, WAIT}; +use super::super::{ + buffer_with, layer_reported_nothing_at_all, read_buffer, validated_device, Messages, + ScratchCache, WAIT, +}; use super::{Lane, FORMATS, SIDE}; use crate::gpu::TEST_DEVICE; use metal2vulkan::metal::{IndexType, TextureUsage}; @@ -440,11 +443,7 @@ fn answers_as_metal_does(draws: &[Draw], expected: Expected) { ); } } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// Check `outcome` against Metal's answer `expected` (the module docs). @@ -748,11 +747,7 @@ fn revokes_after(draws: &[(Draw, CommandBufferError)], revoked_from: Option 0, "{name}: the loop of 200 ran its laying again"); } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// A command buffer committed as failed on another queue with Metal's code of a page fault (3) @@ -271,9 +268,5 @@ fn an_injected_fault_or_hang_stops_a_running_loop_as_the_error_it_stands_for() { assert_eq!(words(&log)[2], 0, "{name}: the mark after the loop ran"); println!("{name}: injected codes 3 and 2 stopped the loop; code 1 left it running"); } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/private_primitives/writes.rs b/crates/metal2vulkan-validation/src/runtime_lane/private_primitives/writes.rs index a4bd88ab0..741915071 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/private_primitives/writes.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/private_primitives/writes.rs @@ -19,7 +19,10 @@ //! Each check draws a private type in one form and asks every slot's count, vertex ID and base //! vertex to be Metal's, and the draw's pipeline to carry the form (`RuntimeFact::PrivateList`). -use super::super::{buffer_with, read_buffer, validated_device, Messages, ScratchCache, WAIT}; +use super::super::{ + buffer_with, layer_reported_nothing_at_all, read_buffer, validated_device, Messages, + ScratchCache, WAIT, +}; use super::{metal_list, Form, PRIVATE}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; @@ -292,9 +295,5 @@ fn vertex_functions_that_write_memory_run_once_a_list_vertex() { cases.len() ); } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/provoking.rs b/crates/metal2vulkan-validation/src/runtime_lane/provoking.rs index 9946d3a39..8a0b388e3 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/provoking.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/provoking.rs @@ -30,7 +30,9 @@ //! reads flat inputs too, which the rotated-weights variant takes back to Metal's order but for //! rounding, are checked. The work counts show which path ran. -use super::{buffer_with, validated_device_with, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, layer_reported_nothing_at_all, validated_device_with, Messages, ScratchCache, WAIT, +}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::device::VkFeature; @@ -886,11 +888,7 @@ fn run(withheld: bool, weights: Weights) { assert!(found.covered > 10_000, "{found:?}"); assert!(found.told_apart > 1_000, "{found:?}"); } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// Every case draws Metal's mode 1 through the device's last provoking vertex where it has one @@ -981,11 +979,7 @@ fn the_third_way_is_drawn_as_mode_1_announced_where_metal_differs() { "{cases:?} on {name}: announced" ); } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } } @@ -1045,11 +1039,7 @@ fn draws_of_no_primitive_announce_nothing() { .collect(); assert!(kinds.is_empty(), "{name} (withheld {withheld}): {kinds:?}"); } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } } @@ -1116,11 +1106,7 @@ fn executions_take_the_first_vertex() { } eprintln!("{name}: {executed_draws} executions at mode 1 drew mode 0's draws"); } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// The model's strip: an odd triangle's order at mode 1 is `(j + 1, j, j + 2)`, at mode 0 diff --git a/crates/metal2vulkan-validation/src/runtime_lane/provoking_mesh.rs b/crates/metal2vulkan-validation/src/runtime_lane/provoking_mesh.rs index 472750009..ec191704f 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/provoking_mesh.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/provoking_mesh.rs @@ -27,7 +27,7 @@ //! alone draws Metal's, unannounced, on every path. use super::provoking::PROVOKING; -use super::{validated_device_with, Messages, ScratchCache, WAIT}; +use super::{layer_reported_nothing_at_all, validated_device_with, Messages, ScratchCache, WAIT}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::device::{VkExtension, VkFeature}; @@ -406,11 +406,7 @@ fn run(withheld: bool, emulated: bool) { } assert_eq!(announced, expected, "{name} ({path:?})"); } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// Every mesh draw draws Metal's mode 1 on the device as it is made. diff --git a/crates/metal2vulkan-validation/src/runtime_lane/pvrtc_textures.rs b/crates/metal2vulkan-validation/src/runtime_lane/pvrtc_textures.rs index cfadd5f2b..90341e4a8 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/pvrtc_textures.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/pvrtc_textures.rs @@ -47,8 +47,8 @@ use super::degrade_notices::{assert_made_once, counts, shared_in_system_memory}; use super::host_memory::Mapping; use super::no_copy_heaps::{no_copy_heap, shared, HEAP}; use super::{ - bound_buffers, encode_case, pipeline_state, public_case, read_buffer, validated_device, - CaseResources, Messages, PublicCase, ScratchCache, WAIT, + bound_buffers, encode_case, layer_reported_nothing_at_all, pipeline_state, public_case, + read_buffer, validated_device, CaseResources, Messages, PublicCase, ScratchCache, WAIT, }; use crate::candidate::engine::ComputeOutput; use crate::gpu::TEST_DEVICE; @@ -128,11 +128,7 @@ fn on_device(test: impl FnOnce(&Lane)) { messages: messages.clone(), }); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } impl Lane { diff --git a/crates/metal2vulkan-validation/src/runtime_lane/queue_storms.rs b/crates/metal2vulkan-validation/src/runtime_lane/queue_storms.rs index 514491178..68071e01b 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/queue_storms.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/queue_storms.rs @@ -94,7 +94,10 @@ //! layer's cost on every call is no part of what the storm compares (the lanes that check the //! device's queues under the layer are `handles`, `command_queues` and the rest). -use super::{validated_device_with, Messages, ScratchCache, VALIDATION_LAYER}; +use super::{ + nothing_reported_without_the_layer, validated_device_with, Messages, ScratchCache, + VALIDATION_LAYER, +}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::pipeline::{ComputePipelineDescriptor, StageSource}; @@ -1014,6 +1017,5 @@ fn four_queues_storm_as_metal_s_do() { #[cfg(all(m2v_gpu, target_os = "macos"))] metal::judge(&ours, &reference); } - let messages = messages.take(); - assert!(messages.is_empty(), "the driver reported: {messages:#?}"); + nothing_reported_without_the_layer(&messages, "nothing the driver said fails"); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/rate_mapped_layers.rs b/crates/metal2vulkan-validation/src/runtime_lane/rate_mapped_layers.rs index 92db2ad4b..6b90e0585 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/rate_mapped_layers.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/rate_mapped_layers.rs @@ -20,7 +20,7 @@ //! `NotImplemented(RateMapRegions(LayeredPipeline))`, the slices unknown to the encoder. use super::rate_maps::descriptor; -use super::{validated_device, Messages, ScratchCache, WAIT}; +use super::{layer_reported_nothing_at_all, validated_device, Messages, ScratchCache, WAIT}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::metal::{ @@ -293,5 +293,5 @@ fn each_slice_of_a_rate_mapped_pass_is_shaded_by_its_layer() { "layer_differ on {name}" ); } - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/rate_mapped_passes.rs b/crates/metal2vulkan-validation/src/runtime_lane/rate_mapped_passes.rs index 8c2ec5a1f..260cb09d3 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/rate_mapped_passes.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/rate_mapped_passes.rs @@ -29,7 +29,9 @@ use super::degrade_notices::{ }; use super::rate_maps::descriptor; use super::renders::map_render; -use super::{buffer_with, validated_device, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, layer_reported_nothing_at_all, validated_device, Messages, ScratchCache, WAIT, +}; use crate::candidate::runtime_case::{render_pipeline_descriptor, render_pipeline_state}; use crate::gpu::TEST_DEVICE; use crate::store::CorpusStore; @@ -347,7 +349,7 @@ fn a_rate_mapped_pass_shades_its_physical_pixels_region_by_region() { fixture.draw_in(&layered, |_| {}).unwrap(); assert_eq!(shaded_in(&target, 0), whole, "slice 0 past the map's layer"); assert_eq!(shaded_in(&target, 1).0, 0, "slice 1 past the map's layer"); - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } /// The kind [`a_pass_over_a_map_of_no_layers_draws_nothing`] takes: a draw over a map of no @@ -364,7 +366,7 @@ fn fresh(test: impl FnOnce(&Fixture, &Messages)) { let device = validated_device(TEST_DEVICE, &messages, cache.path()).unwrap(); let fixture = Fixture::new(&device); test(&fixture, &messages); - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } /// Whether the device announced [`ZERO_LAYER_AFTER_RELEASE`] since `messages` was last read. @@ -1017,5 +1019,5 @@ fn rate_mapped_passes_are_refused_where_metal_or_the_runtime_refuses_them() { RegionRefusal::Scissor ))) ); - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/rate_maps.rs b/crates/metal2vulkan-validation/src/runtime_lane/rate_maps.rs index ab96142aa..ccccc96c9 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/rate_maps.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/rate_maps.rs @@ -12,7 +12,10 @@ use super::degrade_notices::{assert_once, counts}; use super::kernel_textures::census; -use super::{public_cases, read_buffer, validated_device, Messages, ScratchCache}; +use super::{ + layer_reported_nothing, layer_reported_nothing_at_all, public_cases, read_buffer, + validated_device, Messages, ScratchCache, +}; use crate::case::Stage; use crate::gpu::TEST_DEVICE; use metal2vulkan::bind::{ @@ -57,11 +60,7 @@ fn on_device(test: impl FnOnce(&Device, &Messages)) { let device = validated_device(TEST_DEVICE, &messages, cache.path()).unwrap(); test(&device, &messages); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// A descriptor of `width` by `height` screen pixels and these layers, each one sample per axis. @@ -331,8 +330,7 @@ fn parameter_data_copies_where_the_cpu_reaches() { .unwrap(); assert_eq!(copy(&foreign, 0), invalid(Problem::ForeignObject)); drop((foreign, other)); - let reported = messages.take(); - assert!(reported.is_empty(), "the second device: {reported:#?}"); + layer_reported_nothing(&messages, "the second device"); }); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/reflection.rs b/crates/metal2vulkan-validation/src/runtime_lane/reflection.rs index a24841160..9951d1619 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/reflection.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/reflection.rs @@ -27,7 +27,10 @@ //! or its texture. use super::tile_states::descriptor as tile_descriptor; -use super::{buffer_with, read_buffer, validated_device, Messages, ScratchCache}; +use super::{ + buffer_with, layer_reported_nothing_at_all, read_buffer, validated_device, Messages, + ScratchCache, +}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::bind::{ArgumentDescriptor, ArgumentLayoutError, SamplerDescriptor}; @@ -60,11 +63,7 @@ fn on_device(test: impl FnOnce(&Device)) { let device = validated_device(TEST_DEVICE, &messages, cache.path()).unwrap(); test(&device); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// The library of reflection fixture `stem` on `device`. diff --git a/crates/metal2vulkan-validation/src/runtime_lane/render_arguments.rs b/crates/metal2vulkan-validation/src/runtime_lane/render_arguments.rs index 6e25bff06..3a3b73d43 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/render_arguments.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/render_arguments.rs @@ -12,7 +12,8 @@ use super::renders::{public_render, refusal, PublicRender}; use super::{ - buffer_with, read_buffer, texture_with, validated_device, Messages, ScratchCache, WAIT, + buffer_with, layer_reported_nothing_at_all, read_buffer, texture_with, validated_device, + Messages, ScratchCache, WAIT, }; use crate::air_library::AirLibrary; use crate::candidate::engine::graphics::{Assembly, RenderFunction, RenderOutput}; @@ -50,11 +51,7 @@ fn on_device(test: impl FnOnce(&Device)) { let device = validated_device(TEST_DEVICE, &messages, cache.path()).unwrap(); test(&device); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// What a draw of a case reaches through its fragment function's argument buffers: the owners @@ -377,7 +374,7 @@ fn another_devices_resources_are_refused() { drop(command_buffer); drop(foreign); drop(other); - assert!(messages.take().is_empty()); + layer_reported_nothing_at_all(&messages); }); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/render_barriers.rs b/crates/metal2vulkan-validation/src/runtime_lane/render_barriers.rs index 82fddd882..7e7b11bcf 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/render_barriers.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/render_barriers.rs @@ -33,8 +33,8 @@ use super::degrade_notices::assert_once; use super::memoryless::{memoryless, memoryless_msaa}; use super::resolves::{color_pass, lane, quiet, repeat, FULL, MASKED, ONE, SAMPLES, SIZE, WHITE}; use super::{ - buffer_with, buffer_with_options, read_buffer, validated_device, validated_device_with, - Messages, ScratchCache, WAIT, + buffer_with, buffer_with_options, layer_reported_nothing_at_all, read_buffer, validated_device, + validated_device_with, Messages, ScratchCache, WAIT, }; use crate::air_library::AirLibrary; use crate::candidate::runtime_case::executor_layer_settings; @@ -248,7 +248,7 @@ fn a_memory_barrier_orders_a_render_encoders_draws() { }); assert_eq!(words, TWO_DRAWS, "the resource barrier's pass"); }); - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); let notices = messages.take_notices(); assert_once(¬ices, &[Degradation::RenderPassSplit]); let split = notices @@ -287,7 +287,7 @@ fn a_fence_orders_render_encoders() { run(&command_buffer); assert_eq!(read(&words), TWO_DRAWS); }); - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } /// A barrier over the render targets alone, from the fragment stage to the fragment or the @@ -723,5 +723,5 @@ fn a_render_target_barrier_stays_inside_a_multiview_pass() { ); } } - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/render_state.rs b/crates/metal2vulkan-validation/src/runtime_lane/render_state.rs index 1ee30e9b3..ff855d1bf 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/render_state.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/render_state.rs @@ -31,7 +31,10 @@ use super::degrade_notices::made_render_kinds; use super::viewport_ranges::{depth_ranges_refused, native_depth_range}; -use super::{buffer_with, validated_device_with, LaneChecks, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, layer_reported_nothing_at_all, validated_device_with, LaneChecks, Messages, + ScratchCache, WAIT, +}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::device::VkFeature; @@ -478,11 +481,7 @@ fn validated_adjusted(adjust: impl FnOnce(&mut DeviceOptions)) -> (Messages, Scr pub(super) fn quiet(probe: Probe, messages: &Messages) { drop(probe); - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(messages); } /// Each probe draw stores the texels Metal stored (the module docs). Every draw runs, and the diff --git a/crates/metal2vulkan-validation/src/runtime_lane/renders.rs b/crates/metal2vulkan-validation/src/runtime_lane/renders.rs index e1f8bef94..d1f4bc4ca 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/renders.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/renders.rs @@ -34,8 +34,8 @@ //! texels (measured). use super::{ - buffer_with, metal_output, read_buffer, texture_usage, validated_device, Messages, RuntimeRun, - ScratchCache, WAIT, + buffer_with, layer_reported_nothing, layer_reported_nothing_at_all, metal_output, read_buffer, + texture_usage, validated_device, Messages, RuntimeRun, ScratchCache, WAIT, }; use crate::air::reflect::FragmentImageblock; use crate::candidate::engine::graphics::{render_case, RenderCase}; @@ -412,17 +412,17 @@ fn public_render_cases_match_metal() { "failed:\n{}\nat device destruction: {leaked:#?}", failed.join("\n") ); + layer_reported_nothing( + &messages, + "every case's draw was valid and left nothing behind", + ); assert!(matched > 0, "no case ran"); } /// Destroy `device`, then check the validation layer reported nothing, leaks included. fn quiet(device: Device, messages: &Messages) { drop(device); - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(messages); } fn invalid(call: &'static str, problem: Problem) -> Error { diff --git a/crates/metal2vulkan-validation/src/runtime_lane/resolves.rs b/crates/metal2vulkan-validation/src/runtime_lane/resolves.rs index 23dfc3f9e..2c171f061 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/resolves.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/resolves.rs @@ -20,7 +20,10 @@ //! its format's sRGB twin, which keeps its own encoding, as plain Metal's. use super::degrade_notices::assert_once; -use super::{buffer_with, read_buffer, validated_device_with, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, layer_reported_nothing_at_all, read_buffer, validated_device_with, Messages, + ScratchCache, WAIT, +}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::device::DriverFact; @@ -70,11 +73,7 @@ pub(super) fn lane_with(adjust: impl FnOnce(&mut DeviceOptions)) -> (Messages, S pub(super) fn quiet(lane: Lane, messages: &Messages) { drop(lane); - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(messages); } /// The per-sample color fragment of the probe's `f_samples`: red s/3, green 1 on sample 3, blue diff --git a/crates/metal2vulkan-validation/src/runtime_lane/resource_ids.rs b/crates/metal2vulkan-validation/src/runtime_lane/resource_ids.rs index 46fe9364f..b98a6a2a6 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/resource_ids.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/resource_ids.rs @@ -17,9 +17,9 @@ use super::degrade_notices::{ use super::host_memory::{no_copy, not_importable, Mapping, GUEST_PAGE}; use super::sparse_textures::{lacks_sparse, SparseFacts}; use super::{ - bound_buffers, buffer_with, case_making_kinds, creation_checked, encode_case, made_lane_device, - pipeline_state, public_case, read_buffer, texture_descriptor, validated_device_with, - CaseResources, Messages, PublicCase, ScratchCache, + bound_buffers, buffer_with, case_making_kinds, creation_checked, encode_case, + layer_reported_nothing_at_all, made_lane_device, pipeline_state, public_case, read_buffer, + texture_descriptor, validated_device_with, CaseResources, Messages, PublicCase, ScratchCache, }; use crate::candidate::engine::resources::argument_sampler_descriptor; use crate::candidate::engine::ComputeOutput; @@ -184,11 +184,7 @@ fn on_device_with(adjust: impl FnOnce(&mut DeviceOptions), test: impl FnOnce(&De let device = validated_device_with(TEST_DEVICE, &messages, cache.path(), adjust).unwrap(); test(&device, &messages); } - let failing = messages.take(); - assert!( - failing.is_empty(), - "the validation layer reported: {failing:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// [`HANDLE_SAMPLER`] (or another case of its shape: a 2-by-2 texture and a sampler state in its diff --git a/crates/metal2vulkan-validation/src/runtime_lane/restart.rs b/crates/metal2vulkan-validation/src/runtime_lane/restart.rs index bdc390241..5eb8ff989 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/restart.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/restart.rs @@ -22,7 +22,10 @@ //! blit wrote earlier in the command buffer, culled windings, the call's lifetime, and a last //! 16-bit index alone in its word (an odd count, or an offset 2 bytes past a multiple of 4). -use super::{buffer_with, dynamic_input_assembly, validated_device, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, dynamic_input_assembly, layer_reported_nothing_at_all, validated_device, Messages, + ScratchCache, WAIT, +}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::device::DriverFact; @@ -287,11 +290,7 @@ fn indexed_strips_restart_as_metal() { assert_eq!(counts, case.metal(), "{} on {name}: the counts", case.name); } } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// A strip, a list of its class and the strip again, drawn back to back in one encoder through @@ -363,11 +362,7 @@ fn a_strip_and_a_list_of_one_class_restart_as_metal_in_one_encoder() { driver measured to warn of it {warns})" ); } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// Whether `device`'s physical device, as its instance sees it, has both extended dynamic states: @@ -923,11 +918,7 @@ fn strips_restart_at_the_called_index_as_metal() { assert_eq!(counts, expected, "{} on {name}: the counts", case.name); } } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// The call lasts from where it is made, before the pipeline state or after, until the encoder @@ -1017,11 +1008,7 @@ fn the_restart_call_lasts_until_its_encoder_ends() { assert_eq!(&counts, expected, "{sequence} on {name}: the counts"); } } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// An indirect strip of 90,000 positions restarting at 7 every 1000 of them, whose list (3 ยท @@ -1070,11 +1057,7 @@ fn a_restarted_list_past_the_old_index_pool_draws_as_metal() { index pool, completed with Metal's counts" ); } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// A strip of a million positions, a restart every 1000 of them, counts what Metal's answer drawn @@ -1128,9 +1111,5 @@ fn a_million_position_strip_restarts_as_metal() { the pass), {without_pass:.3} ms for the strip at the all-ones index (no pass)" ); } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/rotated_textures.rs b/crates/metal2vulkan-validation/src/runtime_lane/rotated_textures.rs index 2420a8e06..522ca21db 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/rotated_textures.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/rotated_textures.rs @@ -25,7 +25,10 @@ //! `rotated_surface_frame_costs` times frames at the consumer's surface size, 1920x1080, rotated //! and not, and prints them (`ROTATION-COST`). -use super::{validated_device, validated_device_with, Messages, ScratchCache, WAIT}; +use super::{ + layer_reported_nothing_at_all, validated_device, validated_device_with, Messages, ScratchCache, + WAIT, +}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::metal::{ColorWriteMask, PixelFormat, PrimitiveType, TextureType, TextureUsage}; @@ -266,11 +269,7 @@ fn bytes_of(buffer: &Buffer) -> Vec { /// Check the validation layer reported nothing. fn quiet(messages: &Messages) { - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(messages); } /// Where Metal stores the pass texel `(x, y)` of a `w x h` texture of `rotation` (the module diff --git a/crates/metal2vulkan-validation/src/runtime_lane/row_copies.rs b/crates/metal2vulkan-validation/src/runtime_lane/row_copies.rs index 25b0b91ec..360b0457b 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/row_copies.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/row_copies.rs @@ -36,8 +36,8 @@ use super::host_memory::{no_copy, on_device, Mapping, GUEST_PAGE}; use super::{ - buffer_with, loader, open_device, read_buffer, validated_device, ycbcr_textures, Messages, - ScratchCache, + buffer_with, layer_reported_nothing_at_all, loader, open_device, read_buffer, validated_device, + ycbcr_textures, Messages, ScratchCache, }; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; @@ -419,11 +419,7 @@ fn rows_between_buffers_copy_metals_bytes() { let device = validated_device(TEST_DEVICE, &messages, cache.path()).unwrap(); row_copies(&device); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// Blits between buffers of one region each whose sizes a driver may record slowly as one region @@ -467,11 +463,7 @@ fn long_copies_of_any_size_copy_metals_bytes() { assert_eq!(split, 1, "a copy of {size} bytes: its region split"); } } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// A texture of 16-byte texels over a no-copy buffer 4 bytes past a page, which Vulkan copies diff --git a/crates/metal2vulkan-validation/src/runtime_lane/runtime_data.rs b/crates/metal2vulkan-validation/src/runtime_lane/runtime_data.rs index ac4cb64e3..8353a98e1 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/runtime_data.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/runtime_data.rs @@ -19,7 +19,10 @@ //! own), never one per format. use super::argument_linear_samples::{alike, device_filters}; -use super::{pipeline_state, public_cases, run_with, validated_device, Messages, ScratchCache}; +use super::{ + layer_reported_nothing_at_all, pipeline_state, public_cases, run_with, validated_device, + Messages, ScratchCache, +}; use crate::candidate::engine::resources::pixel_format; use crate::gpu::TEST_DEVICE; use metal2vulkan_runtime::ExecutedPipeline; @@ -163,5 +166,5 @@ fn one_pipeline_per_sampler_answers_every_bound_format_as_metal() { variant, whatever the bound format", variants.len() ); - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/runtime_levels.rs b/crates/metal2vulkan-validation/src/runtime_lane/runtime_levels.rs index 19d08593a..c243d6d62 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/runtime_levels.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/runtime_levels.rs @@ -32,7 +32,10 @@ use super::mip_levels::{half, levels, texture, FILTERED, LEVELS}; use super::nearest_positions::{metal_texel, multiplied_first}; -use super::{buffer_with, read_buffer, validated_device, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, layer_reported_nothing_at_all, read_buffer, validated_device, Messages, + ScratchCache, WAIT, +}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::bind::SamplerDescriptor; @@ -275,7 +278,7 @@ fn runtime_samplers_levels_read_metals_levels() { } assert!(wrong.is_empty(), "{name}: {} samples differ", wrong.len()); } - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } /// The positions texture: level `L` of `max(13 >> L, 1)` by `max(11 >> L, 1)` texels, texel @@ -435,5 +438,5 @@ fn runtime_nearest_samples_read_metals_texel_at_their_level() { } assert!(wrong.is_empty(), "{name}: {} lanes differ", wrong.len()); } - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/sample_copies.rs b/crates/metal2vulkan-validation/src/runtime_lane/sample_copies.rs index e1a279fd3..050719593 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/sample_copies.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/sample_copies.rs @@ -19,7 +19,7 @@ use super::degrade_notices::shared_in_system_memory; use super::degrade_notices::signs_depth_tests; use super::degrade_notices::{assert_made_once, clamps_depth_uploads, forced}; use super::degrade_notices::{loses_depth_denormals, made_compute_kinds, made_render_kinds}; -use super::{validated_device, Messages, ScratchCache, WAIT}; +use super::{layer_reported_nothing_at_all, validated_device, Messages, ScratchCache, WAIT}; use crate::candidate::runtime_samples::SampleFill; use crate::candidate::runtime_samples::{encode, fill_descriptor, read_function, read_view}; use crate::case::TextureFormat; @@ -460,9 +460,5 @@ fn multisampled_depth_and_stencil_copy_every_sample_with_colour() { ); } } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/sample_coverage.rs b/crates/metal2vulkan-validation/src/runtime_lane/sample_coverage.rs index d5ac958db..6fda4c445 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/sample_coverage.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/sample_coverage.rs @@ -24,7 +24,10 @@ //! fragments of their own), refused with `Feature::PixelCoverage`. One sample is never refused, //! so every device draws that count's cases. -use super::{buffer_with, read_buffer, validated_device_with, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, layer_reported_nothing_at_all, read_buffer, validated_device_with, Messages, + ScratchCache, WAIT, +}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::error::Feature; @@ -359,11 +362,7 @@ fn the_sample_coverage_keeps_the_samples_metal_keeps() { cases.len() - drawn ); drop(lane); - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// Under the coverage the fragment function still runs for every rasterized sample and reads the @@ -429,9 +428,5 @@ fn the_sample_coverage_applies_after_the_fragment_function() { assert!(drawn >= 3, "{name}: {drawn} draws"); eprintln!("{name}: {drawn} of 9 coverage draws are Metal's"); drop(lane); - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/sample_imageblocks.rs b/crates/metal2vulkan-validation/src/runtime_lane/sample_imageblocks.rs index 673cf8adc..6daf3593e 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/sample_imageblocks.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/sample_imageblocks.rs @@ -16,7 +16,9 @@ //! shader's image writes there). An add that discards column 7, failing with 2 and passing with //! 4, leaves 5 but 1 in column 7. -use super::{buffer_with, validated_device, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, layer_reported_nothing_at_all, validated_device, Messages, ScratchCache, WAIT, +}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::error::{Feature, Needs}; @@ -323,9 +325,5 @@ fn an_imageblock_is_per_sample_and_tested_as_metal_s() { } eprintln!("sample imageblocks on {name}: {}", answers.join("; ")); } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/sample_positions.rs b/crates/metal2vulkan-validation/src/runtime_lane/sample_positions.rs index c3e4e0c9a..0d074ca58 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/sample_positions.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/sample_positions.rs @@ -19,7 +19,10 @@ use super::degrade_notices::{ assert_once, counts, made_render_kinds, shared_in_system_memory, POSITIONED, }; use super::presenting::{image_info, made_image, shared_among}; -use super::{buffer_with, read_buffer, validated_device, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, layer_reported_nothing_at_all, read_buffer, validated_device, Messages, + ScratchCache, WAIT, +}; use crate::air_library::AirLibrary; use crate::candidate::runtime_samples::encode; use crate::executor_contract::multisample::{ReadbackView, SampleRead}; @@ -241,11 +244,7 @@ fn lane() -> (Messages, ScratchCache, Lane) { fn quiet(lane: Lane, messages: &Messages) { drop(lane); - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(messages); } /// Each sample lands where Metal put it: the device's own positions (4x: two of the four left @@ -1005,11 +1004,7 @@ fn depth_lane() -> (Messages, ScratchCache, Depths) { fn depths_quiet(lane: Depths, messages: &Messages) { drop(lane); - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(messages); } /// A depth attachment takes the pass's custom positions (`dz_*`): each sample stores the plane's diff --git a/crates/metal2vulkan-validation/src/runtime_lane/separate_samples.rs b/crates/metal2vulkan-validation/src/runtime_lane/separate_samples.rs index b391f7f35..fc49800e2 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/separate_samples.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/separate_samples.rs @@ -14,7 +14,9 @@ use super::degrade_notices::counts; use super::render_state::stencil; -use super::{buffer_with, validated_device, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, layer_reported_nothing_at_all, validated_device, Messages, ScratchCache, WAIT, +}; use crate::candidate::runtime_samples::{encode, library, shape, SampleFill}; use crate::case::TextureFormat; use crate::executor_contract::multisample::SampleRead; @@ -299,11 +301,7 @@ fn separate_multisampled_depth_and_stencil_keep_every_sample() { ); } } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// How [`three_passes`] ended. @@ -498,11 +496,7 @@ fn a_separate_multisampled_stencil_keeps_every_sample() { ); } } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// The two passes of [`a_separate_multisampled_stencil_keeps_every_sample`] at `extent` on @@ -747,11 +741,7 @@ fn fragment_depth_stores_depth_values_unchanged() { ); } } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// The 16-bit depth tests' extent: its 4 samples a pixel hold each of the 65536 codes once. @@ -873,11 +863,7 @@ fn fragment_depth_keeps_every_16_bit_code() { probe_16_bit_codes(&device); messages.take_notices(); } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// [`fragment_depth_keeps_every_16_bit_code`] on `device`. @@ -955,11 +941,7 @@ fn a_separate_multisampled_16_bit_depth_keeps_every_code() { separate_16_bit_codes(&device); messages.take_notices(); } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// [`a_separate_multisampled_16_bit_depth_keeps_every_code`] on `device`. diff --git a/crates/metal2vulkan-validation/src/runtime_lane/settled_sums.rs b/crates/metal2vulkan-validation/src/runtime_lane/settled_sums.rs index aeb236497..b06854f60 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/settled_sums.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/settled_sums.rs @@ -12,7 +12,10 @@ //! sums must be the correctly rounded ones and `converted`'s integers the truncated differences //! too. -use super::{buffer_with, read_buffer, validated_device, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, layer_reported_nothing_at_all, read_buffer, validated_device, Messages, + ScratchCache, WAIT, +}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::bind::SamplerDescriptor; @@ -387,9 +390,5 @@ fn a_sum_left_as_written_gives_its_settled_twin_s_words() { } assert!(failures.is_empty(), "{failures:#?}"); } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/shader_stencil.rs b/crates/metal2vulkan-validation/src/runtime_lane/shader_stencil.rs index 70210f293..2859a4e5a 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/shader_stencil.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/shader_stencil.rs @@ -44,7 +44,10 @@ use super::degrade_notices::shared_in_system_memory; use super::degrade_notices::{assert_made_once, forced, made_compute_kinds, made_render_kinds}; -use super::{buffer_with, read_buffer, validated_device_with, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, layer_reported_nothing_at_all, read_buffer, validated_device_with, Messages, + ScratchCache, WAIT, +}; use crate::air_library::AirLibrary; use crate::candidate::runtime_samples; use crate::executor_contract::multisample::SampleRead; @@ -773,11 +776,7 @@ fn a_stencil_output_tests_and_writes_the_stencil_as_metal() { eprintln!("stencil outputs on {name}: {}", answers.join("; ")); drop(lane); } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } } @@ -861,11 +860,7 @@ fn executed_commands_test_and_write_the_stencil_as_metal() { eprintln!("executed stencil outputs on {name}: {}", answers.join("; ")); drop(lane); } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } } @@ -927,11 +922,7 @@ fn a_host_step_s_draw_whose_stencil_output_reaches_no_attachment_binds_the_neutr ); drop(lane); } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } } @@ -993,10 +984,6 @@ fn a_host_step_s_run_of_another_shape_makes_its_objects_and_draws() { assert_made_once(&messages, &super::indirect_host_steps::HOST_STEPS, &first); drop(lane); } - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/stage_in_regions.rs b/crates/metal2vulkan-validation/src/runtime_lane/stage_in_regions.rs index 65ccbff4c..c2307939d 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/stage_in_regions.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/stage_in_regions.rs @@ -16,7 +16,10 @@ //! (Metal's probe kernel wrote it alone, so its words are compared plus 0x100), and //! `stage_in_region_pair` writes `(a << 16) | b`, `a` stepping by x and `b` by y. -use super::{buffer_with, read_buffer, validated_device, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, layer_reported_nothing_at_all, read_buffer, validated_device, Messages, + ScratchCache, WAIT, +}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::metal::{AttributeFormat, IndexType, StepFunction}; @@ -483,9 +486,5 @@ fn a_thread_past_the_stage_in_region_reads_as_metal() { assert_eq!(dispatched(&device, case), metal, "{}", case.name); } } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/stage_in_strides.rs b/crates/metal2vulkan-validation/src/runtime_lane/stage_in_strides.rs index 42d304beb..9ca57d57a 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/stage_in_strides.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/stage_in_strides.rs @@ -13,7 +13,10 @@ //! past the first reads as zeros); //! - a layout of a fixed stride reads at its own, whatever stride the buffer is bound with. -use super::{buffer_with, read_buffer, validated_device, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, layer_reported_nothing_at_all, read_buffer, validated_device, Messages, + ScratchCache, WAIT, +}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::metal::{AttributeFormat, IndirectCommandType, StepFunction}; @@ -202,11 +205,7 @@ fn on_device(test: impl FnOnce(&Device)) { let device = validated_device(TEST_DEVICE, &messages, cache.path()).unwrap(); test(&device); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// A dynamic layout reads the stride its buffer was bound with, by each of the three forms, the diff --git a/crates/metal2vulkan-validation/src/runtime_lane/submission_handlers.rs b/crates/metal2vulkan-validation/src/runtime_lane/submission_handlers.rs index 6e94dd8b3..e4845b5d3 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/submission_handlers.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/submission_handlers.rs @@ -15,7 +15,7 @@ //! scheduled handler starts, and Metal's wait for the scheduling returns only once every //! scheduled handler returned. -use super::{validated_device, Messages, ScratchCache}; +use super::{layer_reported_nothing_at_all, validated_device, Messages, ScratchCache}; use crate::gpu::TEST_DEVICE; use metal2vulkan_runtime::{ Buffer, CommandBuffer, CommandBufferStatus, CommandQueue, CommitFailure, DeadlockCause, Device, @@ -42,11 +42,7 @@ fn on_device(test: impl FnOnce(&Device)) { let device = validated_device(TEST_DEVICE, &messages, cache.path()).unwrap(); test(&device); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// A command buffer of `queue` filling `buffer` with `value`, not committed; `wait` leads it with diff --git a/crates/metal2vulkan-validation/src/runtime_lane/sync_coverage.rs b/crates/metal2vulkan-validation/src/runtime_lane/sync_coverage.rs index 50a227a62..3b0c21e5a 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/sync_coverage.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/sync_coverage.rs @@ -9,8 +9,9 @@ //! The races are harmless to the device: both accesses write or read the same few bytes. use super::{ - buffer_with, buffer_with_options, encode_case, pipeline_state, public_case, read_buffer, - validated_device_with, CaseResources, LaneChecks, Messages, PublicCase, ScratchCache, + buffer_with, buffer_with_options, encode_case, layer_reported_nothing_at_all, pipeline_state, + public_case, read_buffer, validated_device_with, CaseResources, LaneChecks, LayerClaim, + Messages, PublicCase, ScratchCache, }; use crate::gpu::TEST_DEVICE; use metal2vulkan::metal::DispatchType; @@ -93,6 +94,73 @@ fn case_buffers(device: &Device, case: &PublicCase) -> BTreeMap { .collect() } +/// The lane's claim that the validation layer reported nothing ([`layer_reported_nothing_at_all`], +/// stated at 300-odd lane sites) is no vacuous one: stated over a run whose hazard the layer did +/// report, it fails, naming what the layer said; stated again once those messages are gone, it +/// holds. The claim's other direction, a device the loader could not give the layer to, is stated +/// device-free (`candidate/runtime_case/layer_claim.rs`). +/// +/// The failing statement is caught here, so the run's output carries one expected panic of its +/// own, marked `SYNC-COVERAGE`. Where the device's instance could not enable the layer there is +/// no hazard to report, and the control says it did not run rather than hold anything. +#[test] +fn the_lane_s_claim_fails_where_the_layer_reported_a_hazard() { + const TEST: &str = "the_lane_s_claim_fails_where_the_layer_reported_a_hazard"; + let cache = ScratchCache::new().unwrap(); + let messages = Messages::default(); + { + let device = validated_device_with(TEST_DEVICE, &messages, cache.path(), |options| { + LaneChecks { + synchronization: true, + ..LaneChecks::default() + } + .apply(options) + }) + .unwrap(); + let opened = layer_reported_nothing_at_all(&messages); + if !opened.exercised() { + eprintln!( + "SYNC-COVERAGE {TEST}: {opened:?}, so the layer can report no hazard here; the \ + control did not run" + ); + return; + } + let queue = device.new_command_queue().unwrap(); + let buffer = device.new_buffer(256, untracked()).unwrap(); + let command_buffer = queue.command_buffer().unwrap(); + for value in [1, 2] { + let mut blit = command_buffer.blit_command_encoder().unwrap(); + blit.fill_buffer(&buffer, 0..256, value).unwrap(); + blit.end_encoding().unwrap(); + } + run(&command_buffer); + eprintln!("SYNC-COVERAGE {TEST}: the panic that follows is the control's own"); + let failure = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + layer_reported_nothing_at_all(&messages) + })) + .expect_err("the claim held over a run whose write after write the layer reported"); + let said = failure + .downcast_ref::() + .cloned() + .or_else(|| { + failure + .downcast_ref::<&str>() + .map(|text| (*text).to_owned()) + }) + .unwrap_or_default(); + assert!( + said.contains("SYNC-HAZARD-WRITE-AFTER-WRITE"), + "the failing claim named something other than the hazard: {said}" + ); + assert_eq!( + layer_reported_nothing_at_all(&messages), + LayerClaim::Held, + "the claim holds once the hazard's messages are gone" + ); + } + layer_reported_nothing_at_all(&messages); +} + /// Two blit encoders of one command buffer fill one untracked buffer: the layer sees transfer /// writes, and reports the write after write. #[test] diff --git a/crates/metal2vulkan-validation/src/runtime_lane/teardown_holders.rs b/crates/metal2vulkan-validation/src/runtime_lane/teardown_holders.rs index 719554ef3..42ff46edc 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/teardown_holders.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/teardown_holders.rs @@ -18,7 +18,7 @@ //! The pipelines are the owned fixture `validation/fixtures/public/examples/runtime_examples.ll`. use super::indirect_host_steps; -use super::{validated_device_with, Messages, ScratchCache, WAIT}; +use super::{layer_reported_nothing, validated_device_with, Messages, ScratchCache, WAIT}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::metal::{ @@ -185,10 +185,9 @@ fn in_every_order(holders: usize, make: impl Fn(&Device) -> Vec>) { messages.unshared_within(WAIT), "dropped in order {order:?}: the device's teardown did not end" ); - assert_eq!( - messages.take(), - Vec::new(), - "dropped in order {order:?} (the device is {holders}): the validation layer reported" + layer_reported_nothing( + &messages, + &format!("dropped in order {order:?} (the device is {holders})"), ); } } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/texel_swizzles.rs b/crates/metal2vulkan-validation/src/runtime_lane/texel_swizzles.rs index 9fd178a5a..38db55388 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/texel_swizzles.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/texel_swizzles.rs @@ -17,7 +17,10 @@ //! - `ob1_texel_buffer` writes the red channel of the `uint` texel of its slot-0 texture buffer //! at the index each thread is given, past the texture buffer for half of them. -use super::{buffer_with, read_buffer, validated_device, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, layer_reported_nothing_at_all, read_buffer, validated_device, Messages, + ScratchCache, WAIT, +}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::metal::{ @@ -349,7 +352,7 @@ fn swizzled_texture_buffers_read_metals_swizzled_texels() { } assert!(wrong.is_empty(), "{name}: {} reads differ", wrong.len()); } - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } /// A view of a texture buffer made with a swizzle reads its own swizzle, replacing its @@ -388,5 +391,5 @@ fn a_swizzled_view_of_a_texture_buffer_reads_its_own_swizzle() { } } } - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/texture_blits.rs b/crates/metal2vulkan-validation/src/runtime_lane/texture_blits.rs index e637726ac..e7a1313cc 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/texture_blits.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/texture_blits.rs @@ -9,7 +9,7 @@ use super::degrade_notices::{assert_made_once, assert_once, forced, loses_depth_denormals}; use super::degrade_notices::{decodes_blocks_its_way, shared_in_system_memory}; use super::degrade_notices::{twins_blocks, twins_carried, twins_depth}; -use super::{validated_device, Messages, ScratchCache}; +use super::{layer_reported_nothing_at_all, validated_device, Messages, ScratchCache}; use crate::gpu::TEST_DEVICE; use metal2vulkan::bind::{MipmapFilterChain, MipmapRule}; use metal2vulkan::device::VkExtension; @@ -407,11 +407,7 @@ fn texture_blits_copy_where_metal_puts_them() { blit.end_encoding().unwrap(); run(&command_buffer); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// A 1D texture made after a small 2D one keeps what a command buffer writing both writes into @@ -480,11 +476,7 @@ fn a_texture_beside_a_compressed_one_keeps_its_texels() { assert_eq!(level_bytes(&line, 0, 0, 4, 1, 4), counted(64, 16)); assert_eq!(level_bytes(&after, 0, 0, 4, 1, 4), counted(128, 16)); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// A size of 0 copies what plain Metal copies (an M4): on an axis a texture of the copy lacks, one @@ -587,11 +579,7 @@ fn empty_sizes_copy_what_plain_metal_copies() { .unwrap(); assert_eq!(read, vec![0x77; 64]); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// A 4x4 `RGBA8Unorm` texture's bytes when each row was copied from `rows` of a @@ -775,11 +763,7 @@ fn copies_off_metals_rules_land_where_plain_metal_puts_them() { .unwrap(); assert_eq!(level_bytes(&host, 0, 0, 4, 4, 4), rows_from([64; 4])); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// Block `i` of `level` of a `BC3_RGBA` texture of [`seeded_bc3`] `seed` (below 4): 16 bytes, each @@ -938,11 +922,7 @@ fn whole_blocks_of_levels_smaller_than_a_block_copy_whole() { assert_eq!(bc3_blocks(&source, small, 4), written); assert_eq!(bc3_blocks(&source, small, 3), seeded(0, small, 3)); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// Copies through the encoder's scratch buffer each start where Vulkan takes a depth aspect's @@ -984,11 +964,7 @@ fn depth_copies_through_the_scratch_buffer_start_at_multiples_of_four() { assert_eq!(level_bytes(&colour, 0, 0, 3, 3, 2), counted(0, 18)); assert_eq!(level_bytes(&colour, 1, 0, 1, 1, 2), counted(32, 2)); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// Copies between textures of different sizes copy what plain Metal copies (an M4 under macOS @@ -1076,11 +1052,7 @@ fn copies_between_textures_of_different_sizes_copy_what_metal_copies() { Err(invalid("copy_texture", Problem::Copy(CopyProblem::Size))) ); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// `generate_mipmaps` leaves a texture of one level, of any format, and a depth or stencil @@ -1168,11 +1140,7 @@ fn mipmaps_leave_single_levels_and_depth_as_they_are() { assert_eq!(level_bytes(&one, 0, 0, 4, 4, 4), counted(0, 64)); assert_eq!(with_bytes(&back, |b| b.to_vec()), values); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// The kind [`depth_outside_the_unit_range_uploads_as_metal_holds_it`] takes when it makes a @@ -1404,11 +1372,7 @@ fn depth_outside_the_unit_range_uploads_as_metal_holds_it() { ); } } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// What `device`'s depth images keep, as the runtime plans them: whether it enabled @@ -1517,11 +1481,7 @@ fn depth_images_keep_what_their_drivers_claim() { } messages.take_notices(); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } fn verdict(v: MipmapVerdict) -> &'static str { @@ -1670,9 +1630,5 @@ fn mipmaps_of_every_format_run_or_are_refused_typed() { ); } } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/texture_creators.rs b/crates/metal2vulkan-validation/src/runtime_lane/texture_creators.rs index d77b013d0..bdf39051e 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/texture_creators.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/texture_creators.rs @@ -18,7 +18,7 @@ //! buffer creators (the runtime's gap, `NotImplemented(WriteSwizzle)`) and stopped by the //! shared creator; the heap size query answers. Without the property every creator stops it. -use super::{validated_device, Messages, ScratchCache}; +use super::{layer_reported_nothing_at_all, validated_device, Messages, ScratchCache}; use crate::gpu::TEST_DEVICE; use metal2vulkan::metal::{ PixelFormat, TextureSwizzle, TextureSwizzleChannels, TextureType, TextureUsage, @@ -204,9 +204,5 @@ fn each_creator_answers_as_metals() { assert_eq!(shared, Some(invalid("new_shared_texture", stop))); assert_eq!(sized, Some(invalid("heap_texture_size_and_align", stop))); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/textures.rs b/crates/metal2vulkan-validation/src/runtime_lane/textures.rs index 7d486e5cc..d4711e1b3 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/textures.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/textures.rs @@ -3,7 +3,10 @@ //! levels, slices and formats, a view of another component layout read in a kernel, and Metal's //! refusals, under the validation layer. -use super::{buffer_with, read_buffer, validated_device, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, layer_reported_nothing_at_all, read_buffer, validated_device, Messages, + ScratchCache, WAIT, +}; use crate::candidate::runtime_samples::encode_through; use crate::candidate::runtime_samples::SampleFill; use crate::case::{TextureFormat as CaseFormat, TextureType as CaseType}; @@ -141,11 +144,7 @@ fn padded_formats_are_made_in_memory_of_their_own() { assert_eq!(texture.pixel_format(), pf); } } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// A padded 10-bit texture in memory of its own reads zero when new and round-trips its words @@ -224,11 +223,7 @@ fn padded_textures_of_their_own_memory_round_trip_their_words() { } } } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// A 2D texture of `pf` and `extent`, read by shaders, with `levels` levels. @@ -339,11 +334,7 @@ fn every_format_makes_a_texture_or_is_refused_typed() { ); assert!(made > 50 && round_trips > 40, "{made} {round_trips}"); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// Levels, slices and 3D images copy where Metal puts them; views present their texture's levels @@ -673,11 +664,7 @@ fn textures_copy_levels_slices_and_views() { )) ); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// A view of another component layout presents its texture's bits, as Metal's does: a 4x @@ -749,11 +736,7 @@ fn a_view_of_another_component_layout_reads_the_textures_bits() { device.name() ); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// Labels and purgeable states of textures as Metal answered them (an Apple M3 Max and an M4): each @@ -876,9 +859,5 @@ fn texture_labels_and_purgeable_states_answer_as_metal() { in_heap.set_label("in a heap"); assert_eq!(in_heap.label().as_deref(), Some("in a heap")); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/tile_dispatches.rs b/crates/metal2vulkan-validation/src/runtime_lane/tile_dispatches.rs index accd58722..309f5fcd7 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/tile_dispatches.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/tile_dispatches.rs @@ -26,7 +26,10 @@ use super::degrade_notices::assert_once; use super::kernel_textures::census; use super::shared_kinds; use super::tile_states::{descriptor, on_device}; -use super::{public_cases, read_buffer, validated_device, Messages, ScratchCache, WAIT}; +use super::{ + layer_reported_nothing_at_all, public_cases, read_buffer, validated_device, Messages, + ScratchCache, WAIT, +}; use crate::case::Stage; use crate::gpu::TEST_DEVICE; use metal2vulkan::metal::{PixelFormat, TextureUsage}; @@ -379,7 +382,7 @@ fn a_tile_dispatch_announces_its_scratch_and_split_once() { }); } } - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); let notices = messages.take_notices(); assert_once(¬ices, &kinds); let split = notices diff --git a/crates/metal2vulkan-validation/src/runtime_lane/tile_shadows.rs b/crates/metal2vulkan-validation/src/runtime_lane/tile_shadows.rs index 4b81e72d7..6ba953176 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/tile_shadows.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/tile_shadows.rs @@ -28,7 +28,10 @@ use super::buffer_texture_blits::{texel, Held, Kind, OFF}; use super::buffer_texture_renders::MERGES; use super::degrade_notices::counts; -use super::{buffer_with, read_buffer, validated_device, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, layer_reported_nothing_at_all, read_buffer, validated_device, Messages, + ScratchCache, WAIT, +}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::metal::{PixelFormat, PrimitiveType, RenderStages, ResourceUsage, TextureUsage}; @@ -250,11 +253,7 @@ fn each_kind(test: impl Fn(&Lane, Kind)) { /// Fail on any validation message. fn quiet(messages: &Messages) { - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(messages); } /// Probe 3's `copy` and `copy_held`: a dispatch copies a texture bound in the tile table, and diff --git a/crates/metal2vulkan-validation/src/runtime_lane/tile_states.rs b/crates/metal2vulkan-validation/src/runtime_lane/tile_states.rs index c785704e9..ca6eae0c7 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/tile_states.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/tile_states.rs @@ -17,7 +17,7 @@ //! a draw with a tile state set. use super::render_state::texture; -use super::{validated_device, Messages, ScratchCache}; +use super::{layer_reported_nothing_at_all, validated_device, Messages, ScratchCache}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::error::DescriptorError; @@ -53,11 +53,7 @@ pub(super) fn on_device(test: impl FnOnce(&Device)) { let device = validated_device(TEST_DEVICE, &messages, cache.path()).unwrap(); test(&device); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// The library of the owned fixture `stem` on `device`. diff --git a/crates/metal2vulkan-validation/src/runtime_lane/topology_classes.rs b/crates/metal2vulkan-validation/src/runtime_lane/topology_classes.rs index 760b722e1..229f05683 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/topology_classes.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/topology_classes.rs @@ -19,7 +19,10 @@ use super::degrade_notices::counts; use super::render_state::{texels, texture}; -use super::{buffer_with, read_buffer, validated_device_with, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, layer_reported_nothing_at_all, read_buffer, validated_device_with, Messages, + ScratchCache, WAIT, +}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::metal::{ @@ -209,11 +212,7 @@ fn a_draw_outside_the_pipeline_s_class_draws_as_plain_metal() { } eprintln!("draws outside their pipeline's class on {name}: Metal's"); drop(lane); - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// `unsized-points`, asked for at every occurrence, is announced where each draw of points the @@ -302,9 +301,5 @@ fn unsized_points_are_announced_at_the_draw_the_commit_and_the_host_step() { "CBF-MARK {name}: unsized points were announced at the draw, the commit and the host \ step, and drew nothing" ); - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/uniform_varyings.rs b/crates/metal2vulkan-validation/src/runtime_lane/uniform_varyings.rs index e6a2951f3..7e1c67a71 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/uniform_varyings.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/uniform_varyings.rs @@ -27,7 +27,10 @@ //! with `xcrun metal -S -emit-llvm -O2` and written with opaque pointers, its alias metadata //! dropped. -use super::{buffer_with, read_buffer, validated_device, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, layer_reported_nothing_at_all, read_buffer, validated_device, Messages, + ScratchCache, WAIT, +}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::metal::{PixelFormat, PrimitiveType, TextureType, TextureUsage}; @@ -742,5 +745,5 @@ fn a_varying_alike_at_every_vertex_reads_metal_s_words() { differs.len() ); } - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/vertex_strides.rs b/crates/metal2vulkan-validation/src/runtime_lane/vertex_strides.rs index ccb941d00..547cf972e 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/vertex_strides.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/vertex_strides.rs @@ -15,7 +15,10 @@ //! layout refuses the commit (`UnstridedBuffer`): Metal reads it at stride 2^32 - 1, past //! vertex 0 whatever memory lies 4 GiB on. -use super::{buffer_with, read_buffer, validated_device, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, layer_reported_nothing_at_all, read_buffer, validated_device, Messages, + ScratchCache, WAIT, +}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::metal::{ @@ -192,7 +195,7 @@ fn vertex_buffers_bind_the_strides_a_dynamic_layout_reads() { "the offset form with a stride of 2^63 + 12" ); } - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } /// The words each vertex wrote after an indirect render command drew `pipeline` (made with @@ -280,7 +283,7 @@ fn an_executed_command_s_unstrided_vertex_buffer_is_refused() { "the stride form" ); } - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } /// A buffer of `length` bytes, more than `2^32`, for a fetch past 4 GiB: on macOS a no-copy @@ -480,5 +483,5 @@ fn vertex_fetches_past_4_gib_of_a_buffer_are_refused() { ); drop((command_buffer, icb, large)); } - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/view_attachments.rs b/crates/metal2vulkan-validation/src/runtime_lane/view_attachments.rs index 136304e7c..f45c8c14e 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/view_attachments.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/view_attachments.rs @@ -24,7 +24,8 @@ use super::buffer_texture_blits::{Held, Kind, OFF}; use super::{ - buffer_with, read_buffer, validated_device, validated_device_with, Messages, ScratchCache, WAIT, + buffer_with, layer_reported_nothing_at_all, read_buffer, validated_device, + validated_device_with, Messages, ScratchCache, WAIT, }; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; @@ -322,11 +323,7 @@ fn on_device(test: impl FnOnce(&Lane)) { let device = validated_device(TEST_DEVICE, &messages, cache.path()).unwrap(); test(&Lane::new(&device)); } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } /// A view of another format renders in that format's encoding into its texture's bytes: the @@ -1053,11 +1050,7 @@ fn an_attachment_in_a_format_the_level_describes_none_of_stops_the_pipeline() { } } } - let messages = messages.take(); - assert!( - messages.is_empty(), - "the validation layer reported: {messages:#?}" - ); + layer_reported_nothing_at_all(&messages); } #[test] diff --git a/crates/metal2vulkan-validation/src/runtime_lane/view_reinterpretation.rs b/crates/metal2vulkan-validation/src/runtime_lane/view_reinterpretation.rs index dda0fb51e..de03be8a9 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/view_reinterpretation.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/view_reinterpretation.rs @@ -15,7 +15,7 @@ use super::buffer_texture_blits::linear_rows_differ; use super::degrade_notices::{assert_made_once, forced, shared_in_system_memory}; use super::presenting::Adopted; -use super::{validated_device_with, Messages, ScratchCache}; +use super::{layer_reported_nothing, validated_device_with, Messages, ScratchCache}; use crate::gpu::TEST_DEVICE; use metal2vulkan::error::Feature; use metal2vulkan::metal::{PixelFormat, TextureType, TextureUsage}; @@ -670,10 +670,6 @@ fn a_shadowed_view_answers_as_a_view_of_the_image_does() { device.name() ); } - let reported = messages.take(); - assert!( - reported.is_empty(), - "withheld {withheld}: the validation layer reported: {reported:#?}" - ); + layer_reported_nothing(&messages, &format!("withheld {withheld}")); } } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/word_samples.rs b/crates/metal2vulkan-validation/src/runtime_lane/word_samples.rs index d867d0b6c..fc09fd373 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/word_samples.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/word_samples.rs @@ -14,7 +14,10 @@ //! Metal's codes). Each sample is read by a kernel through `texture2d_ms`, decoded through Metal's //! table, so equal codes read equal values. -use super::{buffer_with, read_buffer, validated_device_with, Messages, ScratchCache, WAIT}; +use super::{ + buffer_with, layer_reported_nothing_at_all, read_buffer, validated_device_with, Messages, + ScratchCache, WAIT, +}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; use metal2vulkan::metal::format::WordAttachment; @@ -217,9 +220,5 @@ fn a_partly_masked_draw_merges_each_samples_own_word() { ); assert!(mixed > 0, "{name}: no texel's samples differ"); drop(lane); - let reported = messages.take(); - assert!( - reported.is_empty(), - "the validation layer reported: {reported:#?}" - ); + layer_reported_nothing_at_all(&messages); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/wrapped_buffers.rs b/crates/metal2vulkan-validation/src/runtime_lane/wrapped_buffers.rs index 02ed416df..1f722ad77 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/wrapped_buffers.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/wrapped_buffers.rs @@ -19,7 +19,8 @@ use super::host_bytes::{buffer_output, dispatch, over, SAMPLER, TEXTURE_WRITER}; use super::vertex_strides::pipeline; use super::{ - buffer_with, public_case, read_buffer, run_case, validated_device, Messages, ScratchCache, WAIT, + buffer_with, layer_reported_nothing_at_all, public_case, read_buffer, run_case, + validated_device, Messages, ScratchCache, WAIT, }; use crate::gpu::TEST_DEVICE; use ash::vk; @@ -316,7 +317,7 @@ fn a_callers_shared_buffer_is_a_metal_buffer() { // SAFETY: the runtime's buffer is gone, and every command buffer completed. unsafe { made.destroy(&device) }; } - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } /// A `Private` buffer in device memory takes a copy in and gives it back; a buffer the runtime @@ -397,5 +398,5 @@ fn a_callers_private_buffer_copies_and_contradictions_are_refused() { made.destroy(&device); } } - assert_eq!(messages.take(), Vec::new(), "the validation layer reported"); + layer_reported_nothing_at_all(&messages); } diff --git a/docs/VALIDATION.md b/docs/VALIDATION.md index 4afb61994..0a9a97351 100644 --- a/docs/VALIDATION.md +++ b/docs/VALIDATION.md @@ -84,9 +84,15 @@ METAL2VULKAN_LANE_VALIDATION=sync RUSTFLAGS='--cfg m2v_cpu_icd' cargo nextest ru A lane device opens whether or not the loader can provide the layer it asks for: the runtime drops a layer the loader answers `VK_ERROR_LAYER_NOT_PRESENT` for and says so as the device is made. A claim of what the layer reported therefore states what it holds, against the layers the instance -enabled and nothing else (`runtime_lane::layer_reported_nothing`): where the layer was dropped the -claim is not exercised, and the test prints `LANE-LAYER-ABSENT : ...` and a count per message -list instead of passing on an empty list. A host whose layer manifest names its library by a bare +enabled and nothing else: where the layer was dropped the claim is not exercised, and the test +prints `LANE-LAYER-ABSENT : ...` and a count per message list instead of passing on an empty +list. Three forms state it, and no lane test reads a message list for emptiness any other way: + +| Form | The claim | +|---|---| +| `layer_reported_nothing_at_all(&messages)` | The widest claim, and the one the lane states oftenest: whatever the layer checked of the work so far, it reported nothing of it | +| `layer_reported_nothing(&messages, claim)` | The same, of the narrower `claim` the test names, which leads the failure and the `LANE-LAYER-ABSENT` line | +| `nothing_reported_without_the_layer(&messages, claim)` | A device the test made without the validation layer, to time something: the claim is the driver's own messages and the runtime's, so the layer's absence takes nothing from it. It fails where such a device did ask for the layer after all | A host whose layer manifest names its library by a bare filename (which the loader looks for on the system library search path) provides no layer at all, and a lane run there is evidence for everything but the layer's checks. The executor's own Vulkan context refuses to open without the layer instead (`candidate::platform::device`).