diff --git a/crates/metal2vulkan/examples/api_preview.rs b/crates/metal2vulkan/examples/api_preview.rs index 80c9967cd..d60708149 100644 --- a/crates/metal2vulkan/examples/api_preview.rs +++ b/crates/metal2vulkan/examples/api_preview.rs @@ -75,7 +75,7 @@ fn committed_device(stem: &str) -> Result { "crates/metal2vulkan-validation/profiles/{stem}.json" )))?; let description = DeviceDescription::from_khronos_json(&json, None)?; - let device = Device::new(description, DevicePolicy::default())?; + let device = Device::from_queries(description, DevicePolicy::default())?; Ok(device) } diff --git a/crates/metal2vulkan/src/ash_interop/tests.rs b/crates/metal2vulkan/src/ash_interop/tests.rs index bb13122e5..fae955b0f 100644 --- a/crates/metal2vulkan/src/ash_interop/tests.rs +++ b/crates/metal2vulkan/src/ash_interop/tests.rs @@ -1169,7 +1169,7 @@ fn a_queried_description_derives_a_device() { dev.v11_props.subgroup_supported_stages = avk::ShaderStageFlags::ALL; dev.v11_props.subgroup_supported_operations = avk::SubgroupFeatureFlags::from_raw(0xff); let desc = dev.query().unwrap(); - Device::new(desc, DevicePolicy::default()).expect("queried description derives"); + Device::from_queries(desc, DevicePolicy::default()).expect("queried description derives"); } #[test] diff --git a/crates/metal2vulkan/src/bind/check_draw/tests.rs b/crates/metal2vulkan/src/bind/check_draw/tests.rs index dcf2749f8..d31114dcb 100644 --- a/crates/metal2vulkan/src/bind/check_draw/tests.rs +++ b/crates/metal2vulkan/src/bind/check_draw/tests.rs @@ -17,7 +17,7 @@ fn the_modules_are_valid_on_every_committed_device() { } let text = std::fs::read_to_string(&path).expect("read"); let desc = DeviceDescription::from_khronos_json(&text, None).expect("description"); - let device = Device::new(desc, DevicePolicy::default()).expect("device"); + let device = Device::from_queries(desc, DevicePolicy::default()).expect("device"); let profile = device.profile(); assert_valid(merge_vertex_typed_module().expect("vertex"), profile); assert_valid(fragment_typed_module().expect("fragment"), profile); diff --git a/crates/metal2vulkan/src/bind/color_resolve/tests.rs b/crates/metal2vulkan/src/bind/color_resolve/tests.rs index e84c238e2..abf1b8957 100644 --- a/crates/metal2vulkan/src/bind/color_resolve/tests.rs +++ b/crates/metal2vulkan/src/bind/color_resolve/tests.rs @@ -171,7 +171,7 @@ fn the_modules_come_numbered_and_refuse_another_count_or_planes() { .join("../metal2vulkan-validation/profiles/lavapipe.json"); let text = std::fs::read_to_string(&path).expect("read"); let desc = DeviceDescription::from_khronos_json(&text, None).expect("description"); - let device = Device::new(desc, DevicePolicy::default()).expect("device"); + let device = Device::from_queries(desc, DevicePolicy::default()).expect("device"); let format = representatives()[0]; for (format, source) in cases(format) { let modules = diff --git a/crates/metal2vulkan/src/bind/depth_stencil_copy/tests.rs b/crates/metal2vulkan/src/bind/depth_stencil_copy/tests.rs index a5cb2c1b8..1a6c4415d 100644 --- a/crates/metal2vulkan/src/bind/depth_stencil_copy/tests.rs +++ b/crates/metal2vulkan/src/bind/depth_stencil_copy/tests.rs @@ -130,7 +130,7 @@ fn committed_devices() -> Vec<(String, Device)> { .unwrap_or_default(); let text = std::fs::read_to_string(&path).expect("read"); let desc = DeviceDescription::from_khronos_json(&text, None).expect("description"); - let device = Device::new(desc, DevicePolicy::default()).expect("device"); + let device = Device::from_queries(desc, DevicePolicy::default()).expect("device"); out.push((stem, device)); } out.sort_by(|a, b| a.0.cmp(&b.0)); diff --git a/crates/metal2vulkan/src/bind/depth_stencil_resolve/tests.rs b/crates/metal2vulkan/src/bind/depth_stencil_resolve/tests.rs index 4d361c663..282a79c8b 100644 --- a/crates/metal2vulkan/src/bind/depth_stencil_resolve/tests.rs +++ b/crates/metal2vulkan/src/bind/depth_stencil_resolve/tests.rs @@ -79,7 +79,7 @@ fn the_modules_come_numbered_and_refuse_another_count() { .join("../metal2vulkan-validation/profiles/lavapipe.json"); let text = std::fs::read_to_string(&path).expect("read"); let desc = DeviceDescription::from_khronos_json(&text, None).expect("description"); - let device = Device::new(desc, DevicePolicy::default()).expect("device"); + let device = Device::from_queries(desc, DevicePolicy::default()).expect("device"); for draw in every_draw(4) { let modules = depth_stencil_resolve_modules(&device, draw, Feature::Format); match modules { diff --git a/crates/metal2vulkan/src/bind/neutral/tests.rs b/crates/metal2vulkan/src/bind/neutral/tests.rs index 6d181886c..ebe7eed6f 100644 --- a/crates/metal2vulkan/src/bind/neutral/tests.rs +++ b/crates/metal2vulkan/src/bind/neutral/tests.rs @@ -36,7 +36,8 @@ fn committed_devices() -> Vec<(String, Device)> { let stem = p.file_stem().unwrap().to_string_lossy().into_owned(); let text = std::fs::read_to_string(&p).expect("profile is readable"); let desc = DeviceDescription::from_khronos_json(&text, None).expect("profile parses"); - let device = Device::new(desc, DevicePolicy::default()).expect("device derives"); + let device = + Device::from_queries(desc, DevicePolicy::default()).expect("device derives"); (stem, device) }) .collect(); diff --git a/crates/metal2vulkan/src/bind/replay/draws/tests.rs b/crates/metal2vulkan/src/bind/replay/draws/tests.rs index e3a5e81cd..8f4b6ec2b 100644 --- a/crates/metal2vulkan/src/bind/replay/draws/tests.rs +++ b/crates/metal2vulkan/src/bind/replay/draws/tests.rs @@ -53,7 +53,7 @@ fn devices() -> Vec<(String, Device)> { let desc = DeviceDescription::from_khronos_json(&text, None).expect("description"); ( stem, - Device::new(desc, DevicePolicy::default()).expect("device"), + Device::from_queries(desc, DevicePolicy::default()).expect("device"), ) }) .collect(); diff --git a/crates/metal2vulkan/src/bind/replay/tests.rs b/crates/metal2vulkan/src/bind/replay/tests.rs index 25334e847..e798fa4ef 100644 --- a/crates/metal2vulkan/src/bind/replay/tests.rs +++ b/crates/metal2vulkan/src/bind/replay/tests.rs @@ -57,7 +57,7 @@ fn devices() -> Vec<(String, Device)> { .into_owned(); let text = std::fs::read_to_string(&path).expect("profile"); let desc = DeviceDescription::from_khronos_json(&text, None).expect("description"); - let dev = Device::new(desc, DevicePolicy::default()).expect("device"); + let dev = Device::from_queries(desc, DevicePolicy::default()).expect("device"); (stem, dev) }) .collect(); diff --git a/crates/metal2vulkan/src/bind/sample_interleave/tests.rs b/crates/metal2vulkan/src/bind/sample_interleave/tests.rs index eb500c2d5..9e6c02128 100644 --- a/crates/metal2vulkan/src/bind/sample_interleave/tests.rs +++ b/crates/metal2vulkan/src/bind/sample_interleave/tests.rs @@ -84,7 +84,7 @@ fn committed_devices() -> Vec<(String, Device)> { .unwrap_or_default(); let text = std::fs::read_to_string(&path).expect("read"); let desc = DeviceDescription::from_khronos_json(&text, None).expect("description"); - let device = Device::new(desc, DevicePolicy::default()).expect("device"); + let device = Device::from_queries(desc, DevicePolicy::default()).expect("device"); out.push((stem, device)); } out.sort_by(|a, b| a.0.cmp(&b.0)); diff --git a/crates/metal2vulkan/src/bind/sample_planes/tests.rs b/crates/metal2vulkan/src/bind/sample_planes/tests.rs index 506a4de22..fb2e9809c 100644 --- a/crates/metal2vulkan/src/bind/sample_planes/tests.rs +++ b/crates/metal2vulkan/src/bind/sample_planes/tests.rs @@ -106,7 +106,7 @@ fn committed_devices() -> Vec<(String, Device)> { .unwrap_or_default(); let text = std::fs::read_to_string(&path).expect("read"); let desc = DeviceDescription::from_khronos_json(&text, None).expect("description"); - let device = Device::new(desc, DevicePolicy::default()).expect("device"); + let device = Device::from_queries(desc, DevicePolicy::default()).expect("device"); out.push((stem, device)); } out.sort_by(|a, b| a.0.cmp(&b.0)); diff --git a/crates/metal2vulkan/src/cache/tests.rs b/crates/metal2vulkan/src/cache/tests.rs index 56b36fdea..27992d778 100644 --- a/crates/metal2vulkan/src/cache/tests.rs +++ b/crates/metal2vulkan/src/cache/tests.rs @@ -44,7 +44,7 @@ fn device(stem: &str) -> Device { .join(format!("{stem}.json")); let text = std::fs::read_to_string(&path).expect("profile"); let desc = DeviceDescription::from_khronos_json(&text, None).expect("description"); - Device::new(desc, DevicePolicy::default()).expect("device") + Device::from_queries(desc, DevicePolicy::default()).expect("device") } /// `store_const` compiled on `dev`, with its compute pipeline. diff --git a/crates/metal2vulkan/src/device/derive.rs b/crates/metal2vulkan/src/device/derive.rs index 669ad71f3..57fe5fe97 100644 --- a/crates/metal2vulkan/src/device/derive.rs +++ b/crates/metal2vulkan/src/device/derive.rs @@ -1,6 +1,7 @@ -//! `Device::new`: the only producer of a `DeviceProfile`. +//! `Device::from_queries`: the only producer of a `DeviceProfile`. //! -//! The profile is a pure function of the description and the policy. Memory's A/F split is the +//! The profile is a pure function of the description's Vulkan queries and the policy: no driver or +//! GPU identity decides anything. Memory's A/F split is the //! only field that selects a pointer model; every other field selects leaf encodings or feeds the //! requirement check. @@ -8,15 +9,15 @@ use std::collections::BTreeSet; use std::sync::Arc; use crate::device::description::{ - AllocationLimits, DeviceDescription, GeneratedCommandsProperties, APPLE_VENDOR_ID, + AllocationLimits, DeviceDescription, GeneratedCommandsProperties, }; use crate::device::function_storage; use crate::device::metal::MetalDeviceProperties; use crate::device::policy::{ContainmentPolicy, DevicePolicy}; use crate::device::profile::{ BufferAccess, Containment, CubeGradientRoute, CubeGradients, DescriptorCaps, DeviceProfile, - DriverWorkaround, EnabledCaps, FloatFunctions, FormatTable, FragmentCaps, GuestIsolation, - HandleDomain, ImageCaps, Independence, LeafCaps, NanEncoding, PointerDomain, ProfileFacts, + DriverWorkaround, EnabledCaps, FloatFunctions, FormatTable, FragmentCaps, FunctionStorage, + GuestIsolation, HandleDomain, ImageCaps, Independence, LeafCaps, NanEncoding, PointerDomain, ProfileFields, Robustness, }; use crate::device::requirements::{ @@ -24,7 +25,7 @@ use crate::device::requirements::{ VkFeature, VkProperty, }; use crate::device::subgroup::{OpBits, StageSubgroup, SubgroupModel, SubgroupSizes}; -use crate::error::{Capability, DescriptorError, DriverDeviation, Error, Feature, Unsupported}; +use crate::error::{Capability, DescriptorError, Error, Feature, Unsupported}; use crate::pipeline::sym::Stage; use crate::vk; @@ -53,7 +54,11 @@ struct DeviceInner { } impl Device { - /// Derives the device profile from what the consumer enabled and its policy. + /// The device its Vulkan queries decide, under `policy`: the profile is a function of what + /// the description states the device supports and the consumer enabled, and of the policy. + /// The description need not come from a device: one read from a Khronos profiles JSON document + /// ([`DeviceDescription::from_khronos_json`]) or built field by field + /// ([`DeviceDescription::new`]) makes a device with no `VkDevice` behind it. /// /// Refuses a device below Vulkan 1.2 (`Unsupported{VulkanVersion}`), a description that lists /// a feature neither its version nor its listed extensions expose or a feature without the @@ -63,24 +68,8 @@ impl Device { /// (`InvalidDescriptor`), and the identity domains on a device without `bufferDeviceAddress` /// and `shaderInt64` (`Unsupported{IdentityDomains}`). /// - /// It reads the description's identity: the driver facts keyed on the driver and its GPU - /// (`driver_facts`), the workarounds keyed on them, the Function storage measured on a GPU, - /// and the workarounds the consumer measured (`DeviceDescription::measured`), for - /// `metal2vulkan-runtime` until the cutover deletes them and `new` becomes - /// [`Device::from_queries`]. - pub fn new(desc: DeviceDescription, policy: DevicePolicy) -> Result { - // The driver's measured deviations on its GPU, never its name. - let deviations = super::driver_facts::deviations(&desc); - Device::with_deviations(desc, policy, deviations) - } - - /// The device its Vulkan queries decide, under `policy`: the constructor `metal2vulkan-rt` - /// uses. Refuses what [`Device::new`] refuses. - /// /// No identity decides anything: the description's `driver_id`, `driver_version`, - /// `vendor_id`, `device_id` and `device_name`, and its `measured` workarounds, are not read. - /// So no driver fact, deviation, workaround or measured value keyed on a driver or a GPU - /// applies, and every note one of them could turn off stays on: the rasterizer splits clipped + /// `vendor_id`, `device_id` and `device_name` are not read. The rasterizer splits clipped /// coverage and the tessellator orders triangles as the device does /// (`DriverWorkaround::ClippedCoverageNotMetals`, `DriverWorkaround::TessellatorNotMetals`), /// `InterpolateAtOffset` reads from the pixel's center as GLSL.std.450 states, and a thread's @@ -88,53 +77,6 @@ impl Device { /// on every device, whatever its type. Every stage output is 32-bit: a `half` color output /// reaches the device widened to `float`, whatever `storageInputOutput16` says. pub fn from_queries(desc: DeviceDescription, policy: DevicePolicy) -> Result { - Device::derived(desc.without_identity(), policy, |desc, policy| { - let fields = ProfileFields { - ycbcr_in_place: true, - ..derive_fields(desc, policy, &BTreeSet::new()) - }; - (fields, ProfileFacts::EVERY) - }) - } - - /// [`Device::new`] with `deviation` taken or not, and the driver's other deviations as - /// measured: a test's way to take one route alone, which no driver in the table gives. - #[cfg(test)] - pub(crate) fn with_deviation( - desc: DeviceDescription, - policy: DevicePolicy, - deviation: DriverDeviation, - taken: bool, - ) -> Result { - let mut deviations = super::driver_facts::deviations(&desc); - match taken { - true => { - deviations.insert(deviation); - } - false => { - deviations.remove(&deviation); - } - } - Device::with_deviations(desc, policy, deviations) - } - - fn with_deviations( - desc: DeviceDescription, - policy: DevicePolicy, - deviations: BTreeSet, - ) -> Result { - Device::derived(desc, policy, |desc, policy| { - (derive_fields(desc, policy, &deviations), ProfileFacts::ROWS) - }) - } - - /// The device of `desc` under `policy`, its profile's fields and facts as `fields` derives - /// them, once the description and the policy pass their checks. - fn derived( - desc: DeviceDescription, - policy: DevicePolicy, - fields: impl FnOnce(&DeviceDescription, &DevicePolicy) -> (ProfileFields, ProfileFacts), - ) -> Result { if desc.api_version < ApiVersion::V1_2 { return Err(Unsupported::needs( Feature::VulkanVersion, @@ -153,8 +95,7 @@ impl Device { )); } identity_domains(&desc, &policy)?; - let (fields, facts) = fields(&desc, &policy); - let profile = DeviceProfile::of(fields, facts); + let profile = DeviceProfile::of(derive_fields(&desc, &policy)); let metal = MetalDeviceProperties::derive(&profile, &desc.allocation); Ok(Device(Arc::new(DeviceInner { fingerprint: profile.fingerprint(), @@ -229,11 +170,7 @@ fn identity_domains(desc: &DeviceDescription, policy: &DevicePolicy) -> Result<( Ok(()) } -fn derive_fields( - desc: &DeviceDescription, - policy: &DevicePolicy, - deviations: &BTreeSet, -) -> ProfileFields { +fn derive_fields(desc: &DeviceDescription, policy: &DevicePolicy) -> ProfileFields { let has = |f: VkFeature| desc.has(f); let ext = |e: VkExtension| desc.extensions.contains(&e); let api = desc.api_version; @@ -373,16 +310,14 @@ fn derive_fields( }; let (vertex_formats, storage_formats, image_formats) = format_tables(desc); - let deviates = |d: DriverDeviation| deviations.contains(&d); ProfileFields { buffer_access, pointer_domain: policy.pointer_domain, handle_domain: policy.handle_domain, containment, isolation: policy.isolation, - half_chains: policy.half_chains, leaf, - subgroup: subgroup_model(desc, deviates(DriverDeviation::MetalVertexSimdgroups)), + subgroup: subgroup_model(desc), images, descriptors, fragment, @@ -393,138 +328,39 @@ fn derive_fields( vertex_formats, storage_formats, image_formats, - workarounds: workarounds(desc), + // Every rasterizer but Apple's hands a clipped primitive's fragments their coverage by the + // whole primitive (or by its own pieces), never by Apple's pieces; and every tessellator + // but Apple's orders a patch's triangles its own way. No query tells Apple's apart. + workarounds: vec![ + DriverWorkaround::ClippedCoverageNotMetals, + DriverWorkaround::TessellatorNotMetals, + ], api_version: api, // The feature, which both description readers list from 1.3 (core without a member), // so the extended dynamic states a pipeline makes are exactly what it requires. dynamic_vertex_stride: has(VkFeature::ExtendedDynamicState), - enabled: enabled_caps(desc, deviations), - // The measured deviation; unmeasured, the device's own functions. - float_functions: if deviates(DriverDeviation::MetalFloatFunctions) { - FloatFunctions::Metal - } else { - FloatFunctions::Native - }, - // The measured deviation; unmeasured, the device's NaN, noted. - nan_encoding: if deviates(DriverDeviation::MetalCanonicalNans) { - NanEncoding::MetalCanonical - } else { - NanEncoding::Native - }, - // The planes of a two-plane YCbCr texture read in place where the GPU reads host memory - // with no bus between: an integrated GPU's, a CPU device's. - ycbcr_in_place: matches!( - desc.device_type, - Some(vk::PhysicalDeviceType::INTEGRATED_GPU | vk::PhysicalDeviceType::CPU) - ), - ycbcr_in_place_reads: policy.ycbcr_in_place_reads, - // The device's measured value, keyed on its identity as the workarounds are, or the floor. - function_storage: function_storage::of(desc), - // The measured deviations, one per pipeline kind; unmeasured, Vulkan's rule, the device's - // own reading of the gradients handed to it. - cube_gradients: { - let route = |measured: &[(DriverDeviation, CubeGradientRoute)]| { - measured - .iter() - .find(|(deviation, _)| deviates(*deviation)) - .map_or(CubeGradientRoute::Vulkan, |&(_, route)| route) - }; - CubeGradients { - graphics: route(&[( - DriverDeviation::GraphicsCubeGradientTangents, - CubeGradientRoute::AppleProjected, - )]), - compute: route(&[(DriverDeviation::CubeGradientRoute, CubeGradientRoute::Metal)]), - } + enabled: enabled_caps(desc), + float_functions: FloatFunctions::Native, + nan_encoding: NanEncoding::Native, + // The planes of a two-plane YCbCr texture read in place on every device. + ycbcr_in_place: true, + // The floor: no Vulkan query states how much a thread holds. + function_storage: FunctionStorage::Assumed(function_storage::FLOOR), + // Vulkan's rule, the device's own reading of the gradients handed to it. + cube_gradients: CubeGradients { + graphics: CubeGradientRoute::Vulkan, + compute: CubeGradientRoute::Vulkan, }, } } -/// The driver workarounds of the driver `desc` names (`driver_id`), on its GPU (`vendor_id`, or its -/// generation's `device_id`s) where the defect is the GPU's, those of the measured table -/// (`driver_facts::DEFECTS`), and those the consumer measured on the device itself -/// ([`DeviceDescription::measured`]), in order. -fn workarounds(desc: &DeviceDescription) -> Vec { - let mut found = by_identity(desc); - // Every rasterizer but Apple's hands a clipped primitive's fragments their coverage by the - // whole primitive (or, lavapipe, by its own pieces), never by Apple's pieces; and every - // tessellator but Apple's orders a patch's triangles its own way. - if !(desc.driver_id == Some(vk::DriverId::MOLTENVK) && desc.vendor_id == APPLE_VENDOR_ID) { - found.push(DriverWorkaround::ClippedCoverageNotMetals); - found.push(DriverWorkaround::TessellatorNotMetals); - } - found.extend(super::driver_facts::defects(desc)); - found.extend(desc.measured.iter().copied()); - found.sort(); - found.dedup(); - found -} - -/// The workarounds of [`workarounds`] keyed on the driver's identity alone. -fn by_identity(desc: &DeviceDescription) -> Vec { - match desc.driver_id { - Some(vk::DriverId::GOOGLE_SWIFTSHADER) => vec![DriverWorkaround::BufferAtomicsUncontained], - Some(vk::DriverId::MOLTENVK) if desc.vendor_id == APPLE_VENDOR_ID => vec![ - DriverWorkaround::EarlyTestsDropMultisampledImageWrites, - DriverWorkaround::DiscardDropsSimdgroupStores, - ], - Some(vk::DriverId::MESA_LLVMPIPE) => { - vec![DriverWorkaround::ClippedTrianglesSplitPixelFragments] - } - // A `half` round trip folded on every GPU it drives, and on the 3090's generation a - // narrow integer's mask dropped. - Some(vk::DriverId::NVIDIA_PROPRIETARY) => { - let mut found = vec![DriverWorkaround::HalfConversionPairFolded]; - if super::NVIDIA_AMPERE_GA10X.contains(&desc.device_id) { - found.push(DriverWorkaround::NarrowMaskAfterSignedClamp); - } - found - } - // An `f32` operation fused into the conversion of its result to `half`, on every GPU it - // drives. - Some(vk::DriverId::MESA_RADV) => vec![DriverWorkaround::HalfConversionFusedWithArithmetic], - // A register allocator that faults compiling a module past a word bound, products of one - // value by zeros of opposite sign kept as one, a stage past 2^20 objects of its - // serialized form corrupted, and a compiler whose memory outgrows the stage, on every GPU - // it drives. - Some(vk::DriverId::INTEL_OPEN_SOURCE_MESA) => vec![ - DriverWorkaround::RegisterAllocatorOverflowsLargeModules, - DriverWorkaround::OppositeZeroProductsMerged, - DriverWorkaround::SerializedStageWrapsLargeModules, - DriverWorkaround::CompilerMemoryGrowsWithStageSize, - ], - _ => Vec::new(), - } -} - -/// The operation classes measured exact in a vertex function on a driver that takes -/// `DriverDeviation::MetalVertexSimdgroups`: with the vertex stage forced into the profile, -/// MoltenVK 1.4.1 ran `rvc_simd_vertex`'s `simd_sum`, `simd_shuffle`, `simd_shuffle_xor` and -/// `simd_ballot` as Metal does (200 of 200 words on the M4 and the M3 Max), and with the votes -/// added, `gsm2_vertex_votes_shifts`' `simd_all` and `simd_any` over full and partial simdgroups -/// (the four cases matching in both legs on both chips). -/// -/// The clustered class stays out: with it added, MoltenVK 1.4.1 refused `gsm2_quad_ops`' vertex -/// functions, whose quad reductions then lowered to it ("Subgroup builtins are not available in -/// this type of function", SPIRV-Cross's MSL conversion). They now take the ballot -/// and shuffles, so no quad or simdgroup operation of a vertex function on the `Direct` tier needs -/// it. -const MEASURED_VERTEX_OPS: OpBits = OpBits( - OpBits::BASIC.0 | OpBits::VOTE.0 | OpBits::ARITHMETIC.0 | OpBits::BALLOT.0 | OpBits::SHUFFLE.0, -); - /// The subgroup model. /// /// A stage is `pinnable` when subgroup size control is enabled and the stage is in /// `requiredSubgroupSizeStages`; its size range is then `[minSubgroupSize, maxSubgroupSize]`. /// Otherwise SPIR-V 1.5 modules run with the API-constant `subgroupSize`, which is the only size /// the stage exposes. `full_subgroups` is compute-only (`computeFullSubgroups`). -/// -/// Where the driver is measured to run a vertex function's subgroup operations as Metal does -/// though `subgroupSupportedStages` leaves the vertex stage out (`vertex_simdgroups`, -/// `DriverDeviation::MetalVertexSimdgroups`), the vertex stage has subgroups of the device's -/// operations that were measured exact there ([`MEASURED_VERTEX_OPS`]). -fn subgroup_model(desc: &DeviceDescription, vertex_simdgroups: bool) -> SubgroupModel { +fn subgroup_model(desc: &DeviceDescription) -> SubgroupModel { let sg = &desc.subgroup; let control = desc.has(VkFeature::SubgroupSizeControl); let ops = OpBits(sg.supported_operations.as_raw() & OpBits(0xff).0); @@ -534,15 +370,9 @@ fn subgroup_model(desc: &DeviceDescription, vertex_simdgroups: bool) -> Subgroup && sg.required_size_stages.contains(bit) && sg.min_size > 0 && sg.max_size >= sg.min_size; - let advertised = sg.supported_stages.contains(bit); - let measured = !advertised && vertex_simdgroups && stage == Stage::Vertex; StageSubgroup { - supported: advertised || measured, - ops: if measured { - OpBits(ops.0 & MEASURED_VERTEX_OPS.0) - } else { - ops - }, + supported: sg.supported_stages.contains(bit), + ops, api_size: sg.size, sizes: if pinnable { SubgroupSizes { @@ -731,7 +561,7 @@ pub(crate) fn usage_class(usage: FormatUsage) -> UsageClass { } } -fn enabled_caps(desc: &DeviceDescription, deviations: &BTreeSet) -> EnabledCaps { +fn enabled_caps(desc: &DeviceDescription) -> EnabledCaps { let sg = &desc.subgroup; let mut properties = BTreeSet::new(); for (stage, bit) in STAGE_BITS { @@ -804,108 +634,10 @@ fn enabled_caps(desc: &DeviceDescription, deviations: &BTreeSet if desc.rgba4_opaque_black_swizzled { properties.insert(VkProperty::Rgba4OpaqueBlackSwizzled); } - // Where `InterpolateAtOffset` reads, and the measured deviations. - if desc.interpolates_at_offset_centered() { - properties.insert(VkProperty::InterpolateAtOffsetCentered); - } else { - properties.insert(VkProperty::InterpolateAtOffsetFromSevenSixteenths); - } - if deviations.contains(&DriverDeviation::SimdgroupLockstep) { - properties.insert(VkProperty::SimdgroupLockstep); - } - if deviations.contains(&DriverDeviation::MetalSampler) { - properties.insert(VkProperty::MetalSampler); - } else { - // Native device sampling, where the device's sampler is not Metal's. - properties.insert(VkProperty::DeviceSampling); - } - if deviations.contains(&DriverDeviation::MetalColorWrites) { - properties.insert(VkProperty::MetalColorWrites); - } - if deviations.contains(&DriverDeviation::MetalFloatColorNans) { - properties.insert(VkProperty::MetalFloatColorNans); - } - if deviations.contains(&DriverDeviation::MetalHalfFma) { - properties.insert(VkProperty::MetalHalfFma); - } - if deviations.contains(&DriverDeviation::MetalFloatDenormals) { - properties.insert(VkProperty::MetalFloatDenormals); - } - if deviations.contains(&DriverDeviation::MetalCenterVaryings) { - properties.insert(VkProperty::MetalCenterVaryings); - } - if deviations.contains(&DriverDeviation::MetalSmallFloatColorWrites) { - properties.insert(VkProperty::MetalSmallFloatColorWrites); - } - if deviations.contains(&DriverDeviation::MetalNorm16ColorWrites) { - properties.insert(VkProperty::MetalNorm16ColorWrites); - } - if deviations.contains(&DriverDeviation::MetalMinMax) { - properties.insert(VkProperty::MetalMinMax); - } - if deviations.contains(&DriverDeviation::MetalHalfArithmetic) { - properties.insert(VkProperty::MetalHalfArithmetic); - } - if deviations.contains(&DriverDeviation::MetalHalfStorageWrites) { - properties.insert(VkProperty::MetalHalfStorageWrites); - } - if deviations.contains(&DriverDeviation::MetalHalfStorageNans) { - properties.insert(VkProperty::MetalHalfStorageNans); - } - if deviations.contains(&DriverDeviation::MetalFragmentSimdgroups) { - properties.insert(VkProperty::MetalFragmentSimdgroups); - } - if deviations.contains(&DriverDeviation::MetalVertexSimdgroups) { - properties.insert(VkProperty::MetalVertexSimdgroups); - } - if deviations.contains(&DriverDeviation::CenterFragCoordDepth) { - properties.insert(VkProperty::CenterFragCoordDepth); - } - if deviations.contains(&DriverDeviation::SampleFragCoordDepth) { - properties.insert(VkProperty::SampleFragCoordDepth); - } - if deviations.contains(&DriverDeviation::MetalHalfTexelWrites) { - properties.insert(VkProperty::MetalHalfTexelWrites); - } - if deviations.contains(&DriverDeviation::MetalNormStorageWrites) { - properties.insert(VkProperty::MetalNormStorageWrites); - } - if deviations.contains(&DriverDeviation::MetalDepth16Stores) { - properties.insert(VkProperty::MetalDepth16Stores); - } - if deviations.contains(&DriverDeviation::MetalDepth16BiasedStores) { - properties.insert(VkProperty::MetalDepth16BiasedStores); - } - if deviations.contains(&DriverDeviation::MetalInterpolation) { - properties.insert(VkProperty::MetalInterpolation); - } - if deviations.contains(&DriverDeviation::MetalFirstVertexIndices) { - properties.insert(VkProperty::MetalFirstVertexIndices); - } - if deviations.contains(&DriverDeviation::MetalFullQuads) { - properties.insert(VkProperty::MetalFullQuads); - } - if deviations.contains(&DriverDeviation::MetalNormalizedVertexFetch) { - properties.insert(VkProperty::MetalNormalizedVertexFetch); - } - if deviations.contains(&DriverDeviation::MetalAlphaCoverage) { - properties.insert(VkProperty::MetalAlphaCoverage); - } - if deviations.contains(&DriverDeviation::MetalNanMoves) { - properties.insert(VkProperty::MetalNanMoves); - } - if deviations.contains(&DriverDeviation::MetalPackConversions) { - properties.insert(VkProperty::MetalPackConversions); - } - if deviations.contains(&DriverDeviation::MetalHalfConversion) { - properties.insert(VkProperty::MetalHalfConversion); - } - if deviations.contains(&DriverDeviation::MetalSmallFloatNans) { - properties.insert(VkProperty::MetalSmallFloatNans); - } - if deviations.contains(&DriverDeviation::MetalUnaryDenormals) { - properties.insert(VkProperty::MetalUnaryDenormals); - } + // `InterpolateAtOffset` reads from the pixel's center, as GLSL.std.450 states, and the device + // samples natively. + properties.insert(VkProperty::InterpolateAtOffsetCentered); + properties.insert(VkProperty::DeviceSampling); 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 627b03d08..556d956fd 100644 --- a/crates/metal2vulkan/src/device/description.rs +++ b/crates/metal2vulkan/src/device/description.rs @@ -10,7 +10,7 @@ use std::collections::{BTreeMap, BTreeSet}; -use crate::device::profile::{DriverWorkaround, FloatControls, Limits}; +use crate::device::profile::{FloatControls, Limits}; use crate::device::requirements::{ApiVersion, FormatUsage, VkExtension, VkFeature}; use crate::vk; @@ -82,15 +82,6 @@ pub struct DeviceDescription { /// `maxBufferLength` and the runtime's heap sizes read them from the `Device`. #[cfg_attr(feature = "serde", serde(default))] pub allocation: AllocationLimits, - /// The driver workarounds the consumer measured on this device itself, which the profile - /// takes beside those its driver's identity names: the cost facts no identity decides, - /// [`DriverWorkaround::UniformBufferPerLaneReadsSerialize`] and - /// [`DriverWorkaround::ExternalUniformReadsSkipACache`], which the runtime's view check - /// measures once per driver and release. A profile field (its workarounds), so its fingerprint - /// and every cache key follow it. Empty unless the consumer fills it (`new`, `query` and - /// `from_khronos_json` leave it so). - #[cfg_attr(feature = "serde", serde(default))] - pub measured: BTreeSet, } /// A device's allocation sizes, [`DeviceDescription::allocation`]: device facts that size @@ -168,12 +159,9 @@ impl GeneratedCommandsProperties { } } -/// `VkPhysicalDeviceProperties::vendorID` of Apple's GPUs. -pub(crate) const APPLE_VENDOR_ID: u32 = 0x106B; - impl DeviceDescription { /// A description of a device of `api_version` that enables nothing and reports zero limits. - /// Callers fill the public fields; `Device::new` validates the result. + /// Callers fill the public fields; `Device::from_queries` validates the result. pub fn new(api_version: ApiVersion) -> DeviceDescription { DeviceDescription { api_version, @@ -195,7 +183,6 @@ impl DeviceDescription { khr_format_feature_flags2: false, generated_commands: None, allocation: AllocationLimits::default(), - measured: BTreeSet::new(), } } @@ -217,34 +204,6 @@ impl DeviceDescription { pub fn has(&self, feature: VkFeature) -> bool { self.features.contains(&feature) } - - /// This description without what names its driver and GPU rather than answers a Vulkan - /// query: no `driver_id`, `driver_version`, `vendor_id`, `device_id` or `device_name`, and no - /// `measured` workarounds ([`Device::from_queries`](crate::device::Device::from_queries)). - pub(crate) fn without_identity(self) -> DeviceDescription { - DeviceDescription { - driver_id: None, - driver_version: 0, - vendor_id: 0, - device_id: 0, - device_name: String::new(), - measured: BTreeSet::new(), - ..self - } - } - - /// Whether `GLSL.std.450 InterpolateAtOffset` reads at the pixel center plus its offset, as - /// GLSL.std.450 states ("An offset of (0, 0) identifies the center of the pixel"): every - /// driver but MoltenVK, whose SPIRV-Cross converts the instruction to Metal's - /// `interpolate_at_offset(offset + 0.4375)`, which Metal measures from the pixel's upper-left - /// corner, so offset 0 reads a sixteenth of a pixel from the center. That conversion is read in - /// SPIRV-Cross's source and Metal's reading measured on the Apple M3 Max; no release of - /// MoltenVK is measured to read at the center, so none takes it: a device without it has - /// `VkProperty::InterpolateAtOffsetFromSevenSixteenths`, where translation moves a Metal - /// offset by 7/16 and reads nothing else through the instruction. - pub(crate) fn interpolates_at_offset_centered(&self) -> bool { - self.driver_id != Some(vk::DriverId::MOLTENVK) - } } /// Subgroup properties (`VkPhysicalDeviceVulkan11Properties` subgroup members and diff --git a/crates/metal2vulkan/src/device/driver_facts.rs b/crates/metal2vulkan/src/device/driver_facts.rs deleted file mode 100644 index b9b7ff278..000000000 --- a/crates/metal2vulkan/src/device/driver_facts.rs +++ /dev/null @@ -1,2525 +0,0 @@ -//! What a driver is measured to do where the specifications leave the answer to it, keyed on -//! the driver's identity: `VkPhysicalDeviceDriverProperties`'s `driverID`, and -//! `VkPhysicalDeviceProperties`'s `vendorID` and `deviceID` where the measurement is of one GPU -//! vendor's or one GPU's. No row names a release: a row holds at every `driverVersion` of its -//! driver. One table type serves both kinds of fact: the description's deviations, which -//! translation reads and the compile profile holds ([`DriverDeviation`]), and the runtime's driver -//! facts, which no translation reads ([`DriverFact`], in this table as `MEASURED`): a description -//! names its driver's through [`DeviceDescription::driver_facts`], which the runtime puts in its -//! device's properties. None of those is in the compile profile, a cache key or a digest. -//! -//! 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`]. MoltenVK's `deviceID` on Apple's GPUs is the macOS -//! release and the GPU family, so a row of one names every GPU of the family under that macOS. A -//! driver or GPU no row names takes no fact: the reader takes the route each fact's docs name for a -//! driver without it. A question a device answers about itself in a few milliseconds is no row: the -//! runtime's device checks measure it on each device, once per driver and release (whether its -//! submissions that signal nothing merge, whether a held host-pointer import adds to each -//! submission's cost: the runtime's `submit_check.rs`; textures in place over host pages, -//! `in_place_check.rs`; the GPU's idling between `VkQueue`s, `queue_switch_check.rs`; what a -//! `constant` window's reads cost through each view, `view_check.rs`, whose verdicts reach -//! translation as the description's measured workarounds, [`DeviceDescription::measured`]). - -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, Format, FormatFeatureFlags2, PrimitiveTopology}; -use std::borrow::Cow; -use std::collections::BTreeSet; - -/// One driver measured to have the fact `F`, at every release. -#[derive(Clone, Copy, Debug, PartialEq, Eq)] -pub(crate) struct Measured { - pub(crate) fact: F, - pub(crate) driver: DriverId, - /// The GPU vendor (`vendorID`) the fact is measured on, or `None` where it is the driver's - /// on every GPU it runs. - pub(crate) vendor: Option, - /// The GPU (`deviceID`, as the driver reports it) the fact is measured on, or `None` where - /// it is the driver's on every GPU of the vendor: a fact one GPU of a vendor answers and - /// another does not (the graphics cube route). - pub(crate) device: Option, -} - -/// The facts of `table` that the driver `driver` has on GPU `device` of `vendor`, read by the -/// `deviceID` it was measured under ([`DeviceDescription::canonical_device_id`]), at any release. -pub(crate) fn among( - table: &[Measured], - driver: Option, - (vendor, device): (u32, u32), -) -> BTreeSet { - table - .iter() - .filter(|row| { - Some(row.driver) == driver - && row.vendor.is_none_or(|v| v == vendor) - && row.device.is_none_or(|d| d == device) - }) - .map(|row| row.fact) - .collect() -} - -/// Every measured deviation, by driver. Each but the two color-NaN stores (below) is MoltenVK's on -/// Apple's GPUs, at 1.4.1 (`driverVersion` 10401, Homebrew's build of SPIRV-Cross `adec7acb`), -/// measured on the Apple M3 Max and the Apple M4 (macOS 26.7 and 27.0.1). The gate lane -/// `runtime_lane::driver_deviations` checks lockstep, the float functions and both cube routes on -/// each, the sampler's lanes the sampler; the canonical NaN rests on the measurements below: -/// - `SimdgroupLockstep`: kernels `7ab5ddfd` and `4b74b854` answer on the M3 Max what only lockstep -/// explains, and MoltenVK runs `4b74b854` without a barrier and matches; the owned fixture -/// `rtl_lockstep`'s two kernels answer Metal's lockstep order through the device's lockstep on -/// both chips. -/// - `MetalFloatFunctions`: every word of the precise math-library probe Metal's -/// through MoltenVK; on both chips, every word of a function the device's instruction answers, in -/// both math modes. -/// - `MetalCanonicalNans`: every class-A NaN Metal's canonical one through MoltenVK. -/// - `MetalSampler`: Metal's bytes on the 12 linear `half` cases through MoltenVK. -/// - `CubeGradientRoute`, a kernel's: our probe (cases `a54af728` and `315ca8b0` match -/// through MoltenVK on the M3 Max), and the same cases against the M4's own Metal rows on the M4; -/// under macOS 27.0.1 the M3 Max's MoltenVK rows of all eight committed cube-gradient cases -/// match its Metal rows (2026-10-14's re-record). -/// - `GraphicsCubeGradientTangents`, a vertex or fragment function's, on the identity [`APPLE9`] -/// (the M3 Max's and the M4's under macOS 27): the M3 Max under macOS 27.0.1 reads the face's two -/// tangents of each gradient, its normal component dropped, so SPIRV-Cross's `spvGradientCube` -/// (copied verbatim into a Metal kernel, 2026-10-15) of a gradient whose normal component is -/// zero samples as Metal's own sample of the gradient on every lane of an `x` or `z` face, under -/// every sampler (isotropic, anisotropic of degree 2 to 16, nearest and linear mip filters; 4,096 -/// such lanes of 6,144 a sampler), and on a `y` face differs on 922 to 934 of 1,024 a face (the -/// fixup writes the `x` tangent on both). Handed a `y` face's `(64/91 L, 0, 0)` instead (`L` -/// Metal's length of `(g_x, g_z)`, `lower::sampler`'s `Projected` form), the fixup samples as -/// Metal on all 6,144 lanes, every face, under each of three isotropic samplers (trilinear, -/// nearest mip filter, no mips), and on a `y` face under an anisotropic one still differs on 922 -/// to 932 of 1,024 a face. The gate lane checks the `x` and `z` faces' samples of -/// `rtl_cube_grad_fragment` against Metal's kernel rows. The M4's reading under macOS 27 -/// (its earlier probes: both tangents counted, not the normal) is the M3 Max's. -/// - `MetalColorWrites`: `runtime_lane::color_writes` through MoltenVK stored Metal's code for -/// every input of probes (every code's exact value and every tie with two `f32` steps either -/// side, of the 8- and 16-bit unorm and snorm, 10:10:10:2, 8-bit sRGB and half-float formats), -/// plain and blended with factors one and zero, where every other venue's driver differs: on the -/// Apple M4 and the M3 Max. One row per GPU, as measured. -/// -/// The color-NaN stores, measured by `runtime_lane::color_writes` (at 0c344d06f, -/// 2026-10-06): every NaN class of `float` outputs (the rounding writes `0x7fc00000`) to -/// `R16Float`, `RG16Float` and `RGBA16Float`, plain and blended with factors one and zero, -/// against Metal's `0x7e00`: -/// - `MetalFloatColorNans`: NVIDIA's (`NVIDIA_PROPRIETARY`) 615.71.09 on the GeForce RTX 3090 -/// (`deviceID` `0x2204`) and the RTX 5080 Laptop GPU (`0x2c19`): every channel Metal's. One row -/// per GPU, as measured. -/// - `MetalFloatColorNans` alone: lavapipe (`MESA_LLVMPIPE`) from Mesa 26.0.8 through 26.2.4, -/// every `float` NaN Metal's and a `half` NaN another: Mesa 26.0.8 on LLVM 21.1.8, x86_64 (the -/// linux-gate container; signalling `half` NaNs quieted) and arm64 (on an M4 mini; every `half` -/// NaN stored as `0x7e00`), and Mesa 26.2.4 on LLVM 23.1.1, x86_64 (Arch's, on an i9-13900, at -/// 58957da0; quieted). -/// -/// Measured to store another NaN for both outputs, so not listed: RADV, Mesa 26.2.4 on the -/// Radeon 780M, and ANV, Mesa 26.2.4 on the Iris Xe (RPL-P), `0xfe00`. MoltenVK 1.4.1 stores a -/// `half` NaN as `0x7e00` on the M3 Max and the M4, and its `float` NaN as Metal does -/// (`MetalColorWrites`). A `half` output's NaN reaches the attachment through the device's -/// widening of the `half` (`OpFConvert`), whose NaN is the device's, so no driver is listed for -/// it: NVIDIA's 615.71.09 on the RTX 5080 Laptop GPU stores every `half` NaN of the lane's `half` -/// output to `RGBA16Float` as `0x7fff`, where Metal stores the `half`'s own bits (at 961b1ff319, -/// 2026-11-05). -/// -/// `MetalHalfFma`: MoltenVK 1.4.1's `GLSL.std.450 Fma` on 16-bit floats, which SPIRV-Cross writes -/// as Metal's `fma(half, half, half)`, the operation a Metal `half` fused multiply-add compiles to. -/// The gate lane -/// `runtime_lane::driver_deviations::half_fused_multiply_adds_the_device_answers_are_metals` runs -/// the two committed `half` `fma` cases against each chip's Metal rows: 0 of 1,024 `half` words -/// differ in each case, on the M3 Max and the M4. One row per GPU, as measured. -/// -/// `MetalFloatDenormals`: the device's `float` `+ - *`, comparisons, `OpFmaKHR`, `Dot`, `Ldexp`, -/// `Sqrt`, `InverseSqrt`, `Trunc` and `RoundEven` read an `f32` denormal operand as the zero of its -/// sign and flush a denormal result, as Metal does (`Trunc` and `RoundEven`), with no -/// float-controls execution mode declared (Vulkan's `DenormFlushToZero` would guarantee the results -/// alone). The committed rows of the denormal probes (`nan_denormals`, `nan_denormals_fast`: 256 -/// lanes of operand triples rich in denormals of both signs and the smallest normals) differ from -/// Metal's on none of those operations' lanes on MoltenVK 1.4.1 on the M4, RADV (Mesa 26.2.4 on the -/// Radeon 780M), ANV (Mesa 26.2.4 on the UHD 770 of RPL-S) and NVIDIA's 615.71.09 on the RTX 5080 -/// Laptop GPU; the gate lanes `float_denormals_*` measure the M3 Max, the Iris Xe of RPL-P and -/// the RTX 3090 likewise. lavapipe keeps them (Mesa 26.0.8 on LLVM 21.1.8, x86_64 and arm64: -/// 1,249 and 1,032 words of the two probes differ), so it is not listed. NVIDIA's `Floor` and -/// `Ceil` keep a denormal, which the deviation does not cover: every profile leaves their -/// denormals to the device, noted (`lower::arith::denormal`). The probes declare no float-controls -/// mode; in an entry that declares the 16-bit controls NVIDIA's driver keeps `f32` denormals -/// (`DriverWorkaround::FloatDenormalsKeptUnderHalfControls`, in `DEFECTS`), and there the -/// deviation is not taken. One row per GPU, as measured. -/// -/// `MetalCenterVaryings`: MoltenVK 1.4.1 hands Metal a smooth input decorated neither `Centroid` -/// nor `Sample` with no interpolation qualifier (SPIRV-Cross `adec7acb`, `spirv_msl.cpp` -/// 13664-13720), which Metal reads as `center_perspective` (`NoPerspective`: -/// `center_no_perspective`), whatever the sample rate, and Metal reads both at the pixel center in -/// every invocation, a sample-rate one's included. The six authored cases of the owned fixture -/// `engine/multisample` that read center varyings in a function Metal runs per sample -/// (`multisample_center_at_sample`, `multisample_counter` and `multisample_sampled_varying`, at 2 -/// and 4 samples) match Metal's words through MoltenVK with the varyings read as they are, on the -/// M3 Max and the M4. One row per GPU, as measured. -/// -/// The two color-write conversions, measured by `runtime_lane::color_writes` through the device's -/// own conversion (at the scratch commit 9bc673b64, 2026-10-07, and our probe on the UHD 770 the -/// same day): every code's exact value, every tie between neighbouring codes with two `f32` steps -/// either side, and the specials (infinities, past the largest, negatives, every NaN class), of -/// `float` outputs, plain and blended with factors one and zero, against Metal's rule: -/// - `MetalSmallFloatColorWrites`: RADV, Mesa 26.2.4 on the Radeon 780M; ANV, Mesa 26.2.4 on the -/// Iris Xe (RPL-P) and on the UHD 770 (RPL-S), alike channel for channel (the one Intel venue's -/// two devices); and NVIDIA's 615.71.09 on the RTX 3090: every channel of `R16Float`, -/// `RG16Float`, `RGBA16Float` and `RG11B10Float` Metal's but NaNs (RADV and ANV store every -/// NaN of a half-float channel as `0xfe00`, as they store the rounding's; NVIDIA keeps some -/// NaNs' sign or payload, where it stores the rounding's `0x7fc00000` as Metal's NaN). -/// - `MetalNorm16ColorWrites`: RADV, Mesa 26.2.4 on the Radeon 780M: every channel of -/// `R16Unorm`, `RG16Unorm`, `RGBA16Unorm`, `R16Snorm`, `RG16Snorm` and `RGBA16Snorm` Metal's, -/// NaNs included, but a blended snorm channel's NaN (0, where Metal stores -1.0's code), from -/// `half` outputs too. ANV and NVIDIA store another code near ties. -/// -/// One row per GPU, as measured. The gate lane `runtime_lane::color_writes::draws_store_metals_codes` -/// holds them: it draws through the device's own conversion wherever the profile takes them. -/// -/// `MetalMinMax`: MoltenVK 1.4.1's `GLSL.std.450` `NMin`, `NMax` and `NClamp` on 32-bit floats, -/// which SPIRV-Cross writes `precise::min`, `precise::max` and `precise::clamp`, against Metal's -/// `fmin`, `fmax` and `clamp` by their rule (`DriverDeviation::MetalMinMax`), in each of Metal's -/// three math modes (fast, as MoltenVK compiles; relaxed; safe), operands through a run-time -/// select: every pair of widened `half`s (2^32, the translation holds a `half` in a `float`), -/// scalar and four-lane, 2^32 hashed `float` pairs of every class, scalar and four-lane, a -/// 2,048-value `float` set of specials, NaNs of several payloads, denormals and neighbours pair by -/// pair, and `clamp` of every widened `half` against 48 x 48 bounds and of the `float` set against -/// 64 x 64; none differs, on the M3 Max and the M4. A control over the hashed pairs whose two NaNs -/// answer the first operand differs, as it must. The `half` forms (`min`, `max`, `clamp` of `half`, -/// every pair) match too, though the translation does not emit them. One row per GPU, as measured. -/// -/// `MetalHalfArithmetic`: MoltenVK 1.4.1's 16-bit `OpFAdd` and `OpFSub` decorated `NoContraction`, -/// which SPIRV-Cross writes as its `[[clang::optnone]]` `spvFAdd` and `spvFSub`, and its 16-bit -/// `Fma(a, b, -0.0)` decorated `NoContraction`, written `fma(a, b, -0.0h)`, each with operands -/// narrowed from `float` by `half()` and the result widened by `float()`, against Metal's own -/// `half` arithmetic: the exact result rounded once to nearest even on the `half` grid, `half` -/// denormals kept, an exact zero sum `+0` unless both addends are `-0`, and every NaN result -/// `0x7E00`, by integer references, over every pair of `half`s (2^32), in each of Metal's three -/// math modes, on one to four lanes, one kept result narrowed into the next, and a kept result -/// under a plain `float` sum or product (measured the native operators on `half` values). None -/// differs. The same operations undecorated differ in the fast and relaxed modes, which fold the -/// narrowings and the widening away (3,468,601,344 pairs for a sum, 4,014,926,892 for a product, -/// 6,140 for a quotient); so does SPIRV-Cross's `NoContraction` `OpFMul`, `spvFMul`, which answers -/// `+0` for a `-0` product (126,974 pairs). The translation emits the undecorated `OpFAdd`, -/// `OpFSub` and `OpFMul` only for an operation whose AIR flags carry `contract` and `reassoc`, the -/// AIR's own contraction, and records `PrecisionNote::FastMathRewrites` for it; never the decorated -/// `OpFMul`. The sums read every -/// `half` through the device's widening (`x + -0` of every `x`), which every `half` read from its -/// bits takes on a profile with `shaderFloat16` (`lower::arith::narrow::from_bits`), so a module -/// that reads one requires this fact for its denormals; Metal's own widening, read on the M3 Max -/// (macOS 27.0.1) over every bit pattern from threadgroup memory in fast and safe math, takes every -/// `half` but a NaN to its value, denormals included, and every NaN to `0x7FC00000`. One row per -/// GPU, as measured. -/// -/// `MetalFragmentSimdgroups`: MoltenVK 1.4.1's SPIRV-Cross writes a fragment shader's -/// `SubgroupLocalInvocationId` as Metal's `[[thread_index_in_simdgroup]]`, and Metal runs the -/// fragment, so each fragment subgroup is a Metal simdgroup of the same pixels. Metal's own lanes -/// were read from MSL of ours on the M3 Max (macOS 26.7) and the M4 (macOS 27.0.1), equal on both -/// and from run to run: in an aligned 8x4 block one primitive covers whole, quads in row-major -/// order; elsewhere, the rasterizer packs the covered quads of several blocks and primitives into -/// one simdgroup. The gate lane -/// `runtime_lane::driver_deviations::fragment_simdgroup_lanes_are_metal_s` compares MoltenVK's -/// subgroup lanes with Metal's lanes of the same draws on each chip. Its quads are Metal's too: in -/// a function that discards, where the M3 Max shades some quads as several partial quads, the -/// public `helper-threads-*` cases' MoltenVK rows answer Metal's ballots of the helper query word -/// for word. One row per GPU. -/// -/// `MetalVertexSimdgroups` (the coordinator's reversal of the MoltenVK refusal, 2026-10-08): -/// MoltenVK 1.4.1 leaves the vertex stage out of `subgroupSupportedStages`, but hands the vertex -/// function to Metal, which runs it in simdgroups of 32 consecutive vertices. With the stage forced -/// into the profile it ran `rvc_simd_vertex` (`simd_sum`, `simd_shuffle`, `simd_shuffle_xor`, -/// `simd_ballot`) as Metal does on both chips (200 of 200 words); the lane -/// `runtime_lane::driver_deviations:: vertex_simdgroups_are_metal_s` runs it and the -/// explicit-width fill on each chip. One row per GPU. -/// -/// `CenterFragCoordDepth`: MoltenVK 1.4.1 on the M4 gives a per-sample fragment invocation at 4 -/// samples `FragCoord.z` at the pixel centre, its depth bias included (1 of 15 cases equal to the -/// stored per-sample depth, the flat one), and the vertex function's no-perspective window depth -/// read at the sample through `InterpolateAtSample`, plus `FragCoord.z` less the same varying read -/// as it is (the centre), equals the depth it stores at each sample in the flat, sloped, steep, -/// constant and negative bias, clamp, clip, clamped-range and past-the-range cases, and within 2 -/// ulp in the perspective, slope-scaled bias and narrowed or reversed range cases (16,384 samples a -/// case; four arithmetic orders of the window depth alike). The M3 Max (macOS 26.7) answered every -/// 4-sample row as the M4 did (the same probe binary, the coordinator's run of 2026-10-09). One row -/// per GPU. -/// -/// `SampleFragCoordDepth`: RADV, Mesa 26.2.4 on the Radeon 780M, gives a per-sample fragment -/// invocation at 4 samples `FragCoord.z` at its sample, its depth bias included: in the in-shader -/// test's form (the depth attachment kept in the subpass under `Always`), equal bit for bit to the -/// depth the device stores at each sample in all 15 cases (flat, sloped, steep and perspective -/// triangles, constant, negative, slope-scaled, steep and clamped bias, clamp and clip modes, and -/// default, narrowed, reversed and clamped viewport ranges; 13,819 to 16,384 samples a case). -/// Clamped as Metal clamps, it equals the stored depth in 14: in the steep bias case -/// the device stores 17 samples past 1 unclamped, where Metal stores 1, which the clamp gives. -/// MoltenVK (the pixel centre's, measured as `CenterFragCoordDepth`), ANV and NVIDIA (the pixel -/// centre's, 1 of 15 each) do not. -/// -/// The half-float storage writes, measured by `runtime_lane::half_storage_writes` through the -/// device's own conversion (at fd90c81e3, 2026-10-08): a kernel's `float` write through -/// `access::write`, `access::read_write`, a texture buffer and an argument buffer's texture to -/// `R16Float`, `RG16Float` and `RGBA16Float` of every finite half and every tie between -/// neighbouring halves with one `f32` step either side, of either sign, and the specials (zeros, -/// infinities, past the largest, denormals, NaNs of four payloads), against Metal's rule (toward -/// zero, past the largest 65504, every NaN `0x7e00`; every form, plain and under Metal's debug -/// layer): -/// - `MetalHalfStorageWrites`: every channel but NaNs Metal's, on MoltenVK 1.4.1 on the M3 Max -/// and the M4, ANV, Mesa 26.2.4 on the Iris Xe (RPL-P) and the UHD 770 (RPL-S), and NVIDIA's -/// 615.71.09 on the RTX 3090 and the RTX 5080 Laptop GPU, and lavapipe (`MESA_LLVMPIPE`) from -/// Mesa 26.0.8 through 26.2.4: Mesa 26.0.8 on LLVM 21.1.8, x86_64 (the linux-gate container) and -/// arm64 (on an M4 mini), and Mesa 26.2.4 on LLVM 23.1.1, x86_64 (Arch's, on an i9-13900), all -/// at fd90c81e3; and RADV (`MESA_RADV`) on three GPUs of two generations: RDNA3, Mesa 26.2.4 on -/// the Radeon 780M at fd90c81e3 and Mesa 26.2.6 on the RX 7900 XTX at 92202c5ea, and GCN4, Mesa -/// 26.2.6 on the RX 550 (Polaris 12) at 5020ce945 (2026-11-09). -/// - `MetalHalfStorageNans`: every NaN `0x7e00` too, on MoltenVK 1.4.1 on the M3 Max and the M4. -/// -/// One row per GPU, as measured; lavapipe's and RADV's one row each, of the driver on every GPU, -/// every GPU each was measured on agreeing. -/// -/// `MetalHalfTexelWrites`, measured by `runtime_lane::half_write_nans` (at f38e6b9fc, 2026-10-09): -/// a kernel's `half4` write through `access::write` and `access::read_write` of quiet and -/// signalling NaNs of both signs and payload edges, with infinities, zeros, denormals and normals, -/// handed to the device widened: RADV, Mesa 26.2.4 on the Radeon 780M, and NVIDIA's 615.71.09 on -/// the RTX 3090 and the RTX 5080 Laptop GPU store each half's own bits in `R16Float`, `RG16Float` -/// and `RGBA16Float`, as Metal does. MoltenVK 1.4.1 on the M4 stores every NaN `0x7e00`, ANV, Mesa -/// 26.2.4 on the Iris Xe (RPL-P), `0xfe00`, and lavapipe (Mesa 26.0.8 on LLVM 21.1.8, x86_64) -/// quiets a signalling NaN, so none is listed. Every one stores a 32-bit float channel's bits as -/// written. -/// -/// `MetalNormStorageWrites`, measured by `runtime_lane::norm_storage_writes` through the device's -/// own conversion (at a6609204 and our probe at 69fee0d4, 2026-10-10): a kernel's `float` write -/// through `access::write`, `access::read_write`, a texture buffer and an argument buffer's texture -/// of every code's value and every tie between codes with two `f32` steps either side, and the -/// specials (zeros, NaNs, infinities, past the range), to the 8- and 16-bit unorm and snorm -/// formats, `RGB10A2Unorm`, `BGR10A2Unorm`, `A8Unorm` and the packed 16-bit ones, against Metal's -/// rule (the exact product rounded to nearest with a tie away from zero, a NaN 0, a 1-bit channel 1 -/// only above one half): MoltenVK 1.4.1 on the M4 stores every channel of every format it stores -/// (it binds no packed 16-bit format for storage) as Metal does, and RADV, Mesa 26.2.4 on the -/// Radeon 780M, every channel of every format but the 1-bit alpha of `A1BGR5Unorm` and -/// `BGR5A1Unorm`, which it rounds up at one half, where Metal stores 0 (a write that may reach such -/// a texture records `PrecisionNote::DeviceColorConversion` there). ANV, Mesa 26.2.4 on the Iris Xe -/// (RPL-P), and lavapipe (Mesa 26.0.8 on LLVM 21.1.8, x86_64) round the `f32` product with ties to -/// even, and NVIDIA's 615.71.09 on the RTX 3090 stores the code below many values just past a tie, -/// so none is listed. MoltenVK 1.4.1 on the M3 Max under macOS 27.0.1, of the M4's identity -/// ([`APPLE9`]), stores every channel as Metal does too (2026-10-14: both of `norm_storage_writes`' -/// tests with the fact taken, 0 channels off in every form and format it stores, the packed 16-bit -/// ones refused for storage as on the M4). -/// -/// `MetalDepth16Stores`, measured by `runtime_lane::unorm_depth_bias`'s unbiased rows (the 16 -/// depths of probe 7 and the 39 of probe 7b around the midpoints of codes 100 and 40000, each -/// drawn at a constant of 0; at d51c2aa8, 2026-10-07), every code Metal's: -/// - RADV, Mesa 26.2.4 on the Radeon 780M. -/// - ANV, Mesa 26.2.4 on the Iris Xe (RPL-P) and Intel Graphics (RPL-S) (on the Iris Xe, on the -/// RPL-S). One row per GPU, as measured. -/// - MoltenVK 1.4.1 on Apple's GPUs (an M4): Metal stores the depth on every -/// Apple GPU, by construction, MoltenVK making `D16_UNORM` Metal's own `Depth16Unorm`. -/// -/// Measured not to have it, so not listed: lavapipe, Mesa 26.0.8 on LLVM 21.1.8 and Mesa 26.2.4 -/// on LLVM 23.1.1, x86_64, which scales the depth by 65535 as a `float` and rounds the tie that can -/// make to even: 0.3 (`0x3e99999a`, 19660.50078 codes) stored 19660 and 0.9 (`0x3f666666`, -/// 58981.49844) stored 58982, where Metal stores 19661 and 58981; and NVIDIA's 615.71.09 on the RTX -/// 5080 Laptop GPU, which stored the code below Metal's for 26 of the 55 unbiased depths: -/// every depth whose exact scaled value lies at a code's midpoint or above it by up to 0.55 of a -/// code (0.5's 32767.5 stored 32767, 0.1's 6553.50010 stored 6553, 100.55 stored 100), Metal's -/// code from 100.5625 up, as a conversion keeping four fractional bits and rounding their -/// midpoint down would. -/// -/// `MetalDepth16BiasedStores`, measured by -/// `runtime_lane::unorm_depth_bias::a_constant_bias_on_a_16_bit_unorm_depth_stores_metals_codes` -/// (every depth and constant of the probes' draws, each biased by the device): -/// - MoltenVK 1.4.1 on Apple's GPUs, which takes Metal's constant in Metal's own unit: every code -/// Metal's on an M4 mini. On every Apple GPU by construction: MoltenVK 1.4.1 hands the recorded -/// constant, slope and clamp unchanged to the render encoder's `setDepthBias:slopeScale:clamp:` -/// (`MVKCommandEncoderState.mm`) and makes the depth Metal's own `Depth16Unorm` -/// (`MVKPixelFormats.mm`), so Metal biases and stores the depth on whichever Apple GPU runs it. -/// -/// Not listed: every other driver. Each biases Metal's constant `c` by its own unit (Vulkan's `r` -/// of a 16-bit unorm depth, at most twice 2^-16), where Metal biases by `c + 1` units of 1/65535 -/// (`c - 1` below 0), so a constant bias stores another code than Metal's. -/// -/// `MetalInterpolation`: MoltenVK 1.4.1 hands each fragment input to Metal with its -/// interpolation (SPIRV-Cross `adec7acb` writes it as a `[[user(...)]]` input qualified -/// `center_perspective`, `center_no_perspective`, `centroid_*` or `sample_*`, and an -/// `InterpolateAt*` read as Metal's `interpolant`), so Metal's rasterizer interpolates every -/// varying, on whichever Apple GPU runs it. Measured on the M3 Max under macOS 27.0.1 (2026-10-15): -/// seven triangle-list draws of a `float4` attribute read as a perspective and a no-perspective -/// varying (one-hot vertices of a triangle list whose `w` runs from 1 to 5, at 32x32 and 64x64; -/// texcoords and scaled texcoords over a full-screen quad at 64x64 and 100x60 and a full-screen -/// triangle at 100x60; a colour whose `w` runs from 0.6 to 3, at 64x64 and 100x60), every one of -/// the 210,082 interpolated lanes MoltenVK wrote equal to Metal's bit for bit. Every other driver -/// the same probe measured interpolates otherwise, so none is listed (bit-equal lanes of the -/// 105,041 of each form, perspective and not, and the largest difference): -/// - RADV, Mesa 26.2.4 on the Radeon 780M: 38,825 and 43,307, up to `1.2e-4` apart. -/// - ANV, Mesa 26.2.4 on the Iris Xe (RPL-P): 41,417 and 44,356, up to -/// `7.6e-5` apart. -/// - lavapipe, Mesa 26.2.4 on LLVM 23.1.1, x86_64: 32,968 and 35,422, up to -/// `3e-4` apart (it snaps vertices otherwise). -/// - NVIDIA's 615.71.09 on the RTX 5080 Laptop GPU and the RTX 3090, alike word for word: 41,433 -/// and 47,662, up to `1.5e-4` apart. -/// -/// Even the full-screen quad at 64x64, whose texcoords are exact at every pixel center, differs -/// from Metal on each of them in a scaled lane (`17u + 0.3`). -/// -/// `MetalFirstVertexIndices`: MoltenVK 1.4.1 hands a vertex function's `Layer` and `ViewportIndex` -/// to Metal as its own `[[render_target_array_index]]` and `[[viewport_array_index]]` outputs -/// (SPIRV-Cross `adec7acb`, `spirv_msl.cpp` 17815-17820, `CompilerMSL::builtin_qualifier`), so -/// Metal's rasterizer takes a primitive's slice and viewport as it takes its own, from the -/// primitive's first vertex, on whichever Apple GPU runs it. Measured on the M3 Max under macOS -/// 27.0.1 (2026-10-16): `runtime_lane::first_vertex`'s twelve draws of the owned fixture -/// `rt6_first_vertex` (triangle lists in three orders and with indices past the counts, triangle -/// strips both ways, lines both ways, a line strip and points; each vertex its own slice and -/// viewport) left through MoltenVK, with the indices stored from the vertex function, Metal's -/// 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 -/// (2026-10-21, the runtime lanes in release builds under `--cfg m2v_gpu`): every -/// deviation of the 1.4.1 rows of [`APPLE9`]'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. -/// -/// `MetalNormalizedVertexFetch`: MoltenVK hands a normalized vertex format to Metal's own vertex -/// fetch, as the `MTLVertexFormat` of the same layout (`MVKPixelFormats.mm`), so Metal converts the -/// codes. Metal's own answer, read on the M3 Max under macOS 27.0.1 (MSL of ours, 2026-10-28) at -/// every code of every component of the 19 normalized formats, per vertex and per instance, into -/// `float4` and `half4` attributes: the code over its maximum correctly rounded to `float`, but an -/// `Int1010102Normalized` 10-bit field's, `c` times `float(1 / 511)` rounded to `float` (96 of the -/// 1,024 codes one `f32` ulp toward zero of the quotient); into a `half` attribute, the exact -/// quotient rounded once to `half`. The gate lane `runtime_lane::normalized_vertex_fetch` reads -/// every code of every component of the 19 formats through MoltenVK 1.4.2 on the M3 Max (macOS -/// 27.0.1, 2026-10-28) against that rule computed exactly on the CPU, per vertex into `float4` and -/// `half4` attributes and per instance into `float4` ones: every `float4` word Metal's, and every -/// `half4` word but 40 of the 2,114,560, the 16-bit formats' at codes 65455 and 65519 unsigned and -/// 32759 and -32759 signed, whose `float` the module rounds to `half` again (one `half` ulp; noted -/// there). A run that drew every format per instance into both attributes as well (8,458,240 words) -/// answered alike. The committed recordings of `vertex-format-float4`, `-half4` and -/// `-instance-step` (the M3 Max, macOS 27.0.1) hold the same rule at all 1,872 of their normalized -/// components. One row per GPU, as measured. Measured not to have it, so not listed: lavapipe, Mesa -/// 26.0.8 on LLVM 21.1.8, arm64 (the linux-gate container, the same lane), whose reciprocal product -/// reads codes of every format but `Int1010102Normalized` one `f32` ulp off Metal's (126 of the 256 -/// codes of `UCharNormalized`, 512 of the 65,536 of `UShortNormalized`), and per instance the most -/// negative code of an 8- or 16-bit signed format unclamped (-128/127, where Metal reads -1). -/// -/// `MetalAlphaCoverage`: MoltenVK hands `alphaToCoverageEnable` to Metal's own -/// `alphaToCoverageEnabled` (`MVKPipeline.mm` line 2025 at 1.4.2), so Metal covers. The gate lane -/// `runtime_lane::alpha_coverage` draws 639 alphas a sample count, each over its own 4x4 block, -/// through MoltenVK 1.4.2 on the M3 Max (macOS 27.0.1, 2026-10-28) at 1, 2 and 4 samples, against -/// plain Metal's reading of the same draws on the same chip (the probe -/// `metal2vulkan-conformance/probes/alpha_coverage_sweep.m`): every one of the 30,672 pixels -/// Metal's. One row per GPU, as measured. Measured not to have it, so not listed: lavapipe, Mesa -/// 26.0.8 on LLVM 21.1.8, arm64 (the linux-gate container, the same lane), whose 2x2 ordered -/// dither covers at one sample where Metal's covers above an alpha of 1/2 (2,560 of the 10,224 -/// pixels a sample apart there, and 96 of 10,224 at four samples); and NVIDIA's 615.71.09 on the -/// RTX 5080 Laptop GPU, which stores a fragment of alpha 1/2 at one sample (the conformance case -/// `a2c-on-1-alpha-50`). -/// -/// `MetalNanMoves`: MoltenVK 1.4.2 (its SPIRV-Cross `6c09849f`) writes a 16-bit float's widening -/// as Metal's `float(half)`, the narrowing as `half(float)`, `OpFNegate` as `-x` and `FAbs` as -/// `abs(x)`, Metal's own conversions and operators, and the driver's compiler folds a narrowing of -/// a widening moved through the registers (a select, a branch's merge, a function's `float` -/// variable) into the `half` itself, as Metal moves a `half` unwidened. Measured on the M3 Max -/// under macOS 27.0.1 (2026-11-02), word for word against plain Metal: every one of the 65,536 -/// `half` bit patterns widened (every NaN `0x7FC00000`), moved through a `select`, a branch's -/// merge (a `half` and a `half2`) and to a later block and stored (each its own bits), and its -/// `half` `fabs` (every NaN `0x7E00`); and 262,144 `float` words (every `half` value widened, -/// 65,536 NaNs of both signs over every top-12 payload bits and four low patterns, 32,768 random -/// NaNs, 131,072 random words) narrowed to `half`, negated and their magnitude taken: none -/// differs, with and without fast math (the AIR of `runtime_lane::nan_moves`, which checks the -/// runtime against Metal's answers, run on Metal too). The `half` `fneg` matched too, but by the -/// driver's compiler moving the -/// negation onto the `half`, which nothing states, so it stays noted; and a module that carries a -/// widened `half` elsewhere or reads its bits is outside the measurement -/// (`narrow::moves_unfolded`). Measured to differ, so outside it too (2026-11-03, every `half` bit -/// pattern through Metal's compiler, with and without fast math): a merge of a select of the -/// widened `half` against a constant (`b ? float(h) : 0.0`, as the translation's bounds check -/// selects a read) with another widened value answers 2045 of the 2046 NaNs `0x7E00` -/// (`narrow::merges::merges_mixed_selects`, followed member by member where a struct, an array or -/// a vector carries the select and the other value, as a texel read's `{T, i8}` does: not measured -/// through a struct, whose members' merges are the measured shape), where the select merged with a -/// constant, a select of two -/// widened values merged with a third, a merge then a select, two selects and two merges keep -/// every NaN's bits. One row per GPU, as measured. -/// -/// `MetalPackConversions`: MoltenVK 1.4.2 hands `GLSL.std.450`'s `PackUnorm4x8`, `PackSnorm4x8`, -/// `PackUnorm2x16`, `PackSnorm2x16` and their unpacks to Metal's own `pack_float_to_*` and -/// `unpack_*_to_float`, and the other formats' definition to Metal's arithmetic; on the M3 Max -/// under macOS 27.0.1 (2026-11-02) the module's conversion answers Metal's, word for word against plain Metal with and without fast math, for -/// `unpack_unorm565_to_float` (every word: the code times the `float` nearest `1 / D`, as Metal's -/// does), `pack_float_to_unorm565` (3,083,776 `float`s and 385,152 around its products' ties: -/// Metal rounds the product to `float` first), the `half` unpacks of `unorm4x8`, `snorm4x8`, -/// `unorm10a2` and `unorm565` (every code: Metal's quotient rounded once to `half`), and the -/// `half` packs -/// of `unorm4x8`, `snorm4x8`, `unorm2x16`, `snorm2x16`, `unorm10a2` and `unorm565` (every `half` -/// in every channel). The AIR of `runtime_lane::pack_conversions`, which checks the runtime -/// against Metal's answers, run on Metal too, matches its model in every word. Measured to -/// differ, so outside it: the sRGB format (85,511 of 3,083,776 `float` packs, 3,286 `half` ones), -/// `unorm10a2` in `float` (9,163 of 131,072 unpacked words, 1,257 packed `float`s), and the `half` -/// unpacks of `unorm2x16` and `snorm2x16` (8 lanes, a `float` quotient rounded twice); -/// `snorm10a2` is unmeasured. One row per GPU, as measured. -/// -/// `MetalHalfConversion`: MoltenVK 1.4.2 writes `OpFConvert` from 32 to 16 bits as Metal's -/// `half(x)`, and Metal's compiler folds the conversion of an image instruction's `float` texel -/// into the access. On the M3 Max under macOS 27.0.1 (2026-11-03), word for word against plain -/// Metal, with and without fast math: the conversion of a `float` loaded (425,216 words: every -/// `half`'s value, each midpoint between two `half`s and the `float`s either side of it, values -/// inside each interval, the overflow edge, the `half` denormals' range and below it, NaNs and -/// random words, both signs), of a sum, a product and a quotient of two (144,896 pairs each, built -/// to land on and beside the `half` ties), of a fused multiply-add (123,648) and of an integer's -/// quotient (190,208): none differs. Nor does the `half` result of a `read()`, a nearest sample at -/// the texel's centre, a linear sample a quarter texel off it and a gather of every texel of -/// `RGBA32Float` (every `float` word above), `RGBA16Float` (every `half`), `RGBA8Unorm`, its sRGB -/// twin, `RGBA8Snorm`, `RGBA16Unorm` and `RGBA16Snorm` (every code), `RGB10A2Unorm` (every code) -/// and `RG11B10Float` and `RGB9E5Float` (16,384 random words each). Measured to differ, so outside -/// it: Metal's `half` `tanh`, which answers 7 of the 65,536 `half`s otherwise than the nearest -/// even `half` of its `float` `tanh`; `exp`, `sqrt` and a reciprocal on `half` matched, but each is -/// a function or an operation computed otherwise than by the conversion, so it stays noted -/// (`narrow::rounds_unmeasured`). A texel the module decodes itself rounds by the same conversion -/// of the `float` it holds (`narrow::round_texel`): the gate lane -/// `runtime_lane::heap_extended_reads::heap_half_reads_of_every_code_round_their_float` reads every -/// code of the five forms a heap holds by its raw texels that the runtime makes, as `half` through -/// an argument buffer, against the nearest even `half` of the same read as `float` and the slot's -/// `half` read: on the M3 Max under macOS 27.0.1 (2026-11-05), none of the 262,144 channels of -/// `BGRA10_XR`, `BGR10_XR`, `R16Bfloat`, `RG16Bfloat` and `RGBA16Bfloat` each differs. An argument -/// buffer's `half` read of a member of another numeric class rounds -/// nothing: its arms merge the texel's `half` bits as integers (`lower::texture::emit`'s -/// `read_crossed`), widened once after the merge as a slot's read widens them, which the gate lane -/// `runtime_lane::cross_class_reads::argument_buffer_cross_class_reads_are_the_native_words` reads -/// against the slot's words: there, the same day, each of its 2,170 lanes is the slot's words, a -/// NaN's bits included. One row per GPU, as measured. -/// -/// `MetalSmallFloatNans`: MoltenVK 1.4.2 hands a storage image write to Metal's own texture -/// write. On the M3 Max under macOS 27.0.1 (2026-11-03), byte for byte against plain Metal, a -/// kernel's `float4` write of 33,792 words (every top-13 payload pattern of a NaN of both signs, -/// 16,384 random words, the quiet and signalling edges and the infinities) and its `half4` write -/// of every one of the 65,536 `half`s (its 2,046 NaNs among them) into `RG11B10Float` store -/// Metal's bytes in every texel, as the same writes do into `RGBA32Float`, `RG32Float` and -/// `R32Float` (a `half` widened by Metal's own `float(half)`, `MetalNanMoves`). Into `R16Float` -/// and `RGBA16Float` a `half` NaN's payload differs (the device stores `0x7e00`), which -/// `MetalHalfTexelWrites` would state, so outside it. One row per GPU, as measured. lavapipe -/// (`MESA_LLVMPIPE`) packs a small float in its shader code, which writes every NaN as the -/// field's quiet NaN with its sign dropped, Metal's: Mesa 26.2.4 on LLVM 23.1.1, x86_64 (an -/// Ultra 9 275HX), through a kernel's `write`, `read_write`, texture buffer and argument buffer -/// forms, stored Metal's field for each of 32,766 `float` NaNs (every pattern of the top 13 -/// payload bits, its 10 low bits clear and set, both signs) and each of the 2,046 `half` NaNs -/// (the gate lanes -/// `runtime_lane::half_storage_writes::every_nan_a_kernel_writes_to_a_small_float_texture_is_metal_s_where_measured` -/// and -/// `runtime_lane::half_write_nans::every_half_nan_written_to_a_small_float_texture_is_metal_s_where_measured`). -/// One row, of the driver on every CPU. Measured to store another NaN, so not listed: RADV on the -/// Radeon 780M (a `half` NaN's payload bits kept) and NVIDIA's 615.71.09 on the RTX 5080 Laptop -/// GPU (every bit of each NaN field set). -/// -/// `MetalUnaryDenormals`: MoltenVK 1.4.2's `OpFNegate`, `FAbs`, `Floor` and `Ceil` on 32-bit -/// floats, which SPIRV-Cross writes as Metal's `-x`, `fabs`, `floor` and `ceil`. On the M3 Max -/// under macOS 27.0.1, against plain Metal's rows: the gate lane -/// `runtime_lane::driver_deviations::float_denormals_read_as_metal_reads_them` checks the -/// denormal probes' (`nan_denormals`, `nan_denormals_fast`: 256 lanes of operand triples rich in -/// denormals of both signs and the smallest normals) words of `-a`, `fabs(a)`, `floor(a)` and -/// `ceil(a)` beside `0 - a` and `-(a * b)`, and -/// `runtime_lane::driver_deviations::owned_float_fixtures_answer_metal` the owned fixtures' -/// `floor` and `ceil` rows of every pair of a 32-value pool; the committed MoltenVK rows of all -/// four cases are Metal's, word for word. NVIDIA's 615.71.09 and lavapipe answer `floor` and `ceil` -/// of a denormal as `-1` and `1`, and RADV and ANV flush a negated denormal, so they are not -/// listed. One row per GPU, as measured. -/// -/// Another driver has none of them, as Vulkan states, and a listed driver on another vendor's GPU -/// (or another GPU than a row's) is unmeasured: the profile then takes each one's route without -/// it, which the deviation's docs name (`derive.rs`). -pub(crate) const DEVIATIONS: &[Measured] = &[ - moltenvk_on_apple(DriverDeviation::SimdgroupLockstep), - moltenvk_on_apple(DriverDeviation::MetalFloatFunctions), - moltenvk_on_apple(DriverDeviation::MetalCanonicalNans), - moltenvk_on_apple(DriverDeviation::MetalSampler), - moltenvk_on_apple(DriverDeviation::CubeGradientRoute), - Measured { - device: Some(APPLE9), - ..moltenvk_on_apple(DriverDeviation::GraphicsCubeGradientTangents) - }, - Measured { - device: Some(APPLE9), - ..moltenvk_on_apple(DriverDeviation::MetalColorWrites) - }, - nvidia_on(DriverDeviation::MetalFloatColorNans, NVIDIA_RTX_3090), - nvidia_on(DriverDeviation::MetalFloatColorNans, NVIDIA_RTX_5080_LAPTOP), - Measured { - device: Some(APPLE9), - ..moltenvk_on_apple(DriverDeviation::MetalHalfFma) - }, - Measured { - fact: DriverDeviation::MetalFloatColorNans, - driver: DriverId::MESA_LLVMPIPE, - vendor: None, - device: None, - }, - Measured { - device: Some(APPLE9), - ..moltenvk_on_apple(DriverDeviation::MetalFloatDenormals) - }, - mesa_on( - DriverDeviation::MetalFloatDenormals, - DriverId::MESA_RADV, - (AMD_VENDOR_ID, AMD_RADEON_780M), - ), - mesa_on( - DriverDeviation::MetalFloatDenormals, - DriverId::INTEL_OPEN_SOURCE_MESA, - (INTEL_VENDOR_ID, INTEL_UHD_770_RPL_S), - ), - mesa_on( - DriverDeviation::MetalFloatDenormals, - DriverId::INTEL_OPEN_SOURCE_MESA, - (INTEL_VENDOR_ID, INTEL_IRIS_XE_RPL_P), - ), - nvidia_on(DriverDeviation::MetalFloatDenormals, NVIDIA_RTX_3090), - nvidia_on(DriverDeviation::MetalFloatDenormals, NVIDIA_RTX_5080_LAPTOP), - Measured { - device: Some(APPLE9), - ..moltenvk_on_apple(DriverDeviation::MetalCenterVaryings) - }, - mesa_on( - DriverDeviation::MetalSmallFloatColorWrites, - DriverId::MESA_RADV, - (AMD_VENDOR_ID, AMD_RADEON_780M), - ), - mesa_on( - DriverDeviation::MetalSmallFloatColorWrites, - DriverId::INTEL_OPEN_SOURCE_MESA, - (INTEL_VENDOR_ID, INTEL_UHD_770_RPL_S), - ), - mesa_on( - DriverDeviation::MetalSmallFloatColorWrites, - DriverId::INTEL_OPEN_SOURCE_MESA, - (INTEL_VENDOR_ID, INTEL_IRIS_XE_RPL_P), - ), - nvidia_on(DriverDeviation::MetalSmallFloatColorWrites, NVIDIA_RTX_3090), - mesa_on( - DriverDeviation::MetalNorm16ColorWrites, - DriverId::MESA_RADV, - (AMD_VENDOR_ID, AMD_RADEON_780M), - ), - Measured { - device: Some(APPLE9), - ..moltenvk_on_apple(DriverDeviation::MetalMinMax) - }, - Measured { - device: Some(APPLE9), - ..moltenvk_on_apple(DriverDeviation::MetalHalfArithmetic) - }, - Measured { - device: Some(APPLE9), - ..moltenvk_on_apple(DriverDeviation::MetalHalfStorageWrites) - }, - Measured { - fact: DriverDeviation::MetalHalfStorageWrites, - driver: DriverId::MESA_RADV, - vendor: None, - device: None, - }, - mesa_on( - DriverDeviation::MetalHalfStorageWrites, - DriverId::INTEL_OPEN_SOURCE_MESA, - (INTEL_VENDOR_ID, INTEL_UHD_770_RPL_S), - ), - mesa_on( - DriverDeviation::MetalHalfStorageWrites, - DriverId::INTEL_OPEN_SOURCE_MESA, - (INTEL_VENDOR_ID, INTEL_IRIS_XE_RPL_P), - ), - nvidia_on(DriverDeviation::MetalHalfStorageWrites, NVIDIA_RTX_3090), - nvidia_on( - DriverDeviation::MetalHalfStorageWrites, - NVIDIA_RTX_5080_LAPTOP, - ), - Measured { - fact: DriverDeviation::MetalHalfStorageWrites, - driver: DriverId::MESA_LLVMPIPE, - vendor: None, - device: None, - }, - Measured { - device: Some(APPLE9), - ..moltenvk_on_apple(DriverDeviation::MetalHalfStorageNans) - }, - Measured { - device: Some(APPLE9), - ..moltenvk_on_apple(DriverDeviation::MetalFragmentSimdgroups) - }, - Measured { - device: Some(APPLE9), - ..moltenvk_on_apple(DriverDeviation::MetalVertexSimdgroups) - }, - Measured { - device: Some(APPLE9), - ..moltenvk_on_apple(DriverDeviation::CenterFragCoordDepth) - }, - mesa_on( - DriverDeviation::SampleFragCoordDepth, - DriverId::MESA_RADV, - (AMD_VENDOR_ID, AMD_RADEON_780M), - ), - mesa_on( - DriverDeviation::MetalHalfTexelWrites, - DriverId::MESA_RADV, - (AMD_VENDOR_ID, AMD_RADEON_780M), - ), - nvidia_on(DriverDeviation::MetalHalfTexelWrites, NVIDIA_RTX_3090), - nvidia_on( - DriverDeviation::MetalHalfTexelWrites, - NVIDIA_RTX_5080_LAPTOP, - ), - Measured { - device: Some(APPLE9), - ..moltenvk_on_apple(DriverDeviation::MetalNormStorageWrites) - }, - mesa_on( - DriverDeviation::MetalNormStorageWrites, - DriverId::MESA_RADV, - (AMD_VENDOR_ID, AMD_RADEON_780M), - ), - mesa_on( - DriverDeviation::MetalDepth16Stores, - DriverId::MESA_RADV, - (AMD_VENDOR_ID, AMD_RADEON_780M), - ), - mesa_on( - DriverDeviation::MetalDepth16Stores, - DriverId::INTEL_OPEN_SOURCE_MESA, - (INTEL_VENDOR_ID, INTEL_IRIS_XE_RPL_P), - ), - mesa_on( - DriverDeviation::MetalDepth16Stores, - DriverId::INTEL_OPEN_SOURCE_MESA, - (INTEL_VENDOR_ID, INTEL_UHD_770_RPL_S), - ), - moltenvk_on_apple(DriverDeviation::MetalDepth16Stores), - moltenvk_on_apple(DriverDeviation::MetalDepth16BiasedStores), - moltenvk_on_apple(DriverDeviation::MetalInterpolation), - moltenvk_on_apple(DriverDeviation::MetalFirstVertexIndices), - Measured { - device: Some(APPLE9), - ..moltenvk_on_apple(DriverDeviation::MetalFullQuads) - }, - Measured { - device: Some(APPLE9), - ..moltenvk_on_apple(DriverDeviation::MetalNormalizedVertexFetch) - }, - Measured { - device: Some(APPLE9), - ..moltenvk_on_apple(DriverDeviation::MetalAlphaCoverage) - }, - Measured { - device: Some(APPLE9), - ..moltenvk_on_apple(DriverDeviation::MetalNanMoves) - }, - Measured { - device: Some(APPLE9), - ..moltenvk_on_apple(DriverDeviation::MetalPackConversions) - }, - Measured { - device: Some(APPLE9), - ..moltenvk_on_apple(DriverDeviation::MetalHalfConversion) - }, - Measured { - device: Some(APPLE9), - ..moltenvk_on_apple(DriverDeviation::MetalSmallFloatNans) - }, - Measured { - fact: DriverDeviation::MetalSmallFloatNans, - driver: DriverId::MESA_LLVMPIPE, - vendor: None, - device: None, - }, - Measured { - device: Some(APPLE9), - ..moltenvk_on_apple(DriverDeviation::MetalUnaryDenormals) - }, -]; - -/// NVIDIA's `vendorID`. -const NVIDIA_VENDOR_ID: u32 = 0x10de; - -/// The `deviceID` of the GeForce RTX 3090. -pub(crate) const NVIDIA_RTX_3090: u32 = 0x2204; - -/// The `deviceID` of the GeForce RTX 5080 Laptop GPU (the committed capture -/// `nvidia-rtx5080-laptop`). -pub(crate) const NVIDIA_RTX_5080_LAPTOP: u32 = 0x2c19; - -/// The row of `fact` measured on NVIDIA's driver on the GPU `device`. -const fn nvidia_on(fact: F, device: u32) -> Measured { - Measured { - fact, - driver: DriverId::NVIDIA_PROPRIETARY, - vendor: Some(NVIDIA_VENDOR_ID), - device: Some(device), - } -} - -/// AMD's `vendorID`. -const AMD_VENDOR_ID: u32 = 0x1002; - -/// The `deviceID` of the Radeon 780M it was measured under, Phoenix's (the committed capture -/// `amd-780m-radv`); Hawk Point's 0x1900 is the same GPU, so it takes these rows too -/// ([`DeviceDescription::canonical_device_id`]). -pub(crate) const AMD_RADEON_780M: u32 = 0x15bf; - -/// The `deviceID` of the Radeon RX 7900 XTX (Navi 31) its rows were measured on, under RADV. -pub(crate) const AMD_RX_7900_XTX: u32 = 0x744c; - -/// The `deviceID` of the Radeon RX 550 (Polaris 12) its rows were measured on, under RADV. -pub(crate) const AMD_RX_550: u32 = 0x699f; - -/// The `deviceID` of the Intel UHD Graphics 770 of Raptor Lake-S (the committed capture -/// `intel-uhd770-rpls-anv`). -pub(crate) const INTEL_UHD_770_RPL_S: u32 = 0xa780; - -/// The `deviceID` of the Intel Iris Xe Graphics of Raptor Lake-P (the committed capture -/// `intel-irisxe-rplp-anv`). -pub(crate) const INTEL_IRIS_XE_RPL_P: u32 = 0xa7a0; - -/// The row of `fact` measured on Mesa's `driver` on the GPU `(vendor, device)`. -const fn mesa_on(fact: F, driver: DriverId, (vendor, device): (u32, u32)) -> Measured { - Measured { - fact, - driver, - vendor: Some(vendor), - device: Some(device), - } -} - -/// The `deviceID` MoltenVK 1.4.1 reports for an Apple GPU of the Apple9 family under macOS 27: the -/// Apple M3 Max's (the committed capture `moltenvk-m3`, 26A434), and an M4's alike. On an Apple GPU -/// MoltenVK's `deviceID` is not the GPU's: it is the macOS version and the GPU's highest families, -/// `(major << 24) + (minor << 16) + (Mac family << 8) + Apple family` -/// (`MVKPhysicalDevice::getHighestGPUCapability`, MoltenVK 1.4.1), so every GPU of a family on one -/// macOS release has one identity. The rows of this identity were measured under macOS 27, the -/// release the MoltenVK venue runs: a fact that decides an answer on both GPUs, a cost fact on the -/// M3 Max or the M4 alone. -pub(crate) const APPLE9: u32 = 0x1B00_0209; - -/// The row of `fact` measured on MoltenVK on Apple's GPUs. -const fn moltenvk_on_apple(fact: F) -> Measured { - Measured { - fact, - driver: DriverId::MOLTENVK, - vendor: Some(APPLE_VENDOR_ID), - device: None, - } -} - -/// Every measured driver defect translation works around or refuses (`Needs::DriverDefect`), and -/// every measured answer a module records as a precision note, at every release of its driver and -/// never of another driver. -/// - `BothBarycentricFormsRejected`: MoltenVK 1.4.1 (`driverVersion` 10401, SPIRV-Cross -/// `adec7acb`) refused `tail_fragment_barycentric` (`engine/stage_io_tail`) at pipeline -/// creation on an Apple M4. SPIRV-Cross throws in its MSL backend's interface -/// pass whatever the GPU, so the row names no vendor. -/// - `MemoryWritingFragmentsRunPerSample`: MoltenVK 1.4.1 on the Apple M3 Max and the M4 ran the -/// loop over the covered samples of a memory-writing fragment shader without sample shading once -/// per covered sample, every pass repeated per covered sample. Metal runs a function that writes -/// memory once per covered sample; the row names Apple's GPUs, where that was measured. -/// - `InterpolationNeedsTheWholeQuad`: RADV on the Radeon 780M, Mesa 26.0.8 (Ubuntu's) and 26.2.4 -/// (Arch's), read garbage through `InterpolateAtSample`, and through `InterpolateAtOffset` at a -/// nonzero offset, in control flow the helper invocations of the pixel's quad had left (a bare -/// Vulkan program; the RTX 3090 and ANV answered every variant right). The row names no vendor: -/// RADV runs only AMD's GPUs. -/// - `PerspectiveReadsExtrapolated`: RADV on the Radeon 780M, Mesa 26.2.6 (Arch's), answered -/// `runtime_lane::pull_model_interpolation`'s perspective reads at a sample or an offset as the -/// pixel center's value extrapolated along the quad's coarse derivatives: a model of that form, -/// from the lane's geometry, gave each of the 1113 values off Metal's within 0.005, and the -/// form with fine derivatives was up to 0.98 off. The row names no vendor: RADV runs only AMD's -/// GPUs. -/// - `MeshIndexComponentStoresMisplaced`: lavapipe, Mesa 26.0.8 (Ubuntu's, x86, the Linux gate's), -/// drew none of `runtime_lane::mesh_draws`'s triangles, whose indices the mesh function writes -/// one at a time. The row names no vendor: the defect is the driver's -/// compiler, whatever CPU it runs on. -/// - `CompositeInsertsWrittenInPlace`: MoltenVK 1.4.1 (SPIRV-Cross `adec7acb`) on the Apple M3 Max -/// and the M4 wrote an insert into a vector defined before a loop in place in the loop, so the -/// next iteration read the inserted element. SPIRV-Cross does this in its MSL conversion whatever -/// the GPU, so the row names no vendor. -/// - `FunctionsInlinedAtEveryCall`: MoltenVK 1.4.1 (SPIRV-Cross `adec7acb`) wrote every function of -/// a module `always_inline`, its `DontInline` routines included, on the Apple M3 Max and the M4. -/// SPIRV-Cross does this in its MSL conversion whatever the GPU, so the row names no vendor. -/// - `LoadsForwardedIntoLoops`: MoltenVK 1.4.1's SPIRV-Cross (`adec7acb`, the pinned converter of -/// `scripts/moltenvk-msl-helper`) wrote a value loaded before a loop into the loop's text, after -/// which a store in the loop changed what the next iteration read (a synthetic module of our -/// own). The converter does this whatever the GPU, so the row names no vendor. -/// - `LocalizedLoadsForwardedPastAtomicsAndCalls`: MoltenVK 1.4.1 on the Apple M3 Max and the M4 -/// ran authored case `8b812530` wrong, its MSL reading a threadgroup counter after the atomics -/// that overwrite it, where the module reads it before; the `spirv-cross` CLI does the same for -/// synthetic modules of our own past an atomic and past a call. The converter does this whatever -/// the GPU, so the row names no vendor. -/// - `VertexGroupingNotApples`: ANV on Mesa 26.2.4, on the Iris Xe of the Intel venue, ran the -/// vertex fixtures `rvc_simd_vertex` and `rvc_simd_vertex_fill` in subgroups -/// of 8 interleaved vertices, where the Apple M4 groups 32 consecutive ones. The row names no -/// vendor and no device: ANV runs only Intel's GPUs, and the row only makes a vertex function of -/// simdgroup operations record `PrecisionNote::VertexSimdgroupGrouping`, so on a GPU not measured -/// it announces a difference rather than hides one. -/// - `DontInlineKeepsCalls`: NVIDIA's 615.71.09 on the RTX 3090 kept a call of a `DontInline` -/// sample emulation a call, creating a fragment of 256 such calls in 0.39 to 0.40 s against 10.1 -/// to 10.2 s for the same routine without the control, as it kept the linear sums declared so -/// (the RTX 3090). A cost fact: it only chooses between two exact encodings, so a release or GPU -/// not measured loses nothing by going without it and gains no reason to assume it. The same -/// release on the RTX 5080 Laptop GPU made a guest fragment's pipeline under the exact sampling -/// and arithmetic forms (`scripts/making-bench`, cold, its anisotropic emulation one sampling -/// routine) in 22.6 to 22.9 s with each sampling routine `DontInline` and in 45.8 to 54.7 s -/// without, and its linear sampler's pipeline in 8.9 to 11.9 s against 14.8 to 14.9 s, drawing in -/// 0.32 against 0.43 ms. Its rows name those two GPUs, the GPUs measured; another NVIDIA GPU -/// takes it once measured. -/// - `FloatDenormalsKeptUnderHalfControls`: NVIDIA's 615.71.09 on the RTX 5080 Laptop GPU and -/// 620.70.06 on the RTX 3090 kept `f32` denormals in an entry declaring the 16-bit float -/// controls, where their `MetalFloatDenormals` rows' probes, which declare no float-controls -/// mode, read them as Metal does: the gate lane -/// `runtime_lane::driver_deviations::fused_pairs_answer_metals_nans_and_denormals` (2026-11-14, -/// at 400efe7932), 33 of 4,096 words of each of its two fixtures. RADV, Mesa 26.2.6 on the -/// Radeon 780M (Phoenix and Hawk Point), answered every word of both as Metal's under the same -/// modes, so it is not listed. One row per GPU, the GPUs NVIDIA's `MetalFloatDenormals` rows -/// name. -/// - `PushReadsLengthenThreadPayload`: ANV, Mesa 26.2.6 on the Iris Xe of RPL-P, ran -/// `dispatch_chain`'s one-word kernel (4480 threadgroups of 256, 200 dispatches a command -/// buffer, 9 interleaved rounds, medians) over a plain allocation in 55.73 us a dispatch, and the -/// runtime's own module of it in 120.24 us (job m3-max-34063); with the module's one push read, -/// its storage view's `SlotBindOffset` residual, replaced by a constant 0 it ran in 55.69 us, -/// and without its `Aliased` or its specialized-away barrier in 120.24 and 120.17 us. Pushing -/// the runtime's 36 bytes of push constants to the plain kernel, which reads none, ran in -/// 55.68 us, and the runtime's module on the plain kernel's device in 120.19 us (job -/// m3-max-34038). Both modules' loads and stores are the same `untyped_read` and -/// `untyped_write` of binding table entry 1 (job m3-max-33825). A cost fact: it only chooses -/// between two exact encodings. RADV, Mesa 26.2.6 on the Radeon 780M, ran the runtime's form and -/// the plain one alike (109.6 and 109.1 to 114.1 us, job m3-max-34031), so it is not listed; the -/// row names the GPU measured. -/// Where the row holds, a state's creation makes two forms of its predicted key: the one that -/// reads its storage views at their bind offsets, which a command binding them at offset 0, the -/// commonest bind, takes, and its general form, which one binding a storage view elsewhere takes -/// at once; with the general form alone, every state's first command at offset 0 made a second -/// pipeline. -pub(crate) const DEFECTS: &[Measured] = &[ - Measured { - fact: DriverWorkaround::BothBarycentricFormsRejected, - driver: DriverId::MOLTENVK, - vendor: None, - device: None, - }, - moltenvk_on_apple(DriverWorkaround::MemoryWritingFragmentsRunPerSample), - Measured { - fact: DriverWorkaround::InterpolationNeedsTheWholeQuad, - driver: DriverId::MESA_RADV, - vendor: None, - device: None, - }, - Measured { - fact: DriverWorkaround::PerspectiveReadsExtrapolated, - driver: DriverId::MESA_RADV, - vendor: None, - device: None, - }, - Measured { - fact: DriverWorkaround::MeshIndexComponentStoresMisplaced, - driver: DriverId::MESA_LLVMPIPE, - vendor: None, - device: None, - }, - Measured { - fact: DriverWorkaround::CompositeInsertsWrittenInPlace, - driver: DriverId::MOLTENVK, - vendor: None, - device: None, - }, - Measured { - fact: DriverWorkaround::FunctionsInlinedAtEveryCall, - driver: DriverId::MOLTENVK, - vendor: None, - device: None, - }, - Measured { - fact: DriverWorkaround::LoadsForwardedIntoLoops, - driver: DriverId::MOLTENVK, - vendor: None, - device: None, - }, - Measured { - fact: DriverWorkaround::LocalizedLoadsForwardedPastAtomicsAndCalls, - driver: DriverId::MOLTENVK, - vendor: None, - device: None, - }, - Measured { - fact: DriverWorkaround::VertexGroupingNotApples, - driver: DriverId::INTEL_OPEN_SOURCE_MESA, - vendor: None, - device: None, - }, - nvidia_on(DriverWorkaround::DontInlineKeepsCalls, NVIDIA_RTX_3090), - nvidia_on( - DriverWorkaround::DontInlineKeepsCalls, - NVIDIA_RTX_5080_LAPTOP, - ), - nvidia_on( - DriverWorkaround::FloatDenormalsKeptUnderHalfControls, - NVIDIA_RTX_3090, - ), - nvidia_on( - DriverWorkaround::FloatDenormalsKeptUnderHalfControls, - NVIDIA_RTX_5080_LAPTOP, - ), - mesa_on( - DriverWorkaround::PushReadsLengthenThreadPayload, - DriverId::INTEL_OPEN_SOURCE_MESA, - (INTEL_VENDOR_ID, INTEL_IRIS_XE_RPL_P), - ), -]; - -/// The defects translation works around on the driver `description` names, on its GPU. -pub(crate) fn defects(description: &DeviceDescription) -> BTreeSet { - among(DEFECTS, description.driver_id, identity(description)) -} - -/// The deviations of the driver `description` names, on its GPU. -pub(crate) fn deviations(description: &DeviceDescription) -> BTreeSet { - among(DEVIATIONS, description.driver_id, identity(description)) -} - -/// The `vendorID` and the `deviceID` the tables name `description`'s GPU by. -fn identity(description: &DeviceDescription) -> (u32, u32) { - (description.vendor_id, description.canonical_device_id()) -} - -/// 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] -#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] -pub enum DriverFact { - /// Under `robustBufferAccess2`, an index fetched past the bound index buffer range reads - /// zero, to which the draw adds its vertex offset: Metal's answer past the buffer (which finds - /// no value stated). An indexed indirect draw, whose positions its arguments choose on the GPU, - /// stays a single indirect draw on such a driver, its bound range ending where Metal's fetch - /// stops (`draw_source.rs`); elsewhere the index bounds pass draws it (`index_bounds.rs`). - RobustIndexFetchReadsZero, - /// A `D32_SFLOAT` image keeps each denormal value a copy writes into it, as Metal's - /// `Depth32Float` texel keeps any `float`. Vulkan states no such rule, and RADV's and ANV's - /// depth images answer a denormal as zero (RADV's of its sign), to a copy out of them and, on - /// RADV, to the shader's reads. A clear to a denormal and a copy from a buffer keep it too on - /// such a driver; RADV and ANV store either as a zero, and keep only a host copy's - /// (`replace_region` on the host), so a write on the GPU that may store a denormal there - /// announces `depth-denormals`. - DepthImageKeepsDenormals, - /// A fragment shader's `FragDepth` is stored in a 32-bit float depth attachment unchanged: - /// each value in `[0, 1]` it is given, and, for the rest, the value it stored when given it - /// again. Vulkan states the stored value only inside the depth range. A multisampled depth - /// is copied, where maintenance8's depth/colour copies are missing or wrong, by a draw that - /// writes each sample's fetched depth as its fragment depth on such a driver - /// (`depth_copy.rs`); elsewhere such a copy is refused, typed. - FragmentDepthStoresUnchanged, - /// A depth or stencil image lies in memory of its own, not in the memory it is bound to, - /// where Vulkan places a bound image in its memory. Metal places a heap's depth or stencil - /// texture in the heap's bytes, so on such a driver that texture aliases none of the heap's - /// other resources: a write through a buffer or texture over its bytes changes none of its - /// texels, and its own writes change none of their bytes. Its placement, size and texels are - /// Metal's otherwise. The runtime announces `heap-depth-stencil-apart` when it makes one in a - /// heap. - DepthStencilImagesLieApart, - /// A render pass's `AVERAGE` resolve of a multisampled colour attachment of 2 or 4 samples - /// writes Metal's measured resolve: unorm's `(sum + n/2) / n`, snorm's - /// `floor((2·sum + n) / 2n)`, sRGB's mean of 12-bit linear values encoded by Metal's - /// thresholds, and `float`'s flushed sequential sum times `1/n` (the rules - /// `runtime_lane::resolve_rounding` measures each driver's average against). Vulkan leaves the - /// average's rounding to the implementation. The runtime resolves every colour attachment but - /// an extended-range one and one resolving into its format's sRGB twin by the device's average - /// on every driver, a fetching pass's sample planes merged back first; where the fact does not - /// hold, and at 8 samples or more, it announces it (`device-rounded-resolve`, - /// `color_resolve.rs`). - /// The fact holds for every colour format the driver resolves, those without a rule above too - /// (half floats, packed 16-bit, `RG11B10Float`, `RGB9E5Float`): MoltenVK 1.4.1 - /// resolves a subpass's colour attachment by Metal's own multisample resolve store action - /// wherever the Metal pixel format resolves (`kMVKMTLFmtCapsResolve`, which every one of these - /// formats has on Apple's GPUs), so its average is Metal's resolve by construction. The - /// runtime announces no `device-rounded-resolve` for such an attachment on a driver with it. - ColorResolveAverageIsMetals, - /// A render pass's `CLEAR` load operation of a colour attachment its render area covers stores - /// the texel Metal's own `Clear` load action stores for the clear colour: MoltenVK hands the - /// operation to Metal as the attachment's load action wherever the render area covers the - /// attachment, the clear value's floats as Metal's clear colour, and Metal's conversion of a - /// clear colour takes its `float` first. Vulkan lets a clear store either of the two codes - /// closest to a normalized channel's scaled value and leaves its sRGB encode and a float's - /// rounding to the device, so elsewhere a clear whose rounding is in question (a normalized - /// channel's value off a whole code among them) is announced (`device-color-conversion`, - /// `render_pass.rs`). The driver's clear command (`vkCmdClearColorImage`) of a whole level and - /// layer with the same clear value stores the same texel. On a driver with it the runtime - /// announces none for a clear by the load operation of an attachment the pass's render area - /// covers, nor for the same clear made by the clear command (an attachment the pass's first - /// instance leaves out, cleared before the pass; a memoryless attachment's backing; the copy a - /// draw after a memory barrier at the pass's start reads, `texture/attached_reads.rs`), and - /// announces it for the same clear made otherwise (a render pass of the attachment alone, or - /// its sample planes). Measured by - /// `runtime_lane::renders::clears_are_the_device_s_conversion_of_the_clear_value`, which on - /// such a driver also holds that the note stays unannounced: MoltenVK 1.4.2 on the M3 Max under - /// macOS 27.0.1, each of the 71 colour clears Metal was measured with (ties of 8-bit, 10-bit - /// and 16-bit unorm and snorm channels, sRGB channels, the packed 16-bit formats, half and - /// small floats, shared exponents and NaNs among them) into a 1x1 attachment, its 11 depth and - /// 4 stencil clears beside them: all 86 texels Metal's bytes, none a code apart; and each of - /// the 71 by the clear command of the load operation's clear value over the whole 1x1 texture - /// (a plain fill of it): all 71 Metal's bytes. - ColorClearIsMetals, - /// An optimal colour image may keep its compression state apart from the memory it is bound - /// to, so a write through a buffer or another image over its bytes can leave its texels as - /// they were. Vulkan leaves an optimal image's texels undefined after such a write; Metal's - /// heap texture shows it (every texel the texture reads changes). On such a driver a heap's - /// texture takes host-transfer usage where the driver has - /// [`DriverFact::HostTransferImagesKeepTheirBytes`], else a linear image where one serves, - /// else its optimal image, announced (`heap-texture-hides-aliased-writes`). - CompressedImagesHideAliasedWrites, - /// An optimal image of `VK_IMAGE_USAGE_HOST_TRANSFER_BIT` usage keeps its texels in the - /// memory it is bound to: a write through a buffer over its bytes changes every texel it - /// covers. Vulkan states no such rule; on such a driver the heap textures that - /// [`DriverFact::CompressedImagesHideAliasedWrites`] concerns take that usage. - HostTransferImagesKeepTheirBytes, - /// A command's use of an image misses what a command recorded before it in the same - /// `VkCommandBuffer` wrote through a buffer over the image's memory, though a global memory - /// barrier orders the two: a copy out of the image reads its texels as they were. Vulkan - /// defines the result: a buffer and a linear image in `GENERAL` over the same memory are - /// host-accessible aliases, and a memory dependency between two uses makes the earlier write - /// visible to the later. The same two commands in two `VkCommandBuffer`s, the barrier between - /// them, answer as Vulkan says. On such a driver the runtime records such a use in a new - /// `VkCommandBuffer` (`alias_split.rs`), counted by - /// `WorkCounts::command_buffers_split_at_aliases`. - ImageUsesMissBufferWritesInOneCommandBuffer, - /// A depth or stencil image is laid out as Metal lays out its texture with - /// `allowGPUOptimizedContents` on, compression metadata included, whatever the image's create - /// info: no Vulkan request drops the layout, where the image's size is Metal's texture's. - /// Vulkan leaves an image's layout and size to the driver. Metal's depth and stencil texture - /// with the property off takes no metadata, so on such a driver a depth or stencil texture - /// with it off answers a larger heap size than Metal's, and the runtime announces - /// `optimized-depth-stencil-texture` when it sizes one or makes one in a heap. - DepthStencilImagesStayGpuOptimized, - /// A fragment shader's `FragDepth`, given the depth a sample of a `D16_UNORM` depth aspect - /// fetches as, is stored in a `D16_UNORM` attachment as that sample's code, for every code: - /// the fetch's conversion to `float` and the attachment's back are each other's inverse. - /// Vulkan leaves both conversions' rounding to the device. A multisampled `Depth16Unorm` - /// depth is copied, where maintenance8's depth/colour copies are missing or wrong, and its - /// `Min` or `Max` resolve drawn where the device has no such mode, by draws that write each - /// fetched depth as its fragment depth on such a driver (`depth_copy.rs`), as a 32-bit float - /// depth's are by [`FragmentDepthStoresUnchanged`](Self::FragmentDepthStoresUnchanged); - /// elsewhere such a copy or resolve is refused, typed. - FragmentDepthKeepsDepth16Codes, - /// A sampled view's fetch of a unorm or snorm format of 1 to 16 bits a channel, or of a - /// 16-bit float format, returns for every code a value from which the mipmap filter's - /// recovery reads that code back: a unorm code `c` of `b` bits as a `float` within half a - /// step of `c / (2^b - 1)`, a snorm one of `c / (2^(b-1) - 1)`, a half as its own value - /// (`bind::MipmapFilterChain::plan`'s `fetch`). Vulkan states no precision for these - /// conversions. On a driver with it `generate_mipmaps` reads a texture's first level in place - /// through such a view (`mipmap_filter.rs`); elsewhere it copies the level into its scratch - /// buffer first. The integer carriers of the extended-range formats are read in place on - /// every driver: their fetch returns the bits. - SampledFetchRecoversCodes, - /// A cost fact (the module docs): a render pass whose draws fetch a color through the pixel - /// interlock after plain draws wrote it ran no slower split into two render pass instances - /// there, as the runtime runs it on every device, than kept whole, the plain draws writing the - /// color through the interlocked storage form (`VariantKey::interlocked_colors`). On a driver - /// with it the runtime announces no `render-pass-split`, nor `memoryless-backed` for the - /// split, where the interlock's attachments alone split a pass: the device's faster form. - /// Elsewhere such a split is announced. - InterlockedPassSplitNoSlower, - /// A cost fact (the module docs): a render pass ran no slower with a `CLEAR` load of an - /// attachment it does not store (a colour and a depth/stencil, stored `DONT_CARE`) than with - /// a `DONT_CARE` load. Metal's draws read zero (a colour) or the clear value (depth, stencil) - /// of an attachment the pass loads `DontCare` and does not store, wherever they read it, where - /// Vulkan's `DONT_CARE` leaves the contents undefined. On a driver with it the runtime clears - /// such an attachment under `UnstoredDontCarePolicy::Driver`, the default, Metal's answer at - /// no cost; elsewhere it leaves it `DONT_CARE` and announces `dont-care-unstored-load` - /// (`clear_reach.rs`). - UnstoredClearNoSlower, - /// A driver diagnostic (the module docs): the driver reports a warning as it creates a - /// graphics pipeline that makes the primitive restart dynamic with its topology dynamic or a - /// strip or fan, whatever restart the draws set later: a `VALIDATION` message named - /// `mvk-warn` (number 0), `VK_ERROR_FEATURE_NOT_PRESENT: Metal does not support disabling - /// primitive restart.` ([`DriverFact::pipeline_creation_diagnostics`]). MoltenVK reports it so - /// wherever it is built without Metal's private API, Homebrew's build included - /// (`MVKPipeline.mm` lines 881-893 at 1.4.1), because Metal restarts every strip. The runtime - /// makes the restart dynamic only with the topology, and each draw sets the restart Metal - /// applies (on for a strip, off for a list, which Metal never restarts), so the warning reports - /// nothing the draws do: measured on the Apple M4 by `runtime_lane::restart` and - /// `runtime_lane::made_at_creation` (at 41d0f054f, 25 reports, every one at - /// such a pipeline's creation). On a driver with it the runtime withholds exactly that message - /// from the device's message sink inside that pipeline's creation, and counts it - /// (`WorkCounts::driver_diagnostics_withheld`); any other message, and this one anywhere else, - /// relay as before. MoltenVK's own code on every GPU, so the row names no vendor. - 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 render pass's attachment stored `DONT_CARE` is stored as Metal's own `DontCare` on the - /// same GPU, `MultisampleResolve` where it resolves in the subpass: MoltenVK hands the - /// operation to Metal (`MVKAttachmentDescription::getMTLStoreAction` at 1.4.1) wherever it - /// renders the attachment's whole framebuffer in its last subpass and does not restart the - /// Metal pass inside the subpass, which it does at a barrier there whose destination reads - /// input attachments, a tessellated draw, sample positions that change between draws, and an - /// indirect draw of views; at each such point it stores the attachment instead. Apple's GPU - /// keeps the attachment's earlier texels unless its tiler overflows, and a pass that clears it - /// and draws nothing before `MultisampleResolve` leaves the clear where Metal compresses the - /// texture. Vulkan leaves the attachment's contents undefined. On a driver with it the runtime - /// announces no `dont-care-store` for a pass recorded as one render pass instance in which it - /// records none of those (`Device::degrade_pass`). MoltenVK's code decides it. Measured on the - /// M4 and the M3 Max. - DontCareStoreIsMetals, - /// A cost fact (the module docs): the driver samples each `vkCmdWriteTimestamp` in a Metal - /// blit pass of its own, which waits for the work before it and writes a byte of one buffer - /// the whole device shares (`MVKCommandEncoder::encodeTimestampStageCounterSamples` at - /// 1.4.1, on Apple's GPUs, which sample only at a pass's boundaries). Metal's hazard tracking - /// orders every pass that writes that buffer, so a command buffer's timestamps wait for every - /// queue's earlier timestamped work, where Vulkan orders nothing between queues: a 256-byte - /// fill on a queue of another family completed only when a 27 ms dispatch did, in 37 to 40 - /// rounds of 40, and in about 0.25 ms without timestamps (an M4; our upstream draft). Each - /// command buffer's two timestamps also cost it about 150 us of latency, against about 15 us - /// for a bare submission (the runtime lane's `commit_costs`; on the consumer's M3 Max a - /// one-fill command buffer completed 283 to 309 us after its commit without them, 356 to 399 - /// us with them). On a driver with it the runtime answers command buffers' GPU times from the - /// host's clock and writes no timestamps (`gpu_time.rs`, announced once as - /// `gpu-times-from-host`); elsewhere it writes them unless told otherwise. MoltenVK's own code - /// on Apple's GPUs. - TimestampsWaitForEveryQueue, - /// The driver decodes each texel of a BC1 to BC3 texture (`BC1_RGBA`, `BC2_RGBA`, - /// `BC3_RGBA`) to Metal's value, and each texel of their sRGB forms to Metal's code before - /// its sRGB step (which the device's sRGB view then decodes, `PrecisionNote::SrgbTexelDecode`): - /// Vulkan leaves the decode's arithmetic to the - /// implementation. Metal's (an Apple M4, every texel of random blocks of the fourteen BC - /// formats read): each endpoint widened by replicating its bits, the index's - /// weight of 64 (BC7's: 21 and 43 for the thirds, 9 to 55 for BC3's alpha's sevenths, 13 to - /// 51 for its fifths, 32 for BC1's half) summed as `(64 - w) a + w b` and rounded half up to - /// 8 bits; BC2's alpha its 4-bit code times 17. NVIDIA's 615.71.09 (the RTX 3090 and the RTX - /// 5080 Laptop GPU) answers channels up to 4/255 off (BC3's alpha 6/255; the 5080's 6-bit - /// green 4/255 at 961b1ff319, its other channels 3/255), ANV up to 1/255, lavapipe 3/255. On a driver without it a texture of such a format announces - /// `compressed-texel-decode` where the runtime makes it, and its reads, samples and gathers - /// are the device's decode of its own BC image: the runtime keeps no decoded twin of a BC - /// texture. - ColorBlockDecodeIsMetals, - /// The driver decodes each texel of a BC4 or BC5 texture (`BC4_RUnorm` to `BC5_RGSnorm`) to - /// Metal's value. Metal's (an Apple M4): the index's weight of 64 as for - /// BC3's alpha, the sum `(64 - w) a + w b` unrounded, `sum / 16320` (signed `sum / 8128`, - /// an endpoint of -128 summed as it is and the value clamped to -1 after), the six-value - /// constants 0 and 1 (signed -1 and 1), each correctly rounded to `float`. NVIDIA's 615.71.09 - /// answers up to 7.4/255 off (signed 0.065), ANV 1.3/255 (signed 0.013), lavapipe 2.4/255 - /// (signed 0.022), and RADV (Mesa 26.2.4, the Radeon 780M) clamps an endpoint of -128 to -127 - /// before the sum (signed up to 1.7/255 off) and rounds some unsigned values a `float` ulp - /// off. On a driver without it a texture of such a format announces - /// `compressed-texel-decode` where the runtime makes it, its texels the device's decode of its - /// own BC image. - ChannelBlockDecodeIsMetals, - /// A depth image a pass rendered at custom sample positions (made with - /// `VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT`, held in `GENERAL`) answers a - /// shader's read of each sample with the depth at the standard positions, and a later pass - /// at other positions that loads it compares and keeps the depth at its own positions: the - /// driver keeps the triangle's depth as its plane and evaluates the plane where the reader's - /// positions lie. The pass's own depth test compares at the custom positions, and a copy - /// (`vkCmdCopyImage`) recorded after the pass keeps each sample's depth at them. Vulkan's - /// image in `GENERAL` keeps what the pass stored (a layout transition alone takes the - /// locations, `VkSampleLocationsInfoEXT`), and Metal keeps each sample's depth at its - /// position. Transitions to and from `DEPTH_STENCIL_READ_ONLY_OPTIMAL`, - /// `SHADER_READ_ONLY_OPTIMAL`, `TRANSFER_SRC_OPTIMAL` and `DEPTH_STENCIL_ATTACHMENT_OPTIMAL` - /// right after the pass, with and without the locations, change none of it. On a driver with - /// it a depth/stencil attachment at custom positions renders through the stand-in, made with - /// the flag, copied in where the pass loads it and back where it stores it - /// (`attachment_stand_in.rs`), announced as `positions-through-scratch`; elsewhere its own - /// image renders them. - PositionedDepthReadAtStandardPositions, - /// The depth test compares a denormal a `D32_SFLOAT` image holds as Metal's does: a positive - /// one above zero, a negative one not below zero (a fragment at depth 0 passes `Less` - /// against a stored positive denormal and fails `Greater` against a stored negative one). - /// Vulkan states no such rule: NVIDIA's, ANV's and lavapipe's depth tests compare a stored - /// positive denormal as zero, and RADV's a stored negative one (and a stored -0) below zero. - /// On a driver without it a write that may store a denormal in a 32-bit float depth image - /// announces `depth-denormals`. - DepthTestKeepsDenormals, - /// The depth test compares a fragment's depth with the value a `D32_SFLOAT` image holds as - /// Metal's does: by magnitude, as the integers of their low 31 bits, so the sign is dropped - /// and a NaN orders above +inf (a fragment at 0.5 passes `Equal` against a stored -0.5). - /// Vulkan compares the stored value as it is. On a driver whose depth test is a Metal GPU's - /// own (MoltenVK) it holds by construction: the pass's depth test is Metal's test of a - /// `Depth32Float` texture on that GPU, which gives that GPU's Metal answer, and its pass - /// stores what Metal's stores (a pass with depth writes stores each texel it leaves without - /// its sign) wherever a draw hands it a state with depth writes. On a driver with it a write - /// that may store a negative value or a NaN in a render target's depth announces nothing, and - /// a pass that sets such a state but draws under none, which keeps the signs, announces - /// `signed-depth-test`; elsewhere such a write announces it. - DepthTestComparesMagnitudes, - /// The device's first sparse resource's creation (`vkCreateImage` or `vkCreateBuffer` with - /// `SPARSE_BINDING`) waits for the work submitted before it on every queue: ANV through - /// TR-TT (Intel's `i915` kernel driver) sets its translation tables up there with a batch on - /// each queue and waits for them (`anv_trtt_first_bind_init`, Mesa 26.2.4), and each batch - /// runs after its queue's earlier work. Vulkan orders no creation with queue work, and Metal - /// makes a sparse texture without waiting for the GPU. On a driver with it the runtime - /// announces `first-sparse-resource-wait` where it makes the device's first sparse texture. A - /// cost fact. - FirstSparseResourceWaitsForQueues, - /// The driver decodes each texel of a BC6H texture (`BC6H_RGBFloat`, `BC6H_RGBUfloat`) to - /// Metal's value. Direct3D specifies BC6H's decode bit for bit, but Vulkan leaves a - /// compressed format's decode to the implementation, so it is measured, not assumed. On a - /// driver without it a texture of such a format announces `compressed-texel-decode` where - /// the runtime makes it: the runtime has no decoded twin of BC6H. - Bc6hBlockDecodeIsMetals, - /// The driver decodes each texel of a BC7 texture (`BC7_RGBAUnorm`, and `BC7_RGBAUnorm_sRGB` - /// to Metal's code before its sRGB step, which the device's sRGB view then decodes) to Metal's - /// value. lavapipe (Mesa 26.0.8) answers some a `float` ulp off. On a driver without it a - /// texture of such a format announces `compressed-texel-decode` where the runtime makes it: - /// the runtime has no decoded twin of BC7. - Bc7BlockDecodeIsMetals, - /// Each timestamp query pool the driver makes is one Metal counter sample buffer - /// (`MVKTimestampQueryPool`, `MVKQueryPool.mm` at 1.4.1), of at most 4096 timestamps, and - /// Metal keeps at most 32 of those live per GPU (through MoltenVK 1.4.1 on an M3 Max and an - /// M4: the 33rd pool failed, as did a pool of 8192), so every pool a device holds is one - /// fewer for another device on the GPU. Vulkan sets no such limit. A defect fact: on a driver - /// with it the device makes one pool of 4096 timestamps, never more, where elsewhere it adds - /// a pool as its command buffers in flight fill the ones it has (`gpu_time.rs`). - TimestampPoolsAreCounterSampleBuffers, - /// A render pass's attachment stored `DONT_CARE` keeps, at each texel, either its texel from - /// before the pass or the texel the same pass stores with `STORE`: one of the two answers - /// Metal's `DontCare` and `MultisampleResolve` give on Apple's GPUs (the earlier texel, or - /// the stored one where its tiler overflows), never a third. Vulkan leaves the contents - /// undefined, and NVIDIA's 615.71.09 on the RTX 3080 left the pass's clear color in 1984 of - /// 16384 texels of a pass that cleared, drew over them and stored `DONT_CARE`. On a driver with - /// it, or with [`DriverFact::DontCareStoreIsMetals`], the runtime hands Metal's `DontCare` to - /// the driver as `DONT_CARE`; on every other it stores the attachment with `STORE`, the stored - /// answer (`render_target.rs`), and both announce `dont-care-store`. - DontCareStoreIsOneOfMetals, - /// A cost fact (the module docs): the driver runs `vkCmdCopyImageToBuffer` from an optimally tiled - /// color image into a buffer's rows slower than a compute dispatch that fetches the texels through - /// an unsigned-integer view of the image and stores their words. Measured on ANV, Mesa 26.2.4 on - /// the Iris Xe of RPL-P (2026-10-15, a probe of one pass a frame over a - /// 1307x512 `BGRA8Unorm` tile over guest pages with rows of 5248 bytes, 60 frames, three rounds - /// within 3 us of each other): a pass that loads, draws and stores took 1319 us of GPU time with - /// the copy back and 972 us with the dispatch, one half-scissored 742 and 575 us, and one that - /// stores nothing (the mutable shadow's cost alone) 500 and 513 us. On the UHD 770 of RPL-S (a - /// pass a frame over a 1920x1080 `BGRA8Unorm` shadow over anonymous pages, six rounds, GPU time - /// the rounds' median), a pass that loads, draws and stores took 1.68 ms with the dispatches - /// against 1.81 ms with the copies, one that clears 1.04 against 1.14 ms, and one drawn in a - /// centred region of half the width and height 446 against 476 us. The driver's copy cost, so - /// the row names no GPU: it holds on every GPU of ANV. On a driver - /// with it a shadowed texture's copy back is such a dispatch (`shadow_copy_back.rs` in the - /// runtime), and so is a merge's copy of the shadow into its scratch before the commands - /// (`shadow_merge.rs`), its shadow made `MUTABLE_FORMAT` with that view, through which the - /// merge reads the texels the commands left: the same bytes either way, as Vulkan states a - /// compatible view reads a texel's bits unchanged. Measured no faster, so not listed: RADV, - /// Mesa 26.2.4 on the Radeon 780M (whose passes over a mutable shadow took 84 to 150 us longer - /// a frame) and 26.0.8 on the Radeon 780M and the Radeon RX 7900 XTX (where a merge reading a - /// mutable shadow's texels through the view in place of a copy of them saved 6% and 2% of a - /// 1920x1080 pass that loads, and a pass that clears took 75% and 0% more), and NVIDIA's - /// 615.71.09 on the RTX 5080 Laptop GPU. - ShadowCopyBackDispatchFaster, - /// A cost fact (the module docs), on a driver with [`DriverFact::ShadowCopyBackDispatchFaster`]: - /// the GPU runs a merged shadowed texture's copy in (`vkCmdCopyBufferToImage`) and its keep (the - /// copy back's dispatch into the merge's scratch) slower than one dispatch that reads the - /// texels' words from the buffer once and stores them in the shadow, through a storage view of - /// it, and in the scratch, with the shadow's 4-byte texels viewed as `R8G8B8A8_UINT` (whose - /// storage usage keeps the image compressed on ANV, where `R32_UINT` beside storage usage makes - /// gfx12.0 drop its aux surface). Measured on ANV, Mesa 26.2.4 (one pass a frame, or twelve in - /// one command buffer, over a 1920x1080 `BGRA8Unorm` shadow over anonymous pages, 1000 frames, - /// GPU time a frame, two rounds each): on the UHD 770 of RPL-S, a pass that loads, draws and - /// stores took 1427 us against 1643 to 1665 us with the copy back's fact alone, twelve such - /// passes 17.2 ms against 20.0 ms, and one that clears 891 against 1042 us. On the Iris Xe of - /// RPL-P it was measured no faster, so not listed: twelve such passes took 9.3 to 15.8 ms - /// against 9.3 to 15.3 ms with the copy back's fact alone, slower in six of seven alternating - /// rounds (median 5% more), one pass 3.05 against 3.48 ms, one that clears 0.40 to 1.29 - /// against 0.61 to 1.20 ms; and the `R8G8B8A8_UINT` view without the dispatch took longer - /// still there (twelve passes 10.0 to 13.3 ms, a clearing pass 0.89 to 1.67 ms). On a device - /// with it a merged texture's copy in and keep of the same rectangle are that dispatch - /// (`shadow_copy_in.rs` in the runtime), and its shadow's view also stores (`shadow_copy_back.rs` - /// in the runtime): the same bytes either way, as Vulkan states a compatible view reads and - /// stores a texel's bits unchanged. - ShadowCopyInDispatchFaster, - /// A cost fact (the module docs): the driver records each region of a `vkCmdCopyBuffer` as an - /// operation of its own, so a copy of equal rows between two buffers whose rows lie apart costs - /// the recording CPU and the GPU more than one compute dispatch that stores the rows' words. - /// Measured on ANV, Mesa 26.2.4 (`row_copies::row_copies_cost` in the validation crate's runtime - /// lane, one copy a frame of 2 to 1080 rows of 7680 bytes into rows 8192 bytes apart, two rounds - /// each, CPU time the replaying and encoding threads' together): on the Iris Xe of RPL-P, 1080 - /// rows took 3.1-3.3 ms of CPU and 5.3-7.8 ms of GPU time as regions against 0.28-0.40 ms and - /// 1.13 ms as the dispatch, 16 rows 0.24-0.27 ms and 97-100 us against 0.12-0.17 ms and 30 us, - /// and 2 rows the same CPU time and 21.9 us against 14.8 us; on the UHD 770 of RPL-S, 1080 rows - /// 0.77-0.83 ms and 3.3-5.3 ms against 0.04-0.11 ms and 0.59-0.91 ms, and 2 rows the same CPU - /// time and 8.8-14.2 us against 3.1-4.3 us. ANV's per-region cost, so its row names no GPU: it - /// holds on every GPU of ANV. NVIDIA's 615.71.09 on the RTX 5080 - /// Laptop GPU, the GPU its row names (the same probe, two rounds each): 1080 rows took - /// 0.19-0.21 ms of CPU and 2.03-2.05 ms of GPU time as regions against 0.12-0.13 ms and - /// 0.42-0.43 ms as the dispatch, 16 rows 34-40 us of GPU time against 13 us, and 2 rows the - /// same CPU time and 9.1-9.8 us against 8.7-8.8 us. On a driver with it a copy of two or more - /// such rows is the dispatch (`row_copies.rs` in the runtime): the same bytes either way. - /// Measured no faster, so not listed: RADV, Mesa 26.2.4 on the Radeon 780M and the Radeon RX - /// 7900 XTX, where at 1080 rows the dispatch took 5% and 3% more GPU time. - RowCopiesDispatchFaster, - /// A cost fact (the module docs): the driver loads a shader's uniform read at a constant - /// offset ahead of the shader, so a key that reads a buffer slot's uniform view at its bind - /// offset alone (`SpecKey::RangeAtBindOffset` 1) is worth the second `VkPipeline` a state - /// pays for it at its first draw, beside the residual form its creation made. On a driver - /// without it every key is its residual form, which reads the same bytes at every bind offset: - /// a state's draws at any offset take the one pipeline its creation made - /// (`pipeline/render/residual.rs` in the runtime), and nothing an answer depends on differs, - /// only when the driver is called. - /// - /// **No driver is measured with it.** The behaviour is ANV's by report -- Mesa's ANV loads a - /// uniform read at a constant offset ahead of the shader -- with no figure taken for it, on a - /// venue no measurement here could reach, so it carries no row and no driver takes it. A row - /// of ANV's, with its releases and its numbers, is how it would be taken later. - /// - /// Measured without it, so not listed, on `blend-sweep-write-masks` (32 render pipeline - /// states, 32 draws, `conformance cost --alone`), the second form counted and then its - /// absence timed in alternating rounds: llvmpipe (LLVM 23.1.1, Mesa 26.2.4) made 64 - /// `VkPipeline`s against 32, at 100.5, 102.5 and 107.6 ms against 98.0, 96.3 and 103.1; - /// RADV, Mesa 26.2.4 on the Radeon 780M, 64 against 32 at 77.5 and 77.3 ms against 76.0 and - /// 74.5, and on the Radeon RX 7900 XTX 64 against 32; NVIDIA 615.71.09 on the RTX 5080 Laptop - /// GPU, 32 counted with 32 more still in the device's pipeline pool against 32 with none, at - /// 94.1, 85.7 and 84.7 ms against 92.3, 85.5 and 86.1. MoltenVK 1.4.2 on the Apple M3 Max - /// makes the one form either way, measured alike on 1.4.1 (the host benchmark's GPU workload, - /// two runs of each form: a heavy fragment 20.74 against 20.73 ms, a heavy kernel 19.18 - /// against 19.47, a constant-buffer kernel 8.42 against 7.69) while each first draw of a key - /// with a 1 made a second `VkPipeline` there (Metal's specialization and pipeline compile, - /// 5.6 to 24.5 ms). - ConstantOffsetUniformReadsPreloaded, - /// A defect fact (the module docs): the driver reports a command buffer's execution failure - /// only to the instance's debug-utils messengers, naming the `VkQueue` and not the - /// submission, and by default marks the whole `VkDevice` lost for it, where Metal fails the - /// command buffer it struck and runs the queue on. The runtime's workaround is the relay - /// (`device/relay.rs`): its instance asks the driver not to lose the device - /// (`MVK_CONFIG_RESUME_LOST_DEVICE`), each `VkQueue` keeps its submissions in flight in - /// submission order with a fence each, and a failure heard on a queue is given to the first - /// submission whose fence is unsignaled, so the command buffer whose batch it was finishes - /// with that error and the queue's other command buffers complete, as Metal's do. - /// - /// Measured on MoltenVK 1.4.1: `handleMTLCommandBufferError` in `MVKQueue.mm` reports - /// `": Lost|Resumed VkDevice after MTLCommandBuffer \"