From e3ade73ace66a3de032c19785beeb3531bd23afb Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Wed, 21 Oct 2026 19:26:26 +0300 Subject: [PATCH] Run a fragment's quads whole through MoltenVK 1.4.2 without shaderQuadControl The steps this packet landed as, in order: - Withhold MoltenVK 1.4.2's blend warning of attachments it cannot blend - Measure the M3 Max at MoltenVK 1.4.2, named apart from the M4 - Say what queue_storms measured at MoltenVK 1.4.2 plainly - Make a heap's set layout MoltenVK's support query refuses only where it runs it, announced Content: the tree of `development` at 285be2f493, unchanged. --- .../metal2vulkan-runtime/src/degradation.rs | 65 +++- .../src/device/argument_buffers.rs | 7 +- .../src/device/compiles.rs | 12 +- .../metal2vulkan-runtime/src/device/create.rs | 27 +- crates/metal2vulkan-runtime/src/device/mod.rs | 9 +- .../src/driver_defects.rs | 24 ++ .../metal2vulkan-runtime/src/driver_facts.rs | 35 +++ crates/metal2vulkan-runtime/src/lib.rs | 2 + .../src/pipeline/graphics.rs | 12 +- .../src/pipeline/objects.rs | 124 +++++++- .../src/tests/degradation_codes.txt | 1 + .../src/tests/driver_defects.rs | 35 ++- .../metal2vulkan-validation/src/candidate.rs | 1 + .../src/candidate/platform/device.rs | 79 ++++- .../candidate/platform/graphics_pipeline.rs | 8 +- .../src/candidate/platform/profiles.rs | 5 +- .../src/candidate/platform/profiles/tests.rs | 3 + .../src/candidate/runtime_case.rs | 35 ++- .../src/candidate/unsupported_set.rs | 98 ++++++ .../src/runtime_lane.rs | 10 +- .../src/runtime_lane/degrade_notices.rs | 98 ++++-- .../src/runtime_lane/queue_storms.rs | 10 +- .../src/runtime_lane/resource_ids.rs | 75 ++++- crates/metal2vulkan/src/ash_interop/query.rs | 4 + crates/metal2vulkan/src/cache/codec.rs | 1 + crates/metal2vulkan/src/device/derive.rs | 3 + crates/metal2vulkan/src/device/description.rs | 7 + .../metal2vulkan/src/device/driver_facts.rs | 297 ++++++++++++++++-- crates/metal2vulkan/src/device/khronos.rs | 9 + crates/metal2vulkan/src/device/profile.rs | 3 + .../metal2vulkan/src/device/requirements.rs | 8 + .../src/device/tests/driver_facts.rs | 206 ++++++++++-- .../metal2vulkan/src/device/tests/profile.rs | 1 + crates/metal2vulkan/src/error/mod.rs | 17 + crates/metal2vulkan/src/lower/simd/mod.rs | 43 ++- crates/metal2vulkan/src/pipeline/compile.rs | 7 + crates/metal2vulkan/src/tests/engine_simd.rs | 77 +++++ docs/API.md | 33 +- docs/FAST-PATHS.md | 6 +- docs/REFUSALS.md | 20 +- 40 files changed, 1336 insertions(+), 181 deletions(-) create mode 100644 crates/metal2vulkan-validation/src/candidate/unsupported_set.rs diff --git a/crates/metal2vulkan-runtime/src/degradation.rs b/crates/metal2vulkan-runtime/src/degradation.rs index 1d33d816c..55bd5c967 100644 --- a/crates/metal2vulkan-runtime/src/degradation.rs +++ b/crates/metal2vulkan-runtime/src/degradation.rs @@ -68,6 +68,7 @@ use super::color_resolve; use super::device::{DebugMessage, Device, MessageKind, MessageSeverity}; use super::error::Error; use super::fragment_imageblock::PassImageblock; +use super::pipeline::objects::{set_layout_support, SetSupport}; use super::render_pass::{ColorTarget, PassLayout, Target}; use super::render_target::{self, depth_stencil_steps, HandedDontCare, PassShape}; use super::render_values::{LoadAction, StoreAction}; @@ -139,9 +140,10 @@ pub enum DegradationCategory { /// A recorded near-equivalent: Metal's answer is not given exactly. Precision, /// Metal's answer, exactly, through use of the device that its driver does not advertise - /// but runs as Metal does, measured (a `metal2vulkan::error::DriverDeviation`): Vulkan does - /// not allow the use on the device as the driver describes it, so the validation layer - /// reports it. + /// but runs as Metal does, measured (a `metal2vulkan::error::DriverDeviation`, or a + /// `metal2vulkan::error::RuntimeDriverDefect` of a query that refuses what the driver runs): + /// Vulkan does not allow the use on the device as the driver describes it, so the validation + /// layer reports it. Validity, } @@ -692,7 +694,8 @@ degradations! { /// A command buffer's GPU times on a device told to answer them from the host /// (`DeviceOptions::gpu_times_from_host`, `RawDevice::gpu_times_from_host`), or whose /// driver's timestamps wait for every queue's (`DriverFact::TimestampsWaitForEveryQueue`: - /// MoltenVK 1.4.1 on Apple's GPUs), which writes no GPU timestamps (`gpu_time.rs`). Every + /// MoltenVK 1.4.1 on Apple's GPUs, 1.4.2 on the M3 Max), which writes no GPU timestamps + /// (`gpu_time.rs`). Every /// answer is one Metal could give: seconds of Metal's clock (`mach_absolute_time`'s, on /// macOS); its commit, kernel start, kernel end, GPU start, GPU end and the moment its /// completion is observable in that order; and a queue's command buffers one after @@ -1232,6 +1235,14 @@ degradations! { "the device runs them as Metal does, but its driver leaves the vertex stage out of \ subgroupSupportedStages, so Vulkan's validation layer reports each shader module of \ the function (VUID-RuntimeSpirv-None-06343)"; + /// A descriptor set layout the device's driver refuses through + /// `vkGetDescriptorSetLayoutSupport` though it makes and runs it, a heap's set 1 past + /// `maxPerSetDescriptors` ([`metal2vulkan::error::RuntimeDriverDefect::SetLayoutSupportUnderstated`]): + /// the runtime makes it there as the driver runs it (`pipeline/objects.rs`). + SetPastLayoutSupport = "set-past-layout-support", Validity, + "the device runs the set as Metal runs the argument buffer it is encoded in, but its \ + driver's vkGetDescriptorSetLayoutSupport refuses the layout, so Vulkan's validation \ + layer reports each such layout (VUID-vkCreateDescriptorSetLayout-support-09582)"; /// An indirect command naming the ID of a pipeline state the program released is /// executed where the runtime cannot run what Metal runs (`indirect_command_buffer.rs`). A /// command holds the program of the state the CPU set on it, and runs it while its record @@ -1538,9 +1549,10 @@ degradations! { differs"; /// A texture of a BC1 to BC5 format (`BC1_RGBA` to `BC5_RGSnorm`, the sRGB forms too) /// made on a device whose driver is not measured to decode their texels as Metal does - /// (BC1 to BC3 `DriverFact::ColorBlockDecodeIsMetals`: MoltenVK 1.4.1 on Apple's GPUs, - /// RADV from Mesa 26.2.4 on the 780M; BC4 and BC5 `DriverFact::ChannelBlockDecodeIsMetals`: - /// MoltenVK 1.4.1 on Apple's GPUs). Only a texture without a decoded twin + /// (BC1 to BC3 `DriverFact::ColorBlockDecodeIsMetals`: MoltenVK 1.4.1 on Apple's GPUs + /// and 1.4.2 on the M3 Max, RADV from Mesa 26.2.4 on the 780M; BC4 and BC5 + /// `DriverFact::ChannelBlockDecodeIsMetals`: MoltenVK 1.4.1 on Apple's GPUs and 1.4.2 on + /// the M3 Max). Only a texture without a decoded twin /// (`decoded-block-twin`): one over the caller's host pages or laid out apart from a heap's /// bytes, a memoryless or sparse texture, one over a surface or the caller's image, one /// whose twin's format the device cannot sample, filter and copy into. @@ -2476,6 +2488,14 @@ pub(crate) enum CompiledPipeline<'a> { } impl<'a> CompiledPipeline<'a> { + /// The pipeline's layout. + fn layout(self) -> &'a metal2vulkan::pipeline::PipelineLayout { + match self { + CompiledPipeline::Render(p) => &p.layout, + CompiledPipeline::Kernel(p) => &p.layout, + } + } + /// The pipeline's runtime dependencies. fn dependencies(self) -> &'a [metal2vulkan::pipeline::RuntimeDependency] { match self { @@ -3018,8 +3038,10 @@ impl Device { /// word bound ([`Degradation::ExactFormsOverCompilerLimit`]), naming the pipeline state's kind /// (render, mesh render, tile render or compute), and, for a render variant, requirements that /// hold a vertex function's subgroup operations on a driver that runs them as Metal does - /// without advertising the vertex stage ([`Degradation::UnadvertisedVertexSimdgroups`]); for - /// the base variant and every other alike, each pipeline by its own records. + /// without advertising the vertex stage ([`Degradation::UnadvertisedVertexSimdgroups`]), and, + /// for any, a set layout its driver refuses though it runs it + /// ([`Degradation::SetPastLayoutSupport`], before any layout of the variant is made); for the + /// base variant and every other alike, each pipeline by its own records. pub(super) fn degrade_pipeline(&self, pipeline: CompiledPipeline<'_>, at: Occurrence<'_>) { if let Some(dropped) = dropped_exact_forms(pipeline.dependencies()) { self.degrade_at(at, Degradation::ExactFormsOverCompilerLimit, || { @@ -3033,6 +3055,31 @@ impl Device { ) }); } + if self + .shared() + .announced + .pending(Degradation::SetPastLayoutSupport) + { + for set in &pipeline.layout().sets { + if set_layout_support(self, set) != SetSupport::Understated { + continue; + } + let total: u64 = set.bindings.iter().map(|b| u64::from(b.count)).sum(); + self.degrade_at(at, Degradation::SetPastLayoutSupport, || { + ( + pipeline.object().to_owned(), + format!( + "its set {} holds {total} descriptors, which {} makes and runs as \ + Metal runs the argument buffer it encodes the set in (measured, \ + `RuntimeDriverDefect::SetLayoutSupportUnderstated`) though its \ + driver's vkGetDescriptorSetLayoutSupport refuses the layout", + set.set, + self.name() + ), + ) + }); + } + } let CompiledPipeline::Render(pipeline) = pipeline else { return; }; diff --git a/crates/metal2vulkan-runtime/src/device/argument_buffers.rs b/crates/metal2vulkan-runtime/src/device/argument_buffers.rs index ef7902aac..a10356fa5 100644 --- a/crates/metal2vulkan-runtime/src/device/argument_buffers.rs +++ b/crates/metal2vulkan-runtime/src/device/argument_buffers.rs @@ -22,7 +22,10 @@ //! as 1,000,000 where `isTier2MetalArgumentBuffers()` (argument buffers in use on a tier-2 GPU), //! else as `maxPerStageDescriptorSampledImages`; and every Apple GPU a Mac has is tier 2, so on //! one the per-stage value means argument buffers are off. Measured on 1.4.1 on an Apple M3 Max: -//! 1,000,000 (and 256 per stage) with the setting on, 128 and 128 with it off. Not from +//! 1,000,000 (and 256 per stage) with the setting on, 128 and 128 with it off. 1.4.2's +//! `initProperties`, `isTier2MetalArgumentBuffers` and `initMetalFeatures` are 1.4.1's on these +//! (read in its source), and on an Apple M3 Max it reports 1,000,000 with the setting on and is +//! refused with it off (`runtime_lane::degrade_notices`). Not from //! `pipelineCacheUUID`, whose argument-buffer bit `initPipelineCacheUUID` writes before //! `initMetalFeatures` sets the flag, so it is 1 either way (read in 1.4.1's source, and measured). //! Any other release, or another GPU's vendor, or limits of neither shape, is @@ -44,7 +47,7 @@ pub(crate) const SETTING: &CStr = c"MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS"; /// The MoltenVK releases (`driverVersion`, `major * 10000 + minor * 100 + patch`) whose /// `initProperties` and `initMetalFeatures` were read for the limits the module docs decode. -pub(crate) const READ: &[u32] = &[10401]; +pub(crate) const READ: &[u32] = &[10401, 10402]; /// `maxPerStageDescriptorUpdateAfterBindSampledImages` with tier-2 argument buffers in use, at /// each release [`READ`] lists (`1e6` in `initProperties`). diff --git a/crates/metal2vulkan-runtime/src/device/compiles.rs b/crates/metal2vulkan-runtime/src/device/compiles.rs index 92ea0c60e..cdebcddae 100644 --- a/crates/metal2vulkan-runtime/src/device/compiles.rs +++ b/crates/metal2vulkan-runtime/src/device/compiles.rs @@ -410,7 +410,7 @@ mod tests { }, id_name: warning.id_name.into(), id: warning.id, - text: warning.text.into(), + text: warning.text.into_owned(), degradation: None, }; let withheld = u64::from(crate::driver_facts::withholds(&message)); @@ -421,14 +421,16 @@ mod tests { vk::Result::SUCCESS } - /// MoltenVK 1.4.1's warning of a pipeline whose restart is dynamic. + /// MoltenVK's warning of a pipeline whose restart is dynamic. fn restart_warning() -> metal2vulkan::device::DriverDiagnostic { use metal2vulkan::vk::{DynamicState as D, PrimitiveTopology as T}; metal2vulkan::device::DriverFact::DynamicRestartWarns - .pipeline_creation_diagnostic( + .pipeline_creation_diagnostics( &[D::PRIMITIVE_TOPOLOGY, D::PRIMITIVE_RESTART_ENABLE], T::TRIANGLE_LIST, + &[], ) + .pop() .expect("the warning of a dynamic restart") } @@ -573,7 +575,7 @@ mod tests { Q::QOS_CLASS_USER_INITIATED, ] { assert_eq!( - asked(at(start), expecting(vec![warning])), + asked(at(start), expecting(vec![warning.clone()])), (1, 1), "withheld and counted, from {start:?}" ); @@ -584,7 +586,7 @@ mod tests { ); } } - assert_eq!(asked(|| {}, expecting(vec![warning])), (1, 1)); + assert_eq!(asked(|| {}, expecting(vec![warning.clone()])), (1, 1)); assert_eq!(asked(|| {}, expecting(Vec::new())), (0, 0)); unregister(device.handle()); } diff --git a/crates/metal2vulkan-runtime/src/device/create.rs b/crates/metal2vulkan-runtime/src/device/create.rs index afe46d2aa..5d69af707 100644 --- a/crates/metal2vulkan-runtime/src/device/create.rs +++ b/crates/metal2vulkan-runtime/src/device/create.rs @@ -1562,10 +1562,12 @@ mod tests { #[test] fn a_measured_diagnostic_is_withheld_inside_its_call_alone() { let warning = DriverFact::DynamicRestartWarns - .pipeline_creation_diagnostic( + .pipeline_creation_diagnostics( &[D::PRIMITIVE_TOPOLOGY, D::PRIMITIVE_RESTART_ENABLE], T::TRIANGLE_LIST, + &[], ) + .pop() .expect("the warning of a dynamic restart"); let received: Arc>> = Arc::default(); let sink = { @@ -1580,37 +1582,38 @@ mod tests { let user = std::ptr::from_ref(&sink) as usize; use vk::DebugUtilsMessageSeverityFlagsEXT as S; use vk::DebugUtilsMessageTypeFlagsEXT as K; - let report = |severity: S, kind: K, text: &str| sent(user, warning, severity, kind, text); + let report = |severity: S, kind: K, text: &str| sent(user, &warning, severity, kind, text); let delivered = || received.lock().unwrap().len(); - report(S::WARNING, K::VALIDATION, warning.text); + report(S::WARNING, K::VALIDATION, &warning.text); assert_eq!(delivered(), 1, "outside the call"); - let ((), withheld) = crate::driver_facts::expecting(vec![warning], || { - report(S::WARNING, K::VALIDATION, warning.text); + let ((), withheld) = crate::driver_facts::expecting(vec![warning.clone()], || { + report(S::WARNING, K::VALIDATION, &warning.text); assert_eq!(delivered(), 1, "inside the call"); // Another thread, started as the runtime starts its own and joined before the sink // goes. + let other = warning.clone(); crate::exit_guard::spawn(std::thread::Builder::new(), move || { - sent(user, warning, S::WARNING, K::VALIDATION, warning.text) + sent(user, &other, S::WARNING, K::VALIDATION, &other.text) }) .unwrap() .join() .unwrap(); assert_eq!(delivered(), 2, "from another thread"); - report(S::ERROR, K::VALIDATION, warning.text); - report(S::WARNING, K::GENERAL, warning.text); + report(S::ERROR, K::VALIDATION, &warning.text); + report(S::WARNING, K::GENERAL, &warning.text); report( S::WARNING, K::VALIDATION, "VK_ERROR_FEATURE_NOT_PRESENT: Metal does not support something else.", ); assert_eq!(delivered(), 5, "another severity, kind or text"); - report(S::WARNING, K::VALIDATION, warning.text); + report(S::WARNING, K::VALIDATION, &warning.text); }); assert_eq!(withheld, 2, "withheld inside the call"); - report(S::WARNING, K::VALIDATION, warning.text); + report(S::WARNING, K::VALIDATION, &warning.text); assert_eq!(delivered(), 6, "after the call"); let ((), withheld) = crate::driver_facts::expecting(Vec::new(), || { - report(S::WARNING, K::VALIDATION, warning.text); + report(S::WARNING, K::VALIDATION, &warning.text); }); assert_eq!((withheld, delivered()), (0, 7), "a call that expects none"); } @@ -1639,7 +1642,7 @@ mod tests { /// `user`. fn sent( user: usize, - warning: DriverDiagnostic, + warning: &DriverDiagnostic, severity: vk::DebugUtilsMessageSeverityFlagsEXT, kind: vk::DebugUtilsMessageTypeFlagsEXT, text: &str, diff --git a/crates/metal2vulkan-runtime/src/device/mod.rs b/crates/metal2vulkan-runtime/src/device/mod.rs index a898416f7..759bde1b3 100644 --- a/crates/metal2vulkan-runtime/src/device/mod.rs +++ b/crates/metal2vulkan-runtime/src/device/mod.rs @@ -491,8 +491,13 @@ impl DeviceShared { making: crate::shader_cache::driver::Making, create: impl FnOnce(vk::PipelineCache) -> (Result, Option), ) -> Result { - crate::exit_guard::driver_making(|| { - self.shader_cache.make_pipelines(self.vk(), making, create) + // What every making is measured to report, withheld inside it (`driver_facts.rs`); a + // render pipeline's making expects them with its own. + let expected = crate::driver_facts::making_diagnostics(&self.properties); + crate::driver_facts::expecting_where_unset(expected, || { + crate::exit_guard::driver_making(|| { + self.shader_cache.make_pipelines(self.vk(), making, create) + }) }) } diff --git a/crates/metal2vulkan-runtime/src/driver_defects.rs b/crates/metal2vulkan-runtime/src/driver_defects.rs index 5af0be339..61a85d01e 100644 --- a/crates/metal2vulkan-runtime/src/driver_defects.rs +++ b/crates/metal2vulkan-runtime/src/driver_defects.rs @@ -305,6 +305,25 @@ pub(super) struct Affected { /// does (`pending_dispatch.rs`); a host step's dispatch (an indirect dispatch's, an indirect /// command buffer's execution) records in place. Graphics draws are unmeasured. Every lavapipe /// release takes it: 26.2.4, measured clean, has no committed profile to be a measured identity. +/// +/// `SetLayoutSupportUnderstated`: +/// - MoltenVK (`MOLTENVK`): `MVKDevice::getDescriptorSetLayoutSupport` sums the bindings' +/// `descriptorCount` and answers `sum < maxPerSetDescriptors` (1212 on Apple's GPUs: four times +/// a stage's Metal argument-table slots), so a layout of exactly `maxPerSetDescriptors` is +/// refused, where Vulkan guarantees `VK_TRUE`, and so is every layout past it, though the driver +/// encodes an update-after-bind set in a Metal argument buffer and reports +/// `maxDescriptorSetUpdateAfterBind*` limits of 500000 and 1000000. The driver makes such a +/// layout, and a set of it is written and read as Metal reads the argument buffer: a bare +/// Vulkan probe (one binding of 65536 sampled images, `UPDATE_AFTER_BIND_POOL`, element 65535 +/// read in a dispatch) read it right where the query answered `VK_FALSE` at 1212, 1213 and +/// 65536 descriptors, and the runtime lanes that read textures through their IDs past element +/// 1211 (`runtime_lane::resource_ids`) are Metal's. Read in 1.4.1's and 1.4.2's source (the +/// function is the same) and measured on 1.4.2 (driverVersion 10402) on an M3 Max: known broken +/// through 1.4.2. Vulkan-ValidationLayers 1.4.363 asks the query for every layout past +/// `maxPerSetDescriptors` and reports one it refuses +/// (`VUID-vkCreateDescriptorSetLayout-support-09582`). Nothing is refused: a set layout the +/// driver refuses is made there, announced (`set-past-layout-support`, `pipeline/objects.rs`); +/// on every other driver a set layout its driver refuses is refused. pub(super) const AFFECTED: &[Affected] = &[ Affected { defect: RuntimeDriverDefect::MultisampledDepthStencilColourCopies, @@ -403,6 +422,11 @@ pub(super) const AFFECTED: &[Affected] = &[ driver: DriverId::MESA_LLVMPIPE, clean: &[], }, + Affected { + defect: RuntimeDriverDefect::SetLayoutSupportUnderstated, + driver: DriverId::MOLTENVK, + clean: &[], + }, ]; /// The defects of the driver and device `description` names, its GPU read by the `deviceID` it diff --git a/crates/metal2vulkan-runtime/src/driver_facts.rs b/crates/metal2vulkan-runtime/src/driver_facts.rs index 56735c53a..8d392240e 100644 --- a/crates/metal2vulkan-runtime/src/driver_facts.rs +++ b/crates/metal2vulkan-runtime/src/driver_facts.rs @@ -164,6 +164,41 @@ pub(crate) fn expecting( (result, withheld) } +/// The diagnostics every pipeline making on a device of `properties` is measured to report, +/// whatever its pipeline's state: those of its color attachments the driver cannot blend +/// (`DriverFact::BlendlessColorAttachmentsWarn`), one for each format the device lists as a color +/// attachment without blending ([`DeviceDescription::blendless_color_formats`]). The driver names +/// the format, so a pipeline that attaches none of them reports none. +/// +/// [`DeviceDescription::blendless_color_formats`]: metal2vulkan::device::DeviceDescription::blendless_color_formats +pub(crate) fn making_diagnostics(properties: &crate::DeviceProperties) -> Vec { + let blendless = properties.description.blendless_color_formats(); + (properties.driver_facts.iter()) + .flat_map(|fact| { + fact.pipeline_creation_diagnostics( + &[], + metal2vulkan::vk::PrimitiveTopology::TRIANGLE_LIST, + &blendless, + ) + }) + .collect() +} + +/// [`expecting`] where this thread's current call expects nothing yet; inside an expectation, +/// `call` alone, which the outer expectation covers. +pub(crate) fn expecting_where_unset( + diagnostics: Vec, + call: impl FnOnce() -> T, +) -> T { + let unset = EXPECTED + .try_with(|expected| expected.try_borrow().is_ok_and(|e| e.is_none())) + .unwrap_or(false); + match unset { + true => expecting(diagnostics, call).0, + false => call(), + } +} + /// The diagnostics this thread's current call is measured to report ([`expecting`]); none /// outside such a call. A thread of the runtime's that makes the driver call for this one, while /// it waits (`device/compiles.rs`), expects them inside that call alone. diff --git a/crates/metal2vulkan-runtime/src/lib.rs b/crates/metal2vulkan-runtime/src/lib.rs index f45b7fafe..cdd299da4 100644 --- a/crates/metal2vulkan-runtime/src/lib.rs +++ b/crates/metal2vulkan-runtime/src/lib.rs @@ -300,6 +300,8 @@ pub use mipmap::MipmapVerdict; pub use mipmap_plan::MipmapProblem; #[doc(hidden)] pub use pipeline::budget::{set_making_budget_for_measurement, MakingBudgetStarted}; +#[doc(hidden)] +pub use pipeline::objects::makes_layouts_past_support; pub use pipeline::{ BinaryFunctionProblem, BinaryFunctionStage, RenderPipelineFunctionsDescriptor, RequiredThreadsProblem, diff --git a/crates/metal2vulkan-runtime/src/pipeline/graphics.rs b/crates/metal2vulkan-runtime/src/pipeline/graphics.rs index fb315106c..b086bdb24 100644 --- a/crates/metal2vulkan-runtime/src/pipeline/graphics.rs +++ b/crates/metal2vulkan-runtime/src/pipeline/graphics.rs @@ -1010,14 +1010,12 @@ impl VariantObjects { .text(sibling.as_ref().unwrap_or(key)); // The diagnostics the device's driver is measured to report as it makes this pipeline, // withheld inside its creation alone (`driver_facts.rs`). - let expected: Vec<_> = self - .device - .properties() - .driver_facts - .iter() - .filter_map(|fact| { - fact.pipeline_creation_diagnostic(&graphics.dynamic_states, key.topology) + let properties = self.device.properties(); + let expected: Vec<_> = (properties.driver_facts.iter()) + .flat_map(|fact| { + fact.pipeline_creation_diagnostics(&graphics.dynamic_states, key.topology, &[]) }) + .chain(crate::driver_facts::making_diagnostics(properties)) .collect(); // The turn first (none where a piece's thread holds one), once no twin's making is in the // air (`flight.rs`): the driver's time alone is timed, not the wait for a turn or a twin. diff --git a/crates/metal2vulkan-runtime/src/pipeline/objects.rs b/crates/metal2vulkan-runtime/src/pipeline/objects.rs index 84f259774..2e392b616 100644 --- a/crates/metal2vulkan-runtime/src/pipeline/objects.rs +++ b/crates/metal2vulkan-runtime/src/pipeline/objects.rs @@ -34,6 +34,7 @@ use crate::Device; use ash::vk; use metal2vulkan::bind::DispatchRegion; use metal2vulkan::cache::{Hash256, SpecializationKey}; +use metal2vulkan::error::{Feature, RuntimeDriverDefect, Unsupported}; use metal2vulkan::pipeline::{ DescriptorSetLayout, PipelineLayout, RenderPipeline, SlotRef, StageModule, }; @@ -1021,13 +1022,123 @@ impl VariantObjects { /// The `VkDescriptorSetLayout` of `set`, each binding with its `immutable` samplers (none where /// its list is empty or missing) and of its type in `types` (the set's own where the list is -/// shorter). +/// shorter). A layout the driver refuses ([`set_support`]) is refused, but where the driver runs +/// what it refuses (`RuntimeDriverDefect::SetLayoutSupportUnderstated`), whose variant's making +/// announced it (`Device::degrade_pipeline`). pub(crate) fn create_set_layout( device: &Device, set: &DescriptorSetLayout, - (immutable, types): (&[&[vk::Sampler]], &[vk::DescriptorType]), + samplers_and_types: (&[&[vk::Sampler]], &[vk::DescriptorType]), push: bool, ) -> Result { + with_create_info(set, samplers_and_types, push, |info| { + if layout_support(device, set, info) == SetSupport::Refused { + return Err(Error::Unsupported(Unsupported::not_implemented( + Feature::ArgumentBufferTextures, + ))); + } + // SAFETY: `info` and every array it points at are live for the call. + unsafe { + device + .shared() + .vk() + .create_descriptor_set_layout(info, None) + } + .map_err(vulkan) + }) +} + +/// Whether the device makes `set`'s layout (as a pooled set of its own binding types), asking its +/// driver where Vulkan does not promise it ([`set_support`]). +pub(crate) fn set_layout_support(device: &Device, set: &DescriptorSetLayout) -> SetSupport { + with_create_info(set, (&[], &[]), false, |info| { + layout_support(device, set, info) + }) +} + +/// [`set_support`] of `set`, whose create info is `info`, on `device`. +fn layout_support( + device: &Device, + set: &DescriptorSetLayout, + info: &vk::DescriptorSetLayoutCreateInfo<'_>, +) -> SetSupport { + let understated = (device.properties().driver_defects) + .contains(&RuntimeDriverDefect::SetLayoutSupportUnderstated); + let total = set.bindings.iter().map(|b| u64::from(b.count)).sum(); + set_support(total, understated, || { + let mut support = vk::DescriptorSetLayoutSupport::default(); + // SAFETY: `info` and every array it points at are live for the call, and `support` heads + // an empty chain. + unsafe { + device + .shared() + .vk() + .get_descriptor_set_layout_support(info, &mut support) + }; + support.supported == vk::TRUE + }) +} + +/// Whether the runtime makes, on the device `description` names, a descriptor set layout its +/// driver's `vkGetDescriptorSetLayoutSupport` refuses ([`SetSupport::Understated`]): where the +/// driver runs what the query refuses (`RuntimeDriverDefect::SetLayoutSupportUnderstated`, +/// `driver_defects.rs`). Validation's executor makes its own heap sets by it, so its sink passes +/// the validation layer's report of such a layout there as the runtime's does. +#[doc(hidden)] +pub fn makes_layouts_past_support(description: &metal2vulkan::device::DeviceDescription) -> bool { + crate::driver_defects::of(description) + .contains(&RuntimeDriverDefect::SetLayoutSupportUnderstated) +} + +/// The least `maxPerSetDescriptors` Vulkan allows (its Required Limits): a set layout of at most +/// that many descriptors is one `vkGetDescriptorSetLayoutSupport` answers `VK_TRUE` for on every +/// device, so only a larger one is asked about. +pub(crate) const LEAST_PER_SET_DESCRIPTORS: u64 = 1024; + +/// Whether a device makes a descriptor set layout. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub(crate) enum SetSupport { + /// It makes it: Vulkan promises it, or the driver's `vkGetDescriptorSetLayoutSupport` + /// answers `VK_TRUE`. + Supported, + /// The driver's query answers `VK_FALSE`, and the driver runs the layout as Metal runs the + /// argument buffer it encodes it in (`RuntimeDriverDefect::SetLayoutSupportUnderstated`): it + /// is made, announced (`Degradation::SetPastLayoutSupport`), and Vulkan's validation layer + /// reports it (`VUID-vkCreateDescriptorSetLayout-support-09582`). + Understated, + /// The driver's query answers `VK_FALSE`: not made (`Unsupported`), as Vulkan requires + /// (`VUID-vkCreateDescriptorSetLayout-support-09582`: "If the descriptor layout exceeds the + /// limits reported through the physical device limits, then vkGetDescriptorSetLayoutSupport + /// must have returned VkDescriptorSetLayoutSupport with support equal to VK_TRUE"). + Refused, +} + +/// [`SetSupport`] of a layout of `total` descriptors on a device whose driver understates its +/// support (`understated`), `supported` asking the driver: a layout of at most +/// [`LEAST_PER_SET_DESCRIPTORS`] is supported unasked ("If the descriptor set layout satisfies +/// the VkPhysicalDeviceMaintenance3Properties::maxPerSetDescriptors limit, this command is +/// guaranteed to return VK_TRUE"); any other is what the driver answers. +pub(crate) fn set_support( + total: u64, + understated: bool, + supported: impl FnOnce() -> bool, +) -> SetSupport { + if total <= LEAST_PER_SET_DESCRIPTORS || supported() { + SetSupport::Supported + } else if understated { + SetSupport::Understated + } else { + SetSupport::Refused + } +} + +/// `f` of the `VkDescriptorSetLayoutCreateInfo` of `set` as [`create_set_layout`] makes it. +fn with_create_info( + set: &DescriptorSetLayout, + (immutable, types): (&[&[vk::Sampler]], &[vk::DescriptorType]), + push: bool, + f: impl FnOnce(&vk::DescriptorSetLayoutCreateInfo<'_>) -> R, +) -> R { let bindings: Vec> = set .bindings .iter() @@ -1059,14 +1170,7 @@ pub(crate) fn create_set_layout( if flags.iter().any(|f| !f.is_empty()) { info = info.push_next(&mut flags_info); } - // SAFETY: `info` and every array it points at are live for the call. - unsafe { - device - .shared() - .vk() - .create_descriptor_set_layout(&info, None) - } - .map_err(vulkan) + f(&info) } /// The shape of `layout`'s set 0 and push-constant ranges, where its draws push set 0 diff --git a/crates/metal2vulkan-runtime/src/tests/degradation_codes.txt b/crates/metal2vulkan-runtime/src/tests/degradation_codes.txt index e6d4524ea..ad5c2c0ae 100644 --- a/crates/metal2vulkan-runtime/src/tests/degradation_codes.txt +++ b/crates/metal2vulkan-runtime/src/tests/degradation_codes.txt @@ -167,6 +167,7 @@ metal2vulkan-degrade-rotated-load-tiles metal2vulkan-degrade-sample-depth-clamp metal2vulkan-degrade-sample-planes metal2vulkan-degrade-separate-depth-stencil +metal2vulkan-degrade-set-past-layout-support metal2vulkan-degrade-shader-color-conversion metal2vulkan-degrade-shader-half-color-bits metal2vulkan-degrade-shader-resolve diff --git a/crates/metal2vulkan-runtime/src/tests/driver_defects.rs b/crates/metal2vulkan-runtime/src/tests/driver_defects.rs index 63fcb0865..0119091d7 100644 --- a/crates/metal2vulkan-runtime/src/tests/driver_defects.rs +++ b/crates/metal2vulkan-runtime/src/tests/driver_defects.rs @@ -26,13 +26,15 @@ const PUSHES: RuntimeDriverDefect = RuntimeDriverDefect::PushedBufferSizesUnset; const STALE_PUSHES: RuntimeDriverDefect = RuntimeDriverDefect::PushedDescriptorsStaleAfterPipelineBinds; const BAKED_SAMPLERS: RuntimeDriverDefect = RuntimeDriverDefect::ImmutableSamplersLostAfterCopies; +const SET_SUPPORT: RuntimeDriverDefect = RuntimeDriverDefect::SetLayoutSupportUnderstated; /// Every committed profile's driver has its defects at every release and GPU but those a probe /// found clean: MoltenVK the multisampled depth/stencil colour copies, the inexact depths past /// `[0, 1]`, the crashing 2D views of a 3D image in lazily allocated memory, the pipeline cache /// compiled at load, the copies of compressed images that rewrite texels, the reads of command /// buffers after their signal, the frees that fail pending work, the destroys that fail a -/// submission encoding meanwhile and the pushed sets' unset buffer sizes; lavapipe the colour copies, the depth/stencil resolve of the +/// submission encoding meanwhile, the pushed sets' unset buffer sizes and the set layouts its +/// support query refuses though it runs them; lavapipe the colour copies, the depth/stencil resolve of the /// first layer and level, the explicit plane's rows past its height and the baked samplers lost /// after a copy; /// RADV the multisampled copies that convert float NaNs, and the implicit @@ -66,6 +68,7 @@ fn the_committed_profiles_drivers_have_their_defects() { FREES, DESTROYS, PUSHES, + SET_SUPPORT, ] } Some(DriverId::MESA_LLVMPIPE) => vec![COPIES, RESOLVES, PAST_HEIGHT, BAKED_SAMPLERS], @@ -342,3 +345,33 @@ fn the_unmeasured_identity_option_runs_another_gpu_s_paths() { assert!(text.ends_with(&format!("[{UNMEASURED_DRIVER}]")), "{text}"); assert!(!text.contains("metal2vulkan-degrade-"), "{text}"); } + +/// A descriptor set layout of at most 1024 descriptors (the least `maxPerSetDescriptors` Vulkan +/// allows) is made without asking the driver; a larger one is made where the driver's +/// `vkGetDescriptorSetLayoutSupport` answers `VK_TRUE`, made and announced where it answers +/// `VK_FALSE` on a driver that runs what it refuses (`SetLayoutSupportUnderstated`), and refused +/// on any other: never made past the driver's answer unannounced. +#[test] +fn a_set_layout_past_the_least_per_set_limit_is_made_as_the_driver_answers() { + use crate::pipeline::objects::{set_support, SetSupport, LEAST_PER_SET_DESCRIPTORS}; + let unasked = || -> bool { panic!("asked about a layout Vulkan promises") }; + for understated in [false, true] { + for total in [0, 1, 1023, LEAST_PER_SET_DESCRIPTORS] { + assert_eq!( + set_support(total, understated, unasked), + SetSupport::Supported + ); + } + let refused = match understated { + true => SetSupport::Understated, + false => SetSupport::Refused, + }; + for total in [1025, 1212, 65536, 393_216] { + assert_eq!( + set_support(total, understated, || true), + SetSupport::Supported + ); + assert_eq!(set_support(total, understated, || false), refused); + } + } +} diff --git a/crates/metal2vulkan-validation/src/candidate.rs b/crates/metal2vulkan-validation/src/candidate.rs index 29cf7882a..e6d776b1f 100644 --- a/crates/metal2vulkan-validation/src/candidate.rs +++ b/crates/metal2vulkan-validation/src/candidate.rs @@ -162,6 +162,7 @@ pub mod engine; pub mod runtime_case; pub mod runtime_samples; pub(crate) mod unadvertised_stage; +pub(crate) mod unsupported_set; #[cfg(any(target_os = "linux", target_os = "macos"))] mod platform; diff --git a/crates/metal2vulkan-validation/src/candidate/platform/device.rs b/crates/metal2vulkan-validation/src/candidate/platform/device.rs index 34cef0e95..75f2b4e84 100644 --- a/crates/metal2vulkan-validation/src/candidate/platform/device.rs +++ b/crates/metal2vulkan-validation/src/candidate/platform/device.rs @@ -463,12 +463,28 @@ pub fn echo_validation_messages() { /// `DriverDeviation::MetalVertexSimdgroups` ([`MessageSink::unadvertised_vertex`]), the layer's /// report of a vertex module's subgroup operations outside `subgroupSupportedStages` /// (`candidate/unadvertised_stage.rs`) fails nothing: the translation relies on the driver's -/// measured answer there, as the module's requirements state. +/// measured answer there, as the module's requirements state. Nor does a driver diagnostic every +/// pipeline making of the opened device is measured to report ([`MessageSink::making`]), nor, on a +/// device whose driver runs the set layouts its support query refuses +/// ([`MessageSink::unsupported_sets`]), the layer's report of such a layout +/// (`candidate/unsupported_set.rs`). pub(super) struct MessageSink { messages: Mutex>, /// Whether the context's opened profile takes `DriverDeviation::MetalVertexSimdgroups`, set /// once it is derived. unadvertised_vertex: AtomicBool, + /// The diagnostics the opened device's driver facts measure every pipeline making to report, + /// whatever its state: its warning of each color attachment it cannot blend + /// (`DriverFact::BlendlessColorAttachmentsWarn`), for each format the device lists as a color + /// attachment without blending (`DeviceDescription::blendless_color_formats`). The driver + /// reports one only as it makes a render pipeline, naming the format, so a message of exactly + /// one of them fails no row; set once the opened description is known. + making: OnceLock>, + /// Whether the opened device's driver runs the descriptor set layouts its + /// `vkGetDescriptorSetLayoutSupport` refuses, as the runtime makes them there + /// (`metal2vulkan_runtime::makes_layouts_past_support`: a heap's set 1 on MoltenVK), set once + /// the opened description is known. + unsupported_sets: AtomicBool, } impl MessageSink { @@ -537,6 +553,25 @@ unsafe extern "system" fn record_validation_message( { return vk::FALSE; } + if sink.unsupported_sets.load(Ordering::Relaxed) + && crate::candidate::unsupported_set::shape( + &text(data.p_message_id_name), + &text(data.p_message), + ) + { + return vk::FALSE; + } + if severity == vk::DebugUtilsMessageSeverityFlagsEXT::WARNING + && types.contains(vk::DebugUtilsMessageTypeFlagsEXT::VALIDATION) + && sink.making.get().is_some_and(|making| { + let (id_name, text) = (text(data.p_message_id_name), text(data.p_message)); + making + .iter() + .any(|d| d.id_name == id_name && d.id == data.message_id_number && d.text == text) + }) + { + return vk::FALSE; + } let level = if severity.contains(vk::DebugUtilsMessageSeverityFlagsEXT::ERROR) { "error" } else { @@ -663,6 +698,8 @@ fn only_errors_and_validation_warnings_fail_a_row() { let sink = MessageSink { messages: Mutex::new(Vec::new()), unadvertised_vertex: AtomicBool::new(false), + making: OnceLock::new(), + unsupported_sets: AtomicBool::new(false), }; for n in 0..100 { sink.record(format!("m{n}")); @@ -685,11 +722,14 @@ fn a_measured_diagnostic_fails_no_row_inside_its_call_alone() { use vk::DebugUtilsMessageSeverityFlagsEXT as S; use vk::DebugUtilsMessageTypeFlagsEXT as T; let warning = DriverFact::DynamicRestartWarns - .pipeline_creation_diagnostic(&[D::PRIMITIVE_RESTART_ENABLE], P::TRIANGLE_STRIP) + .pipeline_creation_diagnostics(&[D::PRIMITIVE_RESTART_ENABLE], P::TRIANGLE_STRIP, &[]) + .pop() .expect("the warning of a dynamic restart"); let sink = MessageSink { messages: Mutex::new(Vec::new()), unadvertised_vertex: AtomicBool::new(false), + making: OnceLock::new(), + unsupported_sets: AtomicBool::new(false), }; let user = std::ptr::from_ref(&sink) as usize; let report = |severity: S, text: &str| { @@ -710,22 +750,22 @@ fn a_measured_diagnostic_fails_no_row_inside_its_call_alone() { ) }; }; - report(S::WARNING, warning.text); + report(S::WARNING, &warning.text); assert_eq!(sink.take().len(), 1, "outside the call"); - expecting_diagnostics(vec![warning], || { - report(S::WARNING, warning.text); + expecting_diagnostics(vec![warning.clone()], || { + report(S::WARNING, &warning.text); assert_eq!(sink.take().len(), 0, "inside the call"); std::thread::scope(|scope| { - scope.spawn(|| report(S::WARNING, warning.text)); + scope.spawn(|| report(S::WARNING, &warning.text)); }); - report(S::ERROR, warning.text); + report(S::ERROR, &warning.text); report( S::WARNING, "VK_ERROR_FEATURE_NOT_PRESENT: Metal does not support something else.", ); assert_eq!(sink.take().len(), 3, "another thread, severity or text"); }); - report(S::WARNING, warning.text); + report(S::WARNING, &warning.text); assert_eq!(sink.take().len(), 1, "after the call"); } @@ -1565,6 +1605,8 @@ impl VulkanContext { let messages: &'static MessageSink = Box::leak(Box::new(MessageSink { messages: Mutex::new(Vec::new()), unadvertised_vertex: AtomicBool::new(false), + making: OnceLock::new(), + unsupported_sets: AtomicBool::new(false), })); let messenger_info = vk::DebugUtilsMessengerCreateInfoEXT::default() .message_severity( @@ -1771,6 +1813,23 @@ impl VulkanContext { } description }); + if let Ok(description) = &opened_description { + let blendless = description.blendless_color_formats(); + let making = (description.driver_facts().into_iter()) + .flat_map(|fact| { + fact.pipeline_creation_diagnostics( + &[], + metal2vulkan::vk::PrimitiveTopology::TRIANGLE_LIST, + &blendless, + ) + }) + .collect(); + let _ = messages.making.set(making); + messages.unsupported_sets.store( + metal2vulkan_runtime::makes_layouts_past_support(description), + Ordering::Relaxed, + ); + } let opened = opened_description .clone() .and_then(crate::acceptance::derived_profile); @@ -2188,6 +2247,10 @@ unsafe fn describe_formats( identity.driver_version = core.driver_version; identity.vendor_id = core.vendor_id; identity.device_id = core.device_id; + identity.device_name = core + .device_name_as_c_str() + .map(|name| name.to_string_lossy().into_owned()) + .unwrap_or_default(); let unreliable = identity.unreliable_linear_tiling().as_raw(); let mut formats = serde_json::Map::new(); for &format in mvk::Format::KNOWN { diff --git a/crates/metal2vulkan-validation/src/candidate/platform/graphics_pipeline.rs b/crates/metal2vulkan-validation/src/candidate/platform/graphics_pipeline.rs index 7077f0ea2..77bd41985 100644 --- a/crates/metal2vulkan-validation/src/candidate/platform/graphics_pipeline.rs +++ b/crates/metal2vulkan-validation/src/candidate/platform/graphics_pipeline.rs @@ -372,7 +372,9 @@ pub(super) fn front_face(state: &DrawDepthStencil) -> vk::FrontFace { /// Create the graphics pipeline of `pipeline` as `consumer` decides it: the pipeline and the /// duration of the `vkCreateGraphicsPipelines` call alone. The caller owns (and destroys) the /// pipeline. The diagnostics the executing driver's `facts` measure it to report as it makes -/// the pipeline (`DriverFact::pipeline_creation_diagnostic`) fail no row from inside that call. +/// the pipeline (`DriverFact::pipeline_creation_diagnostics`) fail no row from inside that call; +/// those of its color attachments the driver cannot blend fail none anywhere +/// (`MessageSink::making`). pub(super) fn create_graphics_pipeline( device: &ash::Device, facts: &BTreeSet, @@ -567,7 +569,9 @@ pub(super) fn create_graphics_pipeline( } let expected = facts .iter() - .filter_map(|fact| fact.pipeline_creation_diagnostic(&graphics.dynamic_states, topology)) + .flat_map(|fact| { + fact.pipeline_creation_diagnostics(&graphics.dynamic_states, topology, &[]) + }) .collect(); let clock = crate::budgets::CreationClock::start(); let created = super::device::expecting_diagnostics(expected, || { diff --git a/crates/metal2vulkan-validation/src/candidate/platform/profiles.rs b/crates/metal2vulkan-validation/src/candidate/platform/profiles.rs index 9a1a79190..2029a5be9 100644 --- a/crates/metal2vulkan-validation/src/candidate/platform/profiles.rs +++ b/crates/metal2vulkan-validation/src/candidate/platform/profiles.rs @@ -612,6 +612,7 @@ pub(super) fn check_restricted( translated.driver_version = native.driver_version; translated.vendor_id = native.vendor_id; translated.device_id = native.device_id; + translated.device_name.clone_from(&native.device_name); translated.device_type = native.device_type; Ok(translated) } @@ -687,12 +688,13 @@ fn kept_outside(expected: &Value, queried: &Value, native: &Value) -> Vec [(&'static str, String); 5] { +fn identity(description: &DeviceDescription) -> [(&'static str, String); 6] { [ ("driver_id", format!("{:?}", description.driver_id)), ("driver_version", description.driver_version.to_string()), ("vendor_id", description.vendor_id.to_string()), ("device_id", description.device_id.to_string()), + ("device_name", format!("{:?}", description.device_name)), ("device_type", format!("{:?}", description.device_type)), ] } @@ -723,6 +725,7 @@ fn capability_members(description: &DeviceDescription) -> Value { "driver_version", "vendor_id", "device_id", + "device_name", "device_type", "assumed_unmeasured", "extensions", diff --git a/crates/metal2vulkan-validation/src/candidate/platform/profiles/tests.rs b/crates/metal2vulkan-validation/src/candidate/platform/profiles/tests.rs index 044764499..a127ced20 100644 --- a/crates/metal2vulkan-validation/src/candidate/platform/profiles/tests.rs +++ b/crates/metal2vulkan-validation/src/candidate/platform/profiles/tests.rs @@ -366,6 +366,7 @@ fn a_restricted_context_runs_only_on_a_device_that_has_and_reports_its_profile() queried.driver_version = native.driver_version; queried.vendor_id = native.vendor_id; queried.device_id = native.device_id; + queried.device_name.clone_from(&native.device_name); queried.device_type = native.device_type; queried.float_controls.denorm_independence = native.float_controls.denorm_independence; queried.float_controls.rounding_independence = native.float_controls.rounding_independence; @@ -385,6 +386,7 @@ fn a_restricted_context_runs_only_on_a_device_that_has_and_reports_its_profile() translated.driver_version = native.driver_version; translated.vendor_id = native.vendor_id; translated.device_id = native.device_id; + translated.device_name.clone_from(&native.device_name); translated.device_type = native.device_type; assert_ne!(translated.driver_id, profile.driver_id); assert_eq!(check(&native, &tools, &queried), Ok(translated.clone())); @@ -841,6 +843,7 @@ fn the_layer_reports_the_device_value_of_a_member_a_requirements_document_omits( queried.driver_version = native.driver_version; queried.vendor_id = native.vendor_id; queried.device_id = native.device_id; + queried.device_name.clone_from(&native.device_name); queried.device_type = native.device_type; queried.float_controls.denorm_independence = native.float_controls.denorm_independence; queried.float_controls.rounding_independence = native.float_controls.rounding_independence; diff --git a/crates/metal2vulkan-validation/src/candidate/runtime_case.rs b/crates/metal2vulkan-validation/src/candidate/runtime_case.rs index 28e129ba5..7f2d7d455 100644 --- a/crates/metal2vulkan-validation/src/candidate/runtime_case.rs +++ b/crates/metal2vulkan-validation/src/candidate/runtime_case.rs @@ -51,7 +51,7 @@ use crate::candidate::engine::resources::{ use crate::candidate::engine::tables::{FunctionTable, TableBuffers}; use crate::candidate::engine::{ComputeCase, ComputeOutput, LinkedModule}; use crate::candidate::runtime_samples::{multisampled_texture_with, SampleFill}; -use crate::candidate::unadvertised_stage; +use crate::candidate::{unadvertised_stage, unsupported_set}; use crate::case::out_of_bounds::OutOfBoundsResource; use crate::case::{ArgumentBufferSamplerResource, AuthoredCase, RateMapLiteral, TextureType}; use crate::check::interface::{ @@ -204,6 +204,10 @@ pub(crate) fn report_each_message() { /// `Degradation::UnadvertisedVertexSimdgroups` notice, which it gives only where its profile /// takes `DriverDeviation::MetalVertexSimdgroups`. Each such message prints an `UNADVERTISED-STAGE` /// line, and a test's count of them prints once its messages go; before the notice it fails. +/// So does the layer's report of a descriptor set layout the driver's support query refuses +/// (`candidate/unsupported_set.rs`), after the device's `Degradation::SetPastLayoutSupport` notice, +/// which it gives only where its driver runs what the query refuses +/// (`RuntimeDriverDefect::SetLayoutSupportUnderstated`), each printing an `UNSUPPORTED-SET` line. #[derive(Clone, Default)] pub struct Messages(Arc>); @@ -217,6 +221,10 @@ struct Reported { unadvertised_vertex: bool, /// How many of the layer's messages about such a vertex module passed. unadvertised_messages: usize, + /// Whether a device announced `Degradation::SetPastLayoutSupport`. + unsupported_sets: bool, + /// How many of the layer's messages about such a set layout passed. + unsupported_set_messages: usize, /// The thread that made the list: the test's. test: String, /// How many notices of each kind were taken so far (`Messages::take_notices`), less those @@ -233,6 +241,8 @@ impl Default for Reported { layer_gaps: 0, unadvertised_vertex: false, unadvertised_messages: 0, + unsupported_sets: false, + unsupported_set_messages: 0, taken: BTreeMap::new(), test: std::thread::current() .name() @@ -257,6 +267,13 @@ impl Drop for Reported { self.test, self.unadvertised_messages ); } + if self.unsupported_set_messages != 0 { + eprintln!( + "UNSUPPORTED-SET count {}: {} message(s) about set layouts the driver's support \ + query refuses passed", + self.test, self.unsupported_set_messages + ); + } } } @@ -361,6 +378,9 @@ impl Messages { if notice.degradation == Degradation::UnadvertisedVertexSimdgroups { reported.unadvertised_vertex = true; } + if notice.degradation == Degradation::SetPastLayoutSupport { + reported.unsupported_sets = true; + } if reported.notices.len() < Self::MAX { reported.notices.push(message.clone()); } @@ -389,6 +409,19 @@ impl Messages { ); return; } + if reported.unsupported_sets && unsupported_set::shape(&message.id_name, &message.text) + { + reported.unsupported_set_messages += 1; + eprintln!( + "UNSUPPORTED-SET {}: passed, announced as {}: {} ({}): {}", + reported.test, + Degradation::SetPastLayoutSupport.code(), + message.id_name, + message.id, + message.text.replace('\n', " ") + ); + return; + } let gap = host_wait_gap::shape(message.id, &message.id_name, &message.text); if gap && layer.is_some_and(host_wait_gap::read) { reported.layer_gaps += 1; diff --git a/crates/metal2vulkan-validation/src/candidate/unsupported_set.rs b/crates/metal2vulkan-validation/src/candidate/unsupported_set.rs new file mode 100644 index 000000000..cc117e0aa --- /dev/null +++ b/crates/metal2vulkan-validation/src/candidate/unsupported_set.rs @@ -0,0 +1,98 @@ +//! The validation layer's message about a descriptor set layout a driver refuses through +//! `vkGetDescriptorSetLayoutSupport` though it makes and runs it. +//! +//! MoltenVK answers the query `sum of descriptorCount < maxPerSetDescriptors` (1212 on Apple's +//! GPUs), though it encodes an update-after-bind set in a Metal argument buffer and runs one of +//! 65536 elements and more as Metal runs the argument buffer +//! (`RuntimeDriverDefect::SetLayoutSupportUnderstated`). The runtime makes a heap's set 1 there +//! past that answer, announced (`Degradation::SetPastLayoutSupport`). The layer asks the query for +//! every layout past `maxPerSetDescriptors` and reports one it refuses, as Vulkan says it must +//! (`VUID-vkCreateDescriptorSetLayout-support-09582`, "If the descriptor layout exceeds the limits +//! reported through the physical device limits, then vkGetDescriptorSetLayoutSupport must have +//! returned VkDescriptorSetLayoutSupport with support equal to VK_TRUE for pCreateInfo"). That is +//! no layer defect: the use is outside what the driver's query admits, and the measured defect is +//! what licenses it. +//! +//! [`shape`] matches exactly that message: the layer's format, "`pCreateInfo` was passed to +//! vkGetDescriptorSetLayoutSupport which reported this layout is not supported", read in +//! Vulkan-ValidationLayers 1.4.363 (`CoreChecks::ValidateDescriptorSetLayoutSupport`), at +//! `vkCreateDescriptorSetLayout`, as the lanes saw it on MoltenVK 1.4.2, alone or after the +//! layer's note on its last report (`duplicate_message_limit`). The runtime lanes' sink +//! passes it only once the runtime announced `Degradation::SetPastLayoutSupport` +//! (`runtime_case.rs`). Every other message, and this one before the notice, still fails. + +/// The message's id name. +pub(crate) const ID_NAME: &str = "VUID-vkCreateDescriptorSetLayout-support-09582"; + +/// What the message says of a layout the driver's query refused. +const REFUSED: &str = "vkCreateDescriptorSetLayout(): pCreateInfo was passed to \ + vkGetDescriptorSetLayoutSupport which reported this layout is not \ + supported"; + +/// The note the layer puts on a line of its own before a message it reports for the last time +/// (`duplicate_message_limit`). +const LAST_TIME: &str = "(Warning - This VUID has now been reported "; + +/// Whether a message with this id name and text is the layer's report of a layout the driver's +/// support query refused: the report, alone or after the layer's last-time note. +pub(crate) fn shape(id_name: &str, text: &str) -> bool { + let report = match text.strip_prefix(LAST_TIME) { + Some(noted) => noted.split_once('\n').map_or("", |(_, report)| report), + None => text, + }; + id_name == ID_NAME && report.starts_with(REFUSED) +} + +#[cfg(test)] +mod tests { + use super::*; + + /// The message as the layer gave it for a heap's set 1 of `total` descriptors on MoltenVK + /// 1.4.2 (layer 1.4.363). + fn seen(total: u32) -> String { + format!( + "vkCreateDescriptorSetLayout(): pCreateInfo was passed to \ + vkGetDescriptorSetLayoutSupport which reported this layout is not supported.\nThe \ + layout has {total} total descriptors which is more than maxPerSetDescriptors \ + (1212).\nThe Vulkan spec states: If the descriptor layout exceeds the limits \ + reported through the physical device limits, then vkGetDescriptorSetLayoutSupport \ + must have returned VkDescriptorSetLayoutSupport with support equal to VK_TRUE for \ + pCreateInfo (https://docs.vulkan.org/spec/latest/chapters/descriptorsets.html\ + #VUID-vkCreateDescriptorSetLayout-support-09582)" + ) + } + + #[test] + fn a_refused_layout_s_message_is_the_shape() { + for total in [65536, 131072, 393216] { + assert!(shape(ID_NAME, &seen(total)), "{total}"); + // Reported for the last time, after the layer's note. + let last = format!( + "{LAST_TIME}10 times, which is the duplicate_message_limit value, this will be \ + the last time reporting it).\n{}", + seen(total) + ); + assert!(shape(ID_NAME, &last), "{total}, the last time"); + } + } + + #[test] + fn another_message_is_not() { + let text = seen(65536); + assert!(!shape( + "VUID-vkCreateDescriptorSetLayout-flags-00281", + &text + )); + assert!(!shape("", &text)); + // The note before another message. + let noted = format!( + "{LAST_TIME}10 times, which is the duplicate_message_limit value, this will be the \ + last time reporting it).\nvkCreatePipelineLayout(): {text}" + ); + assert!(!shape(ID_NAME, ¬ed)); + assert!(!shape( + ID_NAME, + "vkCreatePipelineLayout(): pCreateInfo was passed to vkGetDescriptorSetLayoutSupport" + )); + } +} diff --git a/crates/metal2vulkan-validation/src/runtime_lane.rs b/crates/metal2vulkan-validation/src/runtime_lane.rs index 0bf79d631..75581c497 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane.rs @@ -1062,6 +1062,11 @@ fn driver_keeps_pipeline_cache(device: &Device) -> bool { binary.internal_cache_control != vk::TRUE } +/// The MoltenVK releases (`driverVersion`) whose argument-buffer state the runtime reads from +/// their limits: 1.4.1 and 1.4.2, the releases whose source sets those limits as the runtime reads +/// them. +pub(crate) const MOLTENVK_ARGUMENT_BUFFERS_READ: [u32; 2] = [10401, 10402]; + /// The kinds a device the lane makes announces as it is made, each from what the lane reads of /// the device and its host apart from the runtime, and nothing else: `metal-level-not-macos` off /// macOS and `metal-level-below-host` on a macOS release that is no measured level, where the @@ -1081,11 +1086,12 @@ pub fn creation_kinds(device: &Device, level_named: bool) -> BTreeSet(stages: impl IntoIterator) -> BTreeS /// [`making_kinds`] of a render pipeline state of `descriptor` on `device`, as the device's /// compile layer compiles it, apart from the runtime (`compile_render_pipeline`, as -/// `color_writes::pipeline_states_announce_the_shader_conversion_once` holds the runtime to). +/// `color_writes::pipeline_states_announce_the_shader_conversion_once` holds the runtime to), and +/// its layout's ([`layout_kinds`]). pub(super) fn made_render_kinds( device: &Device, descriptor: &RenderPipelineDescriptor, @@ -1827,11 +1828,13 @@ pub(super) fn made_render_kinds( .compile_device() .compile_render_pipeline(descriptor, &Budget::standard()) .unwrap(); - making_kinds(&compiled.stages) + let mut kinds = making_kinds(&compiled.stages); + kinds.extend(layout_kinds(device, &compiled.layout)); + kinds } /// [`making_kinds`] of a mesh render pipeline state of `descriptor` on `device`, as its compile -/// layer compiles it (`compile_mesh_pipeline`). +/// layer compiles it (`compile_mesh_pipeline`), and its layout's ([`layout_kinds`]). pub(super) fn made_mesh_kinds( device: &Device, descriptor: &MeshPipelineDescriptor, @@ -1840,11 +1843,13 @@ pub(super) fn made_mesh_kinds( .compile_device() .compile_mesh_pipeline(descriptor, &Budget::standard()) .unwrap(); - making_kinds(&compiled.stages) + let mut kinds = making_kinds(&compiled.stages); + kinds.extend(layout_kinds(device, &compiled.layout)); + kinds } /// [`making_kinds`] of a compute pipeline state of kernel `function` on `device`, as its compile -/// layer compiles it (`compile_compute_pipeline`). +/// layer compiles it (`compile_compute_pipeline`), and its layout's ([`layout_kinds`]). pub(super) fn made_compute_kinds( device: &Device, function: FunctionDescriptor, @@ -1854,7 +1859,64 @@ pub(super) fn made_compute_kinds( .compile_device() .compile_compute_pipeline(&descriptor, &Budget::standard()) .unwrap(); - making_kinds([&compiled.stage]) + let mut kinds = making_kinds([&compiled.stage]); + kinds.extend(layout_kinds(device, &compiled.layout)); + kinds +} + +/// The kinds the making of a pipeline state of `layout` announces on `device` by its layout: +/// `set-past-layout-support` where a set of it is one the device's driver refuses +/// ([`refused_sets`]), which the runtime makes only where the driver runs what it refuses +/// (`RuntimeDriverDefect::SetLayoutSupportUnderstated`; elsewhere it refuses the state, typed). +pub(super) fn layout_kinds(device: &Device, layout: &PipelineLayout) -> BTreeSet { + forced(&[( + Degradation::SetPastLayoutSupport, + !refused_sets(device, layout).is_empty(), + )]) +} + +/// The sets of `layout`, each by its number and descriptor count, whose layout `device`'s driver +/// refuses through `vkGetDescriptorSetLayoutSupport`, asked here apart from the runtime of each +/// set's binding types, counts, stages and flags as the layout states them. +pub(super) fn refused_sets(device: &Device, layout: &PipelineLayout) -> Vec<(u32, u64)> { + // SAFETY: a device-level query on the device's own handle, made while it lives. + let raw = unsafe { device.raw() }; + layout + .sets + .iter() + .filter_map(|set| { + let bindings: Vec> = set + .bindings + .iter() + .map(|binding| { + ash::vk::DescriptorSetLayoutBinding::default() + .binding(binding.binding) + .descriptor_type(binding.ty.into()) + .descriptor_count(binding.count) + .stage_flags(binding.stages.into()) + }) + .collect(); + let flags: Vec = + set.bindings.iter().map(|b| b.flags.into()).collect(); + let mut flags_info = + ash::vk::DescriptorSetLayoutBindingFlagsCreateInfo::default().binding_flags(&flags); + let mut info = ash::vk::DescriptorSetLayoutCreateInfo::default() + .flags(set.flags.into()) + .bindings(&bindings); + if flags.iter().any(|f| !f.is_empty()) { + info = info.push_next(&mut flags_info); + } + let mut support = ash::vk::DescriptorSetLayoutSupport::default(); + // SAFETY: `info` and every array it points at are live for the call, and `support` + // heads an empty chain. + unsafe { + raw.device + .get_descriptor_set_layout_support(&info, &mut support) + }; + let total = set.bindings.iter().map(|b| u64::from(b.count)).sum(); + (support.supported != ash::vk::TRUE).then_some((set.set, total)) + }) + .collect() } /// The kinds a dispatch of kernel `function`'s compute pipeline state on `device` may announce diff --git a/crates/metal2vulkan-validation/src/runtime_lane/queue_storms.rs b/crates/metal2vulkan-validation/src/runtime_lane/queue_storms.rs index 9f2e5a9fb..514491178 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/queue_storms.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/queue_storms.rs @@ -131,8 +131,12 @@ const WAIT: Duration = Duration::from_secs(30); /// The tries of a storm whose busy work changed speed under it. const TRIES: usize = 3; -/// The MoltenVK release (`driverVersion`) whose encoding [`moltenvk_fences`] was read at: 1.4.1. -const MOLTENVK_READ: u32 = 10401; +/// The MoltenVK releases (`driverVersion`) whose encoding [`moltenvk_fences`] was read at: 1.4.1, +/// and 1.4.2, whose fence code (`barrierWait`, `barrierUpdate`, `syncFences` and the residency +/// set's making) is 1.4.1's. On the M3 Max under macOS 27.0.1 at 1.4.2, this lane judged without +/// the fences saw a light burst's median of 1.93 busy command buffers, within the fenced probe's +/// 1.91 to 1.95 above, and it passes judged with them. +const MOLTENVK_READ: [u32; 2] = [10401, 10402]; /// `maxPerStageDescriptorUpdateAfterBindSampledImages` where MoltenVK binds through tier-2 Metal /// argument buffers (`device/argument_buffers.rs` reads it so at [`MOLTENVK_READ`]). @@ -146,7 +150,7 @@ const TIER_2_ARGUMENT_BUFFERS: u32 = 1_000_000; fn moltenvk_fences(device: &Device) -> bool { let description = &device.properties().description; description.driver_id == Some(DriverId::MOLTENVK) - && description.driver_version == MOLTENVK_READ + && MOLTENVK_READ.contains(&description.driver_version) && description.vendor_id == 0x106b && description .limits diff --git a/crates/metal2vulkan-validation/src/runtime_lane/resource_ids.rs b/crates/metal2vulkan-validation/src/runtime_lane/resource_ids.rs index 1d42ae367..8d9575aa5 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/resource_ids.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/resource_ids.rs @@ -7,11 +7,13 @@ //! texture once that holder went. The kernel samples a 2-by-2 `RGBA32Uint` texture through a //! sampler held beside it, so its output is the texels it reached (a float twin of the case reads //! `RGBA16Float` linearly). Each degradation site of the kinds ([`RESOURCE_IDS`] and the device -//! heap's: [`UNVIEWABLE`], [`UNNAMED_SHADOWS`], [`PAST_CAPACITY`], [`OWN_COPIES`]) is taken on a -//! device of its own and announced once. +//! heap's: [`UNVIEWABLE`], [`UNNAMED_SHADOWS`], [`PAST_CAPACITY`], [`PAST_LAYOUT_SUPPORT`], +//! [`OWN_COPIES`]) is taken on a device of its own and announced once. use super::buffer_texture_blits::linear_rows_differ; -use super::degrade_notices::{assert_made_once, assert_once, forced, shared_in_system_memory}; +use super::degrade_notices::{ + assert_made_once, assert_once, forced, refused_sets, shared_in_system_memory, +}; use super::host_memory::{no_copy, not_importable, Mapping, GUEST_PAGE}; use super::sparse_textures::{lacks_sparse, SparseFacts}; use super::{ @@ -21,6 +23,7 @@ use super::{ }; use crate::candidate::engine::resources::argument_sampler_descriptor; use crate::candidate::engine::ComputeOutput; +use crate::candidate::unsupported_set; use crate::gpu::TEST_DEVICE; use crate::literal::LiteralTexture; use ash::vk; @@ -28,7 +31,7 @@ use metal2vulkan::bind::indirect_commands::RECORDS_ID_LIMIT; use metal2vulkan::bind::{SamplerDescriptor, TileMapping}; use metal2vulkan::device::DriverFact; use metal2vulkan::device::VkFeature; -use metal2vulkan::error::Feature; +use metal2vulkan::error::{Feature, RuntimeDriverDefect}; use metal2vulkan::metal::format::direct_format; use metal2vulkan::metal::{ CompareFunction, IndirectCommandType, PixelFormat, RenderStages, ResourceUsage, @@ -67,6 +70,11 @@ pub(super) const UNNAMED_SHADOWS: [Degradation; 1] = [Degradation::UnnamedShadow /// elsewhere). pub(super) const PAST_CAPACITY: [Degradation; 1] = [Degradation::UnnamedTexturesPastCapacity]; +/// The kind [`a_heap_set_its_driver_refuses_is_announced_once_where_it_runs`] takes where the +/// device's driver refuses the pipeline's heap set through its support query (and expects absent +/// elsewhere). +pub(super) const PAST_LAYOUT_SUPPORT: [Degradation; 1] = [Degradation::SetPastLayoutSupport]; + /// The kind [`a_device_without_pending_writes_binds_a_copy_per_command_buffer`] takes. pub(super) const OWN_COPIES: [Degradation; 1] = [Degradation::HeapSetCopied]; @@ -1620,6 +1628,52 @@ fn a_texture_at_the_highest_id_is_reached_where_the_arrays_hold_it() { }); } +/// The case's pipeline state reads its texture through its ID, so its set 1 holds the heap's +/// arrays, past the 1024 descriptors every Vulkan device's set layouts hold. Where the device's +/// driver refuses that layout through `vkGetDescriptorSetLayoutSupport` (asked here apart from +/// the runtime, `degrade_notices::refused_sets`) and runs it as Metal runs the argument buffer +/// (`RuntimeDriverDefect::SetLayoutSupportUnderstated`: MoltenVK), the making announces it once +/// (`PAST_LAYOUT_SUPPORT`), and the validation layer's report of each such layout passes after +/// the notice (`candidate/unsupported_set.rs`); a second state of the case announces nothing +/// again. Where the driver supports the layout, nothing is announced. The dispatch reads the +/// case's texels through the set either way. The line `SET-SUPPORT` reports the sets the driver +/// refuses. +#[test] +fn a_heap_set_its_driver_refuses_is_announced_once_where_it_runs() { + on_device(|device, messages| { + let sampling = Sampling::new(device); + let texture = sampling.texture(); + let (command_buffer, buffers) = sampling.encode(device, texture, Some(texture), None); + command_buffer.commit().unwrap(); + let output = sampling.output(&command_buffer, &buffers); + assert_eq!(output, sampling.case.metal_output, "through the heap set"); + let [execution] = &command_buffer.executions()[..] else { + panic!("one dispatch"); + }; + let ExecutedPipeline::Compute(pipeline) = execution.pipeline() else { + panic!("a compute pipeline"); + }; + let refused = refused_sets(device, &pipeline.layout); + eprintln!( + "SET-SUPPORT {}: the driver refuses the sets (number, descriptors) {refused:?}", + device.name() + ); + let understated = (device.properties().driver_defects) + .contains(&RuntimeDriverDefect::SetLayoutSupportUnderstated); + assert!( + refused.is_empty() || understated, + "made a set its driver refuses: {refused:?}" + ); + let kinds: &[Degradation] = match refused.is_empty() { + true => &[], + false => &PAST_LAYOUT_SUPPORT, + }; + sampling.announced(device, messages, kinds); + drop(pipeline_state(device, &sampling.case).unwrap()); + sampling.announced(device, messages, &[]); + }); +} + /// On a device without `descriptorBindingUpdateUnusedWhilePending` (withheld here; every venue /// has it), which writes no descriptor set a pending command buffer binds, each command buffer /// binds a copy of the heap set of its own, announced once (`OWN_COPIES`). The IDs read as on any @@ -2793,7 +2847,9 @@ type Seen = (Vec, Vec, Vec); fn reservations_keep_ids_from_plain_allocation() { let messages = Messages::default(); // The device's sink keeps the reservation's diagnostic lines, what the validation layer - // reported that fails a run (the rule `Messages` applies), and the notices. + // reported that fails a run (the rule `Messages` applies: a set layout's report after the + // device announced `set-past-layout-support` passes, `candidate/unsupported_set.rs`), and the + // notices. let seen: Arc> = Arc::default(); let cache = ScratchCache::new().unwrap(); { @@ -2810,7 +2866,14 @@ fn reservations_keep_ids_from_plain_allocation() { } else if message.severity == MessageSeverity::Error || (message.severity == MessageSeverity::Warning && message.kind.validation) { - seen.1.push(message.clone()); + let announced = seen.2.iter().any(|notice| { + notice.degradation.as_ref().is_some_and(|notice| { + notice.degradation == Degradation::SetPastLayoutSupport + }) + }); + if !(announced && unsupported_set::shape(&message.id_name, &message.text)) { + seen.1.push(message.clone()); + } } })); }) diff --git a/crates/metal2vulkan/src/ash_interop/query.rs b/crates/metal2vulkan/src/ash_interop/query.rs index 3748f0abc..c65e1622b 100644 --- a/crates/metal2vulkan/src/ash_interop/query.rs +++ b/crates/metal2vulkan/src/ash_interop/query.rs @@ -945,6 +945,10 @@ impl DeviceDescription { desc.driver_version = props.driver_version; desc.vendor_id = props.vendor_id; desc.device_id = props.device_id; + desc.device_name = props + .device_name_as_c_str() + .map(|name| name.to_string_lossy().into_owned()) + .unwrap_or_default(); desc.device_type = Some(props.device_type.into()); desc.driver_id = Some(properties.v12.driver_id.into()); desc.extensions = exposure diff --git a/crates/metal2vulkan/src/cache/codec.rs b/crates/metal2vulkan/src/cache/codec.rs index dc8d72f79..4f8c3b649 100644 --- a/crates/metal2vulkan/src/cache/codec.rs +++ b/crates/metal2vulkan/src/cache/codec.rs @@ -977,6 +977,7 @@ codec_enum! { MetalFragmentSimdgroups, MetalVertexSimdgroups, CenterFragCoordDepth, SampleFragCoordDepth, MetalHalfTexelWrites, MetalNormStorageWrites, Unorm8LinearFilter, DeviceSampling, MetalDepth16Stores, MetalDepth16BiasedStores, MetalInterpolation, MetalFirstVertexIndices, + MetalFullQuads, } VkLimit { MaxComputeWorkGroupSize(f0), MaxComputeWorkGroupCount(f0), MaxComputeWorkGroupInvocations, diff --git a/crates/metal2vulkan/src/device/derive.rs b/crates/metal2vulkan/src/device/derive.rs index c0c5b59b0..d7880ae04 100644 --- a/crates/metal2vulkan/src/device/derive.rs +++ b/crates/metal2vulkan/src/device/derive.rs @@ -924,6 +924,9 @@ fn enabled_caps( if deviations.contains_key(&DriverDeviation::MetalFirstVertexIndices) { properties.insert(VkProperty::MetalFirstVertexIndices); } + if deviations.contains_key(&DriverDeviation::MetalFullQuads) { + properties.insert(VkProperty::MetalFullQuads); + } let l = &desc.limits; let sample_counts: [(vk::SampleCountFlags, fn(u32) -> VkProperty); 6] = [ ( diff --git a/crates/metal2vulkan/src/device/description.rs b/crates/metal2vulkan/src/device/description.rs index ac1a7d970..763c85dde 100644 --- a/crates/metal2vulkan/src/device/description.rs +++ b/crates/metal2vulkan/src/device/description.rs @@ -31,6 +31,12 @@ pub struct DeviceDescription { pub driver_version: u32, pub vendor_id: u32, pub device_id: u32, + /// `VkPhysicalDeviceProperties::deviceName`. No translation reads it but through the tables + /// keyed on a measured GPU, where a `deviceID` names more than one GPU: MoltenVK's on Apple's + /// GPUs is the macOS release and the GPU family, so a release measured on one GPU of such an + /// identity names that GPU by its name (`driver_facts`). Empty where unknown. + #[cfg_attr(feature = "serde", serde(default))] + pub device_name: String, pub device_type: Option, /// Enabled device extensions the core consumes. pub extensions: BTreeSet, @@ -179,6 +185,7 @@ impl DeviceDescription { driver_version: 0, vendor_id: 0, device_id: 0, + device_name: String::new(), device_type: None, extensions: BTreeSet::new(), features: BTreeSet::new(), diff --git a/crates/metal2vulkan/src/device/driver_facts.rs b/crates/metal2vulkan/src/device/driver_facts.rs index 6d56eee07..e01470bc4 100644 --- a/crates/metal2vulkan/src/device/driver_facts.rs +++ b/crates/metal2vulkan/src/device/driver_facts.rs @@ -26,7 +26,10 @@ //! never a host's name), and [`DeviceDescription::measured_identity`] answers whether a description //! is one. A GPU that reports more than one `deviceID` is one device class under each: every table //! here names it by the ID it was measured under, and a description is read by its -//! [`DeviceDescription::canonical_device_id`]. +//! [`DeviceDescription::canonical_device_id`]. A `deviceID` that names more than one GPU +//! (MoltenVK's on Apple's GPUs is the macOS release and the GPU family) is one device class for +//! every release measured on each of its GPUs; a release measured on one of them alone names that +//! GPU by its `deviceName` (`NAMED_RELEASES`), and is no measured identity of the others. //! - **On a measured identity** a fact is taken where a row of its driver names the identity's //! release (from the first through the last) and, where it names them, its vendor and GPU: as //! measured. @@ -43,7 +46,8 @@ use crate::device::description::APPLE_VENDOR_ID; use crate::device::profile::DriverWorkaround; use crate::device::DeviceDescription; use crate::error::DriverDeviation; -use crate::vk::{DriverId, DynamicState, FormatFeatureFlags2, PrimitiveTopology}; +use crate::vk::{DriverId, DynamicState, Format, FormatFeatureFlags2, PrimitiveTopology}; +use std::borrow::Cow; use std::collections::{BTreeMap, BTreeSet}; /// One driver measured to have the fact `F`, over the releases measured. @@ -77,15 +81,21 @@ pub(crate) enum Standing { }, } -/// The facts of `table` that the driver `driver` on GPU `device` of `vendor` has at release -/// `version`, each with its standing; an unmeasured fact is absent. A `device` of `None` is a GPU -/// no row names (`DeviceDescription::measured_gpu`): only the rows of every GPU hold for it. +/// The facts of `table` that the driver `driver` on GPU `device` of `vendor`, named `name` +/// (`VkPhysicalDeviceProperties::deviceName`), has at release `version`, each with its standing; +/// an unmeasured fact is absent. A `device` of `None` is a GPU no row names +/// (`DeviceDescription::measured_gpu`): only the rows of every GPU hold for it. Where `version` of +/// the identity was measured on another GPU of it alone ([`NAMED_RELEASES`]), no row of its GPU +/// that covers `version` holds, so the rows of earlier releases stand beyond their last; a `name` +/// of `None` is put out by no named release. pub(crate) fn among( table: &[Measured], driver: Option, (vendor, device): (u32, Option), version: u32, + name: Option<&str>, ) -> BTreeMap { + let out = name.is_some_and(|name| named_out(driver, (vendor, device), version, name)); let mut facts = BTreeMap::new(); for row in table { let ours = Some(row.driver) == driver @@ -94,13 +104,22 @@ pub(crate) fn among( if !ours || version < row.first { continue; } + if out && row.device.is_some() && version <= row.last { + continue; + } let standing = match version <= row.last { true => Standing::Measured, false => Standing::Beyond { last: row.last }, }; - // Two rows of one fact (a driver measured on two vendors) keep the better standing. + // Two rows of one fact (a driver measured on two vendors, or at two releases) keep the + // better standing: measured, else beyond the later last release measured. let kept = facts.entry(row.fact).or_insert(standing); - *kept = (*kept).min(standing); + *kept = match (*kept, standing) { + (Standing::Beyond { last: a }, Standing::Beyond { last: b }) => { + Standing::Beyond { last: a.max(b) } + } + _ => Standing::Measured, + }; } facts } @@ -467,6 +486,19 @@ pub(crate) fn among( /// words in every slice and viewport quadrant, as a Metal probe of the same functions on the same /// GPU left them. /// +/// MoltenVK 1.4.2 (its SPIRV-Cross `6c09849f`) on the M3 Max under macOS 27.0.1 +/// ([`moltenvk_142`]; 2026-10-21, the runtime lanes in release builds under `--cfg m2v_gpu`): every +/// deviation of the 1.4.1 rows of [`APPLE_M4`]'s identity, each taken, passed the lanes that +/// measured it (`driver_deviations`' lockstep, float function, denormal, half, minimum and +/// maximum, cube gradient, fragment and vertex simdgroup checks, `color_writes`, `first_vertex`, +/// `renders::public_render_cases_match_metal` and the authored cases against the M3 Max's Metal +/// rows), and SPIRV-Cross's `spvGradientCube` is `adec7acb`'s. `MetalFullQuads` is 1.4.2's alone: +/// 1.4.2 stops advertising `shaderQuadControl` on Apple's GPUs, and its SPIRV-Cross writes no +/// mode for `RequireFullQuadsKHR` but hands the fragment function to Metal, whose quads keep their +/// helpers; the lanes that took the feature before (`discard_counts`, `discard_hoist`, +/// `helper_tangle`, `driver_deviations::fragment_simdgroup_lanes_are_metal_s` and the public +/// render cases) answer Metal's with it. +/// /// Another driver has none of them, as Vulkan states, but a listed driver at a release outside /// its rows, or on another vendor's GPU (or another GPU than a row's), is unmeasured: the profile /// then takes each one's conservative route (`derive.rs`). @@ -788,6 +820,33 @@ pub(crate) const DEVIATIONS: &[Measured] = &[ moltenvk_141(DriverDeviation::MetalDepth16BiasedStores), moltenvk_141(DriverDeviation::MetalInterpolation), moltenvk_141(DriverDeviation::MetalFirstVertexIndices), + moltenvk_142(DriverDeviation::SimdgroupLockstep), + moltenvk_142(DriverDeviation::MetalFloatFunctions), + moltenvk_142(DriverDeviation::MetalCanonicalNans), + moltenvk_142(DriverDeviation::MetalSampler), + moltenvk_142(DriverDeviation::CubeGradientRoute), + moltenvk_142(DriverDeviation::GraphicsCubeGradientTangents), + moltenvk_142(DriverDeviation::MetalColorWrites), + moltenvk_142(DriverDeviation::HalfColorOutputBits), + moltenvk_142(DriverDeviation::MetalHalfFma), + moltenvk_142(DriverDeviation::MetalFloatDenormals), + moltenvk_142(DriverDeviation::MetalHalfQuantize), + moltenvk_142(DriverDeviation::MetalHalfConversion), + moltenvk_142(DriverDeviation::MetalCenterVaryings), + moltenvk_142(DriverDeviation::MetalMinMax), + moltenvk_142(DriverDeviation::MetalHalfArithmetic), + moltenvk_142(DriverDeviation::MetalHalfStorageWrites), + moltenvk_142(DriverDeviation::MetalHalfStorageNans), + moltenvk_142(DriverDeviation::MetalFloatStorageNans), + moltenvk_142(DriverDeviation::MetalFragmentSimdgroups), + moltenvk_142(DriverDeviation::MetalVertexSimdgroups), + moltenvk_142(DriverDeviation::CenterFragCoordDepth), + moltenvk_142(DriverDeviation::MetalNormStorageWrites), + moltenvk_142(DriverDeviation::MetalDepth16Stores), + moltenvk_142(DriverDeviation::MetalDepth16BiasedStores), + moltenvk_142(DriverDeviation::MetalInterpolation), + moltenvk_142(DriverDeviation::MetalFirstVertexIndices), + moltenvk_142(DriverDeviation::MetalFullQuads), ]; /// NVIDIA's `vendorID`. @@ -872,6 +931,22 @@ const fn moltenvk_141(fact: DriverDeviation) -> Measured { } } +/// The row of `fact` measured on MoltenVK 1.4.2 (`driverVersion` 10402, Homebrew's build, its +/// SPIRV-Cross `6c09849f`) on the Apple M3 Max under macOS 27.0.1, whose `deviceID` is +/// [`APPLE_M4`]'s: the identity [`MEASURED_DEVICES`] lists at that release, for the M3 Max alone +/// ([`NAMED_RELEASES`]). The M4, which reports the same `deviceID` under macOS 27, is not measured +/// at 1.4.2: its 1.4.1 rows stand beyond their last there. +const fn moltenvk_142(fact: F) -> Measured { + Measured { + fact, + driver: DriverId::MOLTENVK, + vendor: Some(APPLE_VENDOR_ID), + device: Some(APPLE_M4), + first: moltenvk(1, 4, 2), + last: moltenvk(1, 4, 2), + } +} + /// Every measured driver defect translation refuses by release (`Needs::DriverDefect`; the /// coordinator's ruling of 2026-10-06), and every measured answer a module records as a precision /// note: a defect is kept at a release newer than the last measured (the module docs' rule), and @@ -1025,6 +1100,7 @@ pub(crate) fn defects(description: &DeviceDescription) -> BTreeSet BTreeMap, + (vendor, device): (u32, Option), + version: u32, + name: &str, +) -> bool { + NAMED_RELEASES.iter().any(|r| { + Some(r.driver) == driver + && r.vendor == vendor + && Some(r.device) == device + && r.release == version + && r.gpu != name + }) +} + /// A driver's measured answer where Vulkan leaves the result undefined, or its measured cost of /// two exact forms (a cost fact, the module docs). #[non_exhaustive] @@ -1166,6 +1288,21 @@ pub enum DriverFact { /// this one from an unmeasured release relay as before. MoltenVK's own code on every GPU, so /// the row names no vendor; held on the release measured alone (the module docs). DynamicRestartWarns, + /// A driver diagnostic (the module docs): the driver reports a warning as it creates a + /// graphics pipeline for each color attachment whose format lacks + /// `VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BLEND_BIT` in its optimal tiling, whether the + /// pipeline enables blending there or not: a `VALIDATION` message named `mvk-warn` (number 0), + /// `VK_ERROR_FEATURE_NOT_PRESENT: Blending is enabled for attachment with format , + /// which does not support it.`, the format by its registry name + /// ([`DriverFact::pipeline_creation_diagnostics`]). MoltenVK 1.4.2 skips the blend state of + /// such an attachment, whose Metal pixel format lacks `kMVKMTLFmtCapsBlend` (the capability it + /// reports as that feature bit), and warns in that branch without reading the attachment's + /// `blendEnable` (`MVKGraphicsPipeline::addFragmentOutputToPipeline`, `MVKPipeline.mm` lines + /// 1961-1996 at 1.4.2). The runtime never enables blending there, as Vulkan forbids + /// (`VUID-VkGraphicsPipelineCreateInfo-renderPass-06041`), so the warning reports nothing the + /// pipeline does. On a driver with it the runtime withholds exactly those messages inside that + /// pipeline's creation, and counts them, as [`DriverFact::DynamicRestartWarns`]'s. + BlendlessColorAttachmentsWarn, /// A cost fact (the module docs): the driver runs `vkCmdFillBuffer` as a compute dispatch of /// a pipeline it compiles at the first fill each `VkCommandPool`'s command buffers encode, /// inside `vkQueueSubmit`, through the OS's shader compiler, which serves the process's @@ -1548,16 +1685,20 @@ impl DriverFact { } } - /// The diagnostic a driver with this fact reports as it creates a graphics pipeline that - /// makes `dynamic_states` dynamic, of the input assembly topology `topology`: for - /// [`DriverFact::DynamicRestartWarns`], where the pipeline makes + /// The diagnostics a driver with this fact reports as it creates a graphics pipeline that + /// makes `dynamic_states` dynamic, of the input assembly topology `topology`, whose color + /// attachments of the formats `blendless_colors` lack `COLOR_ATTACHMENT_BLEND` in their + /// optimal tiling: for [`DriverFact::DynamicRestartWarns`], one where the pipeline makes /// `PRIMITIVE_RESTART_ENABLE` dynamic and makes `PRIMITIVE_TOPOLOGY` dynamic or takes a - /// strip or a fan. `None` for any other pipeline, and for every other fact. - pub fn pipeline_creation_diagnostic( + /// strip or a fan; for [`DriverFact::BlendlessColorAttachmentsWarn`], one for each format of + /// `blendless_colors` the registry names. None for any other pipeline, and for every other + /// fact. + pub fn pipeline_creation_diagnostics( self, dynamic_states: &[DynamicState], topology: PrimitiveTopology, - ) -> Option { + blendless_colors: &[Format], + ) -> Vec { use PrimitiveTopology as T; match self { Self::DynamicRestartWarns => { @@ -1568,36 +1709,55 @@ impl DriverFact { (dynamic_states.contains(&DynamicState::PRIMITIVE_RESTART_ENABLE) && (strip || dynamic_states.contains(&DynamicState::PRIMITIVE_TOPOLOGY))) .then_some(DYNAMIC_RESTART_WARNING) + .into_iter() + .collect() } - _ => None, + Self::BlendlessColorAttachmentsWarn => blendless_colors + .iter() + .filter_map(|format| format.name()) + .map(|name| DriverDiagnostic { + id_name: MVK_WARN, + id: 0, + text: Cow::Owned(format!( + "VK_ERROR_FEATURE_NOT_PRESENT: Blending is enabled for attachment with \ + format {name}, which does not support it." + )), + }) + .collect(), + _ => Vec::new(), } } } /// A message a driver reports through `VK_EXT_debug_utils` where Vulkan states nothing wrong, at /// `WARNING` severity as a `VALIDATION` message, as a driver diagnostic fact measures it (the -/// module docs; [`DriverFact::pipeline_creation_diagnostic`]). The runtime withholds it from the +/// module docs; [`DriverFact::pipeline_creation_diagnostics`]). The runtime withholds it from the /// device's message sink only inside the call the fact names, on a release measured with the /// fact, where it matches every field exactly; anywhere else it relays. #[non_exhaustive] -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] +#[derive(Clone, Debug, PartialEq, Eq, Hash)] pub struct DriverDiagnostic { /// Its `pMessageIdName`. pub id_name: &'static str, /// Its `messageIdNumber`. pub id: i32, /// Its `pMessage`. - pub text: &'static str, + pub text: Cow<'static, str>, } +/// The name MoltenVK gives a warning: `MVKInstance::debugReportMessage` names a warning +/// `mvk-warn` and numbers it 0, and `MVKBaseObject::reportResult` prefixes the result's name to +/// its text. +const MVK_WARN: &str = "mvk-warn"; + /// MoltenVK's report of a pipeline whose primitive restart may be disabled -/// ([`DriverFact::DynamicRestartWarns`]): `MVKBaseObject::reportResult` prefixes the result's -/// name to its text, and `MVKInstance::debugReportMessage` names a warning `mvk-warn` and -/// numbers it 0. +/// ([`DriverFact::DynamicRestartWarns`]). const DYNAMIC_RESTART_WARNING: DriverDiagnostic = DriverDiagnostic { - id_name: "mvk-warn", + id_name: MVK_WARN, id: 0, - text: "VK_ERROR_FEATURE_NOT_PRESENT: Metal does not support disabling primitive restart.", + text: Cow::Borrowed( + "VK_ERROR_FEATURE_NOT_PRESENT: Metal does not support disabling primitive restart.", + ), }; /// Every measured fact, by driver. @@ -1960,6 +2120,50 @@ const DYNAMIC_RESTART_WARNING: DriverDiagnostic = DriverDiagnostic { /// Measured not to have it: RADV, Mesa 26.2.4 on the Radeon 780M, which passes the first but /// leaves 19 of the second's 495 bands wrong. Every other driver is unmeasured, and takes the /// barrier. +/// +/// MoltenVK 1.4.2 on the M3 Max under macOS 27.0.1 ([`moltenvk_142`]; 2026-10-21, the runtime +/// lanes in release builds under `--cfg m2v_gpu`, each fact taken): +/// - Measured by the lane that measured its 1.4.1 row, which passed: `DepthImageKeepsDenormals` +/// and `DepthImageKeepsValuesOutsideUnitRange` +/// (`texture_blits::depth_images_keep_what_their_drivers_claim`, `depth_denormals`), +/// `DepthTestKeepsDenormals` and `DepthTestComparesMagnitudes` (`depth_denormals`' stored +/// depths, tested and compared as Metal's), `DepthStencilImagesLieApart` +/// (`heap_textures::heap_depth_textures_keep_their_bytes_with_their_twins`), +/// `DepthStencilImagesStayGpuOptimized` +/// (`heap_textures::heap_textures_answer_and_place_as_metal_s_do`), +/// `ColorResolveAverageIsMetals` (`resolve_rounding::color_resolves_against_metals_rules`), +/// `SampledFetchRecoversCodes` +/// (`mipmaps_exact::a_first_level_read_in_place_recovers_every_code`), `DynamicRestartWarns` +/// (`restart`, `made_at_creation`: its warning withheld at each such pipeline's creation and +/// nowhere else), `DontCareStoreIsMetals` (`dont_care_stores`, `kept_buffer_bytes`), +/// `ColorBlockDecodeIsMetals` and `ChannelBlockDecodeIsMetals` +/// (`compressed_decode::bc1_to_bc5_texels_read_as_metal_s`) and `TileStoreIsMetals` +/// (`snorm_tile_store`). +/// - `BlendlessColorAttachmentsWarn`, new at 1.4.2 (the fact's docs): where the release was +/// unmeasured, the warning of each color attachment of a format the device cannot blend +/// (`R32Uint`, `RGBA32Uint` and the rest) failed the runtime's `srgb_fetch_images` and about 25 +/// lanes; with the fact, none. +/// - `TimestampsWaitForEveryQueue`, by the plain Vulkan program behind the fact (our upstream +/// draft's): a 256-byte fill on a queue of another family, submitted just after a 30.7 ms +/// dispatch, completed at 30.78 ms (median) in 40 of 40 rounds where both command buffers wrote +/// timestamps after their work, and at 0.28 ms (1 of 40 held) where neither did; argument +/// buffers on, as the runtime runs. `encodeTimestampStageCounterSamples` is 1.4.1's. +/// - `TimestampPoolsAreCounterSampleBuffers` and `LinearTilingFeaturesUninitialized`, defect +/// facts, read in 1.4.2's source as at 1.4.1: +/// `MVKGPUCounterQueryPool::initMTLCounterSampleBuffer` makes each pool one counter sample +/// buffer of its query count, and `MVKPhysicalDevice` still builds `_pixelFormats` (which reads +/// `renderLinearTextures`) before `initMetalFeatures` sets it. +/// - `Bc6hBlockDecodeIsMetals` and `Bc7BlockDecodeIsMetals`, by construction as at 1.4.1: 1.4.2's +/// `MVKPixelFormats.mm` hands every BC format to Metal as Metal's own, line for line 1.4.1's. +/// +/// Not extended to 1.4.2, so not taken there: `InterlockedPassSplitNoSlower`, a cost fact whose +/// 1.4.1 timing needed a scratch build that keeps such a pass whole (its passes split there, +/// announced, as on any unmeasured release); and `FillCompiledPerCommandPool`, whose wait our +/// probe did not find: a command buffer of one `vkCmdFillBuffer`, the first in a fresh command +/// pool, took 0.022 to 0.038 ms (median) in `vkQueueSubmit` beside one to eight threads making +/// compute pipelines (91 and 496 made), as a `vkCmdUpdateBuffer` did, though +/// `MVKCommandEncodingPool::getCmdFillBufferMTLComputePipelineState` is 1.4.1's (fills there take +/// `vkCmdFillBuffer`). pub(crate) const MEASURED: &[Measured] = &[ Measured { fact: DriverFact::RobustIndexFetchReadsZero, @@ -2513,6 +2717,25 @@ pub(crate) const MEASURED: &[Measured] = &[ first: mesa(26, 2, 4), last: mesa(26, 2, 4), }, + moltenvk_142(DriverFact::DepthImageKeepsDenormals), + moltenvk_142(DriverFact::DepthImageKeepsValuesOutsideUnitRange), + moltenvk_142(DriverFact::DepthTestKeepsDenormals), + moltenvk_142(DriverFact::DepthTestComparesMagnitudes), + moltenvk_142(DriverFact::DepthStencilImagesLieApart), + moltenvk_142(DriverFact::ColorResolveAverageIsMetals), + moltenvk_142(DriverFact::DepthStencilImagesStayGpuOptimized), + moltenvk_142(DriverFact::SampledFetchRecoversCodes), + moltenvk_142(DriverFact::DynamicRestartWarns), + moltenvk_142(DriverFact::BlendlessColorAttachmentsWarn), + moltenvk_142(DriverFact::DontCareStoreIsMetals), + moltenvk_142(DriverFact::TimestampsWaitForEveryQueue), + moltenvk_142(DriverFact::TimestampPoolsAreCounterSampleBuffers), + moltenvk_142(DriverFact::LinearTilingFeaturesUninitialized), + moltenvk_142(DriverFact::ColorBlockDecodeIsMetals), + moltenvk_142(DriverFact::ChannelBlockDecodeIsMetals), + moltenvk_142(DriverFact::Bc6hBlockDecodeIsMetals), + moltenvk_142(DriverFact::Bc7BlockDecodeIsMetals), + moltenvk_142(DriverFact::TileStoreIsMetals), ]; /// Intel's `vendorID`. @@ -2556,6 +2779,12 @@ pub(crate) const MEASURED_DEVICES: &[MeasuredDevice] = &[ device: APPLE_M4, release: moltenvk(1, 4, 1), }, + MeasuredDevice { + driver: DriverId::MOLTENVK, + vendor: APPLE_VENDOR_ID, + device: APPLE_M4, + release: moltenvk(1, 4, 2), + }, MeasuredDevice { driver: DriverId::MESA_LLVMPIPE, vendor: MESA_VENDOR_ID, @@ -2608,6 +2837,7 @@ impl DeviceDescription { /// ([`DriverFact::assumed_where_unmeasured`]). The runtime relies on an answer fact only where /// the driver has it, and elsewhere takes the exact path that needs none. pub fn driver_facts(&self) -> BTreeSet { + // A measured identity is no GPU a named release puts out (`NAMED_RELEASES`). let measured = self.measured_identity(); let gpu = self.measured_gpu(); MEASURED @@ -2635,7 +2865,13 @@ impl DeviceDescription { /// ([`DeviceDescription::assumed_unmeasured`]) is none. pub fn measured_identity(&self) -> bool { let gpu = self.measured_gpu(); - MEASURED_DEVICES.iter().any(|m| { + let identity = (self.vendor_id, gpu); + !named_out( + self.driver_id, + identity, + self.driver_version, + &self.device_name, + ) && MEASURED_DEVICES.iter().any(|m| { Some(m.driver) == self.driver_id && m.vendor == self.vendor_id && Some(m.device) == gpu @@ -2643,6 +2879,21 @@ impl DeviceDescription { }) } + /// The formats the device lists as color attachments of optimal tiling without + /// `COLOR_ATTACHMENT_BLEND`, in order: those whose pipelines a driver with + /// [`DriverFact::BlendlessColorAttachmentsWarn`] warns of + /// ([`DriverFact::pipeline_creation_diagnostics`]). + pub fn blendless_color_formats(&self) -> Vec { + let (color, blend) = ( + FormatFeatureFlags2::COLOR_ATTACHMENT, + FormatFeatureFlags2::COLOR_ATTACHMENT_BLEND, + ); + (self.formats.formats.iter()) + .filter(|(_, p)| p.optimal_tiling.contains(color) && !p.optimal_tiling.contains(blend)) + .map(|(&format, _)| format) + .collect() + } + /// The linear-tiling format features the device's driver may report or not /// ([`DriverFact::unreliable_linear_tiling`] of its [`DeviceDescription::driver_facts`]), /// which the description's formats leave out: `DeviceDescription::query` drops them from every diff --git a/crates/metal2vulkan/src/device/khronos.rs b/crates/metal2vulkan/src/device/khronos.rs index 854d0b27a..4b3117f9c 100644 --- a/crates/metal2vulkan/src/device/khronos.rs +++ b/crates/metal2vulkan/src/device/khronos.rs @@ -338,6 +338,7 @@ impl Merged { desc.driver_version = p.u32("driverVersion")?; desc.vendor_id = p.u32("vendorID")?; desc.device_id = p.u32("deviceID")?; + desc.device_name = p.string("deviceName"); desc.device_type = p.enum_value("deviceType", vk::PhysicalDeviceType::from_name)?; desc.limits = limits(&p, api_version, &self.extensions)?; desc.allocation = AllocationLimits::new( @@ -538,6 +539,14 @@ impl Props<'_> { self.0.get(name) } + /// The string member `name`, empty where absent or not a string. + fn string(&self, name: &str) -> String { + self.get(name) + .and_then(Value::as_str) + .unwrap_or_default() + .to_owned() + } + fn u64_or(&self, name: &str, absent: u64) -> Result { match self.get(name) { None => Ok(absent), diff --git a/crates/metal2vulkan/src/device/profile.rs b/crates/metal2vulkan/src/device/profile.rs index aa88678d2..167aa720d 100644 --- a/crates/metal2vulkan/src/device/profile.rs +++ b/crates/metal2vulkan/src/device/profile.rs @@ -350,6 +350,9 @@ impl DeviceProfile { .enabled .properties .contains(&VkProperty::MetalFirstVertexIndices), + DriverDeviation::MetalFullQuads => { + f.enabled.properties.contains(&VkProperty::MetalFullQuads) + } } } diff --git a/crates/metal2vulkan/src/device/requirements.rs b/crates/metal2vulkan/src/device/requirements.rs index d5241c996..ae21c69ef 100644 --- a/crates/metal2vulkan/src/device/requirements.rs +++ b/crates/metal2vulkan/src/device/requirements.rs @@ -761,6 +761,14 @@ pub enum VkProperty { /// vertices to its builtin requires it; without it, the index goes through the pipeline's /// synthesized geometry stages. MetalFirstVertexIndices, + /// The device runs a fragment shader's quads whole, its helper invocations taking part in + /// every group operation, as Metal runs a fragment function's helper threads (the driver's + /// measured deviation + /// [`DriverDeviation::MetalFullQuads`](crate::error::DriverDeviation::MetalFullQuads)). + /// No Vulkan query reports it: Vulkan gives it only under `RequireFullQuadsKHR`. A fragment + /// module whose group operations observe other lanes requires it in place of + /// `shaderQuadControl` on a device without that feature. + MetalFullQuads, } /// One depth or stencil resolve mode (`VkResolveModeFlagBits`), named by diff --git a/crates/metal2vulkan/src/device/tests/driver_facts.rs b/crates/metal2vulkan/src/device/tests/driver_facts.rs index a0f0391fd..7cc4ff7f8 100644 --- a/crates/metal2vulkan/src/device/tests/driver_facts.rs +++ b/crates/metal2vulkan/src/device/tests/driver_facts.rs @@ -28,7 +28,7 @@ fn a_fact_holds_from_the_first_release_measured_and_past_the_last_as_beyond() { last: mesa(26, 2, 6), }; let at = |table: &[Measured], driver, vendor, version| { - among(table, driver, (vendor, Some(0x1A06_0209)), version) + among(table, driver, (vendor, Some(0x1A06_0209)), version, None) .get(&1) .copied() }; @@ -78,7 +78,7 @@ fn a_fact_holds_from_the_first_release_measured_and_past_the_last_as_beyond() { }; assert_eq!(at(&[one_gpu], mvk, APPLE, 10401), Some(Standing::Measured)); assert_eq!( - among(&[one_gpu], mvk, (APPLE, Some(0x1B00_0209)), 10401).get(&1), + among(&[one_gpu], mvk, (APPLE, Some(0x1B00_0209)), 10401, None).get(&1), None ); // Two rows: the later measurement covers what the earlier left beyond. @@ -91,6 +91,13 @@ fn a_fact_holds_from_the_first_release_measured_and_past_the_last_as_beyond() { at(&[apple, later], mvk, APPLE, moltenvk(1, 4, 2)), Some(Standing::Measured) ); + // Past both, in either order, it names the later of their last releases. + for table in [[apple, later], [later, apple]] { + assert_eq!( + at(&table, mvk, APPLE, moltenvk(1, 4, 3)), + Some(Standing::Beyond { last: 10402 }) + ); + } // The encodings, as the committed profiles state their releases. assert_eq!(nvidia(615, 71, 9), 2_580_660_800); assert_eq!(mesa(26, 2, 4), 109_060_100); @@ -228,6 +235,7 @@ fn taken(p: &crate::device::DeviceProfile) -> Vec D::MetalFirstVertexIndices, property(VkProperty::MetalFirstVertexIndices), ), + (D::MetalFullQuads, property(VkProperty::MetalFullQuads)), ] .into_iter() .inspect(|&(d, taken)| { @@ -441,14 +449,44 @@ fn the_profile_takes_the_deviations_its_driver_release_is_measured_with() { graphics: CubeGradientRoute::Unmeasured, compute: CubeGradientRoute::Unmeasured, }; - // A later release: taken, and listed with the last release measured. - let mut later = m4.clone(); - later.driver_version = moltenvk(1, 4, 2); - let p = profile_of(later); + // MoltenVK 1.4.2 on the GPU of the identity measured there (the M3 Max under macOS 27.0.1, + // `NAMED_RELEASES`): each measured again, and its full quads, none past its measurement. + let mut all_142 = all.clone(); + all_142.push(D::MetalFullQuads); + let mut m3_142 = super::profile("moltenvk-m3"); + m3_142.driver_version = moltenvk(1, 4, 2); + assert_eq!(m3_142.device_name, "Apple M3 Max"); + let p = profile_of(m3_142); + assert_eq!(taken(&p), all_142); + assert!(p.fields().deviations_beyond.is_empty()); + assert!(!centered(&p)); + // The M4, the identity's other GPU, at 1.4.2: not measured there, so its 1.4.1 rows past + // their measurement, and no full quads. + let mut m4_142 = m4.clone(); + m4_142.driver_version = moltenvk(1, 4, 2); + assert_eq!(m4_142.device_name, "Apple M4"); + let p = profile_of(m4_142); assert_eq!(taken(&p), all); let beyond: BTreeMap = all.iter().map(|&d| (d, 10401)).collect(); assert_eq!(p.fields().deviations_beyond, beyond); + // A later release, on either GPU of the identity: taken, and listed with the last release + // measured. + let mut later = m4.clone(); + later.driver_version = moltenvk(1, 4, 3); + let p = profile_of(later); + assert_eq!(taken(&p), all_142); + let beyond: BTreeMap = all_142.iter().map(|&d| (d, 10402)).collect(); + assert_eq!(p.fields().deviations_beyond, beyond); assert!(!centered(&p)); + // Another Apple identity at 1.4.2 (the M3 Max under macOS 26.7): its 1.4.1 rows, past their + // measurement. + let mut m3_macos26_142 = super::profile("moltenvk-m3"); + m3_macos26_142.device_id = crate::device::driver_facts::APPLE_M3_MAX; + m3_macos26_142.driver_version = moltenvk(1, 4, 2); + let p = profile_of(m3_macos26_142); + assert_eq!(taken(&p), m3_max); + let beyond: BTreeMap = m3_max.iter().map(|&d| (d, 10401)).collect(); + assert_eq!(p.fields().deviations_beyond, beyond); // An earlier release, and another vendor's GPU: none, the cube routes unmeasured. let mut earlier = m4.clone(); earlier.driver_version = moltenvk(1, 4, 0); @@ -740,7 +778,7 @@ fn an_unmeasured_identity_takes_its_drivers_defects_alone() { assert!(desc.measured_identity()); assert!(desc.driver_facts().contains(&SPLIT)); assert!(desc.driver_facts().contains(&FETCH)); - for release in [10402, 10400] { + for release in [10403, 10400] { desc.driver_version = release; assert!(!desc.measured_identity()); assert_eq!( @@ -887,9 +925,10 @@ fn a_gpu_under_another_of_its_device_ids_takes_its_measured_rows() { } /// The identities measured whose venue has no committed profile: the RTX 3090 (gem10) at NVIDIA's -/// 615.71.09, lavapipe at Mesa 26.2.4 (the Linux venues' own lavapipe), and the M3 Max under macOS -/// 26.7 at MoltenVK 1.4.1 (its venue's capture is now macOS 27's, the M4's identity). -const MEASURED_WITHOUT_PROFILE: [(DriverId, u32, u32, u32); 3] = [ +/// 615.71.09, lavapipe at Mesa 26.2.4 (the Linux venues' own lavapipe), the M3 Max under macOS +/// 26.7 at MoltenVK 1.4.1 (its venue's capture is now macOS 27's, the M4's identity), and the M3 +/// Max under macOS 27.0.1 at MoltenVK 1.4.2 (its venue's capture is 1.4.1's). +const MEASURED_WITHOUT_PROFILE: [(DriverId, u32, u32, u32); 4] = [ ( DriverId::NVIDIA_PROPRIETARY, 0x10de, @@ -903,6 +942,12 @@ const MEASURED_WITHOUT_PROFILE: [(DriverId, u32, u32, u32); 3] = [ crate::device::driver_facts::APPLE_M3_MAX, moltenvk(1, 4, 1), ), + ( + DriverId::MOLTENVK, + APPLE, + crate::device::driver_facts::APPLE_M4, + moltenvk(1, 4, 2), + ), ]; /// A driver measured to lay depth and stencil images apart from their memory is measured to keep @@ -919,7 +964,7 @@ fn a_driver_that_lays_depth_images_apart_holds_no_depth_twin() { ); for row in apart { let gpu = (row.vendor.unwrap_or(APPLE), Some(row.device.unwrap_or(0))); - let facts = among(MEASURED, Some(row.driver), gpu, row.first); + let facts = among(MEASURED, Some(row.driver), gpu, row.first, None); assert!( facts.contains_key(&DENORMALS) && facts.contains_key(&OUTSIDE), "{:?} from {:#x} lays depth images apart but may lose a depth texel: {facts:?}", @@ -961,18 +1006,19 @@ fn nvidia_s_semaphore_stall_holds_on_the_gpus_measured() { } /// MoltenVK's warning of a pipeline whose restart may be disabled (`MVKPipeline.mm` lines 881-893 -/// at 1.4.1) is the diagnostic of a pipeline that makes the restart dynamic with its topology -/// dynamic or a strip or fan, exactly as the driver reports it; no other pipeline's, and no other -/// fact's. It is measured on MoltenVK 1.4.1 alone, on any GPU: 1.4.0 and 1.4.2 relay it, as does -/// any other driver at 1.4.1's `driverVersion`. +/// at 1.4.1, 883-895 at 1.4.2) is the diagnostic of a pipeline that makes the restart dynamic with +/// its topology dynamic or a strip or fan, exactly as the driver reports it; no other pipeline's, +/// and no other fact's. It is measured on MoltenVK 1.4.1, on any GPU, and on 1.4.2 on the measured +/// identity: 1.4.0 and 1.4.3 relay it, as does any other driver at 1.4.1's `driverVersion`. #[test] -fn moltenvk_1_4_1_warns_of_a_pipeline_whose_restart_is_dynamic() { +fn moltenvk_warns_of_a_pipeline_whose_restart_is_dynamic() { use crate::device::DriverDiagnostic; use crate::vk::{DynamicState as D, PrimitiveTopology as T}; let warning = DriverDiagnostic { id_name: "mvk-warn", id: 0, - text: "VK_ERROR_FEATURE_NOT_PRESENT: Metal does not support disabling primitive restart.", + text: "VK_ERROR_FEATURE_NOT_PRESENT: Metal does not support disabling primitive restart." + .into(), }; let both = [D::PRIMITIVE_TOPOLOGY, D::PRIMITIVE_RESTART_ENABLE]; let restart = [D::CULL_MODE, D::PRIMITIVE_RESTART_ENABLE]; @@ -989,28 +1035,45 @@ fn moltenvk_1_4_1_warns_of_a_pipeline_whose_restart_is_dynamic() { (&[], T::TRIANGLE_STRIP, false), (&[D::CULL_MODE], T::LINE_STRIP, false), ]; + let blendless = [crate::vk::Format::R32_UINT]; for (dynamic, top, warns) in cases { assert_eq!( - RESTART.pipeline_creation_diagnostic(dynamic, top), - warns.then_some(warning), + RESTART.pipeline_creation_diagnostics(dynamic, top, &blendless), + warns + .then(|| warning.clone()) + .into_iter() + .collect::>(), "{dynamic:?} {top:?}" ); for other in [ZERO, DENORMALS, FETCH, SPLIT] { - assert_eq!(other.pipeline_creation_diagnostic(dynamic, top), None); + assert!(other + .pipeline_creation_diagnostics(dynamic, top, &blendless) + .is_empty()); } } - let rows: Vec<_> = MEASURED.iter().filter(|row| row.fact == RESTART).collect(); - assert_eq!(rows.len(), 1); - let row = rows[0]; + let rows: Vec<_> = MEASURED + .iter() + .filter(|row| row.fact == RESTART) + .map(|row| (row.driver, row.vendor, row.device, row.first, row.last)) + .collect(); assert_eq!( - (row.driver, row.vendor, row.device, row.first, row.last), - ( - DriverId::MOLTENVK, - None, - None, - moltenvk(1, 4, 1), - moltenvk(1, 4, 1) - ) + rows, + [ + ( + DriverId::MOLTENVK, + None, + None, + moltenvk(1, 4, 1), + moltenvk(1, 4, 1) + ), + ( + DriverId::MOLTENVK, + Some(APPLE), + Some(crate::device::driver_facts::APPLE_M4), + moltenvk(1, 4, 2), + moltenvk(1, 4, 2) + ), + ] ); let text = std::fs::read_to_string( PathBuf::from(env!("CARGO_MANIFEST_DIR")) @@ -1018,7 +1081,7 @@ fn moltenvk_1_4_1_warns_of_a_pipeline_whose_restart_is_dynamic() { ) .expect("moltenvk-m3"); let mut desc = DeviceDescription::from_khronos_json(&text, None).expect("profile parses"); - for (version, has) in [(10400, false), (10401, true), (10402, false)] { + for (version, has) in [(10400, false), (10401, true), (10402, true), (10403, false)] { desc.driver_version = version; assert_eq!(desc.driver_facts().contains(&RESTART), has, "{version}"); } @@ -1027,6 +1090,85 @@ fn moltenvk_1_4_1_warns_of_a_pipeline_whose_restart_is_dynamic() { assert!(!desc.driver_facts().contains(&RESTART)); } +/// MoltenVK 1.4.2 on the Apple9 family under macOS 27 was measured on the M3 Max alone +/// (`NAMED_RELEASES`): the M3 Max's capture at 1.4.2 is a measured identity and takes the +/// release's facts; the M4's, which reports the same `deviceID`, is not and takes none of them, +/// nor does a GPU of no name; at 1.4.1 both are measured. +#[test] +fn moltenvk_1_4_2_is_measured_on_the_m3_max_alone() { + let m3 = super::profile("moltenvk-m3"); + let m4 = super::profile("moltenvk-m4"); + assert_eq!( + (m3.device_id, m3.driver_version), + (m4.device_id, m4.driver_version) + ); + for (mut d, at_142) in [(m3.clone(), true), (m4, false)] { + assert!(d.measured_identity(), "{}", d.device_name); + d.driver_version = moltenvk(1, 4, 2); + assert_eq!(d.measured_identity(), at_142, "{}", d.device_name); + let blend = d + .driver_facts() + .contains(&DriverFact::BlendlessColorAttachmentsWarn); + assert_eq!(blend, at_142, "{}", d.device_name); + } + let mut nameless = m3; + nameless.driver_version = moltenvk(1, 4, 2); + nameless.device_name.clear(); + assert!(!nameless.measured_identity()); +} + +/// MoltenVK 1.4.2's warning of a color attachment whose format cannot blend +/// (`MVKPipeline.mm`'s `addFragmentOutputToPipeline` at 1.4.2), whether the pipeline blends it +/// or not, is one diagnostic for each such format, named as the registry names it, exactly as the +/// driver reports it; none for a pipeline without such an attachment, and none of another fact. +/// It is measured on 1.4.2 on the M3 Max alone: 1.4.1, which has no such warning, and 1.4.3 relay +/// it. +#[test] +fn moltenvk_1_4_2_warns_of_each_color_attachment_it_cannot_blend() { + use crate::device::DriverDiagnostic; + use crate::vk::{Format as F, PrimitiveTopology as T}; + const BLEND: DriverFact = DriverFact::BlendlessColorAttachmentsWarn; + let warning = |name: &str| DriverDiagnostic { + id_name: "mvk-warn", + id: 0, + text: format!( + "VK_ERROR_FEATURE_NOT_PRESENT: Blending is enabled for attachment with format {name}, \ + which does not support it." + ) + .into(), + }; + let blendless = [F::R32_UINT, F::E5B9G9R9_UFLOAT_PACK32]; + assert_eq!( + BLEND.pipeline_creation_diagnostics(&[], T::TRIANGLE_LIST, &blendless), + [ + warning("VK_FORMAT_R32_UINT"), + warning("VK_FORMAT_E5B9G9R9_UFLOAT_PACK32") + ] + ); + // The text MoltenVK 1.4.2 reported for `R32_UINT` on the M3 Max (2026-10-21). + assert_eq!( + warning("VK_FORMAT_R32_UINT").text, + "VK_ERROR_FEATURE_NOT_PRESENT: Blending is enabled for attachment with format \ + VK_FORMAT_R32_UINT, which does not support it." + ); + assert!(BLEND + .pipeline_creation_diagnostics(&[], T::TRIANGLE_STRIP, &[]) + .is_empty()); + assert!(RESTART + .pipeline_creation_diagnostics(&[], T::TRIANGLE_LIST, &blendless) + .is_empty()); + let text = std::fs::read_to_string( + PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .join("../metal2vulkan-validation/profiles/moltenvk-m3.json"), + ) + .expect("moltenvk-m3"); + let mut desc = DeviceDescription::from_khronos_json(&text, None).expect("profile parses"); + for (version, has) in [(10401, false), (10402, true), (10403, false)] { + desc.driver_version = version; + assert_eq!(desc.driver_facts().contains(&BLEND), has, "{version}"); + } +} + /// A description leaves out of every format's linear tiling the features its driver reports from /// memory it has not initialized: on MoltenVK, measured or not, the color attachment, its /// blending, the blit destination and the depth/stencil attachment diff --git a/crates/metal2vulkan/src/device/tests/profile.rs b/crates/metal2vulkan/src/device/tests/profile.rs index cda3eb82e..107f4a9ba 100644 --- a/crates/metal2vulkan/src/device/tests/profile.rs +++ b/crates/metal2vulkan/src/device/tests/profile.rs @@ -495,6 +495,7 @@ fn fingerprints_distinguish_committed_profiles() { let translated = |stem: &str| { let mut d = profile(stem); (d.vendor_id, d.device_id, d.driver_version, d.device_type) = (0, 0, 0, None); + d.device_name.clear(); d.allocation = AllocationLimits::default(); d }; diff --git a/crates/metal2vulkan/src/error/mod.rs b/crates/metal2vulkan/src/error/mod.rs index 325cd6392..b0377a9f3 100644 --- a/crates/metal2vulkan/src/error/mod.rs +++ b/crates/metal2vulkan/src/error/mod.rs @@ -780,6 +780,16 @@ pub enum DriverDeviation { /// pipeline's synthesized geometry stages, which store the first vertex's at every vertex, /// and is refused on a device without `geometryShader`. MetalFirstVertexIndices, + /// The device runs a fragment function's quads whole, its helper invocations taking part in + /// every group operation, as Metal runs a fragment function's helper threads + /// (`VkProperty::MetalFullQuads`): the driver hands the fragment function to Metal, whose + /// simdgroup functions read, combine and count a quad's helpers wherever the primitive or the + /// target cuts the quad. Vulkan gives that only under `RequireFullQuadsKHR` + /// (`shaderQuadControl`). Where the profile takes it and lacks `shaderQuadControl`, a + /// fragment function whose group operations observe other lanes declares no such mode and + /// requires the property in place of the feature. Unmeasured, such a function needs the + /// feature. + MetalFullQuads, } /// A defect of a device's driver in a command the runtime records for itself, never in a @@ -910,6 +920,13 @@ pub enum RuntimeDriverDefect { /// that bakes samplers records in a `VkCommandBuffer` of its own there, as one whose pipeline /// is still being made does. ImmutableSamplersLostAfterCopies, + /// `vkGetDescriptorSetLayoutSupport` answers `VK_FALSE` for a descriptor set layout the driver + /// makes and runs: one of exactly `maxPerSetDescriptors` descriptors, which Vulkan guarantees + /// `VK_TRUE`, and every one past it, however far within the update-after-bind limits the + /// driver reports. Nothing is refused: the runtime makes such a layout there (a heap's set 1) + /// as the driver runs it, announced (`set-past-layout-support`), and Vulkan's validation layer + /// reports it (`VUID-vkCreateDescriptorSetLayout-support-09582`). + SetLayoutSupportUnderstated, } /// One device capability a refusal can name. diff --git a/crates/metal2vulkan/src/lower/simd/mod.rs b/crates/metal2vulkan/src/lower/simd/mod.rs index c548d39ba..43870fe57 100644 --- a/crates/metal2vulkan/src/lower/simd/mod.rs +++ b/crates/metal2vulkan/src/lower/simd/mod.rs @@ -251,6 +251,11 @@ pub struct SimdPlan { /// The fragment entry declares `RequireFullQuadsKHR`, so every quad starts with its four /// invocations and the helpers take part in the group operations, as Metal's do. pub full_quads: bool, + /// The fragment entry's quads run whole because the device runs a fragment function's helper + /// threads as Metal does though it lacks `shaderQuadControl` + /// (`DriverDeviation::MetalFullQuads`): it declares no mode, and the module requires + /// `VkProperty::MetalFullQuads` ([`full_quads`]). + pub metal_full_quads: bool, /// A fragment's `[[thread_index_in_quadgroup]]` on a profile without the fragment quad tier: /// the stage interface's `FragCoord` object the lane is derived from ([`select_param`]). `None` /// where the lane is the subgroup lane's low two bits. @@ -434,25 +439,35 @@ pub fn finish(cx: &mut SelectCx<'_>) -> Result<(), Error> { /// Complete a fragment function's plan once its tier is chosen: where its group operations /// read, combine, or count other lanes ([`SimdPlan::observes_lanes`]), the entry runs full quads -/// ([`SimdPlan::full_quads`]), and a profile without `shaderQuadControl` refuses it. Metal runs the -/// helpers of a quad the primitive or the target cuts, and they take part: a fill or shuffle reads -/// a helper's value, a reduction folds it in (measured on the M3 Max and the M4). Vulkan launches -/// and activates them for every group operation only under `RequireFullQuadsKHR`; without it a -/// helper may be absent or inactive, and no other form gives its value. After the tier, so a stage -/// without the classes is refused as before. +/// ([`SimdPlan::full_quads`]); a profile without `shaderQuadControl` whose device runs a fragment +/// function's helpers as Metal does (`DriverDeviation::MetalFullQuads`) runs them whole without +/// the mode ([`SimdPlan::metal_full_quads`]), and any other profile without the feature refuses +/// it. Metal runs the helpers of a quad the primitive or the target cuts, and they take part: a +/// fill or shuffle reads a helper's value, a reduction folds it in (measured on the M3 Max and the +/// M4). Vulkan launches and activates them for every group operation only under +/// `RequireFullQuadsKHR`; without it a helper may be absent or inactive, and no other form gives +/// its value but a driver that hands the function to Metal. After the tier, so a stage without +/// the classes is refused as before. pub fn full_quads(cx: &mut SelectCx<'_>) -> Result<(), Error> { if cx.stage != Stage::Fragment || !cx.families.simd.observes_lanes { return Ok(()); } - if !cx.profile.fields().subgroup.quad_control { - return Err(Unsupported::needs( - Feature::SubgroupOperations, - Capability::Feature(VkFeature::ShaderQuadControl), - ) - .into()); + if cx.profile.fields().subgroup.quad_control { + cx.families.simd.full_quads = true; + return Ok(()); } - cx.families.simd.full_quads = true; - Ok(()) + if cx + .profile + .takes_driver_deviation(crate::error::DriverDeviation::MetalFullQuads) + { + cx.families.simd.metal_full_quads = true; + return Ok(()); + } + Err(Unsupported::needs( + Feature::SubgroupOperations, + Capability::Feature(VkFeature::ShaderQuadControl), + ) + .into()) } /// Whether the profile's vertex stage groups vertices otherwise than Apple's GPUs with nothing to diff --git a/crates/metal2vulkan/src/pipeline/compile.rs b/crates/metal2vulkan/src/pipeline/compile.rs index 2f48054fa..d73daa995 100644 --- a/crates/metal2vulkan/src/pipeline/compile.rs +++ b/crates/metal2vulkan/src/pipeline/compile.rs @@ -2393,6 +2393,13 @@ fn compile_kept( .properties .insert(crate::device::requirements::VkProperty::MetalFragmentSimdgroups); } + // A fragment's quads run whole without `RequireFullQuadsKHR` because the device runs its + // helpers as Metal does. + if plan.families.simd.metal_full_quads { + requirements + .properties + .insert(crate::device::requirements::VkProperty::MetalFullQuads); + } // `float` denormals left to the device because it reads them as Metal does. if plan.families.arith.device_denormals { requirements diff --git a/crates/metal2vulkan/src/tests/engine_simd.rs b/crates/metal2vulkan/src/tests/engine_simd.rs index be8409fb0..a2d93283c 100644 --- a/crates/metal2vulkan/src/tests/engine_simd.rs +++ b/crates/metal2vulkan/src/tests/engine_simd.rs @@ -1626,3 +1626,80 @@ fn fragment_group_operations_run_full_quads() { "no profile refused a fragment function for quad control" ); } + +/// MoltenVK 1.4.2 drops `VK_KHR_shader_quad_control` (`shaderQuadControl`) on Apple's GPUs, where +/// it still hands the fragment function to Metal, whose helpers take part in every simdgroup +/// operation (`DriverDeviation::MetalFullQuads`). The committed `moltenvk-m3` description at +/// 1.4.2 without the feature and its extension (the device as it now reports itself) compiles +/// each fragment function whose group operations observe other lanes: it declares no +/// `RequireFullQuadsKHR` and no `QuadControlKHR`, requires `VkProperty::MetalFullQuads` and not +/// the feature, still reads every lane through the ballot of the live lanes, and passes L3. The +/// same description without the deviation refuses each, needing the feature. +#[test] +fn a_device_that_runs_metal_s_helpers_runs_full_quads_without_quad_control() { + use crate::error::{Capability, DriverDeviation, Unsupported}; + let Some(quads) = assemble("gsm2_quad_ops") else { + return; + }; + let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) + .join("../metal2vulkan-validation/profiles/moltenvk-m3.json"); + let text = std::fs::read_to_string(&path).expect("read the MoltenVK description"); + let mut desc = DeviceDescription::from_khronos_json(&text, None).expect("description"); + desc.driver_version = crate::device::driver_facts::moltenvk(1, 4, 2); + assert!(desc.features.remove(&VkFeature::ShaderQuadControl)); + assert!(desc.extensions.remove(&VkExtension::KhrShaderQuadControl)); + let device = |taken: bool| { + Device::with_deviation( + desc.clone(), + DevicePolicy::default(), + DriverDeviation::MetalFullQuads, + taken, + ) + .expect("device") + .profile() + .clone() + }; + let (metals, without) = (device(true), device(false)); + assert!(!metals.fields().subgroup.quad_control); + assert!(metals.takes_driver_deviation(DriverDeviation::MetalFullQuads)); + assert!(!without.takes_driver_deviation(DriverDeviation::MetalFullQuads)); + for entry in [ + "fragment_quad_fills", + "fragment_quad_fills_and_rotations", + "fragment_simd_fills", + "fragment_quad_scans", + ] { + let a = compile(&quads, entry, &metals).unwrap_or_else(|e| panic!("{entry}: {e}")); + assert!( + a.requirements + .properties + .contains(&VkProperty::MetalFullQuads), + "{entry}: the property" + ); + assert!( + !a.requirements + .features + .contains(&VkFeature::ShaderQuadControl), + "{entry}: no feature" + ); + let (_, words) = link_and_validate(&a, &metals).expect("valid"); + let text = spirv_dis(&words); + assert!( + !text.contains("RequireFullQuadsKHR") + && !text.contains("QuadControlKHR") + && !text.contains("OpGroupNonUniformQuadBroadcast") + && !text.contains("OpGroupNonUniformQuadSwap"), + "{entry}" + ); + let want = Unsupported::needs( + Feature::SubgroupOperations, + Capability::Feature(VkFeature::ShaderQuadControl), + ); + match compile(&quads, entry, &without) { + Err(Error::Unsupported(u)) => { + assert_eq!((u.feature, u.needs), (want.feature, want.needs), "{entry}") + } + other => panic!("{entry} without the deviation: {:?}", other.map(|_| ())), + } + } +} diff --git a/docs/API.md b/docs/API.md index fabd5fc1c..d26444487 100644 --- a/docs/API.md +++ b/docs/API.md @@ -199,10 +199,13 @@ MoltenVK's `device_id` is the macOS release and the Apple GPU family, so the M3 one under macOS 27 and a macOS release not measured is another identity), never on a claim of the description itself. A GPU that reports more than one `device_id` is read by the one it was measured under (`DeviceDescription::canonical_device_id`): the Radeon 780M of Hawk Point (`0x1900`) as -Phoenix's (`0x15bf`), at the releases measured there. These are `DriverDeviation`s (simdgroups that run in lockstep, Metal's own -`float` functions, sampler and canonical NaNs, color writes, ...), measured on MoltenVK 1.4.1 on -Apple's M3 Max and M4, with a few per-GPU facts measured elsewhere. A driver, -GPU or release that was not measured takes the conservative, exact route. A newer MoltenVK release +Phoenix's (`0x15bf`), at the releases measured there. A release measured on one GPU of a shared +`device_id` alone names that GPU by its `device_name`: MoltenVK 1.4.2 under macOS 27 was measured +on the M3 Max, so the M4 at 1.4.2 is no measured identity. These are `DriverDeviation`s (simdgroups +that run in lockstep, Metal's own `float` functions, sampler and canonical NaNs, color writes, +...), measured on MoltenVK 1.4.1 on Apple's M3 Max and M4 and on MoltenVK 1.4.2 on the M3 Max, +with a few per-GPU facts measured elsewhere. A driver, GPU or release that was not measured takes +the conservative, exact route. A newer MoltenVK release takes the measured facts and records `PrecisionNote::BeyondMeasuredDeviation`. Metal semantics the translation keeps on every device, beyond Vulkan's: Metal's 32-lane @@ -1417,10 +1420,11 @@ fast forms record, and each `PrecisionNote`'s rustdoc states its bound. - `metal2vulkan-degrade-gpu-times-from-host` (precision). `GpuTimesFromHost`: A command buffer's GPU times on a device told to answer them from the host (`DeviceOptions::gpu_times_from_host`, `RawDevice::gpu_times_from_host`), or whose driver's timestamps wait for every queue's - (`DriverFact::TimestampsWaitForEveryQueue`: MoltenVK 1.4.1 on Apple's GPUs), which writes no GPU - timestamps. Cost: its GPU start is its kernel end time (or its queue's latest GPU end before it) - and its GPU end the host time the runtime saw it complete: a window its work ran in, which holds - the submission's and the completion's latencies, not the GPU's own start and end. + (`DriverFact::TimestampsWaitForEveryQueue`: MoltenVK 1.4.1 on Apple's GPUs, 1.4.2 on the M3 + Max), which writes no GPU timestamps. Cost: its GPU start is its kernel end time (or its queue's + latest GPU end before it) and its GPU end the host time the runtime saw it complete: a window its + work ran in, which holds the submission's and the completion's latencies, not the GPU's own start + and end. - `metal2vulkan-degrade-device-rounded-resolve` (precision). `DeviceRoundedResolve`: A multisample color resolve averages through Vulkan's `AVERAGE` mode, which leaves the rounding of the average (and the sRGB encoding) to the device, on a device not measured to round as Metal does: under @@ -1803,6 +1807,14 @@ fast forms record, and each `PrecisionNote`'s rustdoc states its bound. device runs them as Metal does, but its driver leaves the vertex stage out of subgroupSupportedStages, so Vulkan's validation layer reports each shader module of the function (VUID-RuntimeSpirv-None-06343). +- `metal2vulkan-degrade-set-past-layout-support` (validity). `SetPastLayoutSupport`: A descriptor + set layout the device's driver refuses through `vkGetDescriptorSetLayoutSupport` though it makes + and runs it, a heap's set 1 past `maxPerSetDescriptors` + (`metal2vulkan::error::RuntimeDriverDefect::SetLayoutSupportUnderstated`, MoltenVK): the runtime + makes it there as the driver runs it. Cost: the device runs the set as Metal runs the argument + buffer it is encoded in, but its driver's vkGetDescriptorSetLayoutSupport refuses the layout, so + Vulkan's validation layer reports each such layout + (VUID-vkCreateDescriptorSetLayout-support-09582). - `metal2vulkan-degrade-released-command-state` (precision). `ReleasedCommandState`: An indirect command naming the ID of a pipeline state the program released is executed where the runtime cannot run what Metal runs. Cost: a command naming another ID than the state set on it runs @@ -1988,8 +2000,9 @@ fast forms record, and each `PrecisionNote`'s rustdoc states its bound. - `metal2vulkan-degrade-compressed-texel-decode` (precision). `CompressedTexelDecode`: A texture of a BC1 to BC5 format (`BC1_RGBA` to `BC5_RGSnorm`, the sRGB forms too) made on a device whose driver is not measured to decode their texels as Metal does (BC1 to BC3 - `DriverFact::ColorBlockDecodeIsMetals`: MoltenVK 1.4.1 on Apple's GPUs, RADV from Mesa 26.2.4 on - the 780M; BC4 and BC5 `DriverFact::ChannelBlockDecodeIsMetals`: MoltenVK 1.4.1 on Apple's GPUs). + `DriverFact::ColorBlockDecodeIsMetals`: MoltenVK 1.4.1 on Apple's GPUs and 1.4.2 on the M3 Max, + RADV from Mesa 26.2.4 on the 780M; BC4 and BC5 `DriverFact::ChannelBlockDecodeIsMetals`: MoltenVK + 1.4.1 on Apple's GPUs and 1.4.2 on the M3 Max). Cost: a read, sample or gather of its texels answers the device's decode of its blocks (an sRGB form's code through Metal's table), where Metal interpolates with 6-bit weights: NVIDIA's (615.71.09, the RTX 3090 and RTX 5080 Laptop GPU) answers a BC1 to BC3 channel up to 3/255 off diff --git a/docs/FAST-PATHS.md b/docs/FAST-PATHS.md index c3b64452e..0ec5f1e22 100644 --- a/docs/FAST-PATHS.md +++ b/docs/FAST-PATHS.md @@ -189,7 +189,7 @@ recorded here. textures made once and 3.4-7.1 ms with new ones each frame, where images over the rows took 3.0-6.1 and 4.6-8.6 ms. An ordinary buffer's packed rows avoid it. - **On MoltenVK, a texture over a buffer that renders or that blits write keeps a shadow.** MoltenVK - 1.4.1 reports a format's linear-tiling attachment and blit-destination features from + 1.4.1 and 1.4.2 report a format's linear-tiling attachment and blit-destination features from uninitialized memory, so no MoltenVK description states them (`DriverFact::LinearTilingFeaturesUninitialized`) and such a texture is a shadow (`shadowed-texture`). @@ -332,8 +332,8 @@ driver's. Each is open work. announced as `DeviceSampleLevel`. An extended-range texture's such sample takes Vulkan's level of detail computed in the shader on every device, with the same note. - **An anisotropic cube sample on a `y` face through MoltenVK's vertex and fragment stages under - macOS 27.** SPIRV-Cross's `spvGradientCube`, which MoltenVK 1.4.1 applies, writes a `+Y` or `-Y` - face's gradients as `(d_x, d_z, d_x)`, so Metal loses the `z` gradient. The module hands such a + macOS 27.** SPIRV-Cross's `spvGradientCube`, which MoltenVK 1.4.1 and 1.4.2 apply, writes a + `+Y` or `-Y` face's gradients as `(d_x, d_z, d_x)`, so Metal loses the `z` gradient. The module hands such a face Metal's length of the two tangents on both (`CubeGradientRoute::AppleProjected`): isotropic samples, and every sample on the `x` and `z` faces, are Metal's, but an anisotropic one on a `y` face filters along the face's diagonal, announced as `CubeGradientFootprint` diff --git a/docs/REFUSALS.md b/docs/REFUSALS.md index c502e9a2d..03a674c01 100644 --- a/docs/REFUSALS.md +++ b/docs/REFUSALS.md @@ -14,7 +14,7 @@ Columns: - `none`: no public API path: malformed or non-Metal input, Apple-private calls, or a cap no valid program of ordinary size meets; - `?`: not assessed yet. -Generated at `fc5330cbf`. +Generated at `67c5f4757`. ## Totals @@ -45,7 +45,7 @@ Generated at `fc5330cbf`. | `Recursion` | Recursion (one variant) | every device (not implemented) | 4: `crates/metal2vulkan-air/src/canon/mod.rs:1052`, `crates/metal2vulkan-air/src/canon/mod.rs:1062` (+2) | `rare`: recursion through visible functions | | `DynamicCall` | Indirect calls, function pointers, visible/intersection function tables (one variant) | every device (no Vulkan mechanism); every device (not implemented) | 9: `crates/metal2vulkan-air/src/canon/devirt.rs:1851`, `crates/metal2vulkan-air/src/canon/devirt.rs:447` (+7) | `rare`: function pointers and function tables | | `Linking` | Linkage signatures / stitching / dynamic libraries | every device (not implemented) | 3: `crates/metal2vulkan-air/src/canon/link.rs:249`, `crates/metal2vulkan-air/src/canon/mod.rs:1289` (+1) | `rare`: dynamic libraries and linked functions | -| `SimdWidth` | Simdgroup width 32 is not achievable for this usage, stage, and device | devices without VkProperty::MetalFragmentSimdgroups; devices without a capability the site computes (`width_needs(stage, st)`) | 2: `crates/metal2vulkan/src/device/subgroup.rs:377`, `crates/metal2vulkan/src/lower/simd/mod.rs:377` | `app`: simdgroup functions on a device whose subgroups cannot run 32 wide for the use | +| `SimdWidth` | Simdgroup width 32 is not achievable for this usage, stage, and device | devices without VkProperty::MetalFragmentSimdgroups; devices without a capability the site computes (`width_needs(stage, st)`) | 2: `crates/metal2vulkan/src/device/subgroup.rs:377`, `crates/metal2vulkan/src/lower/simd/mod.rs:382` | `app`: simdgroup functions on a device whose subgroups cannot run 32 wide for the use | | `LocalSize` | A local size beyond a device limit on this axis (`None` | every device (no Vulkan mechanism) | 1: `crates/metal2vulkan/src/bind/dispatch.rs:481` | `app`: a threadgroup size past a smaller device's limit | | `IrreducibleConvergent` | An irreducible region containing a convergent instruction | every device (no Vulkan mechanism) | 1: `crates/metal2vulkan/src/structurize/irreducible.rs:108` | `rare`: irreducible loops around barriers or simd operations | | `ComputeDerivativesWithSimd` | Compute derivatives in a flattened simd tier | every device (no Vulkan mechanism) | 1: `crates/metal2vulkan/src/lower/dispatch.rs:471` | `rare`: derivatives in a kernel | @@ -53,7 +53,7 @@ Generated at `fc5330cbf`. | `QuadOperations` | Quad operations in a stage without quad support | devices without VkLimit::MinSubgroupSize; devices without VkProperty::SubgroupQuadOperationsInAllStages | 2: `crates/metal2vulkan/src/device/subgroup.rs:371`, `crates/metal2vulkan/src/device/subgroup.rs:405` | `app`: quad shuffles in kernels on devices without quad operations there | | `SimdgroupMatrix` | Simdgroup matrix operations | every device (not implemented) | 1: `crates/metal2vulkan/src/lower/simd/matrix.rs:83` | `rare`: simdgroup matrix kernels | | `ArgumentBufferPointers` | Argument buffers holding buffer pointers (dynamic roots) | devices without buffer device addresses (`addressed_needs`) | 1: `crates/metal2vulkan/src/device/metal.rs:236` | `app`: argument buffers holding buffer pointers | -| `ArgumentBufferTextures` | Argument buffers holding textures or samplers (handle domain) | devices short of a device limit the site names; devices without a capability the site computes (`gaps`); devices without a capability the site computes (`missing`); devices without a capability the site computes (`needs`); every device (not implemented) | 16: `crates/metal2vulkan-runtime/src/families/features.rs:1621`, `crates/metal2vulkan-runtime/src/resource_ids.rs:1097` (+14) | `app`: argument buffers holding textures and samplers (bindless) | +| `ArgumentBufferTextures` | Argument buffers holding textures or samplers (handle domain) | devices short of a device limit the site names; devices without a capability the site computes (`gaps`); devices without a capability the site computes (`missing`); devices without a capability the site computes (`needs`); every device (not implemented) | 17: `crates/metal2vulkan-runtime/src/families/features.rs:1621`, `crates/metal2vulkan-runtime/src/pipeline/objects.rs:1036` (+15) | `app`: argument buffers holding textures and samplers (bindless) | | `ArgumentBufferObjects` | Argument-buffer members that are pipeline states, ICBs, function tables, or acceleration structures | every device (not implemented) | 5: `crates/metal2vulkan/src/lower/access/encode.rs:445`, `crates/metal2vulkan/src/lower/access/encode.rs:495` (+3) | `rare`: pipeline states and ICBs in argument buffers | | `DereferenceLoadedPointer` | Dereferencing a pointer loaded from memory or made from an integer | devices short of a Vulkan feature the site names; devices without buffer device addresses (`addressed_needs`); every device (no Vulkan mechanism) | 4: `crates/metal2vulkan/src/lower/access/dynamic.rs:407`, `crates/metal2vulkan/src/lower/access/local.rs:774` (+2) | `app`: pointers loaded from argument buffers | | `PointerToInteger` | Storing a pointer or converting it to an integer | - | via a helper: 1: `crates/metal2vulkan/src/lower/access/dynamic.rs:347` | `rare`: pointer to integer casts | @@ -93,7 +93,7 @@ Generated at `fc5330cbf`. | `Barycentrics` | Barycentric coordinates | devices without VkFeature::FragmentShaderBarycentric; devices without VkFeature::GeometryShader; devices without a capability the site computes (`needs`); drivers with a defect; every device (not implemented) | 5: `crates/metal2vulkan/src/device/metal.rs:263`, `crates/metal2vulkan/src/lower/stage_io/plan.rs:1876` (+3) | `rare`: barycentric coordinates | | `StencilExport` | Stencil export | devices without VkExtension::ExtShaderStencilExport; every device (not implemented) | 6: `crates/metal2vulkan-runtime/src/families/features.rs:1102`, `crates/metal2vulkan/src/bind/graphics.rs:2606` (+4) | `rare`: stencil from the shader | | `SampleRateShading` | Per-sample shading | devices without VkFeature::SampleRateShading; devices without a capability the site computes (`needs`); every device (not implemented) | 3: `crates/metal2vulkan/src/pipeline/link/graphics.rs:832`, `crates/metal2vulkan/src/pipeline/link/graphics.rs:834` (+1) | `rare`: per-sample shading | -| `PixelCoverageAtSampleRate` | The pixel's coverage (`[[sample_mask]]` read) in a fragment function that runs once per sample | drivers with a defect; every device (no Vulkan mechanism); every device (not implemented) | 3: `crates/metal2vulkan/src/lower/fragment/coverage.rs:291`, `crates/metal2vulkan/src/lower/simd/mod.rs:739` (+1) | `rare`: coverage read at sample rate | +| `PixelCoverageAtSampleRate` | The pixel's coverage (`[[sample_mask]]` read) in a fragment function that runs once per sample | drivers with a defect; every device (no Vulkan mechanism); every device (not implemented) | 3: `crates/metal2vulkan/src/lower/fragment/coverage.rs:291`, `crates/metal2vulkan/src/lower/simd/mod.rs:754` (+1) | `rare`: coverage read at sample rate | | `InterfaceComponents` | Too many interface components or locations | devices short of a device limit the site names; devices without VkLimit::MaxColorAttachments; devices without VkLimit::MaxVertexInputAttributes | 4: `crates/metal2vulkan/src/pipeline/compile/color_group.rs:202`, `crates/metal2vulkan/src/pipeline/link/graphics.rs:301` (+2) | `rare`: too many varyings or attachments for a device | | `UnmatchedVarying` | A fragment input without a vertex producer (a Metal link error) | every device (no Vulkan mechanism) | 3: `crates/metal2vulkan/src/pipeline/link/varyings.rs:318`, `crates/metal2vulkan/src/pipeline/link/varyings.rs:537` (+1) | `none`: a Metal link error | | `KernelStageIn` | Kernel `[[stage_in]]` | every device (not implemented) | 3: `crates/metal2vulkan-runtime/src/indirect_execute.rs:350`, `crates/metal2vulkan/src/bind/dispatch.rs:877` (+1) | `rare`: kernel stage-in combinations Metal leaves unestablished | @@ -110,7 +110,7 @@ Generated at `fc5330cbf`. | `Attribute` | An LLVM attribute kind that changes the calling ABI and that AIR does not use (`inalloca`, `preallocated`, `byref`, `nest`, the `swift*` kinds) | - | via a helper: 2: `crates/metal2vulkan-air/src/bitcode/attrs.rs:493`, `crates/metal2vulkan/src/error/mod.rs:256` | `none`: LLVM ABI attributes AIR does not use | | `BitcodeRecord` | A bitcode record LLVM defines in `block` that the typed model does not cover and that has no more specific variant (legacy spellings predating... | - | via a helper: 7: `crates/metal2vulkan-air/src/bitcode/attrs.rs:337`, `crates/metal2vulkan-air/src/bitcode/function.rs:572` (+5) | `none`: bitcode records AIR does not emit | | `SyncScope` | An atomic access or fence in a synchronization scope other than LLVM's built-in `singlethread` and system scopes | - | via a helper: 2: `crates/metal2vulkan-air/src/bitcode/function.rs:1255`, `crates/metal2vulkan/src/error/mod.rs:258` | `none`: synchronization scopes AIR does not use | -| `SubgroupOperations` | Simdgroup operations of a class the stage's subgroups do not support (the stage is not in `subgroupSupportedStages`, or an operation class is... | devices without VkFeature::ShaderQuadControl; devices without VkFeature::ShaderSubgroupExtendedTypes; devices without VkProperty::SubgroupStage | 4: `crates/metal2vulkan-runtime/src/families/features.rs:1686`, `crates/metal2vulkan/src/lower/simd/mod.rs:402` (+2) | `app`: simdgroup functions in a stage a device's subgroups do not support | +| `SubgroupOperations` | Simdgroup operations of a class the stage's subgroups do not support (the stage is not in `subgroupSupportedStages`, or an operation class is... | devices without VkFeature::ShaderQuadControl; devices without VkFeature::ShaderSubgroupExtendedTypes; devices without VkProperty::SubgroupStage | 4: `crates/metal2vulkan-runtime/src/families/features.rs:1686`, `crates/metal2vulkan/src/lower/simd/mod.rs:407` (+2) | `app`: simdgroup functions in a stage a device's subgroups do not support | | `DirectCall` | A call to a defined function the inliner cannot take | every device (not implemented) | 1: `crates/metal2vulkan-air/src/canon/mod.rs:1319` | `rare`: variadic or byval calls the inliner cannot take | | `WideSwitchLiteral` | A switch case literal wider than 32 bits | every device (not implemented) | 1: `crates/metal2vulkan/src/structurize/emit.rs:207` | `rare`: 64-bit switch literals | | `Lowering` | An instruction, intrinsic, or interface element of a lowering family whose lowering has not landed yet (each family narrows its refusals as it lands) | devices short of a device limit the site names; devices without VkFeature::ShaderDemoteToHelperInvocation; every device (not implemented) | 35: `crates/metal2vulkan/src/bind/plan/resources.rs:762`, `crates/metal2vulkan/src/lower/access/handle.rs:1062` (+33) | `system`: the catch-all of lowering families not landed: any shader can meet one | @@ -311,7 +311,7 @@ Each refusal's sites, with the function that builds it. - `feature::Recursion`: `crates/metal2vulkan-air/src/canon/mod.rs:1052 (recursion)`; `crates/metal2vulkan-air/src/canon/mod.rs:1062 (recursion)`; `crates/metal2vulkan-air/src/canon/recursion.rs:2143 (dynamic_alloca)`; `crates/metal2vulkan-air/src/canon/static_init.rs:399 (run)` - `feature::DynamicCall`: `crates/metal2vulkan-air/src/canon/devirt.rs:1851 (site)`; `crates/metal2vulkan-air/src/canon/devirt.rs:447 (record)`; `crates/metal2vulkan-air/src/canon/devirt.rs:569 (unfolded_decl)`; `crates/metal2vulkan-air/src/canon/mod.rs:1332 (post_check)`; `crates/metal2vulkan-air/src/canon/prune.rs:128 (prune_in)`; `crates/metal2vulkan/src/bind/heap.rs:1731 (directory_bytes)`; `crates/metal2vulkan/src/bind/heap.rs:1761 (directory_bytes)`; `crates/metal2vulkan/src/bind/heap.rs:1774 (directory_bytes)`; `crates/metal2vulkan/src/lower/select.rs:892 (route_air)` - `feature::Linking`: `crates/metal2vulkan-air/src/canon/link.rs:249 (not_implemented)`; `crates/metal2vulkan-air/src/canon/mod.rs:1289 (post_check)`; `crates/metal2vulkan-air/src/canon/mod.rs:426 (specialize_dynamic)` -- `feature::SimdWidth`: `crates/metal2vulkan/src/device/subgroup.rs:377 (subgroup_tier)`; `crates/metal2vulkan/src/lower/simd/mod.rs:377 (finish)` +- `feature::SimdWidth`: `crates/metal2vulkan/src/device/subgroup.rs:377 (subgroup_tier)`; `crates/metal2vulkan/src/lower/simd/mod.rs:382 (finish)` - `feature::LocalSize`: `crates/metal2vulkan/src/bind/dispatch.rs:481 (regions)` - `feature::IrreducibleConvergent`: `crates/metal2vulkan/src/structurize/irreducible.rs:108 (refuse_tangled)` - `feature::ComputeDerivativesWithSimd`: `crates/metal2vulkan/src/lower/dispatch.rs:471 (plan_kernel)` @@ -319,7 +319,7 @@ Each refusal's sites, with the function that builds it. - `feature::QuadOperations`: `crates/metal2vulkan/src/device/subgroup.rs:371 (subgroup_tier)`; `crates/metal2vulkan/src/device/subgroup.rs:405 (subgroup_tier)` - `feature::SimdgroupMatrix`: `crates/metal2vulkan/src/lower/simd/matrix.rs:83 (not_implemented)` - `feature::ArgumentBufferPointers`: `crates/metal2vulkan/src/device/metal.rs:236 (unsupported_features)` -- `feature::ArgumentBufferTextures`: `crates/metal2vulkan-runtime/src/families/features.rs:1621 (tier2)`; `crates/metal2vulkan-runtime/src/resource_ids.rs:1097 (check_capacity)`; `crates/metal2vulkan/src/bind/heap.rs:1325 (array)`; `crates/metal2vulkan/src/bind/heap.rs:415 (member_view)`; `crates/metal2vulkan/src/bind/heap.rs:423 (member_view)`; `crates/metal2vulkan/src/bind/heap.rs:467 (member_view)`; `crates/metal2vulkan/src/bind/heap.rs:472 (member_view)`; `crates/metal2vulkan/src/bind/heap.rs:485 (member_view)`; `crates/metal2vulkan/src/lower/access/handle.rs:708 (select)`; `crates/metal2vulkan/src/lower/sampler/select.rs:2362 (select_one)`; `crates/metal2vulkan/src/lower/sampler/select.rs:308 (select_sampling)`; `crates/metal2vulkan/src/lower/sampler/select.rs:469 (select_heap_sampling)`; `crates/metal2vulkan/src/lower/texture/atomic.rs:140 (select)`; `crates/metal2vulkan/src/lower/texture/slot.rs:465 (declare_heap)`; `crates/metal2vulkan/src/lower/texture/slot.rs:534 (declare_heap)`; `crates/metal2vulkan/src/pipeline/link.rs:977 (heap_set)` +- `feature::ArgumentBufferTextures`: `crates/metal2vulkan-runtime/src/families/features.rs:1621 (tier2)`; `crates/metal2vulkan-runtime/src/pipeline/objects.rs:1036 (create_set_layout)`; `crates/metal2vulkan-runtime/src/resource_ids.rs:1097 (check_capacity)`; `crates/metal2vulkan/src/bind/heap.rs:1325 (array)`; `crates/metal2vulkan/src/bind/heap.rs:415 (member_view)`; `crates/metal2vulkan/src/bind/heap.rs:423 (member_view)`; `crates/metal2vulkan/src/bind/heap.rs:467 (member_view)`; `crates/metal2vulkan/src/bind/heap.rs:472 (member_view)`; `crates/metal2vulkan/src/bind/heap.rs:485 (member_view)`; `crates/metal2vulkan/src/lower/access/handle.rs:708 (select)`; `crates/metal2vulkan/src/lower/sampler/select.rs:2362 (select_one)`; `crates/metal2vulkan/src/lower/sampler/select.rs:308 (select_sampling)`; `crates/metal2vulkan/src/lower/sampler/select.rs:469 (select_heap_sampling)`; `crates/metal2vulkan/src/lower/texture/atomic.rs:140 (select)`; `crates/metal2vulkan/src/lower/texture/slot.rs:465 (declare_heap)`; `crates/metal2vulkan/src/lower/texture/slot.rs:534 (declare_heap)`; `crates/metal2vulkan/src/pipeline/link.rs:977 (heap_set)` - `feature::ArgumentBufferObjects`: `crates/metal2vulkan/src/lower/access/encode.rs:445 (select_command)`; `crates/metal2vulkan/src/lower/access/encode.rs:495 (select_command)`; `crates/metal2vulkan/src/lower/access/encode.rs:623 (select_command)`; `crates/metal2vulkan/src/memory/provenance.rs:2185 (classify)`; `crates/metal2vulkan/src/memory/provenance.rs:2547 (access)` - `feature::DereferenceLoadedPointer`: `crates/metal2vulkan/src/lower/access/dynamic.rs:407 (plan_misses)`; `crates/metal2vulkan/src/lower/access/local.rs:774 (access_ptr)`; `crates/metal2vulkan/src/lower/access/local.rs:796 (threadgroup_constant_refusal)`; `crates/metal2vulkan/src/memory/plan.rs:593 (analyze)` - `feature::PointerToInteger`: `crates/metal2vulkan/src/lower/access/dynamic.rs:347 (require_addresses)` @@ -359,7 +359,7 @@ Each refusal's sites, with the function that builds it. - `feature::Barycentrics`: `crates/metal2vulkan/src/device/metal.rs:263 (unsupported_features)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:1876 (input_builtin)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:742 (param)`; `crates/metal2vulkan/src/pipeline/link/geometry.rs:148 (not_implemented)`; `crates/metal2vulkan/src/pipeline/link/geometry.rs:170 (refused)` - `feature::StencilExport`: `crates/metal2vulkan-runtime/src/families/features.rs:1102 (state)`; `crates/metal2vulkan/src/bind/graphics.rs:2606 (shadow_stencil_words)`; `crates/metal2vulkan/src/lower/fragment/stencil.rs:157 (device_form)`; `crates/metal2vulkan/src/lower/fragment/stencil.rs:168 (not_implemented)`; `crates/metal2vulkan/src/pipeline/link/stencil.rs:55 (shadow_stencil)`; `crates/metal2vulkan/src/pipeline/link/stencil.rs:73 (shadow_stencil)` - `feature::SampleRateShading`: `crates/metal2vulkan/src/pipeline/link/graphics.rs:832 (sample_invocations)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:834 (sample_invocations)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:916 (sample_invocations)` -- `feature::PixelCoverageAtSampleRate`: `crates/metal2vulkan/src/lower/fragment/coverage.rs:291 (finish)`; `crates/metal2vulkan/src/lower/simd/mod.rs:739 (select_param)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:867 (sample_invocations)` +- `feature::PixelCoverageAtSampleRate`: `crates/metal2vulkan/src/lower/fragment/coverage.rs:291 (finish)`; `crates/metal2vulkan/src/lower/simd/mod.rs:754 (select_param)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:867 (sample_invocations)` - `feature::InterfaceComponents`: `crates/metal2vulkan/src/pipeline/compile/color_group.rs:202 (refusal)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:301 (graphics_state)`; `crates/metal2vulkan/src/pipeline/link/varyings.rs:409 (assign)`; `crates/metal2vulkan/src/pipeline/link/varyings.rs:90 (limit_error)` - `feature::UnmatchedVarying`: `crates/metal2vulkan/src/pipeline/link/varyings.rs:318 (mesh_fragment)`; `crates/metal2vulkan/src/pipeline/link/varyings.rs:537 (varyings)`; `crates/metal2vulkan/src/pipeline/link/varyings.rs:548 (varyings)` - `feature::KernelStageIn`: `crates/metal2vulkan-runtime/src/indirect_execute.rs:350 (record)`; `crates/metal2vulkan/src/bind/dispatch.rs:877 (instantiate)`; `crates/metal2vulkan/src/lower/stage_io/stage_in.rs:133 (select)` @@ -376,10 +376,10 @@ Each refusal's sites, with the function that builds it. - `feature::Attribute`: `crates/metal2vulkan-air/src/bitcode/attrs.rs:493 (known)`; `crates/metal2vulkan/src/error/mod.rs:256 (from)` - `feature::BitcodeRecord`: `crates/metal2vulkan-air/src/bitcode/attrs.rs:337 (decode_lists)`; `crates/metal2vulkan-air/src/bitcode/function.rs:572 (symtab)`; `crates/metal2vulkan-air/src/bitcode/metadata.rs:130 (decode)`; `crates/metal2vulkan-air/src/bitcode/metadata.rs:157 (decode)`; `crates/metal2vulkan-air/src/bitcode/module.rs:727 (check_bodies)`; `crates/metal2vulkan-air/src/bitcode/module.rs:872 (symtab)`; `crates/metal2vulkan/src/error/mod.rs:257 (from)` - `feature::SyncScope`: `crates/metal2vulkan-air/src/bitcode/function.rs:1255 (atomic)`; `crates/metal2vulkan/src/error/mod.rs:258 (from)` -- `feature::SubgroupOperations`: `crates/metal2vulkan-runtime/src/families/features.rs:1686 (simd)`; `crates/metal2vulkan/src/lower/simd/mod.rs:402 (finish)`; `crates/metal2vulkan/src/lower/simd/mod.rs:448 (full_quads)`; `crates/metal2vulkan/src/lower/simd/mod.rs:975 (select_group)` +- `feature::SubgroupOperations`: `crates/metal2vulkan-runtime/src/families/features.rs:1686 (simd)`; `crates/metal2vulkan/src/lower/simd/mod.rs:407 (finish)`; `crates/metal2vulkan/src/lower/simd/mod.rs:466 (full_quads)`; `crates/metal2vulkan/src/lower/simd/mod.rs:990 (select_group)` - `feature::DirectCall`: `crates/metal2vulkan-air/src/canon/mod.rs:1319 (post_check)` - `feature::WideSwitchLiteral`: `crates/metal2vulkan/src/structurize/emit.rs:207 (check_tree)` -- `feature::Lowering`: `crates/metal2vulkan/src/bind/plan/resources.rs:762 (level_views)`; `crates/metal2vulkan/src/lower/access/handle.rs:1062 (texture_target)`; `crates/metal2vulkan/src/lower/access/handle.rs:1073 (sampler_target)`; `crates/metal2vulkan/src/lower/access/handle.rs:318 (domain_kind)`; `crates/metal2vulkan/src/lower/access/imageblock.rs:175 (operand)`; `crates/metal2vulkan/src/lower/access/mod.rs:571 (not_lowered)`; `crates/metal2vulkan/src/lower/access/pulled.rs:76 (share)`; `crates/metal2vulkan/src/lower/arith/legal.rs:53 (not_lowered)`; `crates/metal2vulkan/src/lower/dispatch.rs:113 (not_lowered)`; `crates/metal2vulkan/src/lower/fragment/discard.rs:144 (not_lowered)`; `crates/metal2vulkan/src/lower/fragment/discard.rs:653 (plan)`; `crates/metal2vulkan/src/lower/fragment/mod.rs:123 (not_lowered)`; `crates/metal2vulkan/src/lower/fragment/snapshot.rs:168 (finish)`; `crates/metal2vulkan/src/lower/mesh/mod.rs:147 (not_lowered)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs:126 (not_lowered)`; `crates/metal2vulkan/src/lower/sampler/mod.rs:212 (refuse)`; `crates/metal2vulkan/src/lower/sampler/select.rs:30 (refuse)`; `crates/metal2vulkan/src/lower/select.rs:829 (not_lowered)`; `crates/metal2vulkan/src/lower/select.rs:918 (route_air)`; `crates/metal2vulkan/src/lower/simd/mod.rs:136 (not_lowered)`; `crates/metal2vulkan/src/lower/simd/mod.rs:732 (select_param)`; `crates/metal2vulkan/src/lower/simd/workgroup.rs:353 (check)`; `crates/metal2vulkan/src/lower/stage_io/fetch.rs:96 (not_lowered)`; `crates/metal2vulkan/src/lower/stage_io/mod.rs:177 (not_lowered)`; `crates/metal2vulkan/src/lower/sync/barrier.rs:72 (not_lowered)`; `crates/metal2vulkan/src/lower/sync/memory_model.rs:269 (not_implemented)`; `crates/metal2vulkan/src/lower/sync/memory_model.rs:310 (select)`; `crates/metal2vulkan/src/lower/tessellation/mod.rs:146 (not_lowered)`; `crates/metal2vulkan/src/lower/texture/mod.rs:180 (refuse)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3665 (select_write)`; `crates/metal2vulkan/src/memory/alloca.rs:54 (not_lowered)`; `crates/metal2vulkan/src/memory/leaf.rs:183 (not_lowered)`; `crates/metal2vulkan/src/memory/plan.rs:490 (not_lowered)`; `crates/metal2vulkan/src/memory/provenance.rs:665 (not_lowered)`; `crates/metal2vulkan/src/pipeline/link/tessellation/mod.rs:96 (patch_fetch_projection)` +- `feature::Lowering`: `crates/metal2vulkan/src/bind/plan/resources.rs:762 (level_views)`; `crates/metal2vulkan/src/lower/access/handle.rs:1062 (texture_target)`; `crates/metal2vulkan/src/lower/access/handle.rs:1073 (sampler_target)`; `crates/metal2vulkan/src/lower/access/handle.rs:318 (domain_kind)`; `crates/metal2vulkan/src/lower/access/imageblock.rs:175 (operand)`; `crates/metal2vulkan/src/lower/access/mod.rs:571 (not_lowered)`; `crates/metal2vulkan/src/lower/access/pulled.rs:76 (share)`; `crates/metal2vulkan/src/lower/arith/legal.rs:53 (not_lowered)`; `crates/metal2vulkan/src/lower/dispatch.rs:113 (not_lowered)`; `crates/metal2vulkan/src/lower/fragment/discard.rs:144 (not_lowered)`; `crates/metal2vulkan/src/lower/fragment/discard.rs:653 (plan)`; `crates/metal2vulkan/src/lower/fragment/mod.rs:123 (not_lowered)`; `crates/metal2vulkan/src/lower/fragment/snapshot.rs:168 (finish)`; `crates/metal2vulkan/src/lower/mesh/mod.rs:147 (not_lowered)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs:126 (not_lowered)`; `crates/metal2vulkan/src/lower/sampler/mod.rs:212 (refuse)`; `crates/metal2vulkan/src/lower/sampler/select.rs:30 (refuse)`; `crates/metal2vulkan/src/lower/select.rs:829 (not_lowered)`; `crates/metal2vulkan/src/lower/select.rs:918 (route_air)`; `crates/metal2vulkan/src/lower/simd/mod.rs:136 (not_lowered)`; `crates/metal2vulkan/src/lower/simd/mod.rs:747 (select_param)`; `crates/metal2vulkan/src/lower/simd/workgroup.rs:353 (check)`; `crates/metal2vulkan/src/lower/stage_io/fetch.rs:96 (not_lowered)`; `crates/metal2vulkan/src/lower/stage_io/mod.rs:177 (not_lowered)`; `crates/metal2vulkan/src/lower/sync/barrier.rs:72 (not_lowered)`; `crates/metal2vulkan/src/lower/sync/memory_model.rs:269 (not_implemented)`; `crates/metal2vulkan/src/lower/sync/memory_model.rs:310 (select)`; `crates/metal2vulkan/src/lower/tessellation/mod.rs:146 (not_lowered)`; `crates/metal2vulkan/src/lower/texture/mod.rs:180 (refuse)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3665 (select_write)`; `crates/metal2vulkan/src/memory/alloca.rs:54 (not_lowered)`; `crates/metal2vulkan/src/memory/leaf.rs:183 (not_lowered)`; `crates/metal2vulkan/src/memory/plan.rs:490 (not_lowered)`; `crates/metal2vulkan/src/memory/provenance.rs:665 (not_lowered)`; `crates/metal2vulkan/src/pipeline/link/tessellation/mod.rs:96 (patch_fetch_projection)` - `feature::SamplerAddressMode`: `crates/metal2vulkan/src/lower/sampler/constexpr.rs:176`; `crates/metal2vulkan/src/metal/sampler.rs:251 (check_sampler)` - `feature::AlphaToOne`: `crates/metal2vulkan/src/pipeline/link/graphics.rs:282 (graphics_state)` - `feature::StageStoresAndAtomics`: `crates/metal2vulkan/src/lower/access/tile_memory.rs:72 (written)`