diff --git a/crates/metal2vulkan-runtime/README.md b/crates/metal2vulkan-runtime/README.md index 1c1d378fb..5ca6dc401 100644 --- a/crates/metal2vulkan-runtime/README.md +++ b/crates/metal2vulkan-runtime/README.md @@ -243,7 +243,9 @@ Calls Metal does not have, for a consumer that emulates a Metal device: 9, draws nothing and fails the command buffer as Metal's GPU does: a hang (`CommandBufferError::GpuHang`), a page fault or a victim of the GPU's recovery (`GpuRecoveryVictim`), by the draw's form, running nothing from its encoder on (docs/API.md, - "Accepted differences", for the timing and the race over the encoders after a fault); + "Accepted differences", for the timing and the race over the encoders after a fault); one that + fails at more than one encoder fails with the first one's error, in the time Metal's GPU takes + to reach and recover from each; a queue's second hang or page fault revokes it, as Metal's does: its later command buffers fail at their commit (`AccessRevoked`). A kernel's draw of a value past the header's draws points, as Metal's does. diff --git a/crates/metal2vulkan-runtime/src/attachment_stand_in.rs b/crates/metal2vulkan-runtime/src/attachment_stand_in.rs index 30f72826b..f56f67d1c 100644 --- a/crates/metal2vulkan-runtime/src/attachment_stand_in.rs +++ b/crates/metal2vulkan-runtime/src/attachment_stand_in.rs @@ -427,7 +427,8 @@ pub(super) fn stand_in_as( } // The exact color resolve reads a multisampled color attachment as an input attachment // (`color_resolve.rs`). - let resolved = multisampled && color_resolve::exact(device, format, target.samples).is_some(); + let resolved = multisampled + && color_resolve::shader_rules(device, pixel_format, format, target.samples).is_some(); if color && (framebuffer_fetch::through_inputs(profile) || resolved) { usage |= ImageUsageFlags::INPUT_ATTACHMENT; } diff --git a/crates/metal2vulkan-runtime/src/color_resolve.rs b/crates/metal2vulkan-runtime/src/color_resolve.rs index 5ad029ee6..b990d77f9 100644 --- a/crates/metal2vulkan-runtime/src/color_resolve.rs +++ b/crates/metal2vulkan-runtime/src/color_resolve.rs @@ -16,6 +16,14 @@ //! format by Metal's multisample resolve store action), elsewhere a recorded near-equivalent, //! announced as `device-rounded-resolve`. //! +//! An extended-range attachment (`BGR10_XR`, `BGRA10_XR`, their `_sRGB` twins and +//! `RGB10A2Unorm_sRGB`, the forms Metal multisamples) is held in its raw format's codes, which no +//! device's resolve averages, so it resolves by the crate-owned resolve at every count and under +//! either policy ([`extended`]: `bind::ColorResolveFormat::extended_range`, whose docs state +//! Metal's measured rule and the near-equivalents of the channels the codes cannot give, announced +//! as `extended-range-resolve`), from any source below; an image that takes neither input +//! attachment usage nor a copy is refused, as no other resolve reads it. +//! //! The choice is made with the attachment's resolve ([`exact`], `resolve.rs`), so the pass's //! shape (`render_target.rs`) leaves such a resolve out of its subpass from its first instance: //! the pass's last instance stores the attachment's samples, and after the pass one render pass @@ -91,7 +99,9 @@ use crate::shader_cache::driver::Making; use ash::vk; use metal2vulkan::bind::{color_resolve_modules, ColorResolveFormat, PlanesCopy, ResolveSource}; use metal2vulkan::device::{DriverFact, FormatUsage, ResolvePolicy}; -use metal2vulkan::error::Feature; +use metal2vulkan::error::{Feature, Unsupported}; +use metal2vulkan::metal::format::ExtendedRange; +use metal2vulkan::metal::PixelFormat; use metal2vulkan::vk::{ ComponentMapping, Format, FormatFeatureFlags2, ImageAspectFlags, ImageUsageFlags, ImageViewType, }; @@ -125,16 +135,43 @@ pub(super) fn average_is_metals(device: &Device, samples: u32) -> bool { .contains(&DriverFact::ColorResolveAverageIsMetals) } -/// The exact resolve of the color attachment `source`, where the runtime resolves it so: [`exact`] -/// of its format and samples, where the resolve may read its samples: through its image's input -/// attachment usage, or from a copy of them into a scratch image that has it ([`copied`]), unless -/// its sample planes hold them (the module docs). +/// The resolve of a multisampled color attachment of the extended-range format `pf`, held in its +/// raw format's codes, which no device's resolve averages: the crate-owned one at every count and +/// under either `ResolvePolicy` (the module docs). `None` for another format. +pub(super) fn extended(pf: PixelFormat) -> Option { + ExtendedRange::of(pf).and_then(ColorResolveFormat::extended_range) +} + +/// The crate-owned resolve of a color attachment of pixel format `pf`, held in `format`, at +/// `samples` on `device`: an extended-range format's ([`extended`]) at every count past one, else +/// [`exact`]. +pub(super) fn shader_rules( + device: &Device, + pf: PixelFormat, + format: Format, + samples: u32, +) -> Option { + match extended(pf) { + Some(rules) => (samples > 1).then_some(rules), + None => exact(device, format, samples), + } +} + +/// The crate-owned resolve of the color attachment `source`, where the runtime resolves it so: +/// [`shader_rules`] of its format and samples, where the resolve may read its samples: through its +/// image's input attachment usage, or from a copy of them into a scratch image that has it +/// ([`copied`]), unless its sample planes hold them (the module docs). An extended-range +/// attachment's image that takes neither is refused: no other resolve reads its codes. pub(super) fn of_attachment( device: &Device, source: &Target, ) -> Result, Error> { - match exact(device, source.format, source.samples) { + let pf = source.texture.pixel_format(); + match shader_rules(device, pf, source.format, source.samples) { Some(rules) if takes_input(source)? || copied(device, source)? => Ok(Some(rules)), + Some(_) if extended(pf).is_some() => Err(Error::Unsupported(Unsupported::not_implemented( + Feature::Format, + ))), _ => Ok(None), } } @@ -190,15 +227,16 @@ pub(super) fn resolve_planes(layout: &mut PassLayout, last_storage: &[u32]) { } } -/// `plan` with input attachment usage, where the runtime may resolve its image by the exact +/// `plan` with input attachment usage, where the runtime may resolve its image by the crate-owned /// resolve reading it as an input attachment: a multisampled color attachment whose format and -/// samples [`exact`] resolves on `device`. `None` where it has the usage already, or needs none. +/// samples [`shader_rules`] resolves on `device`. `None` where it has the usage already, or needs +/// none. pub(super) fn input_candidate(plan: &ImagePlan, device: &Device) -> Option { let usage = plan.usage; let samples = plan.samples.as_raw(); let candidate = usage.contains(ImageUsageFlags::COLOR_ATTACHMENT) && !usage.contains(ImageUsageFlags::INPUT_ATTACHMENT) - && exact(device, plan.format, samples).is_some(); + && shader_rules(device, plan.pixel_format, plan.format, samples).is_some(); candidate.then(|| ImagePlan { usage: usage | ImageUsageFlags::INPUT_ATTACHMENT, ..plan.clone() diff --git a/crates/metal2vulkan-runtime/src/command_buffer/hang.rs b/crates/metal2vulkan-runtime/src/command_buffer/hang.rs index 9d78f2066..aacbabd78 100644 --- a/crates/metal2vulkan-runtime/src/command_buffer/hang.rs +++ b/crates/metal2vulkan-runtime/src/command_buffer/hang.rs @@ -35,6 +35,26 @@ //! encoder; the queue's command buffers committed meanwhile join its list, read `Scheduled` //! early ([`holding`]), and run. //! +//! Metal's GPU that faulted at an encoder goes on, once it recovered, to the later encoders that +//! fail too ([`Later`]): an indexed draw of type 9 then a direct one of 3 vertices, or another +//! indexed one. Measured on the M3 Max (macOS 27.0.1, 88 such command buffers, each pass its own +//! encoder, fresh processes and warm ones): the command buffer failed with the first fault's +//! error (`PageFault`, 88 of 88), every event signal firing. It read `Scheduled` 14.3 to 21.0 ms +//! after its commit, where one that faulted once read it 8.4 to 9.4 ms after and completed 6.1 to +//! 9.0 ms after that: once the GPU recovered from the fault. It completed 25.8 to 29.1 ms after +//! that where a hang followed the fault (56), 6.05 to 9.67 ms after it where a fault did (17), 12.7 +//! to 16.5 ms where two did (5), and 31.65 to 34.97 ms where a fault then a hang did (5); past a +//! hang the GPU reached nothing (a fault after it added nothing, 27.0 to 27.2 ms, 5). The queue's +//! command buffer committed right after it ran nothing where a hang followed the fault (6 of 6), +//! and in 1 of 2 where a fault did. The encoders between the fault and the later failure ran in +//! that shape, as the ones after a single fault there did. A command buffer whose GPU hangs first +//! fails as a hang alone does (30 of 30: `GpuHang`, 27.0 to 28.1 ms after `Scheduled`, the fault +//! after the hang never reached). The runtime answers: `Scheduled` [`FAULT_FROM_REACHED`] after +//! the GPU reached the fault, its wait going [`FAULT_FROM_REACHED`] after that for each later +//! fault, then [`FROM_REACHED`] for a hang ([`Held::after_recovered`]); the queue's command +//! buffers committed meanwhile run nothing where a hang follows, as during a hang, and run where +//! faults alone do; and from the fault on nothing runs, as after a single fault. +//! //! - **The hold.** The hanging encoder's end signals an event of the hang's own to 1 after the //! encoder, and adds the runtime's own wait ([`Batches::hold`]) for 2 after that, so what //! follows it in the command buffer (its later event signals, its completion) waits; its commit @@ -75,6 +95,10 @@ //! whose waits are not met by then, and every one after it, read `Scheduled` with their last //! batch, after the hang's, as does every one where the hang's own came with its last batch, and //! one with a switch of storage forms riding on its commit. +//! - **The device's recovery.** As its wait goes, the hold raises the device's recovery from +//! what it holds for: a hang's, and a fault's that a hang follows, from a hang; else from a +//! fault. A fault's that later failures follow raised the fault's already, as it read +//! `Scheduled`. A predicated loop running meanwhile ends there (`recovery.rs`). //! //! [`Batches::hold`]: super::batches::Batches::hold @@ -82,6 +106,7 @@ use super::super::event::{EventShared, SharedEvent}; use super::super::exit_guard; use super::super::gpu_time; use super::super::{CommandQueue, Device, Error}; +use super::recovery::Recovery; use super::{lock, CommandBufferShared, CommitFailure, FailedEncoders, Item, State}; use std::collections::VecDeque; use std::sync::atomic::{AtomicU8, AtomicUsize, Ordering}; @@ -167,9 +192,9 @@ impl Verdict { impl QueueHangs { /// The count of holds in flight of `held`'s kind. fn counter(&self, held: Held) -> &AtomicUsize { - match held { - Held::Hang => &self.in_flight, - Held::Fault => &self.holding, + match held.discards() { + true => &self.in_flight, + false => &self.holding, } } @@ -235,16 +260,33 @@ pub(super) enum Held { /// Metal's GPU hangs at its encoder (`CommandBufferError::GpuHang`). Hang, /// Metal's GPU faults at its encoder, or fails it as a victim of its recovery - /// (`CommandBufferError::PageFault`, `GpuRecoveryVictim`). - Fault, + /// (`CommandBufferError::PageFault`, `GpuRecoveryVictim`), then at the later encoders + /// [`Later`] counts, which it reaches once it recovered. + Fault(Later), +} + +/// The ended encoders after a faulting one that Metal's GPU fails too, which it reaches once it +/// recovered from the fault (the module docs): the faults (victims too) before the first hang, +/// and whether a hang follows them, past which it reaches none. +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] +pub(super) struct Later { + faults: u32, + hang: bool, } impl Held { + /// Whether the queue's command buffers committed meanwhile run nothing, as during a hang (a + /// hang's hold, and a fault's that a hang follows), or run (a fault's alone, or followed by + /// faults alone) (the module docs). + fn discards(self) -> bool { + matches!(self, Held::Hang | Held::Fault(Later { hang: true, .. })) + } + /// When after its commit the command buffer reads `Scheduled` at the earliest. fn scheduled(self) -> Duration { match self { Held::Hang => SCHEDULED, - Held::Fault => Duration::ZERO, + Held::Fault(_) => Duration::ZERO, } } @@ -252,7 +294,32 @@ impl Held { fn after_reached(self) -> Duration { match self { Held::Hang => FROM_REACHED, - Held::Fault => FAULT_FROM_REACHED, + Held::Fault(_) => FAULT_FROM_REACHED, + } + } + + /// What the GPU recovers from as the wait goes: a hang's, and a fault's that a hang follows, + /// from a hang; else from a fault (`recovery.rs`). + fn recovery(self) -> Recovery { + match self.discards() { + true => Recovery::Hang, + false => Recovery::Fault, + } + } + + /// A fault's that later failures follow: how long after it read `Scheduled`, once the GPU + /// recovered from the fault, its wait goes: [`FAULT_FROM_REACHED`] for each later fault, then + /// [`FROM_REACHED`] for a hang. `None` for a hang's, and a fault's alone. + fn after_recovered(self) -> Option { + match self { + Held::Fault(Later { faults, hang }) if faults > 0 || hang => { + let hang = match hang { + true => FROM_REACHED, + false => Duration::ZERO, + }; + Some(FAULT_FROM_REACHED * faults + hang) + } + _ => None, } } } @@ -306,6 +373,20 @@ impl Hang { self.encoder } + /// Metal's GPU fails a later ended encoder too, hanging there where `hangs`, else faulting: + /// a fault's hold counts it, the GPU reaching it once it recovered, unless a hang came before + /// it, past which the GPU reaches nothing (the module docs). + pub(super) fn fails_later(&mut self, hangs: bool) { + let Held::Fault(later) = &mut self.held else { + return; + }; + match (later.hang, hangs) { + (true, _) => {} + (false, true) => later.hang = true, + (false, false) => later.faults += 1, + } + } + /// The event of its signals and its wait. pub(super) fn event(&self) -> &SharedEvent { &self.event @@ -317,15 +398,18 @@ impl Hang { } /// The command buffer `buffer`, of state `state`, committed at `committed`, runs its hold: - /// its queue counts it until its work signalled [`Hang::DONE`] (a hang's among those that - /// discard the queue's others, a fault's among those that do not); it reads `Scheduled` - /// [`SCHEDULED`] after the commit (a hang's) or at once (a fault's), or later once the batch - /// before its wait was taken ([`Scheduling::Hang`]), and the queue's command buffers committed - /// meanwhile follow ([`QueueHangs::schedule_early`]); its wait goes [`FROM_REACHED`] (a - /// hang's) or [`FAULT_FROM_REACHED`] (a fault's) after it read `Scheduled` and the GPU reached - /// the encoder. One with a switch of storage forms riding on its commit, which settles by its - /// last batch's submission, reads `Scheduled` with that batch, as do the queue's others. Where - /// no thread can be made for that, the wait goes at once, the queue not counting it. + /// its queue counts it until its work signalled [`Hang::DONE`] (a hang's, and a fault's that + /// a hang follows, among those that discard the queue's others; another fault's among those + /// that do not); it reads `Scheduled` [`SCHEDULED`] after the commit (a hang's) or at once (a + /// fault's), or later once the batch before its wait was taken ([`Scheduling::Hang`]), and the + /// queue's command buffers committed meanwhile follow ([`QueueHangs::schedule_early`]); its + /// wait goes [`FROM_REACHED`] (a hang's) or [`FAULT_FROM_REACHED`] (a fault's) after it read + /// `Scheduled` and the GPU reached the encoder. A fault's that later failures follow reads + /// `Scheduled` [`FAULT_FROM_REACHED`] after the GPU reached the encoder, and its wait goes + /// [`Held::after_recovered`] after that. One with a switch of storage forms riding on its + /// commit, which settles by its last batch's submission, reads `Scheduled` with that batch, + /// as do the queue's others. Where no thread can be made for that, the wait goes at once, the + /// queue not counting it. pub(super) fn start( self, buffer: &Arc, @@ -335,6 +419,7 @@ impl Hang { let queue = &buffer.queue; let hangs = Arc::clone(queue.hangs()); let trails = Arc::clone(&queue.device().shared().trails); + let recoveries = Arc::clone(&queue.device().shared().recoveries); let held = self.held; hangs.counter(held).fetch_add(1, Ordering::SeqCst); let hang = { @@ -353,17 +438,30 @@ impl Hang { let builder = std::thread::Builder::new().name("metal2vulkan-hang".to_owned()); let ended = crate::exit_guard::spawn(builder, move || { sleep_until(committed + held.scheduled()); - let scheduled = hang_scheduled(weak); - event.wait_until_signaled_value(Hang::REACHED, SIGNAL_BOUND); - let release = Instant::now() + held.after_reached(); + let (scheduled, release) = match held.after_recovered() { + // A fault that later failures follow reads `Scheduled` once the GPU recovered + // from it, and its wait goes once the GPU recovered from them too. + Some(after) => { + event.wait_until_signaled_value(Hang::REACHED, SIGNAL_BOUND); + std::thread::sleep(FAULT_FROM_REACHED); + recoveries.raise(Recovery::Fault); + (hang_scheduled(weak), Instant::now() + after) + } + None => { + let scheduled = hang_scheduled(weak); + event.wait_until_signaled_value(Hang::REACHED, SIGNAL_BOUND); + (scheduled, Instant::now() + held.after_reached()) + } + }; match scheduled { true => hangs.schedule_early(hang, release), false => sleep_until(release), } let trail = trails.open(); - if held == Held::Hang { + if held.discards() { hangs.decide(); } + recoveries.raise(held.recovery()); event.set_signaled_value(Hang::RELEASED); event.wait_until_signaled_value(Hang::DONE, SIGNAL_BOUND); lock(&hangs.early).joined.clear(); @@ -374,7 +472,7 @@ impl Hang { }); if ended.is_err() { state.hang_scheduling = None; - if held == Held::Hang { + if held.discards() { queue.hangs().decide(); } lock(&queue.hangs().early).joined.clear(); diff --git a/crates/metal2vulkan-runtime/src/command_buffer/mod.rs b/crates/metal2vulkan-runtime/src/command_buffer/mod.rs index ac9501fc9..24261b620 100644 --- a/crates/metal2vulkan-runtime/src/command_buffer/mod.rs +++ b/crates/metal2vulkan-runtime/src/command_buffer/mod.rs @@ -41,6 +41,7 @@ pub(super) mod kept_barriers; pub(super) mod own; mod protection; pub(super) mod rebound_use; +pub(super) mod recovery; mod reencode; pub(super) mod rerun; pub(super) mod revocation; @@ -106,7 +107,7 @@ use checks::{Checks, SubmissionCheck}; use completion::Submitted; use first_submission::{Listing, Live}; use gate::{Gate, Hold}; -use hang::{Hang, Held}; +use hang::{Hang, Held, Later}; use metal2vulkan::bind::{ ExecutionStatus, IndexBoundsPass, ReplayFaults, ResidentRange, ResidentSet, RootTable, StatusReport, @@ -1223,6 +1224,8 @@ impl State { /// it on (`faulted`, `Failure::with_faults`); where nothing failed it from an earlier encoder /// and no earlier encoder faulted, the work before the encoder signals the fault's hold and /// what follows waits for it (`hang.rs`), so the command buffer completes when Metal's does. + /// Where an earlier encoder faulted, the GPU reaches this one once it recovered: the earlier + /// fault's hold counts it (`Hang::fails_later`). pub(super) fn fault( &mut self, encoder: usize, @@ -1230,7 +1233,11 @@ impl State { device: &Device, ) -> Result<(), Error> { if self.fails_from.is_none() && self.hang.is_none() { - self.hold(device, encoder, Held::Fault)?; + self.hold(device, encoder, Held::Fault(Later::default()))?; + } else if !self.faulted.contains_key(&encoder) { + if let Some(hang) = &mut self.hang { + hang.fails_later(false); + } } self.faulted.entry(encoder).or_insert(error); Ok(()) @@ -1240,9 +1247,13 @@ impl State { /// (`hang.rs`): the command buffer fails from it on with `CommandBufferError::GpuHang`, and, /// where nothing failed it from an earlier encoder, the work before the encoder signals the /// hang's event and what follows waits for the hang's hold. Where an earlier encoder faulted, - /// the GPU never reaches it: it fails from the fault (`State::fault`). + /// it fails from the fault with the fault's error (`State::fault`), and the GPU reaches it + /// once it recovered: the fault's hold counts it (`Hang::fails_later`). pub(super) fn hang_from(&mut self, encoder: usize, device: &Device) -> Result<(), Error> { if !self.faulted.is_empty() { + if let Some(hang) = &mut self.hang { + hang.fails_later(true); + } return Ok(()); } if self.fails_from.is_none() && self.hang.is_none() { diff --git a/crates/metal2vulkan-runtime/src/command_buffer/recovery.rs b/crates/metal2vulkan-runtime/src/command_buffer/recovery.rs new file mode 100644 index 000000000..2c7964551 --- /dev/null +++ b/crates/metal2vulkan-runtime/src/command_buffer/recovery.rs @@ -0,0 +1,107 @@ +//! The recoveries of a device's GPU from a fault or a hang, as Metal's GPU makes them, and what +//! they do to a predicated loop that runs again meanwhile (`rerun.rs`). +//! +//! Metal's GPU recovers from a page fault or a hang device-wide: a predicated loop running on the +//! device when it does stops there. Measured on the M3 Max (macOS 27.0.1): a `While` loop of +//! 160,000 passes, its unit's encoder followed by a mark and a blit, committed on a queue; 50 ms on, +//! two command buffers drawing primitive type 9 committed on that queue or another one. +//! - A fault (an indexed draw, `PageFault`; 6 runs, committed 50 ms on or at once) failed the +//! loop's command buffer as a victim (`MTLCommandBufferErrorInternal`, +//! `CommandBufferError::GpuRecoveryVictim`) 0.0 to 0.02 ms before the faulting one completed, +//! 3,463 to 39,098 passes in. The loop ran on through the fault's 8 ms hold, and nothing after +//! its encoder ran. +//! - A hang (a direct draw, `GpuHang`; 2 runs) ended the loop with no error 0.05 to 0.08 ms +//! before the hanging one failed, about 53,450 passes in. Its command buffer completed cleanly +//! and nothing after the loop's encoder ran. +//! - A loop committed behind faults that recovered before it started ran all its passes. +//! +//! The runtime answers so: each hold (`hang.rs`) raises the device's recovery from what it holds +//! for as its wait goes, the GPU's recovery ([`Recoveries::raise`]). A fault's hold that later +//! failures follow raises the fault's once it read `Scheduled`, and the later ones' as its wait +//! goes. Before each run again a loop asks for the first recovery since its command buffer's +//! first submission ([`Recoveries::since`]): +//! - after a fault's, it fails as a victim; +//! - after a hang's, it stops with no error ([`cut`]): from the check's part on, nothing of the +//! command buffer runs, and it completes cleanly. Whether its later event signals fire is not +//! measured; they fire. +//! +//! A fault committed on the loop's own queue behind the loop waits for the loop to end in the +//! runtime, as every batch of a queue does, where Metal's GPU runs it during the loop +//! (`docs/FAST-PATHS.md`, known gaps). + +use super::super::gpu_time; +use super::rerun::LoopCheck; +use super::{lock, CommandBufferShared, State}; +use crate::deferred::Deferred; +use crate::encoder::Recorded; +use std::sync::atomic::{AtomicU64, Ordering}; + +/// A device's GPU recoveries (the module docs): when the last from a fault and the last from a +/// hang came, in host nanoseconds (`gpu_time::host_nanos`); 0 for none. +#[derive(Default)] +pub(crate) struct Recoveries { + fault: AtomicU64, + hang: AtomicU64, +} + +/// What the GPU recovered from. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub(crate) enum Recovery { + /// A page fault, or a draw it fails as a victim of its recovery + /// (`CommandBufferError::PageFault`, `GpuRecoveryVictim`). + Fault, + /// A hang (`CommandBufferError::GpuHang`). + Hang, +} + +impl Recoveries { + /// The GPU recovered from `recovery`, now. + pub(super) fn raise(&self, recovery: Recovery) { + let at = match recovery { + Recovery::Fault => &self.fault, + Recovery::Hang => &self.hang, + }; + at.fetch_max(gpu_time::host_nanos(), Ordering::AcqRel); + } + + /// The GPU's first recovery after host time `since` (nanoseconds), of each kind's last: + /// `None` where none came since. + pub(super) fn since(&self, since: u64) -> Option { + let after = |at: &AtomicU64| Some(at.load(Ordering::Acquire)).filter(|&at| at > since); + match (after(&self.fault), after(&self.hang)) { + (Some(fault), Some(hang)) if hang < fault => Some(Recovery::Hang), + (Some(_), _) => Some(Recovery::Fault), + (None, Some(_)) => Some(Recovery::Hang), + (None, None) => None, + } + } +} + +/// The first recovery of `buffer`'s device since its first submission (the module docs). +pub(super) fn recovered(buffer: &CommandBufferShared) -> Option { + let since = buffer.kernel.start(); + buffer.device.shared().recoveries.since(since) +} + +/// The loop of `check` stopped at a hang's recovery (the module docs): every part of `buffer` +/// from the one holding the check on runs nothing, each keeping its place among the batches with +/// its fences' waits and updates alone (`State::fail_part`), and the command buffer completes +/// with no error. +pub(super) fn cut(buffer: &CommandBufferShared, check: &LoopCheck) { + let mut state = lock(&buffer.state); + let State { + recorded, retained, .. + } = &mut *state; + let holds_check = |part: &Recorded| { + part.segments.iter().any(|segment| match &segment.work { + Deferred::Loop(held) => std::ptr::eq(&**held, check), + _ => false, + }) + }; + let Some(from) = recorded.iter().position(holds_check) else { + return; + }; + for part in &mut recorded[from..] { + State::fail_part(part, retained); + } +} diff --git a/crates/metal2vulkan-runtime/src/command_buffer/rerun.rs b/crates/metal2vulkan-runtime/src/command_buffer/rerun.rs index a2e25cd21..f11126a1c 100644 --- a/crates/metal2vulkan-runtime/src/command_buffer/rerun.rs +++ b/crates/metal2vulkan-runtime/src/command_buffer/rerun.rs @@ -39,13 +39,15 @@ //! once the check ends: they read what the laying leaves. //! - **Ends.** As Metal's GPU runs a loop without bound on after the program let go of every //! handle of its queue and its device, so does the thread, which holds the command buffer, and -//! through it the queue and the device. It stops only at a lost device, a failed submission, -//! wait or recording (each failing the command buffer as its submission or host step would), -//! or the process's exit, which it never holds up: it waits in slices of [`WAIT_SLICE`], each -//! inside a section of the exit guard, and does nothing more once the guard closes. Each run -//! again is counted (`WorkCounts::predicated_loop_runs_again`). +//! through it the queue and the device. It stops only at a lost device, the GPU's recovery +//! from a fault or a hang anywhere on the device, as Metal's loop does (`recovery.rs`), a +//! failed submission, wait or recording (each failing the command buffer as its submission or +//! host step would), or the process's exit, which it never holds up: it waits in slices of +//! [`WAIT_SLICE`], each inside a section of the exit guard, and does nothing more once the +//! guard closes. Each run again is counted (`WorkCounts::predicated_loop_runs_again`). use super::gate::Hold; +use super::recovery::{self, Recovery}; use super::{ command_pool, recording_error, step_error, submission_error, CommandBuffer, CommandBufferShared, }; @@ -177,6 +179,8 @@ enum Round { Ended, /// The command buffer fails so. Failed(CommandBufferError), + /// The loop stopped with no error, and nothing after it runs (`recovery.rs`). + Cut, /// The process is exiting: the thread does nothing more. Exiting, } @@ -482,12 +486,17 @@ fn nothing() -> RecordedSegment { } /// The loop's decision before each run again: `None` where it runs again; else how it ends -/// without running. It stops once its device is lost (the module docs). +/// without running. It stops once its device is lost (the module docs), and at the GPU's +/// recovery from a fault (as a victim) or a hang (cut) since its command buffer's first +/// submission (`recovery.rs`). fn before_round(buffer: &CommandBufferShared) -> Option { if buffer.device.is_lost() { return Some(Round::Failed(CommandBufferError::DeviceLost)); } - None + match recovery::recovered(buffer)? { + Recovery::Fault => Some(Round::Failed(CommandBufferError::GpuRecoveryVictim)), + Recovery::Hang => Some(Round::Cut), + } } /// The check's thread (the module docs): run the laying again until the loop ends, or the check @@ -515,6 +524,10 @@ fn run_again(check: &LoopCheck, buffer: Hold) { Round::Ended => break (None, true), // A recording it left unended leaves the pool to be reset. Round::Failed(error) => break (Some(error), false), + Round::Cut => { + recovery::cut(&buffer, check); + break (None, true); + } // What it holds stays held to the process's end, as the scheduler's does. Round::Exiting => { std::mem::forget(arenas); diff --git a/crates/metal2vulkan-runtime/src/degradation.rs b/crates/metal2vulkan-runtime/src/degradation.rs index 6d7b37ede..2356f81d2 100644 --- a/crates/metal2vulkan-runtime/src/degradation.rs +++ b/crates/metal2vulkan-runtime/src/degradation.rs @@ -753,6 +753,23 @@ degradations! { "the resolve applies the rules Metal's resolve follows at 2 and 4 samples (or the \ device's average, for a format without them), which no Metal answer confirms at \ this count"; + /// A multisample resolve of an extended-range color attachment whose resolve Metal + /// averages from values finer than the codes the attachment holds (`BGRA10_XR`'s alpha, + /// an `_sRGB` twin's color, `RGB10A2Unorm_sRGB`'s channels; + /// `bind::ColorResolveFormat::extended_range`): the crate-owned resolve + /// (`color_resolve.rs`) writes a near-equivalent from the codes where a pixel's samples + /// differ, and Metal's code where they hold one. Measured against Metal's resolve on the + /// M3 Max under macOS 27.0.1 (our probe `xr`, 4096 texels per format at 2 and 4 samples, + /// each sample its own value): `BGRA10_XR`'s alpha Metal's in 84% and 88% of texels and + /// within a code in every one; an `_sRGB` twin's color in 81% and 85% of channels and + /// within a code in 99.5%, at most 7 codes off where the samples' values nearly cancel; + /// `RGB10A2Unorm_sRGB`'s colors in 83% and 87%, within 2, and its alpha in 94% and 97%, + /// within one (`runtime_lane::extended_range_resolve`). A linear form's color is Metal's + /// rule, every texel. + ExtendedRangeResolve = "extended-range-resolve", Precision, + "where a pixel's samples differ, a resolved alpha, or an sRGB color, can differ from \ + Metal's by a code (an sRGB color by a few where the samples' values nearly cancel): \ + Metal averages values finer than the codes the attachment holds"; /// An attachment stored with `DontCare` (or the multisampled attachment of /// `MultisampleResolve`) is Vulkan's `DONT_CARE`, where Apple's GPU keeps the earlier /// texels unless its tiler overflows. Only on a driver measured to keep the earlier texel @@ -4063,10 +4080,18 @@ impl Device { color.target.samples ), format!( - "the device's `AVERAGE` resolve of {:?} at {} samples is not measured to \ - be Metal's{}", - color.target.format, - color.target.samples, + "{}{}", + match color_resolve::extended(color.target.texture.pixel_format()) { + Some(_) => format!( + "no device's resolve averages the codes {:?} holds", + color.target.format + ), + None => format!( + "the device's `AVERAGE` resolve of {:?} at {} samples is not \ + measured to be Metal's", + color.target.format, color.target.samples + ), + }, match copied { true => { "; the attachment's image takes no input attachment usage, so its \ @@ -4078,6 +4103,28 @@ impl Device { ) }); } + // An extended-range resolve whose rule the codes cannot give (`color_resolve.rs`). + let near = colors.clone().find(|color| { + color + .resolve + .as_ref() + .and_then(|r| r.shader) + .is_some_and(|rules| !rules.exact()) + }); + if let Some(color) = near { + self.degrade(Degradation::ExtendedRangeResolve, || { + ( + format!( + "a resolve of a {:?} color attachment of {} samples", + color.target.texture.pixel_format(), + color.target.samples + ), + "Metal averages the samples' values, finer than the codes the attachment \ + holds; the resolve averages the codes" + .to_owned(), + ) + }); + } let unmeasured = colors.clone().find(|color| { color.resolve.is_some() && color.target.samples > color_resolve::METAL_SAMPLES }); diff --git a/crates/metal2vulkan-runtime/src/device/mod.rs b/crates/metal2vulkan-runtime/src/device/mod.rs index df2572ce2..91132d715 100644 --- a/crates/metal2vulkan-runtime/src/device/mod.rs +++ b/crates/metal2vulkan-runtime/src/device/mod.rs @@ -461,6 +461,9 @@ pub(super) struct DeviceShared { /// The trails its threads open between a signal and their last let-go of what they held for /// the work, which a command buffer's waiters wait for (`trails.rs`). pub(crate) trails: Arc, + /// Its GPU's recoveries from faults and hangs, which end a predicated loop running meanwhile + /// (`command_buffer/recovery.rs`). + pub(crate) recoveries: Arc, /// Its graphics pipeline libraries, by part and content, where it links its render /// pipelines from libraries (`pipeline/libraries.rs`, `create.rs`); `None` where it makes /// each whole. @@ -1729,6 +1732,7 @@ impl Device { pipeline_pool: Default::default(), reaper: Default::default(), trails: Arc::default(), + recoveries: Arc::default(), libraries: graphics_pipeline_library.then(Default::default), }); // A CPU device runs the work submitted to it on the process's own threads: the exit hook diff --git a/crates/metal2vulkan-runtime/src/error.rs b/crates/metal2vulkan-runtime/src/error.rs index 99ac95798..e29bc388a 100644 --- a/crates/metal2vulkan-runtime/src/error.rs +++ b/crates/metal2vulkan-runtime/src/error.rs @@ -1507,19 +1507,6 @@ pub enum RuntimeGap { /// The descriptor's pixel format. pixel_format: PixelFormat, }, - /// The multisample resolve (`MultisampleResolve`, `StoreAndMultisampleResolve`) of a color - /// attachment of an extended-range format (`BGRA10_XR`, `BGR10_XR` and their `_sRGB` twins), - /// which Metal makes. The runtime holds such an attachment's raw codes and builds no resolve of - /// them. Metal's, measured on an M3 Max under macOS 27.0.1 at 2 and 4 samples: `BGR10_XR`'s - /// channels and `BGRA10_XR`'s color are the average of the samples' stored 10-bit codes, - /// rounded half up (every texel probed); `BGRA10_XR`'s alpha is near the average of the - /// samples' alphas as `half` values clamped to `[0, 1]`, and the `_sRGB` twins' color near the - /// encoded average of the samples' linear values (not fitted to the code). Both of those read - /// the values the fragment function wrote, which the stored codes do not keep. - ExtendedRangeResolve { - /// The attachment's pixel format. - pixel_format: PixelFormat, - }, /// A blit copy between a buffer and a multisampled texture (`copyFromBuffer:...toTexture:` /// into, or `copyFromTexture:...toBuffer:` out of, a texture of more than one sample). /// Vulkan copies no multisampled image to or from a buffer (its `vkCmdCopyBufferToImage` and @@ -1615,8 +1602,9 @@ pub enum CommandBufferError { /// the command buffer fails (`NotImplemented(SamplerBicubicFilter)`'s reach, decided where the /// function ran). A command buffer whose functions never reach such a sampler runs as Metal's. CubicArgumentSampler, - /// An emulated mesh draw's records did not fit the rest of the command buffer's mesh records - /// pool, or its vertices passed a `u32`: such draws drew nothing. Metal draws them; the + /// An emulated mesh draw's records, or an emulated indirect draw's object slots (one per object + /// threadgroup, the grid and payload its object function writes), did not fit the rest of the + /// command buffer's mesh records pool, or its vertices passed a `u32`: such draws drew nothing. Metal draws them; the /// runtime's pool is the device's budget, so nothing is drawn short silently. The first such /// draw, as its scan saw it. MeshRecordsOverflow(MeshRecordsOverflow), @@ -1632,7 +1620,10 @@ pub enum CommandBufferError { /// as the GPU wrote it, past the task stage's limits (`maxTaskWorkGroupCount`, /// `maxTaskWorkGroupTotalCount`), or a mesh grid past the mesh stage's; on one that folds them, /// a grid of more pieces than `MeshArguments::OBJECT_PIECES` (only under task limits below - /// Vulkan's required least). Nothing is drawn short silently. A direct draw of such a grid on + /// Vulkan's required least); on a device without `VK_EXT_mesh_shader` (the emulation), an + /// indirect draw's object grid past the device's `maxComputeWorkGroupCount`, or one whose + /// threads per grid along an axis reach 2^32 (Metal reports the wrapped grid, which the + /// emulation's dispatch cannot). Nothing is drawn short silently. A direct draw of such a grid on /// a device that does not fold is refused as it is encoded (`Unsupported{MeshShading}` naming /// the limit). Not Metal's failure: an object grid Metal's GPU discards is /// [`GpuRecoveryVictim`](Self::GpuRecoveryVictim). @@ -1960,7 +1951,8 @@ pub struct MeshRecordsOverflow { pub draw: u32, /// Its object threadgroups (1 for a pipeline without an object function). pub object_threadgroups: u32, - /// The mesh threadgroups it launched, saturated at `u32::MAX`. + /// The mesh threadgroups it launched, saturated at `u32::MAX`; 0 where its object slots did + /// not fit, before any launched. pub mesh_threadgroups: u32, /// The bytes of the command buffer's records pool, the device's budget. pub budget: u64, diff --git a/crates/metal2vulkan-runtime/src/families/formats.rs b/crates/metal2vulkan-runtime/src/families/formats.rs index ea1990a4a..979bbd5e4 100644 --- a/crates/metal2vulkan-runtime/src/families/formats.rs +++ b/crates/metal2vulkan-runtime/src/families/formats.rs @@ -36,8 +36,9 @@ //! format: the attachment the pass resolves into, or its scratch image (`resolve.rs`). Integer //! color formats are no resolve source in Metal, measured, and no stencil view of a combined //! format (`X32Stencil8`) answers one, as no column of Apple's tables lists it. Depth and -//! stencil resolve through `SAMPLE_ZERO`, which every Vulkan 1.2 device has. An extended-range format answers the -//! render pass's refusal of its resolve, which the runtime does not model. +//! stencil resolve through `SAMPLE_ZERO`, which every Vulkan 1.2 device has. A private form held +//! in raw codes that Metal makes no multisampled texture of answers the render pass's refusal of +//! its resolve. //! - **Atomic**: a 2D `ShaderAtomic` texture with a storage view of a format a texture atomic //! updates. `R32Uint` and `R32Sint` need their format's `StorageImageAtomic`. `RG32Uint` is //! Metal's `ulong` texture: it needs its `R64_UINT` view's 64-bit image atomics. No other format @@ -402,7 +403,8 @@ pub(crate) fn answers( let resolve = if integer || single.as_ref().is_ok_and(stencil_view) { Err(not_metal()) } else if let Some(unsupported) = unmodelled_resolve(pf) { - // The resolve the render pass refuses (`resolve.rs`), as an extended-range format's. + // The resolve the render pass refuses (`resolve.rs`): a private form's codes, of which + // Metal makes no multisampled texture. Err(Missing::Refused(unsupported)) } else { msaa.clone().and(single.clone()).map(drop) diff --git a/crates/metal2vulkan-runtime/src/gpu_pools.rs b/crates/metal2vulkan-runtime/src/gpu_pools.rs index edacb1173..24b44ada6 100644 --- a/crates/metal2vulkan-runtime/src/gpu_pools.rs +++ b/crates/metal2vulkan-runtime/src/gpu_pools.rs @@ -1,6 +1,7 @@ //! A command buffer's GPU pools: the index pool its index bounds and index rewrite passes reserve //! indices in (`index_bounds.rs`, `index_rewrite.rs`), and the records pool its scanned emulated -//! mesh draws reserve records in (`render/mesh.rs`). The GPU decides how much of each a command +//! mesh draws reserve records in, and their indirect draws with an object function their object +//! slots (`render/mesh.rs`). The GPU decides how much of each a command //! buffer takes (an indirect draw's count, an object stage's grids), after the draws that read //! them were recorded, so a pool is one block bound for the whole command buffer. //! diff --git a/crates/metal2vulkan-runtime/src/owned_kernel.rs b/crates/metal2vulkan-runtime/src/owned_kernel.rs index 70fa6c31d..ee9a053d5 100644 --- a/crates/metal2vulkan-runtime/src/owned_kernel.rs +++ b/crates/metal2vulkan-runtime/src/owned_kernel.rs @@ -111,6 +111,9 @@ pub(super) enum OwnedModule { /// `bind::mesh_scan_module`: a scanned emulated mesh draw's mesh threadgroups, records and /// draw (`render/mesh.rs`). MeshScan, + /// `bind::mesh_object_arguments_module`: an emulated indirect draw's object grid, its slots + /// reserved and its object dispatch written, under the scan's bindings (`render/mesh.rs`). + MeshObjectArguments, /// `bind::mesh_arguments_module` of one form: an indirect mesh draw's group counts, as Metal /// draws them within the device's limits, or a folded object function's pieces /// (`render/mesh_arguments.rs`). @@ -350,7 +353,13 @@ impl OwnedModule { OwnedModule::MeshScan => { let module = metal2vulkan::bind::mesh_scan_module(device.compile_device()) .map_err(Error::Compile)?; - Ok((module.spirv.to_vec(), 3, 0)) + Ok((module.spirv.to_vec(), 4, 0)) + } + OwnedModule::MeshObjectArguments => { + let module = + metal2vulkan::bind::mesh_object_arguments_module(device.compile_device()) + .map_err(Error::Compile)?; + Ok((module.spirv.to_vec(), 4, 0)) } OwnedModule::MeshArguments(form) => { let module = @@ -531,6 +540,7 @@ pub(super) struct OwnedKernels { shadow_copy_ins: HashMap, mipmap_filters: HashMap, mesh_scan: Option, + mesh_object_arguments: Option, mesh_arguments_mesh: Option, mesh_arguments_object: Option, mesh_arguments_folded: Option, @@ -575,6 +585,7 @@ impl OwnedKernels { self.shadow_merge, self.depth_magnitude, self.mesh_scan, + self.mesh_object_arguments, self.mesh_arguments_mesh, self.mesh_arguments_object, self.mesh_arguments_folded, @@ -725,6 +736,7 @@ impl OwnedKernels { | OwnedModule::TwinDecode(_) | OwnedModule::TessellationScan(_) => return None, OwnedModule::MeshScan => &mut self.mesh_scan, + OwnedModule::MeshObjectArguments => &mut self.mesh_object_arguments, OwnedModule::MeshArguments(metal2vulkan::bind::MeshArgumentsForm::Mesh) => { &mut self.mesh_arguments_mesh } diff --git a/crates/metal2vulkan-runtime/src/render.rs b/crates/metal2vulkan-runtime/src/render.rs index 75e0e617c..fddfd04f9 100644 --- a/crates/metal2vulkan-runtime/src/render.rs +++ b/crates/metal2vulkan-runtime/src/render.rs @@ -301,6 +301,7 @@ use super::linear_attachment; use super::linear_merge::LinearMerge; use super::live_bind::{Emptied, LiveBind, Reshape}; use super::nan_clear::{keeps_nan_sign, NanClears, NanDepthWrite}; +use super::owned_kernel::OwnedModule; use super::pipeline::Settled; use super::pipeline::{BufferForms, DrawPipeline}; use super::pipeline::{DrawDynamic, RawPipeline, RenderVariant, VariantObjects}; @@ -8880,8 +8881,33 @@ impl RenderLowering { }) .unwrap_or_default(); let pipelines = variant.mesh_pipelines(specialization, &formats)?; - let object = match (dispatch.object_groups, pipelines.object) { - (Some(groups), Some(pipeline)) => Some((pipeline, groups)), + // An indirect draw with an object function: its object arguments pass, and its + // object dispatch from the work buffer, where the pass writes it. + let arguments = match (dispatch.object_arguments, indirect) { + (Some(range), Some(source)) => Some(mesh::Scan::new( + &mut self.core, + OwnedModule::MeshObjectArguments, + work, + Some((source.raw, range)), + )?), + (None, _) => None, + (Some(_), None) => { + return Err(internal("an object arguments pass without its arguments")) + } + }; + let launch = match (dispatch.object_groups, &arguments) { + (Some(groups), None) => Some(mesh::Launch::Direct(groups)), + (None, Some(_)) => { + let (raw, at) = work.at(MeshDispatch::OBJECT_DISPATCH_OFFSET); + Some(mesh::Launch::Indirect(raw, at)) + } + (None, None) => None, + (Some(_), Some(_)) => { + return Err(internal("an object dispatch of both launches")); + } + }; + let object = match (launch, pipelines.object) { + (Some(launch), Some(pipeline)) => Some((pipeline, launch)), (None, _) => None, (Some(_), None) => { return Err(internal("an object dispatch without the object's pipeline")) @@ -8897,7 +8923,12 @@ impl RenderLowering { return Err(internal("a mesh scan without its arguments")) } }; - let scan = mesh::Scan::new(&mut self.core, work, arguments)?; + let scan = mesh::Scan::new( + &mut self.core, + OwnedModule::MeshScan, + work, + arguments, + )?; let (raw, at) = work.at(MeshDispatch::DISPATCH_OFFSET); (Some(scan), mesh::Launch::Indirect(raw, at)) } @@ -8909,6 +8940,7 @@ impl RenderLowering { offsets: live.offsets.clone(), heap: heap_set, push, + arguments, object, scan, pipeline: pipelines.mesh, diff --git a/crates/metal2vulkan-runtime/src/render/mesh.rs b/crates/metal2vulkan-runtime/src/render/mesh.rs index 71887ee86..fa76b1c62 100644 --- a/crates/metal2vulkan-runtime/src/render/mesh.rs +++ b/crates/metal2vulkan-runtime/src/render/mesh.rs @@ -83,8 +83,14 @@ //! everything after. An indirect command's record before its pass too, or, behind the command's //! barrier where an earlier draw's stages before its fragments touched what they use, before the //! run of the execution's that the barrier begins (`render/executions.rs`). Such draws announce -//! `emulated-mesh-draws` once. An indirect draw of a pipeline with an object function is not -//! emulated yet (`NotImplemented(MeshShading)`). +//! `emulated-mesh-draws` once. An indirect draw of a pipeline with an object function first runs +//! the object arguments pass (`bind::mesh_object_arguments_module`), which reads Metal's +//! arguments, reserves the object threadgroups' slots in the records pool and writes the object +//! dispatch, which then launches indirectly: a grid Metal's GPU discards fails the command +//! buffer as Metal's (`CommandBufferError::GpuRecoveryVictim`), one past the compute limits or +//! whose threads per grid wrap fails it as one the device cannot launch +//! (`CommandBufferError::MeshGridPastLimits`), and one whose slots the pool cannot hold as a +//! records overflow (`CommandBufferError::MeshRecordsOverflow`, naming no mesh threadgroup). use super::replay::Samplers; use super::RenderCommandEncoder; @@ -863,8 +869,8 @@ impl RenderCommandEncoder { /// object grid Metal's GPU discards fails the command buffer as Metal's does /// (`CommandBufferError::GpuRecoveryVictim`), and one past a device's task limits where it /// does not fold them (`CommandBufferError::MeshGridPastLimits`, the module docs). On one - /// without it, a draw of a - /// pipeline with an object function is `NotImplemented(MeshShading)` (the module docs). + /// without it the emulation reads the counts on the GPU: a draw with an object function + /// through its object arguments pass (the module docs). pub fn draw_mesh_threadgroups_indirect( &mut self, indirect_buffer: &Buffer, @@ -973,27 +979,30 @@ impl MeshWork { } } -/// An emulated mesh draw's scan (`bind::MeshScanModule`): the device's kernel and its set over -/// the draw's work buffer, the command buffer's status words, and Metal's arguments. +/// An emulated mesh draw's scan (`bind::MeshScanModule`), or its object arguments pass +/// (`bind::mesh_object_arguments_module`): the device's kernel and its set over the draw's work +/// buffer, the command buffer's status words, Metal's arguments, and the records. pub(crate) struct Scan { kernel: OwnedKernel, sets: Vec, } impl Scan { - /// The scan of `work`, in `core`'s command buffer (which holds its set until it completes), - /// reading Metal's arguments at `arguments` (the `VkBuffer` and the binder's range in it) for - /// an indirect draw. Refused as kernels, uploads and sets are. + /// The scan of `work` (`OwnedModule::MeshScan`), or its object arguments pass + /// (`OwnedModule::MeshObjectArguments`), as `which`, in `core`'s command buffer (which holds + /// its set until it completes), reading Metal's arguments at `arguments` (the `VkBuffer` and + /// the binder's range in it) for an indirect draw. Refused as kernels, uploads and sets are. pub(crate) fn new( core: &mut EncoderCore, + which: OwnedModule, work: &MeshWork, arguments: Option<(vk::Buffer, BufferRange)>, ) -> Result { let device = core.device().clone(); - let kernel = device.owned_kernel(OwnedModule::MeshScan)?; + let kernel = device.owned_kernel(which)?; let status = core.command_buffer().state().status_words(&device)?; let status = (status.raw(), status.offset(), ExecutionStatus::BYTES as u64); - let mut set = [(vk::Buffer::null(), 0, 0); 3]; + let mut set = [(vk::Buffer::null(), 0, 0); 4]; set[MeshScanModule::WORK_BINDING as usize] = (work.work.raw(), work.work.offset(), work.work.len()); set[MeshScanModule::STATUS_BINDING as usize] = status; @@ -1002,6 +1011,7 @@ impl Scan { Some((raw, range)) => (raw, range.offset, range.range), None => status, }; + set[MeshScanModule::RECORDS_BINDING as usize] = work.records; let owned = OwnedSets::write(&device, &kernel, &[set.to_vec()])?; let sets = owned.sets.clone(); core.retain(owned); @@ -1009,14 +1019,35 @@ impl Scan { } } -/// How an emulated mesh draw launches its mesh threadgroups. +/// How an emulated mesh draw launches its object or mesh threadgroups. pub(crate) enum Launch { /// `vkCmdDispatch` of these counts. Direct([u32; 3]), - /// `vkCmdDispatchIndirect` from this `VkBuffer` and byte: the scan's. + /// `vkCmdDispatchIndirect` from this `VkBuffer` and byte: the object arguments pass's, or + /// the scan's. Indirect(vk::Buffer, u64), } +impl Launch { + /// Record the dispatch. + /// + /// # Safety + /// + /// `command_buffer` is recording outside a render pass with a compute pipeline bound, and an + /// indirect launch's arguments are written and visible to `DRAW_INDIRECT` reads. + unsafe fn record(&self, raw: &Vk, command_buffer: vk::CommandBuffer) { + // SAFETY: as the caller states. + unsafe { + match *self { + Launch::Direct([x, y, z]) => raw.cmd_dispatch(command_buffer, x, y, z), + Launch::Indirect(buffer, offset) => { + raw.cmd_dispatch_indirect(command_buffer, buffer, offset) + } + } + } + } +} + /// An emulated mesh draw's compute work (`DrawCommands::mesh_dispatch`), ready to record before /// the draw's render pass instance (the module docs): its object dispatch, its scan, and its mesh /// dispatch, each with the draw's sets and compute-stage push writes, between barriers. @@ -1030,8 +1061,11 @@ pub(crate) struct MeshSteps { pub(crate) heap: Option, /// The draw's push writes of the compute stage. pub(crate) push: Vec, - /// The object function's pipeline and threadgroups, where the pipeline has one. - pub(crate) object: Option<(Arc, [u32; 3])>, + /// The object arguments pass, of an indirect draw with an object function. + pub(crate) arguments: Option, + /// The object function's pipeline and its launch, where the pipeline has one: indirect from + /// the work buffer where the object arguments pass writes it. + pub(crate) object: Option<(Arc, Launch)>, /// The scan, of a draw whose mesh threadgroups the GPU decides. pub(crate) scan: Option, /// The mesh function's pipeline. @@ -1097,8 +1131,8 @@ impl MeshSteps { } } - /// The object dispatch, the scan and the mesh dispatch, each after a barrier from the one - /// before. + /// The object arguments pass, the object dispatch, the scan and the mesh dispatch, each after + /// a barrier from the one before. /// /// # Safety /// @@ -1137,15 +1171,8 @@ impl MeshSteps { } } }; - if let Some((pipeline, [x, y, z])) = &self.object { - bind(pipeline.raw); - // SAFETY: as the caller states. - unsafe { - raw.cmd_dispatch(command_buffer, *x, *y, *z); - Barrier::everything().record(raw, command_buffer); - } - } - if let Some(scan) = &self.scan { + // One workgroup of an owned kernel, then a barrier. + let owned = |scan: &Scan| { // SAFETY: as the caller states; the kernel is the device's. unsafe { raw.cmd_bind_pipeline(command_buffer, point, scan.kernel.pipeline); @@ -1160,17 +1187,25 @@ impl MeshSteps { raw.cmd_dispatch(command_buffer, 1, 1, 1); Barrier::everything().record(raw, command_buffer); } + }; + if let Some(arguments) = &self.arguments { + owned(arguments); + } + if let Some((pipeline, launch)) = &self.object { + bind(pipeline.raw); + // SAFETY: as the caller states; an indirect launch's arguments lie in the work + // buffer, which the object arguments pass wrote before the barrier. + unsafe { + launch.record(raw, command_buffer); + Barrier::everything().record(raw, command_buffer); + } + } + if let Some(scan) = &self.scan { + owned(scan); } bind(self.pipeline.raw); // SAFETY: as the caller states; an indirect launch's arguments lie in the work buffer, // which the scan wrote before the barrier. - unsafe { - match self.launch { - Launch::Direct([x, y, z]) => raw.cmd_dispatch(command_buffer, x, y, z), - Launch::Indirect(buffer, offset) => { - raw.cmd_dispatch_indirect(command_buffer, buffer, offset) - } - } - } + unsafe { self.launch.record(raw, command_buffer) } } } diff --git a/crates/metal2vulkan-runtime/src/resolve.rs b/crates/metal2vulkan-runtime/src/resolve.rs index 88822eeb8..6deb0eb06 100644 --- a/crates/metal2vulkan-runtime/src/resolve.rs +++ b/crates/metal2vulkan-runtime/src/resolve.rs @@ -58,6 +58,12 @@ //! another one each run, and a 32-bit channel takes such a value even where the samples //! agree; only an 8- or 16-bit channel (`RGB10A2Uint`'s too) whose samples agree resolves to //! their value. No rule that holds for every pixel: refused. +//! - An extended-range attachment (`BGR10_XR`, `BGRA10_XR`, their `_sRGB` twins and +//! `RGB10A2Unorm_sRGB`; our probe `xr`, the M3 Max under macOS 27.0.1) resolves a linear form's +//! colors to the average of the samples' codes rounded half up; its alpha and an sRGB form's +//! colors average values finer than the codes. The runtime holds the codes and resolves by the +//! crate-owned resolve at every count (`color_resolve.rs`), Metal's rule where the codes give +//! it and a near-equivalent elsewhere, announced as `extended-range-resolve`. //! - A packed 16-bit attachment the device renders through the view of its word //! (`metal::format::WordAttachment`) holds each sample's stored codes, while Metal's resolve //! averages its tile's values, finer than the codes: not modelled, refused @@ -402,11 +408,14 @@ impl<'a> Wanted<'a> { } } -/// The refusal of a resolve from or into a texture of `pf` that the runtime does not build: an -/// extended-range format's (`RuntimeGap::ExtendedRangeResolve` states Metal's rule). The format's -/// Resolve capability answers it too (`families::formats`). +/// The refusal of a resolve of a multisampled attachment of `pf` that no resolve reads: one of +/// Apple's private forms held in raw codes of which Metal makes no multisampled texture (bfloat, +/// padded and two-plane ones; our probe `xrms`, the M3 Max under macOS 27.0.1), whose codes the +/// crate-owned resolve has no rule for (`color_resolve::extended`). The format's Resolve capability +/// answers it too (`families::formats`). pub(crate) fn unmodelled_resolve(pf: PixelFormat) -> Option { - ExtendedRange::of(pf).map(|_| Unsupported::not_implemented(Feature::Format)) + (ExtendedRange::of(pf).is_some() && super::color_resolve::extended(pf).is_none()) + .then(|| Unsupported::not_implemented(Feature::Format)) } /// What Apple's GPU holds of a multisampled color attachment of a pixel format as its resolve @@ -596,14 +605,9 @@ pub(super) fn color( ) { return Err(problem(call, RenderPassProblem::ResolveFormat(which))); } - // An extended-range attachment's resolve, not built. A resolve texture of such a format is - // the attachment's own or its twin, so of such an attachment, or of another format, which a - // resolve leaves untouched or `destination` refuses. - let pixel_format = source.texture.pixel_format(); - if unmodelled_resolve(pixel_format).is_some() { - return Err(Error::NotImplemented(RuntimeGap::ExtendedRangeResolve { - pixel_format, - })); + // A private form's codes no resolve reads (Metal makes no multisampled texture of it). + if let Some(unsupported) = unmodelled_resolve(source.texture.pixel_format()) { + return Err(Error::Unsupported(unsupported)); } // An attachment rendered through the view of its word (`metal::format::WordAttachment`) holds // each sample's stored codes, while Metal resolves its tile's values: not modelled. diff --git a/crates/metal2vulkan-runtime/src/tests/degradation_codes.txt b/crates/metal2vulkan-runtime/src/tests/degradation_codes.txt index 04bc15a26..a6c580b6a 100644 --- a/crates/metal2vulkan-runtime/src/tests/degradation_codes.txt +++ b/crates/metal2vulkan-runtime/src/tests/degradation_codes.txt @@ -66,6 +66,7 @@ metal2vulkan-degrade-extended-range-bits-kept metal2vulkan-degrade-extended-range-blend-source metal2vulkan-degrade-extended-range-blends-stored-codes metal2vulkan-degrade-extended-range-float-blend-source +metal2vulkan-degrade-extended-range-resolve metal2vulkan-degrade-f16-fma-double-rounding metal2vulkan-degrade-f16-int-conv-double-rounding metal2vulkan-degrade-fast-math-rewrites diff --git a/crates/metal2vulkan-runtime/src/tests/families.rs b/crates/metal2vulkan-runtime/src/tests/families.rs index af5a94318..741f68494 100644 --- a/crates/metal2vulkan-runtime/src/tests/families.rs +++ b/crates/metal2vulkan-runtime/src/tests/families.rs @@ -770,8 +770,8 @@ fn rows_built_since_are_exact_or_the_compile_layer_s() { /// A format Metal makes no multisample texture of answers neither MSAA nor resolve on any /// committed profile, as `new_texture` refuses the texture the probe stands for: the two-plane /// extended-range formats (Metal's validation stops one) and the two-plane YCbCr ones. A one-plane -/// extended-range format still answers MSAA as its held format does, and no resolve, which the -/// render pass refuses. The stencil view `X32Stencil8` answers neither a filter nor a resolve, as +/// extended-range format answers MSAA as its held format does, and a resolve where it answers +/// MSAA, which the crate-owned resolve makes (`color_resolve.rs`). The stencil view `X32Stencil8` answers neither a filter nor a resolve, as /// Apple's tables list neither. Nor do the padded 10-bit formats, whose multisample texture Metal's /// validation stops. #[test] @@ -844,9 +844,11 @@ fn formats_without_a_made_multisample_texture_or_a_modelled_resolve_answer_neith PixelFormat::BGR10XR, PixelFormat::BGR10XRSRGB, ] { - assert!( - !found(pf).contains(FormatCapability::Resolve), - "{stem}: {pf:?} answers a resolve the render pass refuses" + let capabilities = found(pf); + assert_eq!( + capabilities.contains(FormatCapability::Resolve), + capabilities.contains(FormatCapability::Msaa), + "{stem}: {pf:?} resolves where it multisamples" ); } // The stencil view of the combined format: MSAA as the combined format, which it diff --git a/crates/metal2vulkan-validation/fixtures/public/engine/TOOLCHAIN b/crates/metal2vulkan-validation/fixtures/public/engine/TOOLCHAIN index 4c74d6b3a..4eb93c5a6 100644 --- a/crates/metal2vulkan-validation/fixtures/public/engine/TOOLCHAIN +++ b/crates/metal2vulkan-validation/fixtures/public/engine/TOOLCHAIN @@ -333,6 +333,7 @@ fixture wrg_gather_depth_positions: metal: Apple metal version 32023.921 (metalf fixture wrg_sampler_positions: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425) fixture xr_bicubic: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425) fixture xr_planes: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425) +fixture xr_resolve: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425) fixture xr_samples: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425) fixture xr_two_plane_arrays: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425) fixture xr_two_planes: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425) diff --git a/crates/metal2vulkan-validation/fixtures/public/engine/xr_resolve.air.ll b/crates/metal2vulkan-validation/fixtures/public/engine/xr_resolve.air.ll new file mode 100644 index 000000000..3547b38d7 --- /dev/null +++ b/crates/metal2vulkan-validation/fixtures/public/engine/xr_resolve.air.ll @@ -0,0 +1,105 @@ +; Generated by scripts/regen-air-fixtures from xr_resolve.metal (typed pointers; xcrun metal-as reassembles it). Do not edit. +; ModuleID = '-' +source_filename = "-" +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v24:32:32-v32:32:32-v48:64:64-v64:64:64-v96:128:128-v128:128:128-v192:256:256-v256:256:256-v512:512:512-v1024:1024:1024-n8:16:32" +target triple = "air64_v28-apple-macosx26.0.0" + +%struct.Shape = type { i32, i32 } + +; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn +define <{ <4 x float> }> @xrr_vertex(i32 noundef %0) local_unnamed_addr #0 { + %2 = shl i32 %0, 1 + %3 = and i32 %2, 2 + %4 = tail call fast float @air.convert.f.f32.u.i32(i32 %3) #3 + %5 = insertelement <2 x float> undef, float %4, i64 0 + %6 = and i32 %0, 2 + %7 = tail call fast float @air.convert.f.f32.u.i32(i32 %6) #3 + %8 = insertelement <2 x float> %5, float %7, i64 1 + %9 = fmul fast <2 x float> %8, + %10 = fadd fast <2 x float> %9, + %11 = shufflevector <2 x float> %10, <2 x float> poison, <4 x i32> + %12 = shufflevector <4 x float> %11, <4 x float> , <4 x i32> + %13 = insertvalue <{ <4 x float> }> undef, <4 x float> %12, 0 + ret <{ <4 x float> }> %13 +} + +; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn +declare float @air.convert.f.f32.u.i32(i32) local_unnamed_addr #1 + +; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn +define <4 x float> @xrr_samples(<4 x float> %0, i32 noundef %1, <4 x float> addrspace(2)* nocapture noundef readonly "air-buffer-no-alias" %2, %struct.Shape addrspace(2)* nocapture noundef readonly align 4 dereferenceable(8) "air-buffer-no-alias" %3) local_unnamed_addr #2 { + %5 = extractelement <4 x float> %0, i64 1 + %6 = tail call i32 @air.convert.u.i32.f.f32(float %5) #3 + %7 = getelementptr inbounds %struct.Shape, %struct.Shape addrspace(2)* %3, i64 0, i32 0 + %8 = load i32, i32 addrspace(2)* %7, align 4, !tbaa !29, !alias.scope !34, !noalias !37 + %9 = mul i32 %8, %6 + %10 = extractelement <4 x float> %0, i64 0 + %11 = tail call i32 @air.convert.u.i32.f.f32(float %10) #3 + %12 = add i32 %9, %11 + %13 = getelementptr inbounds %struct.Shape, %struct.Shape addrspace(2)* %3, i64 0, i32 1 + %14 = load i32, i32 addrspace(2)* %13, align 4, !tbaa !39, !alias.scope !34, !noalias !37 + %15 = mul i32 %12, %14 + %16 = add i32 %15, %1 + %17 = zext i32 %16 to i64 + %18 = getelementptr inbounds <4 x float>, <4 x float> addrspace(2)* %2, i64 %17 + %19 = load <4 x float>, <4 x float> addrspace(2)* %18, align 16, !tbaa !40, !alias.scope !37, !noalias !34 + ret <4 x float> %19 +} + +; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn +declare i32 @air.convert.u.i32.f.f32(float) local_unnamed_addr #1 + +attributes #0 = { mustprogress nofree nosync nounwind readnone willreturn "approx-func-fp-math"="true" "frame-pointer"="all" "min-legal-vector-width"="0" "no-builtins" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="true" } +attributes #1 = { mustprogress nofree nosync nounwind readnone willreturn } +attributes #2 = { mustprogress nofree nosync nounwind readnone willreturn "approx-func-fp-math"="true" "frame-pointer"="all" "min-legal-vector-width"="128" "no-builtins" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="true" } +attributes #3 = { nounwind readnone willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8} +!air.vertex = !{!9} +!air.fragment = !{!14} +!air.compile_options = !{!23, !24, !25} +!llvm.ident = !{!26} +!air.version = !{!27} +!air.language_version = !{!28} + +!0 = !{i32 2, !"SDK Version", [2 x i32] [i32 27, i32 0]} +!1 = !{i32 1, !"wchar_size", i32 4} +!2 = !{i32 7, !"frame-pointer", i32 2} +!3 = !{i32 7, !"air.max_device_buffers", i32 31} +!4 = !{i32 7, !"air.max_constant_buffers", i32 31} +!5 = !{i32 7, !"air.max_threadgroup_buffers", i32 31} +!6 = !{i32 7, !"air.max_textures", i32 128} +!7 = !{i32 7, !"air.max_read_write_textures", i32 8} +!8 = !{i32 7, !"air.max_samplers", i32 16} +!9 = !{<{ <4 x float> }> (i32)* @xrr_vertex, !10, !12} +!10 = !{!11} +!11 = !{!"air.position", !"air.arg_type_name", !"float4", !"air.arg_name", !"position"} +!12 = !{!13} +!13 = !{i32 0, !"air.vertex_id", !"air.arg_type_name", !"uint", !"air.arg_name", !"id"} +!14 = !{<4 x float> (<4 x float>, i32, <4 x float> addrspace(2)*, %struct.Shape addrspace(2)*)* @xrr_samples, !15, !17} +!15 = !{!16} +!16 = !{!"air.render_target", i32 0, i32 0, !"air.arg_type_name", !"float4"} +!17 = !{!18, !19, !20, !21} +!18 = !{i32 0, !"air.position", !"air.center", !"air.no_perspective", !"air.arg_type_name", !"float4", !"air.arg_name", !"position"} +!19 = !{i32 1, !"air.sample_id", !"air.arg_type_name", !"uint", !"air.arg_name", !"sample"} +!20 = !{i32 2, !"air.buffer", !"air.location_index", i32 0, i32 1, !"air.read", !"air.address_space", i32 2, !"air.arg_type_size", i32 16, !"air.arg_type_align_size", i32 16, !"air.arg_type_name", !"float4", !"air.arg_name", !"colors"} +!21 = !{i32 3, !"air.buffer", !"air.buffer_size", i32 8, !"air.location_index", i32 1, i32 1, !"air.read", !"air.address_space", i32 2, !"air.struct_type_info", !22, !"air.arg_type_size", i32 8, !"air.arg_type_align_size", i32 4, !"air.arg_type_name", !"Shape", !"air.arg_name", !"shape"} +!22 = !{i32 0, i32 4, i32 0, !"uint", !"width", i32 4, i32 4, i32 0, !"uint", !"samples"} +!23 = !{!"air.compile.denorms_disable"} +!24 = !{!"air.compile.fast_math_enable"} +!25 = !{!"air.compile.framebuffer_fetch_enable"} +!26 = !{!"Apple metal version 32023.921 (metalfe-32023.921.6)"} +!27 = !{i32 2, i32 8, i32 0} +!28 = !{!"Metal", i32 4, i32 0, i32 0} +!29 = !{!30, !31, i64 0} +!30 = !{!"_ZTS5Shape", !31, i64 0, !31, i64 4} +!31 = !{!"int", !32, i64 0} +!32 = !{!"omnipotent char", !33, i64 0} +!33 = !{!"Simple C++ TBAA"} +!34 = !{!35} +!35 = distinct !{!35, !36, !"air-alias-scope-arg(3)"} +!36 = distinct !{!36, !"air-alias-scopes(xrr_samples)"} +!37 = !{!38} +!38 = distinct !{!38, !36, !"air-alias-scope-arg(2)"} +!39 = !{!30, !31, i64 4} +!40 = !{!32, !32, i64 0} diff --git a/crates/metal2vulkan-validation/fixtures/public/engine/xr_resolve.ll b/crates/metal2vulkan-validation/fixtures/public/engine/xr_resolve.ll new file mode 100644 index 000000000..bc11b0752 --- /dev/null +++ b/crates/metal2vulkan-validation/fixtures/public/engine/xr_resolve.ll @@ -0,0 +1,105 @@ +; Generated by scripts/regen-air-fixtures from xr_resolve.metal (llvm-dis of xr_resolve.air). Do not edit. +; ModuleID = '' +source_filename = "-" +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v24:32:32-v32:32:32-v48:64:64-v64:64:64-v96:128:128-v128:128:128-v192:256:256-v256:256:256-v512:512:512-v1024:1024:1024-n8:16:32" +target triple = "air64_v28-apple-macosx26.0.0" + +%struct.Shape = type { i32, i32 } + +; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none) +define <{ <4 x float> }> @xrr_vertex(i32 noundef %0) local_unnamed_addr #0 { + %2 = shl i32 %0, 1 + %3 = and i32 %2, 2 + %4 = tail call fast float @air.convert.f.f32.u.i32(i32 %3) #3 + %5 = insertelement <2 x float> undef, float %4, i64 0 + %6 = and i32 %0, 2 + %7 = tail call fast float @air.convert.f.f32.u.i32(i32 %6) #3 + %8 = insertelement <2 x float> %5, float %7, i64 1 + %9 = fmul fast <2 x float> %8, splat (float 2.000000e+00) + %10 = fadd fast <2 x float> %9, splat (float -1.000000e+00) + %11 = shufflevector <2 x float> %10, <2 x float> poison, <4 x i32> + %12 = shufflevector <4 x float> %11, <4 x float> , <4 x i32> + %13 = insertvalue <{ <4 x float> }> undef, <4 x float> %12, 0 + ret <{ <4 x float> }> %13 +} + +; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none) +declare float @air.convert.f.f32.u.i32(i32) local_unnamed_addr #1 + +; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none) +define <4 x float> @xrr_samples(<4 x float> %0, i32 noundef %1, ptr addrspace(2) noundef readonly captures(none) "air-buffer-no-alias" %2, ptr addrspace(2) noundef readonly align 4 captures(none) dereferenceable(8) "air-buffer-no-alias" %3) local_unnamed_addr #2 { + %5 = extractelement <4 x float> %0, i64 1 + %6 = tail call i32 @air.convert.u.i32.f.f32(float %5) #3 + %7 = getelementptr inbounds %struct.Shape, ptr addrspace(2) %3, i64 0, i32 0 + %8 = load i32, ptr addrspace(2) %7, align 4, !tbaa !29, !alias.scope !34, !noalias !37 + %9 = mul i32 %8, %6 + %10 = extractelement <4 x float> %0, i64 0 + %11 = tail call i32 @air.convert.u.i32.f.f32(float %10) #3 + %12 = add i32 %9, %11 + %13 = getelementptr inbounds %struct.Shape, ptr addrspace(2) %3, i64 0, i32 1 + %14 = load i32, ptr addrspace(2) %13, align 4, !tbaa !39, !alias.scope !34, !noalias !37 + %15 = mul i32 %12, %14 + %16 = add i32 %15, %1 + %17 = zext i32 %16 to i64 + %18 = getelementptr inbounds <4 x float>, ptr addrspace(2) %2, i64 %17 + %19 = load <4 x float>, ptr addrspace(2) %18, align 16, !tbaa !40, !alias.scope !37, !noalias !34 + ret <4 x float> %19 +} + +; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none) +declare i32 @air.convert.u.i32.f.f32(float) local_unnamed_addr #1 + +attributes #0 = { mustprogress nofree nosync nounwind willreturn memory(none) "approx-func-fp-math"="true" "frame-pointer"="all" "min-legal-vector-width"="0" "no-builtins" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="true" } +attributes #1 = { mustprogress nofree nosync nounwind willreturn memory(none) } +attributes #2 = { mustprogress nofree nosync nounwind willreturn memory(none) "approx-func-fp-math"="true" "frame-pointer"="all" "min-legal-vector-width"="128" "no-builtins" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="true" } +attributes #3 = { nounwind willreturn memory(none) } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8} +!air.vertex = !{!9} +!air.fragment = !{!14} +!air.compile_options = !{!23, !24, !25} +!llvm.ident = !{!26} +!air.version = !{!27} +!air.language_version = !{!28} + +!0 = !{i32 2, !"SDK Version", [2 x i32] [i32 27, i32 0]} +!1 = !{i32 1, !"wchar_size", i32 4} +!2 = !{i32 7, !"frame-pointer", i32 2} +!3 = !{i32 7, !"air.max_device_buffers", i32 31} +!4 = !{i32 7, !"air.max_constant_buffers", i32 31} +!5 = !{i32 7, !"air.max_threadgroup_buffers", i32 31} +!6 = !{i32 7, !"air.max_textures", i32 128} +!7 = !{i32 7, !"air.max_read_write_textures", i32 8} +!8 = !{i32 7, !"air.max_samplers", i32 16} +!9 = !{ptr @xrr_vertex, !10, !12} +!10 = !{!11} +!11 = !{!"air.position", !"air.arg_type_name", !"float4", !"air.arg_name", !"position"} +!12 = !{!13} +!13 = !{i32 0, !"air.vertex_id", !"air.arg_type_name", !"uint", !"air.arg_name", !"id"} +!14 = !{ptr @xrr_samples, !15, !17} +!15 = !{!16} +!16 = !{!"air.render_target", i32 0, i32 0, !"air.arg_type_name", !"float4"} +!17 = !{!18, !19, !20, !21} +!18 = !{i32 0, !"air.position", !"air.center", !"air.no_perspective", !"air.arg_type_name", !"float4", !"air.arg_name", !"position"} +!19 = !{i32 1, !"air.sample_id", !"air.arg_type_name", !"uint", !"air.arg_name", !"sample"} +!20 = !{i32 2, !"air.buffer", !"air.location_index", i32 0, i32 1, !"air.read", !"air.address_space", i32 2, !"air.arg_type_size", i32 16, !"air.arg_type_align_size", i32 16, !"air.arg_type_name", !"float4", !"air.arg_name", !"colors"} +!21 = !{i32 3, !"air.buffer", !"air.buffer_size", i32 8, !"air.location_index", i32 1, i32 1, !"air.read", !"air.address_space", i32 2, !"air.struct_type_info", !22, !"air.arg_type_size", i32 8, !"air.arg_type_align_size", i32 4, !"air.arg_type_name", !"Shape", !"air.arg_name", !"shape"} +!22 = !{i32 0, i32 4, i32 0, !"uint", !"width", i32 4, i32 4, i32 0, !"uint", !"samples"} +!23 = !{!"air.compile.denorms_disable"} +!24 = !{!"air.compile.fast_math_enable"} +!25 = !{!"air.compile.framebuffer_fetch_enable"} +!26 = !{!"Apple metal version 32023.921 (metalfe-32023.921.6)"} +!27 = !{i32 2, i32 8, i32 0} +!28 = !{!"Metal", i32 4, i32 0, i32 0} +!29 = !{!30, !31, i64 0} +!30 = !{!"_ZTS5Shape", !31, i64 0, !31, i64 4} +!31 = !{!"int", !32, i64 0} +!32 = !{!"omnipotent char", !33, i64 0} +!33 = !{!"Simple C++ TBAA"} +!34 = !{!35} +!35 = distinct !{!35, !36, !"air-alias-scope-arg(3)"} +!36 = distinct !{!36, !"air-alias-scopes(xrr_samples)"} +!37 = !{!38} +!38 = distinct !{!38, !36, !"air-alias-scope-arg(2)"} +!39 = !{!30, !31, i64 4} +!40 = !{!32, !32, i64 0} diff --git a/crates/metal2vulkan-validation/fixtures/public/engine/xr_resolve.metal b/crates/metal2vulkan-validation/fixtures/public/engine/xr_resolve.metal new file mode 100644 index 000000000..9ff7aa81d --- /dev/null +++ b/crates/metal2vulkan-validation/fixtures/public/engine/xr_resolve.metal @@ -0,0 +1,29 @@ +// The functions of the extended-range resolve lane +// (validation/src/runtime_lane/extended_range_resolve.rs), our own MSL: a fullscreen triangle, and a +// fragment function that runs once per sample and writes each sample its own color, read from +// buffer 0 at `(y * width + x) * samples + sample`, the width and the samples in buffer 1. +#include +using namespace metal; + +struct Position { + float4 position [[position]]; +}; + +struct Shape { + uint width; + uint samples; +}; + +vertex Position xrr_vertex(uint id [[vertex_id]]) { + float2 p = float2((id << 1) & 2, id & 2); + Position out; + out.position = float4(p * 2.0 - 1.0, 0.5, 1.0); + return out; +} + +fragment float4 xrr_samples(Position in [[stage_in]], uint sample [[sample_id]], + constant float4 *colors [[buffer(0)]], + constant Shape &shape [[buffer(1)]]) { + uint pixel = uint(in.position.y) * shape.width + uint(in.position.x); + return colors[pixel * shape.samples + sample]; +} diff --git a/crates/metal2vulkan-validation/src/runtime_lane.rs b/crates/metal2vulkan-validation/src/runtime_lane.rs index cb9d71eaa..a990c1e34 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane.rs @@ -406,6 +406,8 @@ mod extended_range_blends; #[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))] mod extended_range_planes; #[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))] +mod extended_range_resolve; +#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))] mod extended_range_samples; #[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))] mod extended_range_targets; diff --git a/crates/metal2vulkan-validation/src/runtime_lane/extended_range_resolve.rs b/crates/metal2vulkan-validation/src/runtime_lane/extended_range_resolve.rs new file mode 100644 index 000000000..926b83de7 --- /dev/null +++ b/crates/metal2vulkan-validation/src/runtime_lane/extended_range_resolve.rs @@ -0,0 +1,408 @@ +//! Multisample resolves of the extended-range formats Metal makes multisampled textures of +//! (`BGR10_XR`, `BGRA10_XR`, their `_sRGB` twins and `RGB10A2Unorm_sRGB`), on the device the cfg +//! selects, under the validation layer, over the owned fixture `xr_resolve`. +//! +//! Each pass draws an 8 x 4 target at 2 or 4 samples, each sample its own color: our probe `xr`'s +//! values (its generator, seed 7, its first 32 pixels), whose resolves Metal wrote on an Apple M3 +//! Max under macOS 27.0.1 ([`METAL`]). A linear form's color resolves by Metal's rule, the +//! average of the samples' codes rounded half up, so each such channel is Metal's code; +//! `BGRA10_XR`'s alpha, an `_sRGB` twin's color and `RGB10A2Unorm_sRGB`'s channels average values +//! the codes do not keep, so the runtime writes a near-equivalent, announced as +//! `extended-range-resolve`, each such channel here within one code of Metal's (the probe's 32 +//! pixels; `bind::ColorResolveFormat::extended_range` states the bounds over its 4096). A second +//! pass draws every sample of a pixel alike, whose resolve is the code a single-sampled target of +//! the same draw stores, as Metal's resolve of samples of one value is. + +use super::degrade_notices::assert_once; +use super::{buffer_with, read_buffer, validated_device_with, Messages, ScratchCache, WAIT}; +use crate::air_library::AirLibrary; +use crate::gpu::TEST_DEVICE; +use metal2vulkan::metal::{PixelFormat, PrimitiveType, TextureType, TextureUsage}; +use metal2vulkan::pipeline::{ColorAttachmentDescriptor, RenderPipelineDescriptor, StageSource}; +use metal2vulkan_devtools::{engine_dir, llvm_assemble}; +use metal2vulkan_runtime::{ + BlitOption, ClearColor, CommandQueue, Degradation, Device, Library, LoadAction, Origin, + PipelineOptions, RenderPassDescriptor, ResourceOptions, Size, StoreAction, Texture, + TextureDescriptor, +}; + +/// The target's width and height. +const WIDTH: u64 = 8; +const HEIGHT: u64 = 4; +/// Its pixels. +const PIXELS: usize = (WIDTH * HEIGHT) as usize; + +/// Metal's resolved codes of each pixel (red, green, blue and alpha, 16 bits each from the top; +/// `BGR10_XR`'s alpha 0), by format and sample count: probe `xr` on an Apple M3 Max under macOS +/// 27.0.1. +#[rustfmt::skip] +const METAL: [(PixelFormat, u32, [u64; PIXELS]); 10] = [ + (PixelFormat::BGRA10XR, 2, [ + 0x03ce_00c1_02a0_0278, 0x00b8_002c_0040_021d, 0x0343_0327_00df_0336, 0x01bf_017e_02a3_02f2, + 0x0117_01c3_002a_0308, 0x03bd_01be_0197_0280, 0x0141_011a_002b_0180, 0x03d1_02f8_025f_0360, + 0x00a0_02cd_00d5_01c6, 0x020d_0162_0150_0180, 0x01ba_016e_021a_019c, 0x0056_00ec_0362_0180, + 0x0280_01ac_01f5_025c, 0x0301_01e0_019f_0252, 0x0391_022c_0158_0257, 0x0241_02ad_0000_0180, + 0x030e_022d_01d8_0180, 0x0009_032e_0113_030f, 0x03fc_004a_0252_0291, 0x029d_0386_033d_037e, + 0x0144_038f_0033_0318, 0x0146_0134_0279_01c4, 0x028c_01ad_0129_0247, 0x024a_02fa_005c_02df, + 0x01f4_01c8_02ee_01cc, 0x002d_01ee_01a9_01e8, 0x0066_02e3_005d_02fa, 0x0088_0342_026e_0180, + 0x01e3_0270_0114_0219, 0x0008_0183_016c_0250, 0x0102_004f_01b5_037e, 0x006d_026e_0122_01eb, + ]), + (PixelFormat::BGRA10XR, 4, [ + 0x026b_026e_0199_0281, 0x03ec_033f_00e0_0227, 0x004b_02ac_01a5_0180, 0x03bd_0174_00e5_01e6, + 0x0284_02a6_02ed_01d6, 0x01ed_036f_03d7_0205, 0x01b9_01d7_025f_01c7, 0x03b9_0204_036b_0294, + 0x01ab_033f_01b1_0229, 0x0241_03ff_0000_0180, 0x00ff_03c2_0113_01d8, 0x0348_021b_0081_02be, + 0x01e7_018b_01ff_0286, 0x007a_008f_0128_032a, 0x0108_028f_0002_037e, 0x002c_00b5_0024_0316, + 0x01a9_02af_0198_0257, 0x0382_02b8_03f5_0180, 0x0102_02c1_00e3_02c9, 0x02a5_027d_0179_01a7, + 0x01e1_018a_00f9_0278, 0x00f1_0201_0196_0212, 0x00af_03d4_03ff_02f4, 0x0001_019b_01fd_037e, + 0x017b_0265_0164_025b, 0x017d_00ed_031d_037e, 0x0252_016c_0381_02ac, 0x0376_0007_02a4_0368, + 0x0299_0272_018a_0231, 0x00d5_0296_03c1_0308, 0x0138_012f_00f4_01a7, 0x00a5_009e_032f_01fa, + ]), + (PixelFormat::BGRA10XRSRGB, 2, [ + 0x039f_0037_030d_0278, 0x002f_0000_0000_021d, 0x0363_0356_004f_0336, 0x0245_0167_030e_02f2, + 0x0085_024b_0000_0308, 0x0399_0244_01f8_0280, 0x00bb_0088_0000_0180, 0x03a1_033d_02e1_0360, + 0x001e_0327_007c_01c6, 0x029f_00f7_00d2_0180, 0x023c_0115_02aa_019c, 0x0000_005a_0371_0180, + 0x02f7_0226_0287_025c, 0x0343_0270_020b_0252, 0x0386_02ba_00e1_0257, 0x02cb_0314_0000_0180, + 0x0349_02ba_0267_0180, 0x0000_0359_0081_030f, 0x03b2_0000_02d8_0291, 0x030a_0381_0360_037e, + 0x00be_0385_0000_0318, 0x00c3_00a9_02f3_01c4, 0x02ff_0227_009a_0247, 0x02d2_033e_0000_02df, + 0x02bb_0252_0339_01cc, 0x0000_027f_021f_01e8, 0x0000_0333_0000_02fa, 0x000d_0363_02eb_0180, + 0x0274_02ed_0082_0219, 0x0000_019f_0111_0250, 0x006f_0000_0235_037e, 0x0000_02eb_0092_01eb, + ]), + (PixelFormat::BGRA10XRSRGB, 4, [ + 0x02ea_02ec_01fc_0281, 0x03ac_0361_0050_0227, 0x0000_0313_0217_0180, 0x0399_012d_0055_01e6, + 0x0307_0310_0338_01d6, 0x027f_0377_03a3_0205, 0x023c_0265_02e1_01c7, 0x0397_0296_0375_0294, + 0x022e_0361_0238_0229, 0x02cb_03ba_0000_0180, 0x006d_039b_0081_01d8, 0x0365_02ac_0009_02be, + 0x0278_0225_0291_0286, 0x0004_0012_009a_032a, 0x0076_0302_0000_037e, 0x0000_002d_0000_0316, + 0x0220_0315_0236_0257, 0x0380_031a_03af_0180, 0x006f_0320_0053_02c9, 0x030f_02f5_0141_01a7, + 0x0271_01cc_0082_0278, 0x0060_0293_01f5_0212, 0x0029_03a2_03b6_02f4, 0x0000_0202_028f_037e, + 0x01d7_02e5_0130_025b, 0x015d_005c_0350_037e, 0x02d8_0110_037f_02ac, 0x037a_0000_030e_0368, + 0x030b_02ee_021c_0231, 0x0047_0305_039a_0308, 0x00ad_00a1_0062_01a7, 0x0022_001d_035a_01fa, + ]), + (PixelFormat::BGR10XR, 2, [ + 0x03ce_00c1_02a0_0000, 0x00b8_002c_0040_0000, 0x0343_0327_00df_0000, 0x01bf_017e_02a3_0000, + 0x0117_01c3_002a_0000, 0x03bd_01be_0197_0000, 0x0141_011a_002b_0000, 0x03d1_02f8_025f_0000, + 0x00a0_02cd_00d5_0000, 0x020d_0162_0150_0000, 0x01ba_016e_021a_0000, 0x0056_00ec_0362_0000, + 0x0280_01ac_01f5_0000, 0x0301_01e0_019f_0000, 0x0391_022c_0158_0000, 0x0241_02ad_0000_0000, + 0x030e_022d_01d8_0000, 0x0009_032e_0113_0000, 0x03fc_004a_0252_0000, 0x029d_0386_033d_0000, + 0x0144_038f_0033_0000, 0x0146_0134_0279_0000, 0x028c_01ad_0129_0000, 0x024a_02fa_005c_0000, + 0x01f4_01c8_02ee_0000, 0x002d_01ee_01a9_0000, 0x0066_02e3_005d_0000, 0x0088_0342_026e_0000, + 0x01e3_0270_0114_0000, 0x0008_0183_016c_0000, 0x0102_004f_01b5_0000, 0x006d_026e_0122_0000, + ]), + (PixelFormat::BGR10XR, 4, [ + 0x026b_026e_0199_0000, 0x03ec_033f_00e0_0000, 0x004b_02ac_01a5_0000, 0x03bd_0174_00e5_0000, + 0x0284_02a6_02ed_0000, 0x01ed_036f_03d7_0000, 0x01b9_01d7_025f_0000, 0x03b9_0204_036b_0000, + 0x01ab_033f_01b1_0000, 0x0241_03ff_0000_0000, 0x00ff_03c2_0113_0000, 0x0348_021b_0081_0000, + 0x01e7_018b_01ff_0000, 0x007a_008f_0128_0000, 0x0108_028f_0002_0000, 0x002c_00b5_0024_0000, + 0x01a9_02af_0198_0000, 0x0382_02b8_03f5_0000, 0x0102_02c1_00e3_0000, 0x02a5_027d_0179_0000, + 0x01e1_018a_00f9_0000, 0x00f1_0201_0196_0000, 0x00af_03d4_03ff_0000, 0x0001_019b_01fd_0000, + 0x017b_0265_0164_0000, 0x017d_00ed_031d_0000, 0x0252_016c_0381_0000, 0x0376_0007_02a4_0000, + 0x0299_0272_018a_0000, 0x00d5_0296_03c1_0000, 0x0138_012f_00f4_0000, 0x00a5_009e_032f_0000, + ]), + (PixelFormat::BGR10XRSRGB, 2, [ + 0x039f_0037_030d_0000, 0x002f_0000_0000_0000, 0x0363_0356_004f_0000, 0x0245_0167_030e_0000, + 0x0085_024b_0000_0000, 0x0399_0244_01f8_0000, 0x00bb_0088_0000_0000, 0x03a1_033d_02e1_0000, + 0x001e_0327_007c_0000, 0x029f_00f7_00d2_0000, 0x023c_0115_02aa_0000, 0x0000_005a_0371_0000, + 0x02f7_0226_0287_0000, 0x0343_0270_020b_0000, 0x0386_02ba_00e1_0000, 0x02cb_0314_0000_0000, + 0x0349_02ba_0267_0000, 0x0000_0359_0081_0000, 0x03b2_0000_02d8_0000, 0x030a_0381_0360_0000, + 0x00be_0385_0000_0000, 0x00c3_00a9_02f3_0000, 0x02ff_0227_009a_0000, 0x02d2_033e_0000_0000, + 0x02bb_0252_0339_0000, 0x0000_027f_021f_0000, 0x0000_0333_0000_0000, 0x000d_0363_02eb_0000, + 0x0274_02ed_0082_0000, 0x0000_019f_0111_0000, 0x006f_0000_0235_0000, 0x0000_02eb_0092_0000, + ]), + (PixelFormat::BGR10XRSRGB, 4, [ + 0x02ea_02ec_01fc_0000, 0x03ac_0361_0050_0000, 0x0000_0313_0217_0000, 0x0399_012d_0055_0000, + 0x0307_0310_0338_0000, 0x027f_0377_03a3_0000, 0x023c_0265_02e1_0000, 0x0397_0296_0375_0000, + 0x022e_0361_0238_0000, 0x02cb_03ba_0000_0000, 0x006d_039b_0081_0000, 0x0365_02ac_0009_0000, + 0x0278_0225_0291_0000, 0x0004_0012_009a_0000, 0x0076_0302_0000_0000, 0x0000_002d_0000_0000, + 0x0220_0315_0236_0000, 0x0380_031a_03af_0000, 0x006f_0320_0053_0000, 0x030f_02f5_0141_0000, + 0x0271_01cc_0082_0000, 0x0060_0293_01f5_0000, 0x0029_03a2_03b6_0000, 0x0000_0202_028f_0000, + 0x01d7_02e5_0130_0000, 0x015d_005c_0350_0000, 0x02d8_0110_037f_0000, 0x037a_0000_030e_0000, + 0x030b_02ee_021c_0000, 0x0047_0305_039a_0000, 0x00ad_00a1_0062_0000, 0x0022_001d_035a_0000, + ]), + (PixelFormat::RGB10A2UnormSRGB, 2, [ + 0x03fc_01a8_034a_0001, 0x0198_0000_0000_0001, 0x03be_03af_01d4_0002, 0x02bd_0284_0361_0002, + 0x021a_02c0_0000_0002, 0x03fe_02bc_029b_0002, 0x0248_0220_0000_0000, 0x03ff_0393_0335_0003, + 0x0170_037b_01f1_0000, 0x02fb_026a_0258_0000, 0x02b8_0275_0303_0000, 0x00aa_01e4_03cf_0000, + 0x034a_02ad_02e8_0001, 0x0399_02d8_02a2_0001, 0x03e8_0310_0261_0001, 0x031f_0366_0000_0000, + 0x0396_0311_02d2_0000, 0x0000_03b3_0215_0002, 0x03ff_0065_032b_0002, 0x035c_03e2_03bb_0003, + 0x024b_03e2_0087_0002, 0x024e_023c_0345_0001, 0x0351_02ae_022f_0001, 0x0325_0394_00c0_0002, + 0x02f0_02c5_037d_0000, 0x0000_02e2_02ab_0001, 0x00e3_0388_00c5_0002, 0x0140_03bd_033d_0000, + 0x02da_033f_0217_0001, 0x0000_028a_0274_0001, 0x0201_0087_02b5_0003, 0x00f8_033d_0227_0001, + ]), + (PixelFormat::RGB10A2UnormSRGB, 4, [ + 0x0335_0333_029c_0002, 0x03ff_03bc_01d6_0001, 0x006b_0366_02a8_0000, 0x03fe_027b_01dc_0001, + 0x034e_0362_038d_0001, 0x02e1_03d6_03ff_0001, 0x02b7_02d0_0335_0001, 0x03fc_02f4_03d4_0002, + 0x02ad_03bb_02b2_0001, 0x031f_03ff_0000_0000, 0x01fd_03ff_0217_0001, 0x03c1_0305_012e_0002, + 0x02da_0298_02ef_0002, 0x011c_014d_022f_0002, 0x020a_0354_0000_0003, 0x0000_0194_0000_0002, + 0x02ab_0368_02ab_0001, 0x03e0_036d_03ff_0000, 0x0200_0374_01d9_0002, 0x0361_0348_027f_0000, + 0x02d8_0283_0208_0001, 0x01ee_02f1_029b_0001, 0x018a_03ff_03ff_0002, 0x0000_029f_02ed_0003, + 0x0286_0338_0271_0001, 0x0283_01e7_03a9_0003, 0x032c_0274_03df_0002, 0x03d9_0000_0360_0003, + 0x0350_0341_029e_0001, 0x01c5_0358_03ff_0002, 0x023f_0234_01f1_0000, 0x0177_016c_03b4_0001, + ]), +]; + +/// The probe's generator: a 64-bit LCG, each draw its top 53 bits over 2^53. +struct Lcg(u64); + +impl Lcg { + fn next(&mut self) -> f64 { + self.0 = self + .0 + .wrapping_mul(6364136223846793005) + .wrapping_add(1442695040888963407); + (self.0 >> 11) as f64 / 9007199254740992.0 + } +} + +/// The probe's per-sample colors (red, green, blue, alpha) of its first [`PIXELS`] pixels at +/// `samples` for `pf`, each pixel's samples in turn, in the probe's draw order: each channel +/// anything in its range, or by the pixel's kind near one code (centers, off center, or half +/// codes). +fn values(pf: PixelFormat, samples: u32) -> Vec<[f32; 4]> { + let mut rng = Lcg(7); + let n = samples as usize; + let mut out = vec![[0.0f32; 4]; PIXELS * n]; + let padded = pf == PixelFormat::RGB10A2UnormSRGB; + for px in 0..PIXELS { + let kind = px & 3; + for ch in 0..4 { + let (lo, hi) = match (padded, ch) { + (true, _) => (-0.1, 1.1), + (false, 3) => (-0.2, 1.2), + (false, _) => (-0.8, 1.3), + }; + let base = lo + (hi - lo) * rng.next(); + let code = (base * 510.0 + 384.5) as i32; + for sample in &mut out[px * n..(px + 1) * n] { + let x = match kind { + 0 => lo + (hi - lo) * rng.next(), + 1 => f64::from(code + (rng.next() * 3.0) as i32 - 1 - 384) / 510.0, + 2 => (f64::from(code) + (rng.next() - 0.5) * 3.0 - 384.0) / 510.0, + _ => { + let halves = f64::from((rng.next() * 4.0) as i32); + (f64::from(code - 384) + 0.5 * halves - 1.0) / 510.0 + } + }; + sample[ch] = x as f32; + } + } + } + out +} + +/// The bytes of a texel of `pf`. +fn texel_bytes(pf: PixelFormat) -> u64 { + match pf { + PixelFormat::BGRA10XR | PixelFormat::BGRA10XRSRGB => 8, + _ => 4, + } +} + +/// The codes (red, green, blue, alpha; `BGR10_XR`'s alpha 0) of a raw texel of `pf`. +fn codes(pf: PixelFormat, texel: &[u8]) -> [u32; 4] { + match pf { + PixelFormat::BGRA10XR | PixelFormat::BGRA10XRSRGB => { + let (fields, _) = texel.as_chunks::<2>(); + let field = |i: usize| u32::from(u16::from_le_bytes(fields[i])) >> 6; + [field(2), field(1), field(0), field(3)] + } + PixelFormat::BGR10XR | PixelFormat::BGR10XRSRGB => { + let w = u32::from_le_bytes(texel.try_into().unwrap()); + [(w >> 20) & 1023, (w >> 10) & 1023, w & 1023, 0] + } + _ => { + let w = u32::from_le_bytes(texel.try_into().unwrap()); + [w & 1023, (w >> 10) & 1023, (w >> 20) & 1023, w >> 30] + } + } +} + +/// The channels `pf` has. +fn channels(pf: PixelFormat) -> usize { + match pf { + PixelFormat::BGR10XR | PixelFormat::BGR10XRSRGB => 3, + _ => 4, + } +} + +/// Whether `pf`'s channel `ch` resolves by Metal's rule (a linear form's color), not by the +/// near-equivalent. +fn by_rule(pf: PixelFormat, ch: usize) -> bool { + matches!(pf, PixelFormat::BGRA10XR | PixelFormat::BGR10XR) && ch < 3 +} + +/// Metal's codes of `word`, red first. +fn unpacked(word: u64) -> [u32; 4] { + [48, 32, 16, 0].map(|shift| ((word >> shift) & 0xffff) as u32) +} + +struct Lane { + device: Device, + queue: CommandQueue, + library: Library, +} + +impl Lane { + fn new(messages: &Messages, cache: &ScratchCache) -> Lane { + let device = validated_device_with(TEST_DEVICE, messages, cache.path(), |_| {}).unwrap(); + let bitcode = llvm_assemble(&engine_dir().join("xr_resolve.ll")).unwrap(); + Lane { + queue: device.new_command_queue().unwrap(), + library: device.new_library_with_air(&bitcode).unwrap(), + device, + } + } + + fn function(&self, name: &str) -> StageSource { + StageSource::Function( + self.library + .new_function_with_name(name) + .unwrap() + .function_descriptor(), + ) + } + + /// A private render target of `pf`, `samples` deep. + fn texture(&self, pf: PixelFormat, samples: u32) -> Texture { + let mut d = TextureDescriptor::texture_2d(pf, WIDTH, HEIGHT, false); + if samples > 1 { + d.texture_type = TextureType::Type2DMultisample; + d.sample_count = u64::from(samples); + } + d.usage = TextureUsage::RENDER_TARGET; + d.resource_options = ResourceOptions::private(); + self.device.new_texture(&d).unwrap() + } + + /// Each pixel's codes after a pass drawing `colors` (each pixel's samples in turn) into a + /// target of `pf` at `samples`: stored and resolved into a single-sampled texture past one + /// sample, else stored. + fn draw(&self, pf: PixelFormat, samples: u32, colors: &[[f32; 4]]) -> Vec<[u32; 4]> { + let mut d = RenderPipelineDescriptor::new(self.function("xrr_vertex")); + d.fragment = Some(self.function("xrr_samples")); + d.color_attachments[0] = Some(ColorAttachmentDescriptor::new(pf)); + d.raster_sample_count = samples; + let pipeline = self + .device + .new_render_pipeline_state(&d, &PipelineOptions::default()) + .unwrap_or_else(|e| panic!("{pf:?} at {samples}: {e}")); + let target = self.texture(pf, samples); + let resolved = (samples > 1).then(|| self.texture(pf, 1)); + let bytes: Vec = colors + .iter() + .flatten() + .flat_map(|v| v.to_le_bytes()) + .collect(); + let values = buffer_with(&self.device, &bytes).unwrap(); + let shape = [WIDTH as u32, samples].map(u32::to_le_bytes).concat(); + let shape = buffer_with(&self.device, &shape).unwrap(); + let mut pass = RenderPassDescriptor::new(); + let a = &mut pass.color_attachments[0]; + a.texture = Some(target.clone()); + a.load_action = LoadAction::Clear; + a.clear_color = ClearColor::new(0.0, 0.0, 0.0, 0.0); + a.store_action = match &resolved { + Some(resolved) => { + a.resolve_texture = Some(resolved.clone()); + StoreAction::StoreAndMultisampleResolve + } + None => StoreAction::Store, + }; + let command_buffer = self.queue.command_buffer().unwrap(); + let mut e = command_buffer.render_command_encoder(&pass).unwrap(); + e.set_render_pipeline_state(&pipeline).unwrap(); + e.set_fragment_buffer(Some(&values), 0, 0).unwrap(); + e.set_fragment_buffer(Some(&shape), 0, 1).unwrap(); + e.draw_primitives(PrimitiveType::Triangle, 0, 3, 1, 0) + .unwrap(); + e.end_encoding().unwrap(); + let texel = texel_bytes(pf); + let length = texel * WIDTH * HEIGHT; + let out = buffer_with(&self.device, &vec![0; length as usize]).unwrap(); + let mut blit = command_buffer.blit_command_encoder().unwrap(); + blit.copy_from_texture_to_buffer( + resolved.as_ref().unwrap_or(&target), + 0, + 0, + Origin::new(0, 0, 0), + Size::new(WIDTH, HEIGHT, 1), + &out, + 0, + texel * WIDTH, + length, + BlitOption::None, + ) + .unwrap(); + blit.end_encoding().unwrap(); + command_buffer.commit().unwrap(); + command_buffer.wait_until_completed_for(WAIT).unwrap(); + assert_eq!(command_buffer.error(), None, "{pf:?} at {samples}"); + read_buffer(&out, 0, length) + .unwrap() + .chunks(texel as usize) + .map(|t| codes(pf, t)) + .collect() + } +} + +/// Each form's resolve of the probe's samples: a linear form's colors Metal's codes, the rest +/// within one code of Metal's; and of samples drawn alike, the code a single-sampled target of +/// the same draw stores. The near-equivalent is announced once, as is the extra pass. +#[test] +fn extended_range_resolves_are_metals_or_within_a_code() { + let messages = Messages::default(); + let cache = ScratchCache::new().unwrap(); + let lane = Lane::new(&messages, &cache); + let name = lane.device.name().to_owned(); + let mut wrong = Vec::new(); + for &(pf, samples, metal) in &METAL { + let colors = values(pf, samples); + let got = lane.draw(pf, samples, &colors); + let (mut same, mut near) = (0, 0); + for (px, (got, &metal)) in got.iter().zip(&metal).enumerate() { + let metal = unpacked(metal); + for ch in 0..channels(pf) { + match (got[ch].abs_diff(metal[ch]), by_rule(pf, ch)) { + (0, _) => same += 1, + (1, false) => near += 1, + _ => wrong.push(format!( + "{pf:?} at {samples}, pixel {px} channel {ch}: {} against Metal's {}", + got[ch], metal[ch] + )), + } + } + } + println!("{name}: {pf:?} at {samples}: {same} channels Metal's, {near} one code off"); + // Every sample of a pixel alike: the code a single-sampled draw of that color stores. + let firsts: Vec<[f32; 4]> = colors.iter().step_by(samples as usize).copied().collect(); + let alike: Vec<[f32; 4]> = firsts + .iter() + .flat_map(|&c| std::iter::repeat_n(c, samples as usize)) + .collect(); + let stored = lane.draw(pf, 1, &firsts); + let resolved = lane.draw(pf, samples, &alike); + if resolved != stored { + wrong.push(format!( + "{pf:?} at {samples}, samples alike: resolved {resolved:x?} against stored \ + {stored:x?}" + )); + } + } + assert!( + wrong.is_empty(), + "{name}: {} channels:\n{}", + wrong.len(), + wrong.join("\n") + ); + assert_once( + &messages.take_notices(), + &[ + Degradation::ExtendedRangeResolve, + Degradation::ShaderResolve, + ], + ); + drop(lane); + let reported = messages.take(); + assert!( + reported.is_empty(), + "the validation layer reported: {reported:#?}" + ); +} diff --git a/crates/metal2vulkan-validation/src/runtime_lane/mesh_draws.rs b/crates/metal2vulkan-validation/src/runtime_lane/mesh_draws.rs index c1b8f1939..f482cd926 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/mesh_draws.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/mesh_draws.rs @@ -41,9 +41,10 @@ //! be Metal's there too: the object function's compute dispatch writes each object threadgroup's //! grid and payload, a scan places their mesh threadgroups (or an indirect draw's, from Metal's //! arguments), and the mesh function's compute dispatch writes records that a synthesized vertex -//! stage draws. There the grid case's indirect draw draws; the object case's indirect draw is -//! refused (`NotImplemented(MeshShading)`), and so is a partial object threadgroup, as on a device -//! with the extension. +//! stage draws. There indirect draws draw too: an object function's through an object arguments +//! pass, which reads Metal's arguments, reserves the object threadgroups' slots in the records +//! pool and writes the object dispatch's grid. A partial object threadgroup is refused +//! (`NotImplemented(MeshShading)`), as on a device with the extension. use super::degrade_notices::{assert_made_once, made_mesh_kinds}; use super::gpu_times::read_kinds; @@ -492,8 +493,8 @@ fn mesh_draws_store_metals_words() { ); } -/// Each object case draws the words Metal drew (the module docs), but the indirect one and those -/// that leave a partial object threadgroup, refused, and each of [`OBJECT_PAST_CASES`] nothing; a +/// Each object case draws the words Metal drew (the module docs), but those that leave a partial +/// object threadgroup, refused, and each of [`OBJECT_PAST_CASES`] nothing; a /// device without `VK_EXT_mesh_shader` announces its emulated draws once ([`EMULATED_MESH`]), and /// another none. #[test] @@ -524,14 +525,6 @@ fn object_draws_store_metals_words() { }); let metals = metals(OBJECT_ANSWERS, case); match (draw, drawn) { - // The emulation's indirect draw with an object function. - (Draw::Indirect(..), Err(Error::Bind(BindError::Unsupported(u)))) - if u.feature == Feature::MeshShading - && u.needs == Needs::NotImplemented - && emulates(&lane.device) => - { - eprintln!("{case} on {name}: refused, emulated; Metal's: {metals:?}") - } (Draw::Threads(..), Err(Error::Bind(BindError::Unsupported(u)))) if u.feature == Feature::MeshShading && u.needs == Needs::NotImplemented => { @@ -753,8 +746,9 @@ const PAST_GRID: [u32; 3] = [(1 << 29) + 1, 1, 1]; /// Each of [`OBJECT_GRID_CASES`] leaves Metal's words on a device with `VK_EXT_mesh_shader`, its /// grid folded into the task stage's limits where it passes them, and each draw of [`PAST_GRID`] /// draws nothing and fails its command buffer as Metal's GPU discards it, a direct one from its -/// encoder on; the emulation refuses what passes its compute limits, and its indirect draws -/// (`Unsupported{MeshShading}`), printed. +/// encoder on. The emulation refuses a direct grid past its compute limits +/// (`Unsupported{MeshShading}`), and an indirect one past them, or whose threads per grid wrap +/// along an axis, draws nothing and fails its command buffer (`MeshGridPastLimits`), each printed. #[test] fn object_grids_run_as_metal_runs_them() { let cache = ScratchCache::new().unwrap(); @@ -836,14 +830,28 @@ fn object_grids_run_as_metal_runs_them() { ); (drawn, command_buffer.error(), words, what, tail) }; - // The emulation's refusals: an indirect draw with an object function, and a grid past its - // compute limits. + // The emulation's refusal of a direct grid past its compute limits. let refused = |drawn: &Result<(), Error>| match drawn { Err(Error::Bind(BindError::Unsupported(u))) if u.feature == Feature::MeshShading => { emulates(&device) } _ => false, }; + // An indirect grid the emulation cannot dispatch as Metal runs it: an axis past its + // compute limits, or whose threads per grid reach 2^32 (Metal reports the wrapped grid). + let limits = device + .compile_device() + .profile() + .limits() + .max_compute_work_group_count; + let undispatched = |c: &GridCase| { + emulates(&device) + && !c.direct + && !c.groups.contains(&0) + && (0..3).any(|i| { + c.groups[i] > limits[i] || u64::from(c.groups[i]) * c.threads[i] >= 1 << 32 + }) + }; for c in &OBJECT_GRID_CASES { // The threadgroups Metal ran. if cfg!(m2v_cpu_icd) && c.words[0] > 1 << 20 { @@ -857,6 +865,17 @@ fn object_grids_run_as_metal_runs_them() { if let Err(e) = drawn { panic!("{what}: {e}"); } + if undispatched(c) { + eprintln!("{what}: past the emulation's dispatch: {error:?}"); + assert_eq!( + error, + Some(CommandBufferError::MeshGridPastLimits), + "{what}" + ); + assert_eq!(words, RAN_NONE, "{what}"); + assert!(tail, "{what}: the encoder after the draw's"); + continue; + } assert_eq!(error, None, "{what}"); assert_eq!(words, c.words, "{what}"); assert!(tail, "{what}: the encoder after the draw's"); diff --git a/crates/metal2vulkan-validation/src/runtime_lane/private_primitives/type_nine.rs b/crates/metal2vulkan-validation/src/runtime_lane/private_primitives/type_nine.rs index a398240c5..c5a14d50f 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/private_primitives/type_nine.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/private_primitives/type_nine.rs @@ -56,6 +56,9 @@ use metal2vulkan_runtime::{ use std::sync::{Arc, OnceLock}; use std::time::{Duration, Instant}; +mod in_turn; +mod loops; + /// The earliest Metal's command buffer its GPU hung at read `Scheduled` after its commit: /// 5.06 ms. const SCHEDULED: Duration = Duration::from_micros(5_060); diff --git a/crates/metal2vulkan-validation/src/runtime_lane/private_primitives/type_nine/in_turn.rs b/crates/metal2vulkan-validation/src/runtime_lane/private_primitives/type_nine/in_turn.rs new file mode 100644 index 000000000..8410d3d79 --- /dev/null +++ b/crates/metal2vulkan-validation/src/runtime_lane/private_primitives/type_nine/in_turn.rs @@ -0,0 +1,251 @@ +//! Device tests of a command buffer that draws primitive type 9 in more than one pass, on the +//! device the cfg selects, under the validation layer: it fails as Metal's GPU fails it, its +//! error and its timing, and its queue's command buffer committed right after answers as Metal's +//! did. +//! +//! Metal's answers (probes on the Apple M3 Max, macOS 27.0.1, 118 command buffers of a blit, then +//! per draw its pass, a blit and an event signal, then a blit and a signal; the numbers are in +//! `command_buffer/hang.rs` of the runtime): +//! +//! - **A fault, then later failures** (an indexed draw, then another or a direct one of 3 +//! vertices): the command buffer fails with the fault's error, `PageFault`, every event signal +//! firing. It reads `Scheduled` once the GPU recovered from the fault, and completes once the +//! GPU recovered from each later fault, then from a hang (in a hang's time), past which it +//! reaches nothing. The queue's command buffer committed right after runs nothing where a hang +//! follows the fault, as during a hang, and runs where faults alone do. +//! - **A hang, then a fault**: as the hang alone, `GpuHang`; the GPU never reaches the fault. +//! +//! The runtime runs nothing from the first failing pass on, as for one failure. + +use super::{buffer_with, read_buffer, validated_device, Messages, ScratchCache}; +use super::{targets, Answer, Lane, Tracked, FAULT, HANG, SCHEDULED}; +use crate::gpu::TEST_DEVICE; +use metal2vulkan::metal::IndexType; +use metal2vulkan_runtime::{ + CommandBufferError, CommandBufferStatus, CommandQueue, DrawPrimitiveType, EventRef, Region, + RenderPipelineState, +}; +use std::time::Duration; + +/// A pass's draw of type 9. +#[derive(Clone, Copy, Debug)] +enum Nine { + /// An indexed draw of 3 16-bit indices, at which Metal's GPU faults. + Faults, + /// A direct draw of 3 vertices, at which Metal's GPU hangs. + Hangs, +} + +/// How a command buffer of [`Nine`]s ends, as Metal's does. +struct Expected { + error: CommandBufferError, + /// The earliest after its commit it reads `Scheduled`. + scheduled: Duration, + /// The earliest after it read `Scheduled` it fails. + fails: Duration, + /// Whether the queue's command buffer committed right after it runs. + next_runs: bool, +} + +/// One command buffer's run ([`in_turn`]). +struct InTurn { + drawn: Answer, + /// Which of its marks ran: before the first pass, after each pass, at its end. + marks: Vec, + /// Its event signals' values: after each pass, at its end. + signals: Vec, + /// Whether a pass cleared its target. + cleared: bool, + /// The queue's command buffer committed right after it, and whether its mark ran. + next: (Answer, bool), +} + +/// A mark's byte, by slot. +fn mark_of(slot: usize) -> u8 { + 0x60 + slot as u8 +} + +/// On `queue`, one command buffer of a mark, then for each of `draws` its pass (over targets of +/// its own, under `pipeline`), a mark and a signal of an event of its own, then a mark and a +/// signal; and right after it one of a mark: both committed, waited for. +fn in_turn( + lane: &Lane, + queue: &CommandQueue, + pipeline: &RenderPipelineState, + draws: &[Nine], +) -> InTurn { + let device = &lane.device; + let slots = draws.len() + 3; + let marks = buffer_with(device, &vec![0; slots * 4]).unwrap(); + let mark = |tracked: &Tracked, slot: usize| { + let mut blit = tracked.command_buffer.blit_command_encoder().unwrap(); + let at = slot as u64 * 4; + blit.fill_buffer(&marks, at..at + 4, mark_of(slot)).unwrap(); + blit.end_encoding().unwrap(); + }; + let indices = buffer_with(device, &[0, 0, 1, 0, 2, 0, 0, 0]).unwrap(); + let events: Vec<_> = (0..=draws.len()) + .map(|_| device.new_shared_event().unwrap()) + .collect(); + let mut drawn = Tracked::new(queue); + mark(&drawn, 0); + let mut drawn_into = Vec::new(); + for (at, draw) in draws.iter().enumerate() { + let (targets, pass) = targets(lane); + let mut encoder = drawn.command_buffer.render_command_encoder(&pass).unwrap(); + encoder.set_render_pipeline_state(pipeline).unwrap(); + encoder + .set_vertex_buffer(Some(&lane.positions), 0, 0) + .unwrap(); + encoder + .set_vertex_buffer(Some(&lane.offsets), 0, 1) + .unwrap(); + let nine = DrawPrimitiveType::Nine; + match draw { + Nine::Faults => { + encoder.draw_indexed_primitives(nine, 3, IndexType::UInt16, &indices, 0, 1, 0, 0) + } + Nine::Hangs => encoder.draw_primitives(nine, 0, 3, 1, 0), + } + .unwrap(); + encoder.end_encoding().unwrap(); + mark(&drawn, at + 1); + drawn + .command_buffer + .encode_signal_event(EventRef::from(&events[at]), 1) + .unwrap(); + drawn_into.push(targets); + } + mark(&drawn, draws.len() + 1); + drawn + .command_buffer + .encode_signal_event(EventRef::from(&events[draws.len()]), 1) + .unwrap(); + let mut next = Tracked::new(queue); + mark(&next, draws.len() + 2); + drawn.commit(); + next.commit(); + drawn.wait(); + next.wait(); + let read = read_buffer(&marks, 0, slots as u64 * 4).unwrap(); + let ran = |slot: usize| read[slot * 4] == mark_of(slot); + let cleared = drawn_into.iter().any(|targets| { + let mut texel = [0u8; 16]; + targets[0] + .get_bytes(&mut texel, 16, 16, Region::new_2d(0, 0, 1, 1), 0, 0) + .unwrap(); + texel == [0; 16] + }); + InTurn { + drawn: drawn.answer(), + marks: (0..=draws.len() + 1).map(ran).collect(), + signals: events.iter().map(|event| event.signaled_value()).collect(), + cleared, + next: (next.answer(), ran(draws.len() + 2)), + } +} + +/// Run each of `cases` on a queue of its own (a queue's second fault or hang revokes it) and +/// check it against Metal's answer: the command buffer fails with the error, reads `Scheduled` +/// and fails no sooner than Metal's did, runs only its mark before the first pass, every event +/// signal firing; the queue's command buffer committed right after completes cleanly after it, +/// running where Metal's did. +fn fails_in_turn(cases: &[(&[Nine], Expected)]) { + let cache = ScratchCache::new().unwrap(); + let messages = Messages::default(); + { + let device = validated_device(TEST_DEVICE, &messages, cache.path()).unwrap(); + let name = device.name().to_owned(); + let lane = Lane::new(device); + let pipeline = lane.pipeline("pt_plain"); + for (draws, expected) in cases { + let label = format!("{draws:?} on {name}"); + let queue = lane.device.new_command_queue().unwrap(); + let run = in_turn(&lane, &queue, &pipeline, draws); + let drawn = &run.drawn; + assert_eq!(drawn.status, CommandBufferStatus::Error, "{label}"); + assert_eq!(drawn.error, Some(expected.error), "{label}"); + let scheduled = drawn.to_scheduled(); + assert!( + scheduled >= expected.scheduled, + "{label}: read Scheduled {scheduled:?} after its commit" + ); + let fails = drawn.since_scheduled(); + assert!( + fails >= expected.fails, + "{label}: failed {fails:?} after it read Scheduled" + ); + let mut only_before = vec![false; draws.len() + 2]; + only_before[0] = true; + assert_eq!(run.marks, only_before, "{label}: the marks that ran"); + assert!(!run.cleared, "{label}: a pass cleared its target"); + assert!( + run.signals.iter().all(|&value| value == 1), + "{label}: its event signals: {:?}", + run.signals + ); + let (next, next_ran) = &run.next; + assert!( + next.completed_cleanly(), + "{label}: the one right after: {next:?}" + ); + assert_eq!( + *next_ran, expected.next_runs, + "{label}: whether the one right after ran" + ); + assert!( + next.completed >= drawn.completed, + "{label}: the one right after completed first" + ); + let ms = |duration: Duration| duration.as_secs_f64() * 1e3; + println!( + "{label}: {:?} Scheduled at {:.1} ms, failed {:.1} ms after; the one right \ + after ran: {next_ran}", + drawn.error, + ms(scheduled), + ms(fails), + ); + } + } + let reported = messages.take(); + assert!( + reported.is_empty(), + "the validation layer reported: {reported:#?}" + ); +} + +/// A fault, then later faults or a hang, in one command buffer: it fails with `PageFault`, reads +/// `Scheduled` once the GPU recovered from the fault and fails once it recovered from each later +/// fault and a hang, none past a hang; the queue's command buffer committed right after runs +/// nothing where a hang follows the fault, and runs where faults alone do. +#[test] +fn a_fault_then_later_failures_fail_as_metal_s_gpu_does() { + let fault = |fails, next_runs| Expected { + error: CommandBufferError::PageFault, + scheduled: FAULT, + fails, + next_runs, + }; + use Nine::{Faults, Hangs}; + fails_in_turn(&[ + (&[Faults, Hangs], fault(HANG, false)), + (&[Faults, Faults], fault(FAULT, true)), + (&[Faults, Faults, Hangs], fault(FAULT + HANG, false)), + (&[Faults, Hangs, Faults], fault(HANG, false)), + ]); +} + +/// A hang, then a fault, in one command buffer fails as the hang alone does: `GpuHang`, and the +/// queue's command buffer committed right after runs nothing. +#[test] +fn a_hang_then_a_fault_fails_as_the_hang_does() { + fails_in_turn(&[( + &[Nine::Hangs, Nine::Faults], + Expected { + error: CommandBufferError::GpuHang, + scheduled: SCHEDULED, + fails: HANG, + next_runs: false, + }, + )]); +} diff --git a/crates/metal2vulkan-validation/src/runtime_lane/private_primitives/type_nine/loops.rs b/crates/metal2vulkan-validation/src/runtime_lane/private_primitives/type_nine/loops.rs new file mode 100644 index 000000000..e43d4f445 --- /dev/null +++ b/crates/metal2vulkan-validation/src/runtime_lane/private_primitives/type_nine/loops.rs @@ -0,0 +1,218 @@ +//! Device tests of a predicated loop that runs again while Metal's GPU recovers from a fault or a +//! hang of primitive type 9 elsewhere on the device, on the device the cfg selects, under the +//! validation layer. +//! +//! Metal's answers (probes on the Apple M3 Max, macOS 27.0.1: a `While` loop of 160,000 passes on +//! a queue, and 50 ms on two command buffers drawing type 9 on another queue or the same one): +//! a fault failed the loop's command buffer as a victim of the GPU's recovery +//! (`MTLCommandBufferErrorInternal`) as the faulting one completed, and a hang ended the loop +//! with no error as the hanging one failed; either way nothing after the loop ran. A loop +//! committed behind faults that the GPU recovered from before it started ran all its passes. +//! +//! Each check commits a loop without bound (`while (log[1] != 1) mark 0`, then mark 2) on a queue +//! of its own, waits until the runtime runs its laying again, then commits the draw of type 9 on +//! another queue: without the stop, the loop would run until the process ends. + +use super::{ + buffer_with, one, read_buffer, validated_device, Draw, Lane, Messages, ScratchCache, WAIT, +}; +use crate::air_library::AirLibrary; +use crate::gpu::TEST_DEVICE; +use metal2vulkan::pipeline::{ComputePipelineDescriptor, StageSource}; +use metal2vulkan_devtools::llvm_assemble_text; +use metal2vulkan_runtime::{ + Buffer, CommandBuffer, CommandBufferError, CommandBufferStatus, ComputeCommandEncoder, + ComputePipelineState, Device, PipelineOptions, Size, +}; +use std::time::Instant; + +/// The owned synthetic kernel `lp_mark`: adds 1 to word `t[0]` of `log`. +const KERNEL: &str = r#"; Owned synthetic kernel: a loop's marks. +source_filename = "loops.metal" + +define void @lp_mark(ptr addrspace(2) %t, ptr addrspace(1) %log) { +entry: + %i = load i32, ptr addrspace(2) %t, align 4 + %i64 = zext i32 %i to i64 + %o = getelementptr inbounds i32, ptr addrspace(1) %log, i64 %i64 + %cur = load i32, ptr addrspace(1) %o, align 4 + %n = add i32 %cur, 1 + store i32 %n, ptr addrspace(1) %o, align 4 + ret void +} + +!air.kernel = !{!0} +!air.version = !{!20} +!air.language_version = !{!21} +!0 = !{ptr @lp_mark, !1, !2} +!1 = !{} +!2 = !{!3, !4} +!3 = !{i32 0, !"air.buffer", !"air.location_index", i32 0, i32 1, !"air.read", !"air.address_space", i32 2, !"air.arg_type_size", i32 4, !"air.arg_type_align_size", i32 4, !"air.arg_type_name", !"uint", !"air.arg_name", !"t"} +!4 = !{i32 1, !"air.buffer", !"air.location_index", i32 1, i32 1, !"air.read_write", !"air.address_space", i32 1, !"air.arg_type_size", i32 4, !"air.arg_type_align_size", i32 4, !"air.arg_type_name", !"uint", !"air.arg_name", !"log"} +!20 = !{i32 2, i32 8, i32 0} +!21 = !{!"Metal", i32 4, i32 0, i32 0} +"#; + +/// Metal's comparison code `!=`. +const NOT_EQUAL: u64 = 1; + +/// The marking kernel's state on `device`. +fn mark_state(device: &Device) -> ComputePipelineState { + let library = device + .new_library_with_air(&llvm_assemble_text(KERNEL).unwrap()) + .unwrap(); + let function = library.new_function_with_name("lp_mark").unwrap(); + let descriptor = + ComputePipelineDescriptor::new(StageSource::Function(function.function_descriptor())); + device + .new_compute_pipeline_state(&descriptor, &PipelineOptions::default()) + .unwrap() +} + +/// Mark `tag` into `log` from `encoder`. +fn mark(encoder: &mut ComputeCommandEncoder, state: &ComputePipelineState, log: &Buffer, tag: u32) { + encoder.set_compute_pipeline_state(state).unwrap(); + encoder.set_bytes(&tag.to_le_bytes(), 0).unwrap(); + encoder.set_buffer(Some(log), 0, 1).unwrap(); + let one = Size::new(1, 1, 1); + encoder.dispatch_threads(one, one).unwrap(); +} + +/// A loop's command buffer on a queue of its own: `while (log[word] != until) mark 0`, then mark +/// 2, committed. +fn looping( + device: &Device, + state: &ComputePipelineState, + log: &Buffer, + (word, until): (u64, u32), +) -> CommandBuffer { + let queue = device.new_command_queue().unwrap(); + let command_buffer = queue.command_buffer().unwrap(); + let mut encoder = command_buffer.compute_command_encoder().unwrap(); + encoder + .encode_start_while(Some(log), 4 * word, NOT_EQUAL, until) + .unwrap(); + mark(&mut encoder, state, log, 0); + assert_eq!(encoder.encode_end_while(), Ok(true)); + mark(&mut encoder, state, log, 2); + encoder.end_encoding().unwrap(); + command_buffer.commit().unwrap(); + command_buffer +} + +/// The log's words 0 to 2. +fn words(log: &Buffer) -> [u32; 3] { + let bytes = read_buffer(log, 0, 12).unwrap(); + std::array::from_fn(|i| u32::from_le_bytes(bytes[i * 4..i * 4 + 4].try_into().unwrap())) +} + +/// Wait until `device` ran a loop's laying again `more` times past `before`. +fn ran_again(device: &Device, before: u64, more: u64) { + let start = Instant::now(); + while device.work_counts().predicated_loop_runs_again < before + more { + assert!( + start.elapsed() < WAIT, + "the loop's laying ran again too few times" + ); + std::thread::yield_now(); + } +} + +/// A running loop without bound stops at the GPU's recovery from a type-9 draw on another queue: +/// a fault (an indexed draw) fails its command buffer as a victim, a hang (a direct draw) ends it +/// with no error, and nothing after the loop runs either way. A loop committed after a fault the +/// GPU recovered from runs every pass. +#[test] +fn a_running_loop_stops_at_the_gpu_s_recovery_as_metal_s_does() { + let cache = ScratchCache::new().unwrap(); + let messages = Messages::default(); + { + let device = validated_device(TEST_DEVICE, &messages, cache.path()).unwrap(); + let name = device.name().to_owned(); + let lane = Lane::new(device); + let pipeline = lane.pipeline("pt_plain"); + let state = mark_state(&lane.device); + let cases = [ + ( + Draw::Indexed { + indices: 3, + instances: 1, + }, + CommandBufferError::PageFault, + Some(CommandBufferError::GpuRecoveryVictim), + ), + ( + Draw::Direct { + vertices: 3, + instances: 1, + }, + CommandBufferError::GpuHang, + None, + ), + ]; + for (draw, error, loop_error) in cases { + let label = format!("{draw:?} on {name}"); + let log = buffer_with(&lane.device, &[0; 16]).unwrap(); + let before = lane.device.work_counts().predicated_loop_runs_again; + let looped = looping(&lane.device, &state, &log, (1, 1)); + ran_again(&lane.device, before, 2); + let other = lane.device.new_command_queue().unwrap(); + let (drawn, _, _) = one(&lane, &other, &pipeline, Some(draw)); + assert_eq!( + drawn.error, + Some(error), + "{label}: the draw's command buffer" + ); + looped.wait_until_completed_for(WAIT).unwrap(); + let status = match loop_error { + Some(_) => CommandBufferStatus::Error, + None => CommandBufferStatus::Completed, + }; + assert_eq!( + looped.status(), + status, + "{label}: the loop's command buffer" + ); + assert_eq!( + looped.error(), + loop_error, + "{label}: the loop's command buffer" + ); + let [passes, _, after] = words(&log); + assert!(passes > 0, "{label}: the loop ran no pass"); + assert_eq!(after, 0, "{label}: the mark after the loop ran"); + println!( + "{label}: the loop stopped after {passes} passes, {:?} {:?}", + looped.status(), + looped.error() + ); + } + // A fault the GPU recovered from before the loop's first submission leaves it running: + // a loop of 200 passes, past the runtime's copies, runs them all. + let other = lane.device.new_command_queue().unwrap(); + let fault = Draw::Indexed { + indices: 3, + instances: 1, + }; + let (drawn, _, _) = one(&lane, &other, &pipeline, Some(fault)); + assert_eq!(drawn.error, Some(CommandBufferError::PageFault)); + let log = buffer_with(&lane.device, &[0; 16]).unwrap(); + let before = lane.device.work_counts().predicated_loop_runs_again; + let bounded = looping(&lane.device, &state, &log, (0, 200)); + bounded.wait_until_completed_for(WAIT).unwrap(); + assert_eq!(bounded.status(), CommandBufferStatus::Completed, "{name}"); + assert_eq!(bounded.error(), None, "{name}"); + assert_eq!( + words(&log), + [200, 0, 1], + "{name}: the passes and the mark after" + ); + let again = lane.device.work_counts().predicated_loop_runs_again - before; + assert!(again > 0, "{name}: the loop of 200 ran its laying again"); + } + let reported = messages.take(); + assert!( + reported.is_empty(), + "the validation layer reported: {reported:#?}" + ); +} diff --git a/crates/metal2vulkan-validation/src/runtime_lane/resolves.rs b/crates/metal2vulkan-validation/src/runtime_lane/resolves.rs index 2941e997e..23dfc3f9e 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/resolves.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/resolves.rs @@ -1502,36 +1502,6 @@ fn a_resolve_into_the_srgb_twin_keeps_the_attachment_s_encoding() { quiet(lane, &messages); } -/// A multisampled extended-range attachment's resolve into its own format, which the runtime does -/// not build, is refused at the pass naming the format (`RuntimeGap::ExtendedRangeResolve`), by -/// both resolving store actions. -#[test] -fn an_extended_range_resolve_is_refused_naming_its_format() { - let (messages, _cache, lane) = lane(); - for pf in [ - PixelFormat::BGRA10XR, - PixelFormat::BGRA10XRSRGB, - PixelFormat::BGR10XR, - PixelFormat::BGR10XRSRGB, - ] { - for store in [ - StoreAction::MultisampleResolve, - StoreAction::StoreAndMultisampleResolve, - ] { - let msaa = lane.msaa(pf); - let resolve = lane.single(pf); - let pass = color_pass(&msaa, Some(&resolve), store, (0, 0)); - match lane.run(&pass, |_, _, _| {}) { - Err(Error::NotImplemented(RuntimeGap::ExtendedRangeResolve { pixel_format })) => { - assert_eq!(pixel_format, pf, "{store:?}") - } - other => panic!("{pf:?} {store:?}: {other:?}"), - } - } - } - quiet(lane, &messages); -} - /// A multisampled color attachment's resolve into a texture of a pixel format Metal does not store /// its tile into, which Metal's validation stops, as plain Metal runs it (our probe `xres`, the M3 /// Max under macOS 27.0.1, 2 and 4 samples): the resolve texture keeps its texels (each byte 0x5a diff --git a/crates/metal2vulkan/src/bind/color_resolve.rs b/crates/metal2vulkan/src/bind/color_resolve.rs index 0d989ab9f..1820efe4e 100644 --- a/crates/metal2vulkan/src/bind/color_resolve.rs +++ b/crates/metal2vulkan/src/bind/color_resolve.rs @@ -87,6 +87,35 @@ //! its input attachment 0, and for [`ResolveSource::RawInputAttachment`] a view of it in its raw //! twin. //! +//! **Extended-range forms** ([`ColorResolveFormat::extended_range`]): Metal makes multisampled +//! textures of `BGR10_XR`, `BGRA10_XR`, their `_sRGB` twins and `RGB10A2Unorm_sRGB`, and of none of +//! Apple's other private forms (our probe `xrms`, the M3 Max under macOS 27.0.1). Such an attachment +//! is held in its raw format's codes (`metal::format::ExtendedRange`), so these modules read the +//! source in that unsigned format (sample planes of a bits copy, a two-word texel split into +//! `BGRA10_XR`'s four fields) and write the resolved raw texel, a `uvec4`, to `Location` 0 of a +//! resolve attachment in that format. Metal's resolve, measured by our probe `xr` on the M3 Max +//! under macOS 27.0.1 (4096 texels per form at 2 and at 4 samples, each sample its own value): a +//! linear form's color channel is the average of the samples' codes rounded half up, every texel, +//! which the modules apply. Metal's other channels average values the stored codes do not keep, +//! so the modules write a near-equivalent where a pixel's samples differ: +//! +//! - `BGRA10_XR`'s alpha (and its twin's): Metal averages `floor(4080 a)` over the samples' +//! alphas `a` (each the written value as a `half`, clamped to `[0, 1]`) and rounds half up to a +//! code, three bits finer than the code; the modules average the codes with a tie rounded down +//! (Metal's code in 84% of the probe's texels at 2 samples and 88% at 4, every one within a code); +//! - an `_sRGB` twin's color and `RGB10A2Unorm_sRGB`'s: Metal encodes an average of the samples' +//! linear values (near that of the written values as `half`s, clamped to the codes' range), +//! which lies within the samples' codes; the modules average the codes' decoded values in `f32`, +//! encode it as a kernel's write does, and hold the code within the samples' (81% and 85% of the +//! twins' channels, 99.5% within a code and at most 7 codes off where the samples' values nearly +//! cancel; 83% and 87% of `RGB10A2Unorm_sRGB`'s, within 2); +//! - `RGB10A2Unorm_sRGB`'s 2-bit alpha: the average of the codes rounded half up (94% and 97%, +//! within a code). +//! +//! A pixel whose samples hold one code resolves to it, as Metal's does, without the decode and the +//! encode. The rules apply at every count; Apple's GPUs have no texture past 4 samples. +//! [`ColorResolveFormat::exact`] says which forms are Metal's at every texel. +//! //! **Synchronization** (consumer): the samples' writes before the draw's reads, and the resolve //! texture's earlier accesses before its color writes. @@ -96,6 +125,8 @@ use crate::budget::{Budget, Meter}; use crate::device::requirements::Requirements; use crate::device::Device; use crate::error::{Error, Feature, InternalError, InternalKind, Unsupported}; +use crate::lower::arith::extended_range as xr; +use crate::metal::format::ExtendedRange; use crate::pipeline::sym::{ResourceKind, ResourceSlot, Stage, Symbol}; use crate::spirv::builder::constructs::{ArmEnd, ArmFn}; use crate::spirv::builder::{FunctionBuilder, ModuleBuilder}; @@ -220,6 +251,9 @@ pub struct ColorResolveFormat { /// Whether the result is written through the raw twin's view /// ([`ColorResolveFormat::written_raw`]). written_raw: bool, + /// The extended-range form whose raw codes the format holds + /// ([`ColorResolveFormat::extended_range`]). + extended: Option, } /// A channel of `rule` at bit `offset`. @@ -293,9 +327,47 @@ impl ColorResolveFormat { format, channels, written_raw: false, + extended: None, }) } + /// The resolve of a multisampled color attachment of the extended-range `form`, held in its + /// raw format's codes (`metal::format::ExtendedRange::raw_format`): `BGR10_XR`, `BGRA10_XR`, + /// their `_sRGB` twins and `RGB10A2Unorm_sRGB`, the forms Metal makes multisampled textures + /// of. `None` for another form, of which Metal makes none (the module docs). It has no + /// [`channels`](Self::channels): the modules read and write the raw codes by the rules the + /// module docs state for these forms, at every sample count. + pub fn extended_range(form: ExtendedRange) -> Option { + match form { + ExtendedRange::Bgr10 { .. } + | ExtendedRange::Bgra10 { .. } + | ExtendedRange::Rgb10A2Srgb => Some(ColorResolveFormat { + format: form.raw_format(), + channels: [None; 4], + written_raw: false, + extended: Some(form), + }), + _ => None, + } + } + + /// The extended-range form whose raw codes the format holds + /// ([`extended_range`](Self::extended_range)), if any. + pub fn extended(self) -> Option { + self.extended + } + + /// Whether the resolve writes Metal's resolve at every texel: every format's but an + /// extended-range form's whose resolve averages values its codes do not keep (`BGRA10_XR`'s + /// alpha, an `_sRGB` twin's color, `RGB10A2Unorm_sRGB`'s channels), which the modules write a + /// near-equivalent of where a pixel's samples differ (the module docs). + pub fn exact(self) -> bool { + matches!( + self.extended, + None | Some(ExtendedRange::Bgr10 { srgb: false }) + ) + } + /// The Vulkan format. pub fn format(self) -> Format { self.format @@ -1339,33 +1411,14 @@ fn alike( elem: t.u32_, len: 4, })?; - let words = |f: &mut FunctionBuilder<'_>, texel: Value| -> BResult { - match source.reads_bits() { - true => Ok(texel), - false => f.convert(ConvOp::Bitcast, texel, uvec4), - } - }; - let (&first, rest) = texels - .split_first() - .ok_or(crate::spirv::error::BuildError::IdSpaceExhausted)?; - let first = words(f, first)?; - let mut differ: Option = None; - for &texel in rest { - let other = words(f, texel)?; - let bits = f.binary(BinOp::BitwiseXor, first, other)?; - differ = Some(match differ { - None => bits, - Some(d) => f.binary(BinOp::BitwiseOr, d, bits)?, + let mut words = Vec::with_capacity(texels.len()); + for &texel in texels { + words.push(match source.reads_bits() { + true => texel, + false => f.convert(ConvOp::Bitcast, texel, uvec4)?, }); } - let differ = differ.ok_or(crate::spirv::error::BuildError::IdSpaceExhausted)?; - let mut any = f.composite_extract(differ, &[0])?; - for lane in 1..4 { - let word = f.composite_extract(differ, &[lane])?; - any = f.binary(BinOp::BitwiseOr, any, word)?; - } - let zero = uint(f, t, 0)?; - f.binary(BinOp::IEqual, any, zero) + all_equal(f, t, &words) } /// The resolved output floats (R, G, B, A; 0 where the format has no channel) of `format` from @@ -1443,6 +1496,9 @@ pub fn fragment_typed_module( samples: u32, source: ResolveSource, ) -> BResult { + if let Some(form) = format.extended { + return extended_fragment(form, samples, source); + } let mut b = ModuleBuilder::new(); let t = Types::new(&mut b)?; let srgb = if format.srgb() { @@ -1450,10 +1506,38 @@ pub fn fragment_typed_module( } else { None }; - let (image, coord) = match source { + let sampled = match source { + ResolveSource::Planes(copy) if copy.moves_bits() => t.u32_, + _ => t.f32_, + }; + let (image, coord) = declare_source(&mut b, t, source, sampled)?; + let output = b.fixed_io(0, IoDir::Output, t.vec4, false)?; + let void = b.ty(Type::Void)?; + let mut f = b.function(void)?; + let texels = read_samples(&mut f, t, (image, coord), samples)?; + let lanes = resolve_texel(&mut f, t, srgb, format, &texels, source)?; + let value = f.composite_construct(t.vec4, &lanes)?; + let output = f.module().global_value(output)?; + f.store(output, value, MemAccess::default())?; + f.ret(None)?; + let id = f.finish()?; + b.entry(ExecModel::Fragment, id, vec![ExecMode::OriginUpperLeft])?; + b.finalize() +} + +/// The source binding of `source`, whose texels are `sampled` (`u32` or `f32`) lanes: the +/// multisampled input attachment, or the planes' sampled 2D-array image and the `FragCoord` +/// input it is fetched at. +fn declare_source( + b: &mut ModuleBuilder, + t: Types, + source: ResolveSource, + sampled: TypeId, +) -> BResult<(GlobalId, Option)> { + Ok(match source { ResolveSource::InputAttachment | ResolveSource::RawInputAttachment => { let ty = b.ty(Type::Image(ImageType { - sampled_type: t.f32_, + sampled_type: sampled, dim: Dim::SubpassData, depth: false, arrayed: false, @@ -1466,12 +1550,9 @@ pub fn fragment_typed_module( None, ) } - ResolveSource::Planes(copy) => { + ResolveSource::Planes(_) => { let ty = b.ty(Type::Image(ImageType { - sampled_type: match copy.moves_bits() { - true => t.u32_, - false => t.f32_, - }, + sampled_type: sampled, dim: Dim::D2, depth: false, arrayed: true, @@ -1485,10 +1566,17 @@ pub fn fragment_typed_module( Some(coord), ) } - }; - let output = b.fixed_io(0, IoDir::Output, t.vec4, false)?; - let void = b.ty(Type::Void)?; - let mut f = b.function(void)?; + }) +} + +/// Each of the `samples` texels of the pixel the invocation shades, from the source `image` +/// ([`declare_source`]): the input attachment's samples, or the planes' layers at `coord`. +fn read_samples( + f: &mut FunctionBuilder<'_>, + t: Types, + (image, coord): (GlobalId, Option), + samples: u32, +) -> BResult> { let image = f.module().global_value(image)?; let image = f.load(image, MemAccess::default())?; let ivec2 = f.module().ty(Type::Vector { @@ -1518,7 +1606,7 @@ pub fn fragment_typed_module( None => { let origin = f.module().constant(Constant::Null { ty: ivec2 })?; let origin = f.module().const_value(origin)?; - let sample = int(&mut f, t, s as i32)?; + let sample = int(f, t, s as i32)?; let ops = ImageOperands { sample: Some(sample), ..ImageOperands::default() @@ -1526,9 +1614,9 @@ pub fn fragment_typed_module( f.read(image, origin, &ops, TexelMemory::PRIVATE)? } Some((x, y)) => { - let layer = uint(&mut f, t, s)?; + let layer = uint(f, t, s)?; let at = f.composite_construct(uvec3, &[x, y, layer])?; - let level = uint(&mut f, t, 0)?; + let level = uint(f, t, 0)?; let ops = ImageOperands { lod: Some(level), ..ImageOperands::default() @@ -1538,8 +1626,42 @@ pub fn fragment_typed_module( }; texels.push(texel); } - let lanes = resolve_texel(&mut f, t, srgb, format, &texels, source)?; - let value = f.composite_construct(t.vec4, &lanes)?; + Ok(texels) +} + +/// The fragment stage of the extended-range `form` at `samples` reading `source` (the module +/// docs): the samples' raw texels in, the resolve's raw texel out, a `uvec4` at `Location` 0. +fn extended_fragment( + form: ExtendedRange, + samples: u32, + source: ResolveSource, +) -> BResult { + // The planes hold the codes only where their copy moves the texels' bits. + if matches!(source, ResolveSource::Planes(copy) if !copy.moves_bits()) { + return Err(crate::spirv::error::BuildError::Type( + crate::spirv::error::TypeRule::FunctionSignature, + )); + } + let mut b = ModuleBuilder::new(); + let t = Types::new(&mut b)?; + let table = match form { + ExtendedRange::Rgb10A2Srgb => xr::declare_padded(&mut b, form)?, + _ if form.srgb() => Some(xr::declare(&mut b)?), + _ => None, + }; + let uvec4 = b.ty(Type::Vector { + elem: t.u32_, + len: 4, + })?; + let read = declare_source(&mut b, t, source, t.u32_)?; + let output = b.fixed_io(0, IoDir::Output, uvec4, false)?; + let void = b.ty(Type::Void)?; + let mut f = b.function(void)?; + let mut raws = Vec::with_capacity(samples as usize); + for texel in read_samples(&mut f, t, read, samples)? { + raws.push(extended_texel(&mut f, t, form, texel, source)?); + } + let value = resolve_extended(&mut f, t, form, table, &raws)?; let output = f.module().global_value(output)?; f.store(output, value, MemAccess::default())?; f.ret(None)?; @@ -1548,6 +1670,164 @@ pub fn fragment_typed_module( b.finalize() } +/// The `uvec4` of `lanes`, each a `u32` constant. +fn uvec4_const(f: &mut FunctionBuilder<'_>, t: Types, lanes: [u32; 4]) -> BResult { + let uvec4 = f.module().ty(Type::Vector { + elem: t.u32_, + len: 4, + })?; + let mut v = Vec::with_capacity(4); + for lane in lanes { + v.push(uint(f, t, lane)?); + } + f.composite_construct(uvec4, &v) +} + +/// Whether the `uvec4`s `words` all hold the first's bits, as a `bool`. +fn all_equal(f: &mut FunctionBuilder<'_>, t: Types, words: &[Value]) -> BResult { + let (&first, rest) = words + .split_first() + .ok_or(crate::spirv::error::BuildError::IdSpaceExhausted)?; + let mut differ: Option = None; + for &other in rest { + let bits = f.binary(BinOp::BitwiseXor, first, other)?; + differ = Some(match differ { + None => bits, + Some(d) => f.binary(BinOp::BitwiseOr, d, bits)?, + }); + } + let differ = differ.ok_or(crate::spirv::error::BuildError::IdSpaceExhausted)?; + let mut any = f.composite_extract(differ, &[0])?; + for lane in 1..4 { + let word = f.composite_extract(differ, &[lane])?; + any = f.binary(BinOp::BitwiseOr, any, word)?; + } + let zero = uint(f, t, 0)?; + f.binary(BinOp::IEqual, any, zero) +} + +/// The raw texel (the raw format's `uvec4`, as an input attachment of it reads) of `form` in a +/// sample's `texel` read from `source`: the texel itself, or, from sample planes of 8-byte texels +/// (`PlanesCopy::Rg32`, two words), `BGRA10_XR`'s four 16-bit fields, the lowest first. +fn extended_texel( + f: &mut FunctionBuilder<'_>, + t: Types, + form: ExtendedRange, + texel: Value, + source: ResolveSource, +) -> BResult { + if !(matches!(source, ResolveSource::Planes(PlanesCopy::Rg32)) + && matches!(form, ExtendedRange::Bgra10 { .. })) + { + return Ok(texel); + } + let uvec4 = f.module().ty(Type::Vector { + elem: t.u32_, + len: 4, + })?; + let low = uint(f, t, 0xffff)?; + let sixteen = uint(f, t, 16)?; + let mut fields = Vec::with_capacity(4); + for word in 0..2 { + let w = f.composite_extract(texel, &[word])?; + fields.push(f.binary(BinOp::BitwiseAnd, w, low)?); + fields.push(f.binary(BinOp::ShiftRightLogical, w, sixteen)?); + } + f.composite_construct(uvec4, &fields) +} + +/// The codes (red first) of `form` averaged over `codes`, each sample's, as Metal's resolve or its +/// near-equivalent takes them (the module docs): the sum plus `bias` per lane, shifted down by +/// the count's power of two. +fn averaged_codes( + f: &mut FunctionBuilder<'_>, + t: Types, + codes: &[Value], + bias: [u32; 4], +) -> BResult { + let (&first, rest) = codes + .split_first() + .ok_or(crate::spirv::error::BuildError::IdSpaceExhausted)?; + let mut sum = first; + for &c in rest { + sum = f.binary(BinOp::IAdd, sum, c)?; + } + let bias = uvec4_const(f, t, bias)?; + let sum = f.binary(BinOp::IAdd, sum, bias)?; + let n = codes.len() as u32; + let shift = uvec4_const(f, t, [n.trailing_zeros(); 4])?; + f.binary(BinOp::ShiftRightLogical, sum, shift) +} + +/// The raw texel the resolve of `form` writes from each sample's raw texel `raws` (the module +/// docs), `table` the form's sRGB table where it has one. +fn resolve_extended( + f: &mut FunctionBuilder<'_>, + t: Types, + form: ExtendedRange, + table: Option, + raws: &[Value], +) -> BResult { + let n = raws.len() as u32; + let mut codes = Vec::with_capacity(raws.len()); + for &raw in raws { + codes.push(xr::codes(f, form, raw)?); + } + let &first = codes + .first() + .ok_or(crate::spirv::error::BuildError::IdSpaceExhausted)?; + // A color code rounds a tie up; `BGRA10_XR`'s alpha down, and `RGB10A2Unorm_sRGB`'s up. + let half = n / 2; + let alpha = match form { + ExtendedRange::Bgra10 { .. } => half - 1, + _ => half, + }; + let bias = [half, half, half, alpha]; + if matches!( + form, + ExtendedRange::Bgr10 { srgb: false } | ExtendedRange::Bgra10 { srgb: false } + ) { + let code = averaged_codes(f, t, &codes, bias)?; + return xr::pack(f, form, code); + } + // The decode, the average and the encode run only where the samples' codes differ. + let same = all_equal(f, t, &codes)?; + let kept: ArmFn<'_, ()> = + Box::new(|f, _| Ok(ArmEnd::FallThrough(vec![xr::pack(f, form, first)?]))); + let average: ArmFn<'_, ()> = Box::new(|f, _| { + let mut sum: Option = None; + for &raw in raws { + let v = xr::decode(f, form, raw, table, false)?; + sum = Some(match sum { + None => v, + Some(s) => f.binary_no_contraction(BinOp::FAdd, s, v)?, + }); + } + let sum = sum.ok_or(crate::spirv::error::BuildError::IdSpaceExhausted)?; + // `1 / n` of a power of two: the product is exact. + let scale = float(f, t, 1.0 / n as f32)?; + let scale = f.composite_construct(t.vec4, &[scale; 4])?; + let mean = f.binary_no_contraction(BinOp::FMul, sum, scale)?; + let alpha_code = averaged_codes(f, t, &codes, bias)?; + let colors = xr::write_codes(f, form, mean, table)?; + // Within the samples' codes, where Metal's encode of an average of values that encode to + // them lies: a decoded code's encode can fall below it where codes share a decode step + // (`RGB10A2Unorm_sRGB`'s darkest). + let (mut lo, mut hi) = (first, first); + for &c in &codes[1..] { + lo = f.glsl(GlslOp::UMin, &[lo, c])?; + hi = f.glsl(GlslOp::UMax, &[hi, c])?; + } + let colors = f.glsl(GlslOp::UClamp, &[colors, lo, hi])?; + let code = f.vector_shuffle(colors, alpha_code, &[0, 1, 2, 7])?; + Ok(ArmEnd::FallThrough(vec![xr::pack(f, form, code)?])) + }); + let out = f.if_(&mut (), same, kept, Some(average))?.0; + out.first() + .copied() + .ok_or(crate::spirv::error::BuildError::IdSpaceExhausted) +} + /// The fixed binding numbers of the modules' symbols. fn binding_of(sym: &Symbol) -> Option { match sym { @@ -1631,5 +1911,7 @@ pub fn color_resolve_modules( }) } +#[cfg(test)] +mod extended_tests; #[cfg(test)] mod tests; diff --git a/crates/metal2vulkan/src/bind/color_resolve/extended_tests.rs b/crates/metal2vulkan/src/bind/color_resolve/extended_tests.rs new file mode 100644 index 000000000..af1473145 --- /dev/null +++ b/crates/metal2vulkan/src/bind/color_resolve/extended_tests.rs @@ -0,0 +1,335 @@ +//! The extended-range resolve modules (the module docs' extended-range forms): the forms Metal +//! multisamples, valid on every committed profile and needing nothing of a device, and on the CPU +//! interpreter a linear form's colors and every alpha by their rules, an `_sRGB` color within its +//! samples' codes, and a pixel of alike samples its code. + +use super::*; +use crate::spirv::interp::{run, Buffer, Config, Order, Resources}; +use crate::spirv::testing::{assert_valid, committed_profiles}; + +/// SplitMix64. +struct SplitMix(u64); + +impl SplitMix { + fn next(&mut self) -> u64 { + self.0 = self.0.wrapping_add(0x9E37_79B9_7F4A_7C15); + let mut z = self.0; + z = (z ^ (z >> 30)).wrapping_mul(0xBF58_476D_1CE4_E5B9); + z = (z ^ (z >> 27)).wrapping_mul(0x94D0_49BB_1331_11EB); + z ^ (z >> 31) + } +} + +/// Every form Metal makes multisampled textures of. +const FORMS: [ExtendedRange; 5] = [ + ExtendedRange::Bgr10 { srgb: false }, + ExtendedRange::Bgr10 { srgb: true }, + ExtendedRange::Bgra10 { srgb: false }, + ExtendedRange::Bgra10 { srgb: true }, + ExtendedRange::Rgb10A2Srgb, +]; + +/// The forms Metal makes no multisampled texture of (probe `xrms`). +const UNMADE: [ExtendedRange; 9] = [ + ExtendedRange::Planes { srgb: false }, + ExtendedRange::Planes { srgb: true }, + ExtendedRange::R10X6, + ExtendedRange::Rg10X12, + ExtendedRange::R10X6Srgb, + ExtendedRange::Rg10X12Srgb, + ExtendedRange::R16Bfloat, + ExtendedRange::Rg16Bfloat, + ExtendedRange::Rgba16Bfloat, +]; + +/// The sources a test reads `form` from: the input attachment, and the sample planes of its raw +/// format's bits copy. +fn sources(form: ExtendedRange) -> [ResolveSource; 2] { + let copy = PlanesCopy::for_planes(form.raw_format()).expect("a bits copy"); + [ResolveSource::InputAttachment, ResolveSource::Planes(copy)] +} + +#[test] +fn the_forms_are_the_ones_metal_multisamples() { + for form in FORMS { + let rules = ColorResolveFormat::extended_range(form).expect("a form Metal multisamples"); + assert_eq!(rules.format(), form.raw_format(), "{form:?}"); + assert_eq!(rules.extended(), Some(form)); + assert_eq!(rules.channels(), [None; 4]); + assert_eq!(rules.raw_format(), rules.format()); + assert!(rules.resolves(2) && rules.resolves(4) && rules.resolves(8)); + assert_eq!( + rules.exact(), + form == ExtendedRange::Bgr10 { srgb: false }, + "{form:?}" + ); + } + for form in UNMADE { + assert_eq!(ColorResolveFormat::extended_range(form), None, "{form:?}"); + } + assert!(ColorResolveFormat::of(Format::R8G8B8A8_UNORM) + .expect("closed") + .exact()); +} + +/// Each form's fragment stage needs nothing of a device beyond Vulkan 1.2's shaders and is valid on +/// every committed profile, at 2, 4 and 8 samples, from each source. +#[test] +fn the_modules_are_valid_and_need_nothing_of_a_device() { + let profiles = committed_profiles().expect("profiles"); + for form in FORMS { + let rules = ColorResolveFormat::extended_range(form).expect("form"); + for source in sources(form) { + for samples in [2, 4, 8] { + let m = fragment_typed_module(rules, samples, source).expect("module"); + let r = crate::spirv::serialize::serialize(m.clone()) + .expect("serialize") + .requirements; + assert!( + r.features.is_empty(), + "{form:?} x{samples} {source:?}: {r:?}" + ); + for (_, profile) in &profiles { + let _ = assert_valid(m.clone(), profile); + } + } + } + } + // Planes not of a bits copy hold no codes. + let rules = ColorResolveFormat::extended_range(FORMS[0]).expect("form"); + assert!(fragment_typed_module(rules, 4, ResolveSource::Planes(PlanesCopy::Alpha8)).is_err()); +} + +const SAMPLES_IN: ResourceSlot = ResourceSlot { + stage: Stage::Kernel, + kind: ResourceKind::Buffer, + index: 0, +}; +const RESOLVED_OUT: ResourceSlot = ResourceSlot { + stage: Stage::Kernel, + kind: ResourceKind::Buffer, + index: 1, +}; + +/// A kernel running `form`'s resolve: invocation `i` reads its `samples` raw texels as four words +/// each from `SAMPLES_IN` and writes the resolved raw texel's four words to `RESOLVED_OUT`. +fn kernel(form: ExtendedRange, samples: u32) -> TypedModule { + let mut b = ModuleBuilder::new(); + let t = Types::new(&mut b).expect("types"); + let table = match form { + ExtendedRange::Rgb10A2Srgb => xr::declare_padded(&mut b, form).expect("table"), + _ if form.srgb() => Some(xr::declare(&mut b).expect("table")), + _ => None, + }; + let words = super::super::visibility_resolve::words_buffer; + let input = words(&mut b, SAMPLES_IN, t.u32_).expect("in"); + let output = words(&mut b, RESOLVED_OUT, t.u32_).expect("out"); + let uvec3 = b + .ty(Type::Vector { + elem: t.u32_, + len: 3, + }) + .expect("uvec3"); + let uvec4 = b + .ty(Type::Vector { + elem: t.u32_, + len: 4, + }) + .expect("uvec4"); + let invocation = b + .builtin(crate::spv::BuiltIn::GlobalInvocationId, IoDir::Input, uvec3) + .expect("id"); + let void = b.ty(Type::Void).expect("void"); + let mut f = b.function(void).expect("function"); + let build = |f: &mut FunctionBuilder<'_>| -> BResult<()> { + let zero = uint(f, t, 0)?; + let invocation = f.module().global_value(invocation)?; + let invocation = f.load(invocation, MemAccess::default())?; + let i = f.composite_extract(invocation, &[0])?; + let input = f.module().global_value(input)?; + let output = f.module().global_value(output)?; + let per = uint(f, t, samples * 4)?; + let base = f.binary(BinOp::IMul, i, per)?; + let mut raws = Vec::new(); + for s in 0..samples { + let mut lanes = Vec::new(); + for w in 0..4 { + let k = uint(f, t, s * 4 + w)?; + let at = f.binary(BinOp::IAdd, base, k)?; + let p = f.access_chain(input, &[zero, at])?; + lanes.push(f.load(p, MemAccess::default())?); + } + raws.push(f.composite_construct(uvec4, &lanes)?); + } + let out = resolve_extended(f, t, form, table, &raws)?; + let four = uint(f, t, 4)?; + let out_base = f.binary(BinOp::IMul, i, four)?; + for lane in 0..4 { + let word = f.composite_extract(out, &[lane])?; + let c = uint(f, t, lane)?; + let at = f.binary(BinOp::IAdd, out_base, c)?; + let p = f.access_chain(output, &[zero, at])?; + f.store(p, word, MemAccess::default())?; + } + Ok(()) + }; + build(&mut f).expect("body"); + f.ret(None).expect("ret"); + let id = f.finish().expect("finish"); + b.entry( + ExecModel::GLCompute, + id, + vec![ExecMode::LocalSize { x: 1, y: 1, z: 1 }], + ) + .expect("entry"); + b.finalize().expect("finalize") +} + +/// The raw texel of `form` (as an input attachment of its raw format reads it) of `codes`, red +/// first. +fn raw(form: ExtendedRange, [r, g, b, a]: [u32; 4]) -> [u32; 4] { + match form { + ExtendedRange::Bgr10 { .. } => [0xC000_0000 | r << 20 | g << 10 | b, 0, 0, 1], + ExtendedRange::Bgra10 { .. } => [b << 6, g << 6, r << 6, a << 6], + _ => [r | g << 10 | b << 20 | a << 30, 0, 0, 1], + } +} + +/// The codes (red first) of `form`'s raw texel `t` as the resolve writes it, and whether its +/// unused bits are as Metal writes them (`BGR10_XR`'s top two ones, `BGRA10_XR`'s low six zeros). +fn unpacked(form: ExtendedRange, t: [u32; 4]) -> ([u32; 4], bool) { + match form { + ExtendedRange::Bgr10 { .. } => ( + [(t[0] >> 20) & 1023, (t[0] >> 10) & 1023, t[0] & 1023, 894], + t[0] >> 30 == 3, + ), + ExtendedRange::Bgra10 { .. } => ( + [t[2] >> 6, t[1] >> 6, t[0] >> 6, t[3] >> 6], + t.iter().all(|&w| w & 63 == 0 && w < 1 << 16), + ), + _ => ( + [ + t[0] & 1023, + (t[0] >> 10) & 1023, + (t[0] >> 20) & 1023, + t[0] >> 30, + ], + true, + ), + } +} + +/// A random code of `form`'s channel `ch`, near `around` where it is given. +fn code(form: ExtendedRange, ch: usize, r: &mut SplitMix, around: Option) -> u32 { + let (lo, hi) = match (form, ch) { + (ExtendedRange::Bgr10 { .. }, 3) => (894, 894), + (ExtendedRange::Bgra10 { .. }, 3) => (384, 894), + (ExtendedRange::Rgb10A2Srgb, 3) => (0, 3), + _ => (0, 1023), + }; + let x = match around { + Some(c) => (c + (r.next() % 5) as u32).saturating_sub(2), + None => lo + (r.next() % u64::from(hi - lo + 1)) as u32, + }; + x.clamp(lo, hi) +} + +/// Run `form`'s resolve at `samples` over `pixels` (each sample's codes, red first). +fn resolved(form: ExtendedRange, samples: usize, pixels: &[Vec<[u32; 4]>]) -> Vec<[u32; 4]> { + let input: Vec = pixels + .iter() + .flatten() + .flat_map(|&c| raw(form, c)) + .flat_map(u32::to_le_bytes) + .collect(); + let res = Resources { + buffers: vec![ + Buffer { + slot: Some(SAMPLES_IN), + address: None, + bytes: input, + }, + Buffer { + slot: Some(RESOLVED_OUT), + address: None, + bytes: vec![0; pixels.len() * 16], + }, + ], + push: Vec::new(), + spec: Default::default(), + }; + let cfg = Config { + order: Order::Forward, + workgroups: [pixels.len() as u32, 1, 1], + ..Config::default() + }; + let out = run(&kernel(form, samples as u32), &cfg, res) + .expect("run") + .buffers + .remove(1); + out.as_chunks::<16>() + .0 + .iter() + .map(|t| { + let (words, _) = t.as_chunks::<4>(); + std::array::from_fn(|w| u32::from_le_bytes(words[w])) + }) + .collect() +} + +/// A linear form's color is the samples' codes' average rounded half up (Metal's rule); every +/// form's alpha its near-equivalent (`BGRA10_XR`'s a tie down, `RGB10A2Unorm_sRGB`'s up); an +/// `_sRGB` color lies within its samples' codes; and a pixel of alike samples is their code, with +/// the unused bits as Metal writes them. +#[test] +fn the_resolves_follow_their_rules() { + let mut r = SplitMix(0x5eed_0e7e); + for form in FORMS { + for samples in [2usize, 4, 8] { + let mut pixels: Vec> = Vec::new(); + for i in 0..384 { + let alike = i % 8 == 0; + let base: [u32; 4] = std::array::from_fn(|ch| code(form, ch, &mut r, None)); + let mut pixel = Vec::new(); + for _ in 0..samples { + pixel.push(match alike { + true => base, + false => std::array::from_fn(|ch| { + let near = i % 2 == 1; + code(form, ch, &mut r, near.then_some(base[ch])) + }), + }); + } + pixels.push(pixel); + } + let n = samples as u32; + for (pixel, got) in pixels.iter().zip(resolved(form, samples, &pixels)) { + let (codes, bits) = unpacked(form, got); + assert!(bits, "{form:?} x{samples}: {got:x?}"); + for ch in 0..4 { + let each: Vec = pixel.iter().map(|s| s[ch]).collect(); + let sum: u32 = each.iter().sum(); + let tie_down = matches!(form, ExtendedRange::Bgra10 { .. }) && ch == 3; + let rule = match tie_down { + true => (sum + n / 2 - 1) / n, + false => (sum + n / 2) / n, + }; + let srgb_color = ch < 3 && (form.srgb() || form == ExtendedRange::Rgb10A2Srgb); + let alike = pixel.iter().all(|s| s == &pixel[0]); + let lo = *each.iter().min().unwrap(); + let hi = *each.iter().max().unwrap(); + let ok = match (alike, srgb_color) { + (true, _) => codes[ch] == each[0], + (false, true) => (lo..=hi).contains(&codes[ch]), + (false, false) => codes[ch] == rule, + }; + assert!( + ok, + "{form:?} x{samples} channel {ch}: samples {each:?} resolved {}", + codes[ch] + ); + } + } + } + } +} diff --git a/crates/metal2vulkan/src/bind/graphics.rs b/crates/metal2vulkan/src/bind/graphics.rs index dbc392d8f..fb93854b9 100644 --- a/crates/metal2vulkan/src/bind/graphics.rs +++ b/crates/metal2vulkan/src/bind/graphics.rs @@ -309,8 +309,14 @@ //! draw are indirect from the work buffer, and the records lie in the command buffer's //! records pool, where a draw that does not fit draws nothing and fails the command buffer //! (`StatusReport::mesh_records_overflow`). Neither asks for its arguments on the CPU. -//! - An indirect draw of a pipeline with an object function is not implemented: its object -//! threadgroups, which size its work buffer, are GPU-written. +//! - An indirect draw of a pipeline with an object function, whose object threadgroups only the +//! GPU knows, runs an object arguments pass first (`mesh_object_arguments_module`, +//! `MeshDispatch::object_arguments`): it reads Metal's arguments, reserves the object +//! threadgroups' slots and offsets in the records pool (`lower::mesh::work::SLOTS`), and +//! writes the object dispatch, which reads its counts from the work buffer; then the scan as +//! above. A grid Metal's GPU discards, one past the compute limits or whose threads per grid +//! wrap, and one whose slots the pool cannot hold draw nothing and say so in the command +//! buffer's `ExecutionStatus`. use std::collections::BTreeMap; @@ -625,12 +631,18 @@ impl Default for DrawCommands { /// - creates a compute pipeline of each of the pipeline's `COMPUTE` modules (the object /// function's first, where it has one), under the pipeline's layout and the draw's /// `DrawCommands::specialization`; +/// - for an indirect draw with an object function ([`object_arguments`](Self::object_arguments)), +/// dispatches [`mesh_object_arguments_module`](crate::bind::mesh_object_arguments_module) (one +/// workgroup) under the scan's bindings first: it reads Metal's arguments, reserves the draw's +/// slots and offsets in the records pool, and writes the object dispatch's +/// `VkDispatchIndirectCommand` at [`OBJECT_DISPATCH_OFFSET`](Self::OBJECT_DISPATCH_OFFSET); /// - with an object function, binds its pipeline and the draw's sets at the compute bind point, /// records the push writes whose stages are `COMPUTE`, and `vkCmdDispatch` of -/// [`object_groups`](Self::object_groups); +/// [`object_groups`](Self::object_groups), or, for an indirect draw, `vkCmdDispatchIndirect` +/// from the work buffer at [`OBJECT_DISPATCH_OFFSET`](Self::OBJECT_DISPATCH_OFFSET); /// - for [`MeshGroups::Scanned`], dispatches [`MeshScanModule`](crate::bind::MeshScanModule) -/// (one workgroup) over the work buffer, the command buffer's `ExecutionStatus` buffer and the -/// arguments the variant names; +/// (one workgroup) over the work buffer, the command buffer's `ExecutionStatus` buffer, the +/// arguments the variant names and the records; /// - binds the mesh function's pipeline and the draw's sets, records the push writes whose /// stages are `COMPUTE`, and dispatches its threadgroups: `vkCmdDispatch` of /// [`MeshGroups::Direct`]'s counts (nothing where one is 0), or `vkCmdDispatchIndirect` from @@ -652,8 +664,13 @@ pub struct MeshDispatch { /// The work buffer's bytes, at least 16. pub work_bytes: u64, /// The object function's threadgroups, the object dispatch's group counts; `None` for a - /// pipeline without an object function. + /// pipeline without an object function, and for an indirect draw with one. pub object_groups: Option<[u32; 3]>, + /// An indirect draw with an object function: the range of the Metal indirect buffer its + /// object arguments pass binds at `MeshScanModule::ARGUMENTS_BINDING`, from the arguments' + /// offset aligned down to `minStorageBufferOffsetAlignment` through their 12 bytes (the work + /// buffer's `OBJECT_ARGUMENTS` word names where they begin). `None` for any other draw. + pub object_arguments: Option, /// The mesh threadgroups. pub mesh: MeshGroups, /// The records. @@ -670,6 +687,9 @@ impl MeshDispatch { pub const DISPATCH_OFFSET: u64 = 4 * crate::lower::mesh::work::DISPATCH as u64; /// The byte of the work buffer where the draw's `VkDrawIndirectCommand` lies. pub const DRAW_OFFSET: u64 = 4 * crate::lower::mesh::work::DRAW as u64; + /// The byte of the work buffer where the object dispatch's `VkDispatchIndirectCommand` lies, + /// which the object arguments pass writes ([`object_arguments`](Self::object_arguments)). + pub const OBJECT_DISPATCH_OFFSET: u64 = 4 * crate::lower::mesh::work::OBJECT_DISPATCH as u64; } /// Where an emulated mesh draw's mesh threadgroups come from ([`MeshDispatch`]). @@ -3343,7 +3363,8 @@ fn mesh_draw( let (command, dispatch) = match &t.records { None => (command, None), Some(r) => { - let (command, dispatch) = emulated_draw(r, t.object.is_some(), draw, groups, launches)?; + let (command, dispatch) = + emulated_draw(r, t.object.is_some(), draw, (groups, lo), launches)?; (command, Some(dispatch)) } }; @@ -3431,8 +3452,8 @@ fn mesh_draw( /// The draw and the compute work of an emulated mesh draw `draw` under `r` ([`MeshDispatch`]), /// of a pipeline with an object function where `object`: `groups` are the first stage's -/// threadgroups of a direct draw (`None` for an indirect one), and a draw that `launches` -/// nothing runs nothing and draws nothing. +/// threadgroups of a direct draw (`None` for an indirect one), `lo` the threads of an object +/// threadgroup, and a draw that `launches` nothing runs nothing and draws nothing. /// /// - A direct draw without an object function is the host's: `G` mesh threadgroups (refused as /// a group count where they pass a `u32`), their records exactly (`maxStorageBufferRange`, @@ -3444,13 +3465,15 @@ fn mesh_draw( /// work buffer must be bindable whole, else refused naming `maxStorageBufferRange` with its /// bytes), and an indirect draw without one reads Metal's arguments in the scan: both are /// scanned, their records in the command buffer's pool. -/// - An indirect draw with an object function is not implemented: its object threadgroups, -/// which size its work buffer, are GPU-written. +/// - An indirect draw with an object function, of object threadgroups of `lo` threads, runs the +/// object arguments pass first (`MeshDispatch::object_arguments`), which reads Metal's +/// arguments, reserves the slots and offsets of its object threadgroups in the pool, and writes +/// the object dispatch, which reads its counts from the work buffer; then the scan, as above. fn emulated_draw( r: &RecordsTemplate, object: bool, draw: &DrawCall, - groups: Option<[u32; 3]>, + (groups, lo): (Option<[u32; 3]>, [u32; 3]), launches: bool, ) -> Result<(vk::DrawCommand, MeshDispatch), BindError> { use crate::lower::mesh::work; @@ -3478,6 +3501,18 @@ fn emulated_draw( } Ok(bytes) }; + // The range of Metal's arguments at `offset` a pass binds, from the offset aligned down to + // `minStorageBufferOffsetAlignment`, and the arguments' byte in it. + let arguments_range = |offset: u64| { + let a = r.alignment.max(4); + let start = offset - offset % a; + let residual = offset - start; + let range = BufferRange { + offset: start, + range: residual + 12, + }; + (range, residual) + }; let scanned = |objects: u32, object_groups, arguments| -> Result<_, BindError> { let command = vk::DrawCommand::DrawIndirect { offset: MeshDispatch::DRAW_OFFSET, @@ -3488,6 +3523,7 @@ fn emulated_draw( work: header(objects), work_bytes: work_bytes(u64::from(objects))?, object_groups, + object_arguments: None, mesh: MeshGroups::Scanned { arguments }, records: MeshRecordsRegion::Pool, }; @@ -3537,6 +3573,7 @@ fn emulated_draw( work: w, work_bytes: work_bytes(1)?, object_groups: None, + object_arguments: None, mesh: MeshGroups::Direct(folded), records: MeshRecordsRegion::Exact(bytes), }; @@ -3553,19 +3590,28 @@ fn emulated_draw( let DrawCall::MeshThreadgroupsIndirect { indirect, .. } = *draw else { return Err(internal(format!("an indirect mesh draw of {draw:?}"))); }; - let a = r.alignment.max(4); - let start = indirect.offset - indirect.offset % a; - let residual = indirect.offset - start; - let range = BufferRange { - offset: start, - range: residual + 12, - }; + let (range, residual) = arguments_range(indirect.offset); let mut out = scanned(1, None, Some(range))?; let word = u32::try_from(residual / 4 + 1).map_err(|_| count_past())?; out.1.work[work::ARGUMENTS as usize] = word; Ok(out) } - (true, None) if launches => Err(not_implemented(Feature::MeshShading)), + // Metal's arguments are the object grid: the object arguments pass reads them, reserves + // the slots in the pool and writes the object dispatch; then the scan. + (true, None) if launches => { + let DrawCall::MeshThreadgroupsIndirect { indirect, .. } = *draw else { + return Err(internal(format!("an indirect mesh draw of {draw:?}"))); + }; + let range = arguments_range(indirect.offset); + let mut out = scanned(0, None, None)?; + let word = u32::try_from(range.1 / 4 + 1).map_err(|_| count_past())?; + let packed = crate::lower::dispatch::pack_nominal(lo) + .ok_or_else(|| internal(format!("object threadgroups of {lo:?} threads")))?; + out.1.work[work::OBJECT_ARGUMENTS as usize] = word; + out.1.work[work::OBJECT_THREADS as usize] = packed; + out.1.object_arguments = Some(range.0); + Ok(out) + } // A draw that launches nothing: no step runs, and nothing is drawn. (_, _) => { let command = vk::DrawCommand::Draw { @@ -3580,6 +3626,7 @@ fn emulated_draw( work: w, work_bytes: work_bytes(1)?, object_groups: None, + object_arguments: None, mesh: MeshGroups::Direct([0; 3]), records: MeshRecordsRegion::Exact(MIN_RECORDS_BYTES), }; @@ -4781,11 +4828,11 @@ fn instantiate( Some(indices) => uses.push(indices), None => draw_uses(uses, draw, overrun, t.tessellation.as_ref()), } - // An indirect mesh draw's arguments pass, or an emulated one's scan, reads Metal's 12 bytes - // in the compute stage. - let scanned = mesh_dispatch - .as_ref() - .is_some_and(|d| matches!(d.mesh, MeshGroups::Scanned { arguments: Some(_) })); + // An indirect mesh draw's arguments pass, or an emulated one's scan or object arguments pass, + // reads Metal's 12 bytes in the compute stage. + let scanned = mesh_dispatch.as_ref().is_some_and(|d| { + matches!(d.mesh, MeshGroups::Scanned { arguments: Some(_) }) || d.object_arguments.is_some() + }); if scanned || mesh_arguments.is_some() { uses.push(ResourceUse { resource: UseTarget::Indirect, diff --git a/crates/metal2vulkan/src/bind/mesh_scan.rs b/crates/metal2vulkan/src/bind/mesh_scan.rs index 691d989fe..f2e817218 100644 --- a/crates/metal2vulkan/src/bind/mesh_scan.rs +++ b/crates/metal2vulkan/src/bind/mesh_scan.rs @@ -40,7 +40,9 @@ use std::sync::Arc; use crate::bind::index_bounds::finished; -use crate::bind::mesh_arguments::{METAL_MESH_GRID_AXIS, METAL_MESH_GRID_TOTAL}; +use crate::bind::mesh_arguments::{ + METAL_MESH_GRID_AXIS, METAL_MESH_GRID_TOTAL, METAL_OBJECT_GRID_TOTAL, +}; use crate::bind::replay::checked_mul; use crate::bind::status::{StatusBits, StatusWord}; use crate::device::requirements::Requirements; @@ -76,6 +78,9 @@ impl MeshScanModule { pub const STATUS_BINDING: u32 = 1; /// The Metal indirect buffer, a storage buffer. pub const ARGUMENTS_BINDING: u32 = 2; + /// The draw's records, a storage buffer: the command buffer's records pool, where an indirect + /// draw with an object function keeps its slots and offsets (`MeshDispatch::object_arguments`). + pub const RECORDS_BINDING: u32 = 3; /// Invocations of the one workgroup, along x. pub const LOCAL_SIZE: u32 = 64; } @@ -92,6 +97,12 @@ pub const ARGUMENTS: ResourceSlot = ResourceSlot { kind: ResourceKind::Buffer, index: 1, }; +/// The records' binding symbol ([`MeshScanModule::RECORDS_BINDING`]). +pub const RECORDS: ResourceSlot = ResourceSlot { + stage: Stage::Kernel, + kind: ResourceKind::Buffer, + index: 2, +}; /// The status buffer's binding symbol ([`MeshScanModule::STATUS_BINDING`]). pub const STATUS: ResourceSlot = ResourceSlot { stage: Stage::Kernel, @@ -238,6 +249,61 @@ pub(crate) fn for_range<'a>( f.loop_(&mut (), LoopSpec::default(), body) } +/// Where the draw's slots and offsets begin (`work::SLOTS`): whether in the records, and the word +/// of their first in the buffer that holds them. +#[derive(Clone, Copy)] +pub(crate) struct Slots { + work: Value, + records: Value, + pooled: Value, + start: Value, +} + +impl Slots { + pub(crate) fn of(f: &mut FunctionBuilder<'_>, work: Value, records: Value) -> BResult { + let word = load_at(f, work, work::SLOTS)?; + let zero = k(f, 0)?; + let one = k(f, 1)?; + let pooled = f.binary(BinOp::INotEqual, word, zero)?; + let in_pool = f.binary(BinOp::ISub, word, one)?; + let header = k(f, work::HEADER)?; + let start = f.select(pooled, in_pool, header)?; + Ok(Slots { + work, + records, + pooled, + start, + }) + } + + /// Word `at` of the slots and offsets (from their first). + pub(crate) fn load(self, f: &mut FunctionBuilder<'_>, at: Value) -> BResult { + let zero = k(f, 0)?; + let at = f.binary(BinOp::IAdd, self.start, at)?; + let in_work = f.select(self.pooled, zero, at)?; + let in_pool = f.select(self.pooled, at, zero)?; + let from_work = load(f, self.work, in_work)?; + let from_pool = load(f, self.records, in_pool)?; + f.select(self.pooled, from_pool, from_work) + } + + /// Store `v` at word `at` of the slots and offsets (from their first). + pub(crate) fn store(self, f: &mut FunctionBuilder<'_>, at: Value, v: Value) -> BResult<()> { + let at = f.binary(BinOp::IAdd, self.start, at)?; + let (records, work) = (self.records, self.work); + let pool: ArmFn<'_, ()> = Box::new(move |f, _| { + store(f, records, at, v)?; + Ok(ArmEnd::FallThrough(Vec::new())) + }); + let local: ArmFn<'_, ()> = Box::new(move |f, _| { + store(f, work, at, v)?; + Ok(ArmEnd::FallThrough(Vec::new())) + }); + f.if_(&mut (), self.pooled, pool, Some(local))?; + Ok(()) + } +} + /// Run `then(f)` where `c` holds. pub(crate) fn when<'a>( f: &mut FunctionBuilder<'_>, @@ -285,6 +351,7 @@ pub fn scan_typed_module() -> BResult { let work = words_buffer(&mut b, WORK, u32_)?; let arguments = words_buffer(&mut b, ARGUMENTS, u32_)?; let status = words_buffer(&mut b, STATUS, u32_)?; + let records = words_buffer(&mut b, RECORDS, u32_)?; let invocation = b.builtin( crate::spv::BuiltIn::LocalInvocationIndex, IoDir::Input, @@ -295,6 +362,7 @@ pub fn scan_typed_module() -> BResult { let work = f.module().global_value(work)?; let arguments = f.module().global_value(arguments)?; let status = f.module().global_value(status)?; + let records = f.module().global_value(records)?; let partial = f.module().global_value(partial)?; let total_var = f.module().global_value(total_var)?; let invocation = f.module().global_value(invocation)?; @@ -311,7 +379,7 @@ pub fn scan_typed_module() -> BResult { let draw_id = load_at(&mut f, work, work::DRAW_ID)?; let row = load_at(&mut f, work, work::ROW)?; let argument_word = load_at(&mut f, work, work::ARGUMENTS)?; - let header = k(&mut f, work::HEADER)?; + let slots = Slots::of(&mut f, work, records)?; // An indirect draw's grid (slot 0, `O = 1`): Metal's arguments, read by every invocation. let indirect = f.binary(BinOp::INotEqual, argument_word, zero)?; @@ -338,13 +406,12 @@ pub fn scan_typed_module() -> BResult { })?; // The mesh threadgroups object threadgroup `o` launches. let groups = move |f: &mut FunctionBuilder<'_>, o: Value| -> BResult { - let into = f.binary(BinOp::IMul, o, slot_words)?; - let slot = f.binary(BinOp::IAdd, header, into)?; + let slot = f.binary(BinOp::IMul, o, slot_words)?; let mut g = [slot; 3]; for (i, v) in g.iter_mut().enumerate() { let off = k(f, i as u32)?; let w = f.binary(BinOp::IAdd, slot, off)?; - *v = load(f, work, w)?; + *v = slots.load(f, w)?; } let set = bounded_groups(f, g)?; f.select(indirect, argued, set) @@ -388,15 +455,14 @@ pub fn scan_typed_module() -> BResult { })?; barrier(&mut f)?; // The offsets of the run's object threadgroups. - let slots = f.binary(BinOp::IMul, objects, slot_words)?; - let offsets = f.binary(BinOp::IAdd, header, slots)?; + let offsets = f.binary(BinOp::IMul, objects, slot_words)?; let own = f.access_chain(partial, &[lin])?; let base = f.load(own, MemAccess::default())?; f.store(sum, base, MemAccess::default())?; for_range(&mut f, u32_, (lo, hi), move |f, o| { let running = f.load(sum, MemAccess::default())?; let at = f.binary(BinOp::IAdd, offsets, o)?; - store(f, work, at, running)?; + slots.store(f, at, running)?; let n = groups(f, o)?; let next = saturating_add(f, running, n)?; f.store(sum, next, MemAccess::default()) @@ -407,7 +473,7 @@ pub fn scan_typed_module() -> BResult { let one = k(f, 1)?; let total = f.load(total_var, MemAccess::default())?; let at = f.binary(BinOp::IAdd, offsets, objects)?; - store(f, work, at, total)?; + slots.store(f, at, total)?; let cursor_at = k(f, StatusWord::MeshRecordsCursor.index())?; let cursor_ptr = word_ptr(f, status, cursor_at)?; let cursor = f.load(cursor_ptr, MemAccess::default())?; @@ -483,6 +549,165 @@ pub fn scan_typed_module() -> BResult { b.finalize() } +/// The object arguments pass as a typed module, before serialization: the module +/// [`mesh_object_arguments_module`] serializes for a device of `compute` +/// (`maxComputeWorkGroupCount`), which the CPU interpreter runs. One invocation reads Metal's +/// arguments, the object grid, at the header's `OBJECT_ARGUMENTS` word (the module docs), and: +/// +/// - a grid with a zero count runs nothing; +/// - one of more threadgroups than [`METAL_OBJECT_GRID_TOTAL`], which Metal's GPU discards, runs +/// nothing and sets [`StatusBits::MESH_GRID_DISCARDED`]; +/// - one with a count past `compute` on its axis, or whose threads per grid wrap to 32 bits along +/// an axis (whose grid builtins the object dispatch cannot report as Metal's), runs nothing and +/// sets [`StatusBits::MESH_GRID_PAST_LIMITS`]; +/// - else it reserves `O · S + O + 1` words of the records pool from its cursor for the slots and +/// offsets, and writes `O` (`OBJECT_GROUPS`), their first word plus 1 (`SLOTS`) and the object +/// dispatch (`OBJECT_DISPATCH`, the grid); where the rest of the pool cannot hold them it runs +/// nothing and sets [`StatusBits::MESH_RECORDS_OVERFLOW`], naming the draw and its object +/// threadgroups (and no mesh threadgroup) where it is the command buffer's first records fault. +/// +/// A grid that runs nothing writes 0 for `O`, `SLOTS` and the dispatch. Its bindings are the +/// scan's. +pub fn object_arguments_typed_module(compute: [u32; 3]) -> BResult { + let mut b = ModuleBuilder::new(); + let u32_ = b.ty(Type::Int { + width: 32, + signed: false, + })?; + let work = words_buffer(&mut b, WORK, u32_)?; + let arguments = words_buffer(&mut b, ARGUMENTS, u32_)?; + let status = words_buffer(&mut b, STATUS, u32_)?; + // The records are bound for the scan's layout; this pass only reserves from their cursor. + words_buffer(&mut b, RECORDS, u32_)?; + let void = b.ty(Type::Void)?; + let mut f = b.function(void)?; + let work = f.module().global_value(work)?; + let arguments = f.module().global_value(arguments)?; + let status = f.module().global_value(status)?; + let zero = k(&mut f, 0)?; + let one = k(&mut f, 1)?; + let argument_word = load_at(&mut f, work, work::OBJECT_ARGUMENTS)?; + let at = f.binary(BinOp::ISub, argument_word, one)?; + let packed = load_at(&mut f, work, work::OBJECT_THREADS)?; + let mask = k(&mut f, (1 << crate::lower::dispatch::NOMINAL_AXIS_BITS) - 1)?; + let mut grid = [zero; 3]; + let mut any_zero = boolean(&mut f, false)?; + let mut past = boolean(&mut f, false)?; + for (i, g) in grid.iter_mut().enumerate() { + let off = k(&mut f, i as u32)?; + let w = f.binary(BinOp::IAdd, at, off)?; + *g = contained(&mut f, arguments, w)?; + let z = f.binary(BinOp::IEqual, *g, zero)?; + any_zero = f.binary(BinOp::LogicalOr, any_zero, z)?; + let limit = k(&mut f, compute[i])?; + let over = f.binary(BinOp::UGreaterThan, *g, limit)?; + past = f.binary(BinOp::LogicalOr, past, over)?; + let shift = k(&mut f, crate::lower::dispatch::NOMINAL_AXIS_BITS * i as u32)?; + let t = f.binary(BinOp::ShiftRightLogical, packed, shift)?; + let t = f.binary(BinOp::BitwiseAnd, t, mask)?; + let t = f.binary(BinOp::IAdd, t, one)?; + let (_, wraps) = checked_mul(&mut f, *g, t, zero)?; + past = f.binary(BinOp::LogicalOr, past, wraps)?; + } + let some = f.unary(UnOp::LogicalNot, any_zero)?; + let (xy, wraps_xy) = checked_mul(&mut f, grid[0], grid[1], zero)?; + let (n, wraps_n) = checked_mul(&mut f, xy, grid[2], zero)?; + let mut many = f.binary(BinOp::LogicalOr, wraps_xy, wraps_n)?; + let most = k(&mut f, METAL_OBJECT_GRID_TOTAL)?; + let over = f.binary(BinOp::UGreaterThan, n, most)?; + many = f.binary(BinOp::LogicalOr, many, over)?; + let discarded = f.binary(BinOp::LogicalAnd, some, many)?; + let kept = f.unary(UnOp::LogicalNot, many)?; + let past = f.binary(BinOp::LogicalAnd, past, kept)?; + let past = f.binary(BinOp::LogicalAnd, past, some)?; + // The slots and offsets: `n · S + n + 1` words, held below 2^29 · 2^17 by the grid's bound + // and the slot's (a payload of at most 16 KiB); counted without wrapping all the same. + let slot_words = load_at(&mut f, work, work::SLOT_WORDS)?; + let pool_words = load_at(&mut f, work, work::POOL_WORDS)?; + let draw_id = load_at(&mut f, work, work::DRAW_ID)?; + let (slots, wraps_slots) = checked_mul(&mut f, n, slot_words, zero)?; + let offsets = f.binary(BinOp::IAdd, n, one)?; + let words = saturating_add(&mut f, slots, offsets)?; + let cursor_at = k(&mut f, StatusWord::MeshRecordsCursor.index())?; + let cursor_ptr = word_ptr(&mut f, status, cursor_at)?; + let cursor = f.load(cursor_ptr, MemAccess::default())?; + let used = f.glsl(GlslOp::UMin, &[cursor, pool_words])?; + let room = f.binary(BinOp::ISub, pool_words, used)?; + let fits = f.binary(BinOp::ULessThanEqual, words, room)?; + let wraps_slots = f.unary(UnOp::LogicalNot, wraps_slots)?; + let fits = f.binary(BinOp::LogicalAnd, fits, wraps_slots)?; + let launched = f.binary(BinOp::LogicalOr, discarded, past)?; + let launched = f.unary(UnOp::LogicalNot, launched)?; + let launched = f.binary(BinOp::LogicalAnd, launched, some)?; + let runs = f.binary(BinOp::LogicalAnd, launched, fits)?; + let short = f.unary(UnOp::LogicalNot, fits)?; + let overflow = f.binary(BinOp::LogicalAnd, launched, short)?; + let next = f.binary(BinOp::IAdd, used, words)?; + let cursor_after = f.select(runs, next, cursor)?; + f.store(cursor_ptr, cursor_after, MemAccess::default())?; + let first_word = f.binary(BinOp::IAdd, used, one)?; + let objects = f.select(runs, n, zero)?; + let slots_word = f.select(runs, first_word, zero)?; + store_at(&mut f, work, work::OBJECT_GROUPS, objects)?; + store_at(&mut f, work, work::SLOTS, slots_word)?; + for (i, g) in grid.into_iter().enumerate() { + let v = f.select(runs, g, zero)?; + store_at(&mut f, work, work::OBJECT_DISPATCH + i as u32, v)?; + } + // What runs nothing says why: Metal's discard, the device's limits, or the pool. + let discard_bit = k(&mut f, StatusBits::MESH_GRID_DISCARDED.0)?; + let past_bit = k(&mut f, StatusBits::MESH_GRID_PAST_LIMITS.0)?; + let discard_bit = f.select(discarded, discard_bit, zero)?; + let past_bit = f.select(past, past_bit, zero)?; + let bits = f.binary(BinOp::BitwiseOr, discard_bit, past_bit)?; + let set = f.binary(BinOp::INotEqual, bits, zero)?; + when(&mut f, set, move |f| { + let word = k(f, StatusWord::Status.index())?; + let p = word_ptr(f, status, word)?; + f.atomic(AtomicOp::Or, p, Scope::Device, Semantics::RELAXED, bits)?; + Ok(()) + })?; + when(&mut f, overflow, move |f| { + let zero = k(f, 0)?; + let word = k(f, StatusWord::Status.index())?; + let bit = k(f, StatusBits::MESH_RECORDS_OVERFLOW.0)?; + let p = word_ptr(f, status, word)?; + let old = f.atomic(AtomicOp::Or, p, Scope::Device, Semantics::RELAXED, bit)?; + let either = k(f, StatusBits::RECORDS_FAULTS.0)?; + let had = f.binary(BinOp::BitwiseAnd, old, either)?; + let new = f.binary(BinOp::IEqual, had, zero)?; + when(f, new, move |f| { + let zero = k(f, 0)?; + for (w, v) in [ + (StatusWord::MeshFaultDraw, draw_id), + (StatusWord::MeshFaultObjects, n), + (StatusWord::MeshFaultGroups, zero), + ] { + store_at(f, status, w.index(), v)?; + } + Ok(()) + }) + })?; + f.ret(None)?; + let id = f.finish()?; + b.entry( + ExecModel::GLCompute, + id, + vec![ExecMode::LocalSize { x: 1, y: 1, z: 1 }], + )?; + b.finalize() +} + +/// The `bool` constant `v`. +fn boolean(f: &mut FunctionBuilder<'_>, v: bool) -> BResult { + let ty = f.module().ty(Type::Bool)?; + let c = f.module().constant(Constant::Scalar { + ty, + bits: ConstBits(u64::from(v)), + })?; + f.module().const_value(c) +} + /// The fixed binding numbers of the scan's symbols. fn binding_of(sym: &Symbol) -> Option { match sym { @@ -490,10 +715,34 @@ fn binding_of(sym: &Symbol) -> Option { Symbol::Binding(s) if *s == WORK => Some(MeshScanModule::WORK_BINDING), Symbol::Binding(s) if *s == ARGUMENTS => Some(MeshScanModule::ARGUMENTS_BINDING), Symbol::Binding(s) if *s == STATUS => Some(MeshScanModule::STATUS_BINDING), + Symbol::Binding(s) if *s == RECORDS => Some(MeshScanModule::RECORDS_BINDING), _ => None, } } +/// The object arguments pass of `device` ([`object_arguments_typed_module`] of its +/// `maxComputeWorkGroupCount`), which an emulated indirect draw with an object function dispatches +/// (one workgroup of one invocation) before its object dispatch, under the scan's bindings +/// (`MeshDispatch::object_arguments`): built with the typed builder, verified, serialized, and +/// numbered with the fixed bindings of [`MeshScanModule`]. +pub fn mesh_object_arguments_module(device: &Device) -> Result { + let compute = device + .profile() + .fields() + .limits + .max_compute_work_group_count; + let (spirv, requirements) = finished( + device, + object_arguments_typed_module(compute)?, + binding_of, + "the mesh object arguments pass", + )?; + Ok(MeshScanModule { + spirv, + requirements, + }) +} + /// The mesh scan module of `device`: built with the typed builder, verified, serialized, and /// numbered with the fixed bindings of [`MeshScanModule`]. pub fn mesh_scan_module(device: &Device) -> Result { diff --git a/crates/metal2vulkan/src/bind/mesh_scan/tests.rs b/crates/metal2vulkan/src/bind/mesh_scan/tests.rs index 62c6bd8a9..6d0e80f33 100644 --- a/crates/metal2vulkan/src/bind/mesh_scan/tests.rs +++ b/crates/metal2vulkan/src/bind/mesh_scan/tests.rs @@ -2,7 +2,10 @@ //! each object threadgroup's first mesh threadgroup, the draw's `T`, its reservation in the //! records pool, its dispatch folded into rows and its draw; an indirect draw's grid from Metal's //! arguments, held to Metal's limit; and a draw the pool cannot hold draws nothing, sets -//! `MESH_RECORDS_OVERFLOW` and names itself, the first such draw only. +//! `MESH_RECORDS_OVERFLOW` and names itself, the first such draw only. Slots in the records pool +//! (`work::SLOTS`) scan as slots in the work buffer do. The object arguments pass: valid on every +//! committed profile, and on the interpreter it reserves an indirect draw's slots and writes its +//! object dispatch, or runs nothing and says why. use super::*; use crate::bind::status::{ExecutionStatus, MeshRecordsFault, StatusReport}; @@ -25,7 +28,8 @@ fn bytes(words: &[u32]) -> Vec { /// A draw's work buffer before the scan: `grids` of the object threadgroups, slots of /// `slot_words`, the records of `group_words` words and `group_vertices` vertices per mesh /// threadgroup, a pool of `pool_words`, draw number 7, rows of `row`, and Metal's arguments at -/// word `arguments - 1` where it is not 0. +/// word `arguments - 1` where it is not 0; the slots and offsets at word `pooled` of the pool +/// where it is `Some`, else after the header. struct Draw { grids: Vec<[u32; 3]>, slot_words: u32, @@ -34,6 +38,7 @@ struct Draw { pool_words: u32, row: u32, arguments: u32, + pooled: Option, } impl Draw { @@ -46,9 +51,34 @@ impl Draw { pool_words: 1000, row: 4, arguments: 0, + pooled: None, } } + /// The slots and the offsets before the scan. + fn slots(&self) -> Vec { + let mut w = Vec::new(); + for g in &self.grids { + let mut slot = vec![0xAAAA_AAAA; self.slot_words as usize]; + slot[..3].copy_from_slice(g); + slot[3] = 0; + w.extend(slot); + } + // The offsets, which the scan writes. + w.extend(std::iter::repeat_n(0xEEEE_EEEE, self.grids.len() + 1)); + w + } + + /// The pool's words before the scan: `len` words, the slots at `pooled`. + fn pool(&self, len: usize) -> Vec { + let mut w = vec![0x5555_5555; len]; + if let Some(at) = self.pooled { + let slots = self.slots(); + w[at as usize..][..slots.len()].copy_from_slice(&slots); + } + w + } + fn words(&self) -> Vec { let o = self.grids.len() as u32; let mut w = vec![0u32; work::HEADER as usize]; @@ -60,25 +90,28 @@ impl Draw { w[work::DRAW_ID as usize] = 7; w[work::ROW as usize] = self.row; w[work::ARGUMENTS as usize] = self.arguments; - for g in &self.grids { - let mut slot = vec![0xAAAA_AAAA; self.slot_words as usize]; - slot[..3].copy_from_slice(g); - slot[3] = 0; - w.extend(slot); + match self.pooled { + Some(at) => { + w[work::SLOTS as usize] = at + 1; + w.push(0xEEEE_EEEE); + } + None => w.extend(self.slots()), } - // The offsets, which the scan writes. - w.extend(std::iter::repeat_n(0xEEEE_EEEE, o as usize + 1)); w } } -/// What a scan left: the work words, the status report, and the pool's cursor. +/// What a scan left: the work words, the status report, the pool's cursor, and the pool. struct Scanned { work: Vec, report: StatusReport, cursor: u32, + pool: Vec, } +/// The pool's words in the tests. +const POOL: usize = 4096; + /// Run the scan of `draw` over `arguments` (bound whole) with the pool's cursor at `cursor` and /// the status bits `bits`, in both invocation orders. fn scan(draw: &Draw, arguments: &[u32], cursor: u32, bits: u32) -> Scanned { @@ -105,6 +138,11 @@ fn scan(draw: &Draw, arguments: &[u32], cursor: u32, bits: u32) -> Scanned { address: None, bytes: bytes(&status), }, + Buffer { + slot: Some(RECORDS), + address: None, + bytes: bytes(&draw.pool(POOL)), + }, ], push: Vec::new(), spec: Default::default(), @@ -123,13 +161,17 @@ fn scan(draw: &Draw, arguments: &[u32], cursor: u32, bits: u32) -> Scanned { work: words(&after[0]), report: ExecutionStatus::decode(&status_bytes), cursor: status[StatusWord::MeshRecordsCursor.index() as usize], + pool: words(&after[3]), } } -/// The offsets after `draw`'s slots. -fn offsets(draw: &Draw, work: &[u32]) -> Vec { - let at = (work::HEADER + draw.grids.len() as u32 * draw.slot_words) as usize; - work[at..].to_vec() +/// The offsets after `draw`'s slots, where they lie. +fn offsets(draw: &Draw, s: &Scanned) -> Vec { + let slots = draw.grids.len() * draw.slot_words as usize; + match draw.pooled { + Some(at) => s.pool[at as usize + slots..][..draw.grids.len() + 1].to_vec(), + None => s.work[work::HEADER as usize + slots..].to_vec(), + } } fn header(work: &[u32], at: u32, n: usize) -> Vec { @@ -159,7 +201,7 @@ fn the_scan_places_each_object_threadgroups_mesh_threadgroups() { [1024, 1024, 1], ]); let s = scan(&draw, &[0], 40, 0); - assert_eq!(offsets(&draw, &s.work), vec![0, 2, 2, 8, 9, 9, 9, 9]); + assert_eq!(offsets(&draw, &s), vec![0, 2, 2, 8, 9, 9, 9, 9]); assert_eq!(s.work[work::MESH_GROUPS as usize], 9); assert_eq!(s.work[work::RECORDS_BASE as usize], 40); assert_eq!(s.cursor, 40 + 9 * 10); @@ -186,7 +228,7 @@ fn the_scan_places_runs_of_many_object_threadgroups() { running += g[0]; } want.push(running); - assert_eq!(offsets(&draw, &s.work), want); + assert_eq!(offsets(&draw, &s), want); assert_eq!(s.work[work::MESH_GROUPS as usize], running); assert_eq!(header(&s.work, work::DISPATCH, 3), vec![running, 1, 1]); } @@ -199,7 +241,7 @@ fn an_indirect_scan_reads_metals_arguments() { draw.arguments = 1 + 2; let s = scan(&draw, &[9, 9, 3, 2, 2], 0, 0); assert_eq!(&s.work[work::HEADER as usize..][..3], &[3, 2, 2]); - assert_eq!(offsets(&draw, &s.work), vec![0, 12]); + assert_eq!(offsets(&draw, &s), vec![0, 12]); assert_eq!(s.work[work::MESH_GROUPS as usize], 12); assert_eq!(header(&s.work, work::DRAW, 4), vec![36, 1, 0, 0]); for past in [ @@ -266,3 +308,269 @@ fn a_draw_the_pool_cannot_hold_draws_nothing_and_says_so() { Some(1023 * 1025) ); } + +/// Slots in the records pool scan as slots in the work buffer do, and the offsets land after +/// them there; the work buffer keeps its own words. +#[test] +fn the_scan_reads_slots_in_the_records_pool() { + let grids = [[2, 1, 1], [0, 5, 1], [3, 2, 1], [1, 1, 1], [1, 65536, 1]]; + let mut draw = Draw::of(&grids); + draw.pooled = Some(200); + let s = scan(&draw, &[0], 300, 0); + assert_eq!(offsets(&draw, &s), vec![0, 2, 2, 8, 9, 9]); + assert_eq!(s.work[work::MESH_GROUPS as usize], 9); + assert_eq!(s.work[work::RECORDS_BASE as usize], 300); + assert_eq!(s.cursor, 300 + 9 * 10); + assert_eq!(header(&s.work, work::DISPATCH, 3), vec![4, 3, 1]); + assert_eq!(s.report, StatusReport::default()); + assert_eq!(&s.work[work::HEADER as usize..], &[0xEEEE_EEEE]); + assert_eq!(&s.pool[200..][..3], &[2, 1, 1]); + // Below the slots, the pool is as it was. + assert!(s.pool[..200].iter().all(|&w| w == 0x5555_5555)); +} + +/// An object arguments pass: Metal's arguments `arguments` at word `at` (0: none), object +/// threadgroups of `threads`, slots of 6 words, a pool of `pool_words` with its cursor at +/// `cursor`, the status bits `bits`, and the device's `compute` limits. +struct Arguments { + arguments: Vec, + at: u32, + threads: [u32; 3], + pool_words: u32, + cursor: u32, + bits: u32, + compute: [u32; 3], +} + +impl Arguments { + fn of(grid: [u32; 3]) -> Arguments { + let mut arguments = vec![9]; + arguments.extend(grid); + Arguments { + arguments, + at: 1, + threads: [32, 1, 1], + pool_words: 1000, + cursor: 40, + bits: 0, + compute: [65535; 3], + } + } + + /// The work words before the pass. + fn work(&self) -> Vec { + let mut w = vec![0xAAAA_AAAA; work::HEADER as usize + 1]; + w[work::OBJECT_ARGUMENTS as usize] = self.at + 1; + w[work::OBJECT_THREADS as usize] = + crate::lower::dispatch::pack_nominal(self.threads).expect("threads"); + w[work::SLOT_WORDS as usize] = 6; + w[work::POOL_WORDS as usize] = self.pool_words; + w[work::DRAW_ID as usize] = 7; + w + } + + /// Run the pass; the work words, the status report and the pool's cursor after it. + fn run(&self) -> Scanned { + let module = object_arguments_typed_module(self.compute).expect("arguments"); + let mut status = [0u32; 8]; + status[StatusWord::Status.index() as usize] = self.bits; + status[StatusWord::MeshRecordsCursor.index() as usize] = self.cursor; + let pool = vec![0x5555_5555; 16]; + let res = Resources { + buffers: vec![ + Buffer { + slot: Some(WORK), + address: None, + bytes: bytes(&self.work()), + }, + Buffer { + slot: Some(ARGUMENTS), + address: None, + bytes: bytes(&self.arguments), + }, + Buffer { + slot: Some(STATUS), + address: None, + bytes: bytes(&status), + }, + Buffer { + slot: Some(RECORDS), + address: None, + bytes: bytes(&pool), + }, + ], + push: Vec::new(), + spec: Default::default(), + }; + let after = run(&module, &Config::default(), res) + .expect("arguments run") + .buffers; + let status_bytes: [u8; 32] = after[2].as_slice().try_into().expect("status"); + let status = words(&after[2]); + Scanned { + work: words(&after[0]), + report: ExecutionStatus::decode(&status_bytes), + cursor: status[StatusWord::MeshRecordsCursor.index() as usize], + pool: words(&after[3]), + } + } +} + +/// The words a pass that runs nothing leaves: no object threadgroups, no slots, an empty +/// dispatch, and the cursor where it was. +fn runs_nothing(a: &Arguments, s: &Scanned) { + assert_eq!(s.work[work::OBJECT_GROUPS as usize], 0); + assert_eq!(s.work[work::SLOTS as usize], 0); + assert_eq!(header(&s.work, work::OBJECT_DISPATCH, 3), vec![0, 0, 0]); + assert_eq!(s.cursor, a.cursor); +} + +#[test] +fn the_object_arguments_pass_is_valid_on_every_committed_profile() { + for (_, p) in committed_profiles().expect("profiles") { + let compute = p.fields().limits.max_compute_work_group_count; + assert_valid( + object_arguments_typed_module(compute).expect("arguments"), + &p, + ); + } +} + +/// A grid that runs: its slots and offsets reserved after the cursor (`n · S + n + 1` words), the +/// slots' first word plus 1, and the grid as the object dispatch; the pool is the scan's to write. +#[test] +fn the_object_arguments_pass_reserves_a_grids_slots() { + let a = Arguments::of([3, 2, 2]); + let s = a.run(); + assert_eq!(s.work[work::OBJECT_GROUPS as usize], 12); + assert_eq!(s.work[work::SLOTS as usize], 41); + assert_eq!(header(&s.work, work::OBJECT_DISPATCH, 3), vec![3, 2, 2]); + assert_eq!(s.cursor, 40 + 12 * 6 + 13); + assert_eq!(s.report, StatusReport::default()); + assert!(s.pool.iter().all(|&w| w == 0x5555_5555)); + // The arguments at another word, and exactly the room left. + let mut a = Arguments::of([3, 2, 2]); + a.arguments.insert(0, 1); + a.at = 2; + a.cursor = 1000 - 85; + let s = a.run(); + assert_eq!(s.work[work::OBJECT_GROUPS as usize], 12); + assert_eq!(s.cursor, 1000); + assert_eq!(s.report, StatusReport::default()); +} + +/// A grid with an axis of 0 runs nothing and says nothing, however large its other axes; so do +/// arguments past the bound range. +#[test] +fn the_object_arguments_pass_runs_an_empty_grid_silently() { + for grid in [[3, 0, 2], [0, 1, 1], [1 << 20, 1 << 20, 0]] { + let a = Arguments::of(grid); + let s = a.run(); + runs_nothing(&a, &s); + assert_eq!(s.report, StatusReport::default(), "{grid:?}"); + } + let mut a = Arguments::of([3, 2, 2]); + a.arguments.pop(); + let s = a.run(); + runs_nothing(&a, &s); + assert_eq!(s.report, StatusReport::default()); +} + +/// More than 2^29 threadgroups in all (a wrapping product too): Metal discards the command +/// buffer, so the pass runs nothing and sets the discard bit alone; exactly 2^29 runs. +#[test] +fn the_object_arguments_pass_discards_what_metal_discards() { + for grid in [[1 << 15, 1 << 15, 1], [(1 << 29) + 1, 1, 1], [65535; 3]] { + let mut a = Arguments::of(grid); + a.compute = [u32::MAX; 3]; + a.threads = [1, 1, 1]; + let s = a.run(); + runs_nothing(&a, &s); + assert!(s.report.mesh_grid_discarded, "{grid:?}"); + assert!(!s.report.mesh_grid_past_limits, "{grid:?}"); + assert_eq!(s.report.mesh_records_overflow, None, "{grid:?}"); + } + let mut a = Arguments::of([1 << 29, 1, 1]); + a.compute = [u32::MAX; 3]; + a.threads = [1, 1, 1]; + a.pool_words = u32::MAX; + a.cursor = 0; + let s = a.run(); + assert_eq!(s.work[work::OBJECT_GROUPS as usize], 1 << 29); + assert_eq!(s.cursor, (1 << 29) * 7 + 1); + assert_eq!(s.report, StatusReport::default()); +} + +/// An axis past the device's compute limits, or whose threads per grid wrap (Metal runs it; the +/// dispatch cannot report its wrapped grid), runs nothing and sets the past-limits bit. +#[test] +fn the_object_arguments_pass_holds_the_device_limits() { + for (grid, compute, threads) in [ + ([65536, 1, 1], [65535; 3], [1, 1, 1]), + ([1, 1, 3], [65535, 65535, 2], [1, 1, 1]), + ([1 << 22, 1, 1], [u32::MAX; 3], [1024, 1, 1]), + ([1, 1 << 23, 1], [u32::MAX; 3], [1, 512, 1]), + ] { + let mut a = Arguments::of(grid); + a.compute = compute; + a.threads = threads; + a.pool_words = u32::MAX; + let s = a.run(); + runs_nothing(&a, &s); + assert!(s.report.mesh_grid_past_limits, "{grid:?}"); + assert!(!s.report.mesh_grid_discarded, "{grid:?}"); + } + // One threadgroup less does not wrap. + let mut a = Arguments::of([(1 << 22) - 1, 1, 1]); + a.compute = [u32::MAX; 3]; + a.threads = [1024, 1, 1]; + a.pool_words = u32::MAX; + let s = a.run(); + assert_eq!(s.work[work::OBJECT_GROUPS as usize], (1 << 22) - 1); + assert_eq!(s.report, StatusReport::default()); +} + +/// Slots the rest of the pool cannot hold: nothing runs, the cursor stays, and the first such +/// draw names itself (no mesh threadgroups yet); a later fault leaves the first one's words. +#[test] +fn the_object_arguments_pass_says_when_the_pool_is_full() { + let mut a = Arguments::of([3, 2, 2]); + a.cursor = 1000 - 84; + let s = a.run(); + runs_nothing(&a, &s); + assert_eq!( + s.report.mesh_records_overflow, + Some(MeshRecordsFault { + draw: 7, + object_threadgroups: 12, + mesh_threadgroups: 0, + }) + ); + // A cursor already past the pool. + a.cursor = 5000; + let s = a.run(); + runs_nothing(&a, &s); + assert!(s.report.mesh_records_overflow.is_some()); + a.bits = StatusBits::MESH_RECORDS_OVERFLOW.0; + let s = a.run(); + assert_eq!( + s.report.mesh_records_overflow, + Some(MeshRecordsFault::default()) + ); +} + +/// The pass, the object function's slots and the scan in turn: the scan places the threadgroups +/// of the slots the pass reserved, after them in the pool. +#[test] +fn the_scan_places_the_grids_of_the_slots_the_pass_reserved() { + let a = Arguments::of([2, 2, 1]); + let s = a.run(); + let at = s.work[work::SLOTS as usize] - 1; + let grids = [[2, 1, 1], [0, 5, 1], [3, 2, 1], [1, 1, 1]]; + let mut draw = Draw::of(&grids); + draw.pooled = Some(at); + let scanned = scan(&draw, &[0], s.cursor, 0); + assert_eq!(offsets(&draw, &scanned), vec![0, 2, 2, 8, 9]); + assert_eq!(scanned.work[work::RECORDS_BASE as usize], s.cursor); + assert_eq!(scanned.cursor, s.cursor + 9 * 10); +} diff --git a/crates/metal2vulkan/src/bind/mod.rs b/crates/metal2vulkan/src/bind/mod.rs index 30c4912d1..fdf53077b 100644 --- a/crates/metal2vulkan/src/bind/mod.rs +++ b/crates/metal2vulkan/src/bind/mod.rs @@ -252,7 +252,7 @@ pub use mesh_arguments::{ MeshArgumentsModule, MeshGridLimits, MeshGridRule, ObjectFold, METAL_MESH_GRID_AXIS, METAL_MESH_GRID_TOTAL, METAL_OBJECT_GRID_TOTAL, }; -pub use mesh_scan::{mesh_scan_module, MeshScanModule}; +pub use mesh_scan::{mesh_object_arguments_module, mesh_scan_module, MeshScanModule}; pub use mipmap_filter::{ mipmap_filter_module, MipmapFilterChain, MipmapFilterKernel, MipmapFilterLevel, MipmapFilterModule, MipmapRule, diff --git a/crates/metal2vulkan/src/bind/status.rs b/crates/metal2vulkan/src/bind/status.rs index 1f74c9220..01031fe96 100644 --- a/crates/metal2vulkan/src/bind/status.rs +++ b/crates/metal2vulkan/src/bind/status.rs @@ -99,9 +99,11 @@ pub struct StatusReport { /// command buffer is Metal's. pub absent_argument_read: bool, /// A mesh scan found no room in the command buffer's records pool for an emulated mesh - /// draw's records, or the draw's vertices passed a `u32` (`bind::MeshScanModule`): such draws - /// drew nothing. The first one, as the scan saw it, where it was the command buffer's first - /// records fault; a fault of all zeros where a tessellation draw's was. + /// draw's records, or the draw's vertices passed a `u32` (`bind::MeshScanModule`), or an + /// object arguments pass none for an emulated indirect draw's object slots + /// (`bind::mesh_object_arguments_module`, no mesh threadgroups yet): such draws drew nothing. + /// The first one, as the pass saw it, where it was the command buffer's first records fault; + /// a fault of all zeros where a tessellation draw's was. pub mesh_records_overflow: Option, /// A tessellation scan found no room in the command buffer's records pool for an emulated /// tessellation draw's records, or the draw's records passed a `u32` @@ -118,13 +120,13 @@ pub struct StatusReport { /// capture settle took every tile of the pass's mask (`bind::CaptureSettleModule`): the /// pass's reach is the announced fallback, not its draws' tiles. pub captured_reach_unmeasured: bool, - /// An indirect mesh draw's arguments pass met an object grid that Metal's GPU discards - /// (`StatusBits::MESH_GRID_DISCARDED`): that draw drew nothing, and the command buffer fails - /// as Metal's does (`MTLCommandBufferErrorInternal`). + /// An indirect mesh draw's arguments pass (or an emulated one's object arguments pass) met an + /// object grid that Metal's GPU discards (`StatusBits::MESH_GRID_DISCARDED`): that draw drew + /// nothing, and the command buffer fails as Metal's does (`MTLCommandBufferErrorInternal`). pub mesh_grid_discarded: bool, - /// An indirect mesh draw's arguments pass met a grid that Metal draws and the device cannot - /// launch (`StatusBits::MESH_GRID_PAST_LIMITS`): that draw drew nothing, and the command buffer - /// fails (not Metal's failure). + /// An indirect mesh draw's arguments pass (or an emulated one's object arguments pass) met a + /// grid that Metal draws and the device cannot launch (`StatusBits::MESH_GRID_PAST_LIMITS`): + /// that draw drew nothing, and the command buffer fails (not Metal's failure). pub mesh_grid_past_limits: bool, } @@ -137,7 +139,8 @@ pub struct MeshRecordsFault { pub draw: u32, /// The draw's object threadgroups (1 without an object function). pub object_threadgroups: u32, - /// The mesh threadgroups the draw's object threadgroups launched, saturated at `u32::MAX`. + /// The mesh threadgroups the draw's object threadgroups launched, saturated at `u32::MAX`; 0 + /// where its object slots did not fit, before any launched. pub mesh_threadgroups: u32, } @@ -231,9 +234,10 @@ impl StatusBits { /// gives no value, and took zero for it (`RuntimeFact::AbsentArgumentRead`). pub const ABSENT_ARGUMENT_READ: StatusBits = StatusBits(1 << 4); /// A mesh scan found no room in the command buffer's records pool for an emulated mesh - /// draw's records, or the draw's vertices passed a `u32`, and the draw drew nothing - /// (`bind::MeshScanModule`); the fault words name the command buffer's first records fault of - /// either kind. + /// draw's records, or the draw's vertices passed a `u32`, or an object arguments pass none for + /// an emulated indirect draw's object slots, and the draw drew nothing + /// (`bind::MeshScanModule`, `bind::mesh_object_arguments_module`); the fault words name the + /// command buffer's first records fault of either kind. pub const MESH_RECORDS_OVERFLOW: StatusBits = StatusBits(1 << 5); /// A function sampled, gathered, or queried through a sampler an argument buffer holds whose /// min or mag filter is `Cubic`, whose bicubic filter it does not emulate there @@ -252,11 +256,15 @@ impl StatusBits { /// An indirect mesh draw's arguments pass met a grid that Metal draws and the device cannot /// launch: a mesh grid past the mesh stage's limits, an unfolded object grid past the task /// stage's, or a folded one of more pieces than `MeshArguments::OBJECT_PIECES` (only under task - /// limits below Vulkan's required least); the draw drew nothing (`bind::MeshArguments`). + /// limits below Vulkan's required least); or an emulated indirect draw's object arguments pass + /// met an object grid past the device's compute limits, or one whose threads per grid wrap + /// along an axis (`bind::mesh_object_arguments_module`); the draw drew nothing + /// (`bind::MeshArguments`). pub const MESH_GRID_PAST_LIMITS: StatusBits = StatusBits(1 << 9); /// An indirect mesh draw's arguments pass met an object grid of more threadgroups than - /// `bind::METAL_OBJECT_GRID_TOTAL`, which Metal's GPU discards; the draw drew nothing - /// (`bind::MeshArguments`). + /// `bind::METAL_OBJECT_GRID_TOTAL`, which Metal's GPU discards (or an emulated draw's object + /// arguments pass did); the draw drew nothing (`bind::MeshArguments`, + /// `bind::mesh_object_arguments_module`). pub const MESH_GRID_DISCARDED: StatusBits = StatusBits(1 << 10); /// Either records fault: the command buffer's first one of either kind writes the fault /// words. diff --git a/crates/metal2vulkan/src/lower/arith/extended_range.rs b/crates/metal2vulkan/src/lower/arith/extended_range.rs index 196fb9848..dbcc31271 100644 --- a/crates/metal2vulkan/src/lower/arith/extended_range.rs +++ b/crates/metal2vulkan/src/lower/arith/extended_range.rs @@ -78,7 +78,11 @@ fn floats() -> Form { /// channel order, red first; `BGR10_XR`'s alpha is the code of 1, and `BGRA10_XR`'s is clamped /// to `[384, 894]`, the codes of `[0, 1]`. A two-plane texel's alpha is its alpha byte (the /// second component), an 8-bit unorm code. -fn codes(fb: &mut FunctionBuilder<'_>, form: ExtendedRange, raw: Value) -> BResult { +pub(crate) fn codes( + fb: &mut FunctionBuilder<'_>, + form: ExtendedRange, + raw: Value, +) -> BResult { let u = words(); let ut = crate::lower::arith::ops::ty(fb, u)?; match form { @@ -456,37 +460,10 @@ pub fn encode( // rounded to nearest (every value of a grid and around every midpoint), in // its word's top 10 bits, the low 6 bits zero. if form.padded() { - let (u, f) = (words(), floats()); - let zero = fsplat(fb, f, 0.0)?; - let nan = fb.unary(crate::spirv::ir::UnOp::IsNan, v)?; - let v = fb.select(nan, zero, v)?; - let one = fsplat(fb, f, 1.0)?; - let v = fb.glsl(GlslOp::FClamp, &[v, zero, one])?; - let scales: &[u32] = match form { - ExtendedRange::Rgb10A2Srgb => &[1023, 1023, 1023, 3], - _ => &[1023], - }; - let k = round_exact_product_lanes(fb, f, v, scales, false)?; - let k = match form { - ExtendedRange::R10X6Srgb | ExtendedRange::Rg10X12Srgb | ExtendedRange::Rgb10A2Srgb => { - let table = table.ok_or_else(missing_table)?; - padded_srgb_codes(fb, form, table, v, k)? - } - _ => k, - }; - // `RGB10A2Unorm_sRGB`'s fields from bit 0, alpha in bits 30 and 31. + let u = words(); + let k = padded_codes(fb, form, v, table)?; if form == ExtendedRange::Rgb10A2Srgb { - let shifts = per_lane(fb, [0, 10, 20, 30])?; - let k = fb.binary(BinOp::ShiftLeftLogical, k, shifts)?; - let mut w = fb.composite_extract(k, &[0])?; - for lane in 1..4u32 { - let x = fb.composite_extract(k, &[lane])?; - w = fb.binary(BinOp::BitwiseOr, w, x)?; - } - let z = fb.u32_const(0)?; - let z = fb.module().const_value(z)?; - let ut = crate::lower::arith::ops::ty(fb, u)?; - return fb.composite_construct(ut, &[w, z, z, z]); + return pack(fb, form, k); } let six = splat(fb, u, 6)?; let w = fb.binary(BinOp::ShiftLeftLogical, k, six)?; @@ -500,6 +477,50 @@ pub fn encode( pack(fb, form, code) } +/// The codes a write of `v` (a `vec4` of `f32`, red first) to a slot of a padded form stores +/// ([`encode`]): the exact product of the value, clamped to `[0, 1]` (a NaN 0), with 1023 (alpha's +/// with 3), rounded to nearest, an `_sRGB` form's color codes through its `table`. +fn padded_codes( + fb: &mut FunctionBuilder<'_>, + form: ExtendedRange, + v: Value, + table: Option, +) -> BResult { + let f = floats(); + let zero = fsplat(fb, f, 0.0)?; + let nan = fb.unary(crate::spirv::ir::UnOp::IsNan, v)?; + let v = fb.select(nan, zero, v)?; + let one = fsplat(fb, f, 1.0)?; + let v = fb.glsl(GlslOp::FClamp, &[v, zero, one])?; + let scales: &[u32] = match form { + ExtendedRange::Rgb10A2Srgb => &[1023, 1023, 1023, 3], + _ => &[1023], + }; + let k = round_exact_product_lanes(fb, f, v, scales, false)?; + match form { + ExtendedRange::R10X6Srgb | ExtendedRange::Rg10X12Srgb | ExtendedRange::Rgb10A2Srgb => { + let table = table.ok_or_else(missing_table)?; + padded_srgb_codes(fb, form, table, v, k) + } + _ => Ok(k), + } +} + +/// The codes (red first) a write of `v` (a `vec4` of `f32`, red first) to a slot of `form` stores, +/// as [`encode`] packs them: a linear or `_sRGB` form's color codes and alpha's, or a padded +/// form's. `table` is the form's ([`declare`], [`declare_padded`]) where it has one. +pub(crate) fn write_codes( + fb: &mut FunctionBuilder<'_>, + form: ExtendedRange, + v: Value, + table: Option, +) -> BResult { + match form.padded() { + true => padded_codes(fb, form, v, table), + false => linear_codes(fb, form, v, table), + } +} + /// The lanes a bfloat form keeps of a first vector, the rest taken from a second: red; red and /// green; or all four. fn bfloat_lanes(form: ExtendedRange) -> &'static [u32] { @@ -718,8 +739,12 @@ fn linear_codes( } /// The raw texel (the raw format's `uvec4`) of the codes `code` (red first; a two-plane form's -/// alpha its byte) of a linear or `_sRGB` form. -fn pack(fb: &mut FunctionBuilder<'_>, form: ExtendedRange, code: Value) -> BResult { +/// alpha its byte) of a linear or `_sRGB` form, or of `RGB10A2Unorm_sRGB`. +pub(crate) fn pack( + fb: &mut FunctionBuilder<'_>, + form: ExtendedRange, + code: Value, +) -> BResult { let u = words(); let ut = crate::lower::arith::ops::ty(fb, u)?; let planes = matches!(form, ExtendedRange::Planes { .. }); @@ -753,12 +778,24 @@ fn pack(fb: &mut FunctionBuilder<'_>, form: ExtendedRange, code: Value) -> BResu let six = splat(fb, u, 6)?; fb.binary(BinOp::ShiftLeftLogical, c, six) } - // A padded form's words are [`encode`]'s own, and a bfloat form's. + // `RGB10A2Unorm_sRGB`'s fields from bit 0, alpha in bits 30 and 31. + ExtendedRange::Rgb10A2Srgb => { + let shifts = per_lane(fb, [0, 10, 20, 30])?; + let k = fb.binary(BinOp::ShiftLeftLogical, code, shifts)?; + let mut w = fb.composite_extract(k, &[0])?; + for lane in 1..4u32 { + let x = fb.composite_extract(k, &[lane])?; + w = fb.binary(BinOp::BitwiseOr, w, x)?; + } + let z = fb.u32_const(0)?; + let z = fb.module().const_value(z)?; + fb.composite_construct(ut, &[w, z, z, z]) + } + // Another padded form's words are [`encode`]'s own, and a bfloat form's. ExtendedRange::R10X6 | ExtendedRange::Rg10X12 | ExtendedRange::R10X6Srgb | ExtendedRange::Rg10X12Srgb - | ExtendedRange::Rgb10A2Srgb | ExtendedRange::R16Bfloat | ExtendedRange::Rg16Bfloat | ExtendedRange::Rgba16Bfloat => Err(crate::spirv::error::BuildError::Type( diff --git a/crates/metal2vulkan/src/lower/mesh/mod.rs b/crates/metal2vulkan/src/lower/mesh/mod.rs index bbc6b8c0d..a00c7cb3c 100644 --- a/crates/metal2vulkan/src/lower/mesh/mod.rs +++ b/crates/metal2vulkan/src/lower/mesh/mod.rs @@ -92,10 +92,12 @@ //! Every emulated draw has a work buffer ([`work`], `SyntheticBinding::MeshWork`): its header //! (the object threadgroups `O`, the mesh threadgroups `T`, the records' first word, the mesh //! dispatch's and the draw's indirect arguments), a slot per object threadgroup (the grid it -//! launched, then its payload's words), and each object threadgroup's first mesh threadgroup. -//! An object function is a `GLCompute` entry too: its payload is workgroup memory, its wrapper -//! zeroes its grid, runs the body between two barriers, and writes the grid it set (held to -//! Metal's limit) and its payload into its slot. The binder or a scan +//! launched, then its payload's words), and each object threadgroup's first mesh threadgroup. An +//! indirect draw with an object function keeps its slots and offsets in its records instead, +//! where its object arguments pass reserved them (`work::SLOTS`); the wrappers and the scan read +//! the header's word to find them. An object function is a `GLCompute` entry too: its payload is +//! workgroup memory, its wrapper zeroes its grid, runs the body between two barriers, and writes +//! the grid it set (held to Metal's limit) and its payload into its slot. The binder or a scan //! (`bind::mesh_scan_module`) fills the rest of the header. The mesh wrapper's threadgroup is //! number `w` of the draw's `T` (past `T` it returns); it finds its object threadgroup by //! bisecting the offsets, and its place in that threadgroup's grid, which every grid builtin @@ -1056,6 +1058,14 @@ pub const OBJECT_WORK_SLOT: ResourceSlot = ResourceSlot { index: 0, }; +/// The binding symbol of the records for an emulated object function ([`RECORDS_SLOT`]), where +/// an indirect draw keeps its slots (`work::SLOTS`). +pub const OBJECT_RECORDS_SLOT: ResourceSlot = ResourceSlot { + stage: Stage::Object, + kind: ResourceKind::Synthetic(SyntheticBinding::MeshRecords), + index: 0, +}; + pub mod work; /// An emulated mesh function's records ([`MeshRecords`]) with each output's word offset in its @@ -1182,9 +1192,11 @@ pub fn declare( let uvec3 = mb.ty(Type::Vector { elem: u32_, len: 3 })?; d.grid = Some(mb.plain_global(StorageClass::Workgroup, uvec3, None)?); } - // An emulated object function that sets its grid writes its slot of the work buffer. + // An emulated object function that sets its grid writes its slot: in the work buffer, or in + // the records where an indirect draw's object arguments pass reserved it (`work::SLOTS`). if mp.emulated && mp.object { d.work = Some(words_buffer(mb, OBJECT_WORK_SLOT)?); + d.records = Some(words_buffer(mb, OBJECT_RECORDS_SLOT)?); } let Some(shape) = mp.mesh else { return Ok(d); @@ -1456,6 +1468,70 @@ fn load_word(fb: &mut FunctionBuilder<'_>, buffer: GlobalId, at: SValue) -> BRes fb.load(ptr, MemAccess::default()) } +/// Where an emulated draw's slots and offsets begin (`work::SLOTS`): in the records, at the word +/// the header names, for an indirect draw with an object function (whose object arguments pass +/// reserved them), else after the work buffer's header. +#[derive(Clone, Copy)] +struct Slots { + work: GlobalId, + records: GlobalId, + pooled: SValue, + start: SValue, +} + +impl Slots { + fn of(fb: &mut FunctionBuilder<'_>, work: GlobalId, records: GlobalId) -> BResult { + let at = k32(fb, work::SLOTS)?; + let word = load_word(fb, work, at)?; + let zero = k32(fb, 0)?; + let one = k32(fb, 1)?; + let pooled = fb.binary(BinOp::INotEqual, word, zero)?; + let in_pool = fb.binary(BinOp::ISub, word, one)?; + let header = k32(fb, work::HEADER)?; + let start = fb.select(pooled, in_pool, header)?; + Ok(Slots { + work, + records, + pooled, + start, + }) + } + + /// Word `at` of the slots and offsets (from their first). + fn load(self, fb: &mut FunctionBuilder<'_>, at: SValue) -> BResult { + let zero = k32(fb, 0)?; + let at = fb.binary(BinOp::IAdd, self.start, at)?; + let in_work = fb.select(self.pooled, zero, at)?; + let in_pool = fb.select(self.pooled, at, zero)?; + let from_work = load_word(fb, self.work, in_work)?; + let from_pool = load_word(fb, self.records, in_pool)?; + fb.select(self.pooled, from_pool, from_work) + } + + /// Store `value` at word `at` of the slots and offsets (from their first). + fn store( + self, + fb: &mut FunctionBuilder<'_>, + cx: &mut C, + at: SValue, + value: SValue, + access: MemAccess, + ) -> BResult<()> { + let at = fb.binary(BinOp::IAdd, self.start, at)?; + let (records, work) = (self.records, self.work); + let pool: ArmFn<'_, C> = Box::new(move |fb, _| { + store_word(fb, records, at, value, access)?; + Ok(ArmEnd::FallThrough(Vec::new())) + }); + let local: ArmFn<'_, C> = Box::new(move |fb, _| { + store_word(fb, work, at, value, access)?; + Ok(ArmEnd::FallThrough(Vec::new())) + }); + fb.if_(cx, self.pooled, pool, Some(local))?; + Ok(()) + } +} + /// Store `value`, an element of output `output` of an emulated mesh function, as words in record /// `at` (its element `inner` of a clip distance array, `value` a `float`), where `at` lies inside /// the output's array: a lane per word, a `float` or `int` as its bits and a `bool` as 1 or 0 @@ -2033,9 +2109,9 @@ fn payload_word( } /// An emulated object function's wrapper (the module docs): its grid zeroed, the body between -/// two barriers, then its slot of the work buffer, placed by its threadgroup's linear index in -/// the grid: the grid it stored, held to Metal's limit, and its payload's words that the slot -/// holds. +/// two barriers, then its slot ([`Slots`]: in the work buffer, or in the records for an indirect +/// draw), placed by its threadgroup's linear index in the grid: the grid it stored, held to +/// Metal's limit, and its payload's words that the slot holds. fn emulated_object_wrapper( cx: &mut EmitCx<'_>, mut fb: FunctionBuilder<'_>, @@ -2043,8 +2119,8 @@ fn emulated_object_wrapper( body: FuncId, ) -> BResult { let d = &cx.decl.families.mesh; - let (Some(g), Some(work)) = (d.grid, d.work) else { - return Err(cx.fail("an emulated object wrapper without its grid or work buffer")); + let (Some(g), Some(work), Some(records)) = (d.grid, d.work, d.records) else { + return Err(cx.fail("an emulated object wrapper without its grid, work buffer or records")); }; let coherence = coherence(cx.plan); let zero = k32(&mut fb, 0)?; @@ -2059,7 +2135,8 @@ fn emulated_object_wrapper( device_barrier(cx, &mut fb)?; fb.call(body, &[])?; device_barrier(cx, &mut fb)?; - // Its slot: `HEADER + o · S`, `o = x + X · (y + Y · z)` its threadgroup's linear index. + // Its slot: word `o · S` of the slots, `o = x + X · (y + Y · z)` its threadgroup's linear + // index. let at = builtin(cx, &mut fb, KernelBuiltin::ThreadgroupPositionInGrid)?; let grid = builtin(cx, &mut fb, KernelBuiltin::ThreadgroupsPerGrid)?; let [x, y, z] = [0, 1, 2].map(|i| fb.composite_extract(at, &[i])); @@ -2070,9 +2147,8 @@ fn emulated_object_wrapper( let o = fb.binary(BinOp::IAdd, x?, xyz)?; let at_s = k32(&mut fb, work::SLOT_WORDS)?; let s = load_word(&mut fb, work, at_s)?; - let header = k32(&mut fb, work::HEADER)?; - let into = fb.binary(BinOp::IMul, o, s)?; - let slot = fb.binary(BinOp::IAdd, header, into)?; + let slots = Slots::of(&mut fb, work, records)?; + let slot = fb.binary(BinOp::IMul, o, s)?; when(&mut fb, cx, first, move |fb, cx| { let p = fb.module().global_value(g)?; let access = word_access(coherence, fb, false)?; @@ -2082,7 +2158,7 @@ fn emulated_object_wrapper( for (i, v) in bounded.into_iter().enumerate() { let off = k32(fb, i as u32)?; let w = fb.binary(BinOp::IAdd, slot, off)?; - store_word(fb, work, w, v, MemAccess::default())?; + slots.store(fb, cx, w, v, MemAccess::default())?; } Ok(()) })?; @@ -2100,7 +2176,7 @@ fn emulated_object_wrapper( return Err(cx.fail("a payload read without its value")); }; let w = fb.binary(BinOp::IAdd, start, i)?; - store_word(fb, work, w, v, MemAccess::default()) + slots.store(fb, cx, w, v, MemAccess::default()) }) })?; } @@ -2166,9 +2242,8 @@ fn emulated_wrapper( let objects = load_word(&mut fb, work, at)?; let at = k(&mut fb, work::SLOT_WORDS)?; let s = load_word(&mut fb, work, at)?; - let header = k(&mut fb, work::HEADER)?; - let slots = fb.binary(BinOp::IMul, objects, s)?; - let offsets = fb.binary(BinOp::IAdd, header, slots)?; + let slots = Slots::of(&mut fb, work, records)?; + let offsets = fb.binary(BinOp::IMul, objects, s)?; let lo = fb.local_var(u32_, None)?; let hi = fb.local_var(u32_, None)?; let (lo, hi) = (fb.var_ptr(lo)?, fb.var_ptr(hi)?); @@ -2189,7 +2264,7 @@ fn emulated_wrapper( let half = fb.binary(BinOp::ShiftRightLogical, gap, one)?; let mid = fb.binary(BinOp::IAdd, a, half)?; let at = fb.binary(BinOp::IAdd, offsets, mid)?; - let offset = load_word(fb, work, at)?; + let offset = slots.load(fb, at)?; let below = fb.binary(BinOp::ULessThanEqual, offset, w)?; let a = fb.select(below, mid, a)?; let b = fb.select(below, b, mid)?; @@ -2199,16 +2274,15 @@ fn emulated_wrapper( fb.loop_(cx, LoopSpec::default(), search)?; let o = fb.load(lo, MemAccess::default())?; // Its place in the object threadgroup's grid: `w − offsets[o]`, x fastest. - let into = fb.binary(BinOp::IMul, o, s)?; - let slot = fb.binary(BinOp::IAdd, header, into)?; + let slot = fb.binary(BinOp::IMul, o, s)?; let mut axis = |i: u32| -> BResult { let off = k(&mut fb, i)?; let at = fb.binary(BinOp::IAdd, slot, off)?; - load_word(&mut fb, work, at) + slots.load(&mut fb, at) }; let [gx, gy, gz] = [axis(0)?, axis(1)?, axis(2)?]; let at = fb.binary(BinOp::IAdd, offsets, o)?; - let start = load_word(&mut fb, work, at)?; + let start = slots.load(&mut fb, at)?; let local = fb.binary(BinOp::ISub, w, start)?; // The object threadgroup launched `w`, so none of its counts is 0. let x = fb.binary(BinOp::UMod, local, gx)?; @@ -2240,7 +2314,7 @@ fn emulated_wrapper( let held = fb.binary(BinOp::ULessThan, i, room)?; let at = fb.binary(BinOp::IAdd, from, i)?; let at = fb.select(held, at, from)?; - let read = load_word(fb, work, at)?; + let read = slots.load(fb, at)?; let zero = k32(fb, 0)?; let v = fb.select(held, read, zero)?; payload_word(cx, fb, i, Some(v)).map(|_| ()) diff --git a/crates/metal2vulkan/src/lower/mesh/work.rs b/crates/metal2vulkan/src/lower/mesh/work.rs index c49538662..2056c9200 100644 --- a/crates/metal2vulkan/src/lower/mesh/work.rs +++ b/crates/metal2vulkan/src/lower/mesh/work.rs @@ -1,7 +1,9 @@ //! The words of an emulated mesh draw's work buffer (`SyntheticBinding::MeshWork`, `lower::mesh`'s //! module docs), each a `u32`: a header of [`HEADER`] words, then a slot of `S` words per object //! threadgroup (its grid's three counts and a zero, then its payload), then `O + 1` offsets: the -//! first mesh threadgroup of each object threadgroup, and `T`. +//! first mesh threadgroup of each object threadgroup, and `T`. An indirect draw with an object +//! function keeps its slots and offsets in its records binding instead, where its object arguments +//! pass reserves them (`bind::mesh_scan`, [`SLOTS`]). //! //! The binder, the mesh scan (`bind::mesh_scan`) and the runtime read these words at run time, //! so this file is a runtime input (`validation/build.rs`); the lowering writes them. @@ -34,8 +36,22 @@ pub const ROW: u32 = 15; /// arguments range where Metal's indirect arguments (the mesh grid of a pipeline without an /// object function) begin, which the scan reads into slot 0. pub const ARGUMENTS: u32 = 16; +/// 0 where the slots and offsets follow the header; else 1 plus the word of the records binding +/// (the command buffer's records pool) where they begin: an indirect draw with an object function, +/// whose object arguments pass reserves them. +pub const SLOTS: u32 = 17; +/// The object dispatch's `VkDispatchIndirectCommand`, three words, which the object arguments pass +/// writes (an indirect draw with an object function). +pub const OBJECT_DISPATCH: u32 = 18; +/// 0 for any other draw; else 1 plus the word of the bound arguments range where Metal's indirect +/// arguments (the object grid of an indirect draw with an object function) begin, which the +/// object arguments pass reads. +pub const OBJECT_ARGUMENTS: u32 = 21; +/// The threads per object threadgroup, packed as a region record packs them +/// (`lower::dispatch::pack_nominal`), of an indirect draw with an object function. +pub const OBJECT_THREADS: u32 = 22; /// The header's words. -pub const HEADER: u32 = 20; +pub const HEADER: u32 = 24; /// The words of a slot before its payload: the grid's three counts and a zero. pub const GRID: u32 = 4; diff --git a/crates/metal2vulkan/src/pipeline/api_tests.rs b/crates/metal2vulkan/src/pipeline/api_tests.rs index 64de2e622..3ab05c1e3 100644 --- a/crates/metal2vulkan/src/pipeline/api_tests.rs +++ b/crates/metal2vulkan/src/pipeline/api_tests.rs @@ -1311,6 +1311,10 @@ mod bind_serde_round_trips { work: vec![1, 0, 0, 2], work_bytes: 112, object_groups: Some([2, 1, 1]), + object_arguments: Some(crate::bind::BufferRange { + offset: 0, + range: 12, + }), mesh: crate::bind::MeshGroups::Scanned { arguments: Some(crate::bind::BufferRange { offset: 64, diff --git a/crates/metal2vulkan/src/tests/engine_mesh.rs b/crates/metal2vulkan/src/tests/engine_mesh.rs index 2def4b74a..aa9f36dce 100644 --- a/crates/metal2vulkan/src/tests/engine_mesh.rs +++ b/crates/metal2vulkan/src/tests/engine_mesh.rs @@ -1123,9 +1123,12 @@ fn without_the_extension_a_mesh_pipeline_draws_its_records() { /// `mesh_draws_mesh` and `mesh_draws_fragment`): the object function's compute stage first, one /// push range of both compute stages' windows, both work bindings; a draw of object threadgroups /// dispatches them, is scanned into the records pool, and is drawn from the work buffer, whose -/// slots hold the payload. +/// slots hold the payload; an indirect one runs its object arguments pass first, its slots in the +/// pool. fn object_records_draws(dev: &crate::device::Device, draws: &crate::library::Library, stem: &str) { - use crate::bind::{BindState, DrawCall, MeshDispatch, MeshGroups, MeshRecordsRegion}; + use crate::bind::{ + BindState, DrawCall, MeshDispatch, MeshGroups, MeshRecordsRegion, UseTarget, + }; use crate::budget::Budget; use crate::lower::mesh::work; use crate::metal::PixelFormat; @@ -1134,6 +1137,7 @@ fn object_records_draws(dev: &crate::device::Device, draws: &crate::library::Lib }; use crate::pipeline::layout::BindingSource; use crate::pipeline::sym::SyntheticBinding; + use crate::pipeline::AccessSet; use crate::vk; let stage = |name: &str| { StageSource::Function(FunctionDescriptor::new( @@ -1195,6 +1199,12 @@ fn object_records_draws(dev: &crate::device::Device, draws: &crate::library::Lib Some(vk::ShaderStageFlags::COMPUTE | vk::ShaderStageFlags::VERTEX), "{stem}" ); + // The object function's slots of an indirect draw lie in the records (`work::SLOTS`). + assert_eq!( + stages_of(Stage::Object, SyntheticBinding::MeshRecords), + Some(vk::ShaderStageFlags::COMPUTE), + "{stem}" + ); let records = pipeline .graphics .mesh_records @@ -1242,26 +1252,58 @@ fn object_records_draws(dev: &crate::device::Device, draws: &crate::library::Lib 4 * work::words(6, records.slot_words), "{stem}" ); - // A partial object threadgroup is not implemented; an indirect draw is not either. + // An indirect draw runs its object arguments pass first: Metal's arguments at word 1 plus + // the offset's residual, the object threadgroup packed, no object count yet, and the slots in + // the pool, which the pass reserves. + let indirect = DrawCall::MeshThreadgroupsIndirect { + indirect: crate::bind::IndirectRef::new(1, 4), + threads_per_object_group: [4, 1, 1], + threads_per_mesh_group: [8, 1, 1], + }; + let cmds = plan + .instantiate_draw(&state, &indirect) + .unwrap_or_else(|e| panic!("{stem}: an indirect draw: {e}")); + let d = cmds.mesh_dispatch.expect("the draw's dispatch"); + assert_eq!(d.object_groups, None, "{stem}"); + let range = d.object_arguments.expect("the object arguments pass"); + assert_eq!(range.offset + range.range, 16, "{stem}"); + assert_eq!(d.mesh, MeshGroups::Scanned { arguments: None }, "{stem}"); + assert_eq!(d.records, MeshRecordsRegion::Pool, "{stem}"); + assert_eq!( + d.work[work::OBJECT_ARGUMENTS as usize], + u32::try_from((4 - range.offset) / 4 + 1).expect("a word"), + "{stem}" + ); + assert_eq!( + d.work[work::OBJECT_THREADS as usize], + crate::lower::dispatch::pack_nominal([4, 1, 1]).expect("packs"), + "{stem}" + ); + assert_eq!(d.work[work::OBJECT_GROUPS as usize], 0, "{stem}"); + assert_eq!( + d.work_bytes, + 4 * work::words(0, records.slot_words), + "{stem}" + ); + assert!( + cmds.uses + .iter() + .any(|u| u.resource == UseTarget::Indirect && u.access == AccessSet::READ), + "{stem}: the pass reads Metal's arguments" + ); + // A partial object threadgroup is not implemented. let threads = DrawCall::MeshThreads { threads: [6, 1, 1], threads_per_object_group: [4, 1, 1], threads_per_mesh_group: [8, 1, 1], }; - let indirect = DrawCall::MeshThreadgroupsIndirect { - indirect: crate::bind::IndirectRef::new(1, 0), - threads_per_object_group: [4, 1, 1], - threads_per_mesh_group: [8, 1, 1], - }; - for draw in [threads, indirect] { - assert_eq!( - plan.instantiate_draw(&state, &draw).err(), - Some(crate::error::BindError::Unsupported( - crate::error::Unsupported::not_implemented(Feature::MeshShading) - )), - "{stem}: {draw:?}" - ); - } + assert_eq!( + plan.instantiate_draw(&state, &threads).err(), + Some(crate::error::BindError::Unsupported( + crate::error::Unsupported::not_implemented(Feature::MeshShading) + )), + "{stem}: {threads:?}" + ); } /// The binder's draws of mesh pipeline `p` with an object function: each stage's threadgroup size diff --git a/crates/metal2vulkan/src/tests/owned_divisions.rs b/crates/metal2vulkan/src/tests/owned_divisions.rs index c6b1ecae0..e5a7a4715 100644 --- a/crates/metal2vulkan/src/tests/owned_divisions.rs +++ b/crates/metal2vulkan/src/tests/owned_divisions.rs @@ -87,6 +87,7 @@ fn modules() -> Vec { index_bounds_fill_module, index_bounds_plan_module, indirect_clamp_module, + mesh_object_arguments_module, mesh_scan_module, plane_bytes_copy_module, plane_copy_module, diff --git a/crates/metal2vulkan/tests/air_input/xr_resolve.txt b/crates/metal2vulkan/tests/air_input/xr_resolve.txt new file mode 100644 index 000000000..173ef3ae5 --- /dev/null +++ b/crates/metal2vulkan/tests/air_input/xr_resolve.txt @@ -0,0 +1,146 @@ +target triple = "air64_v28-apple-macosx26.0.0" +source_filename = "-" +; datalayout DataLayout { endian: Little, pointers: {0: PointerSpec { size_bits: 64, abi_bits: 64, pref_bits: 64, index_bits: 64 }}, ints: {1: AlignSpec { abi_bits: 8, pref_bits: 8 }, 8: AlignSpec { abi_bits: 8, pref_bits: 8 }, 16: AlignSpec { abi_bits: 16, pref_bits: 16 }, 32: AlignSpec { abi_bits: 32, pref_bits: 32 }, 64: AlignSpec { abi_bits: 64, pref_bits: 64 }}, floats: {16: AlignSpec { abi_bits: 16, pref_bits: 16 }, 32: AlignSpec { abi_bits: 32, pref_bits: 32 }, 64: AlignSpec { abi_bits: 64, pref_bits: 64 }, 128: AlignSpec { abi_bits: 128, pref_bits: 128 }}, vectors: {16: AlignSpec { abi_bits: 16, pref_bits: 16 }, 24: AlignSpec { abi_bits: 32, pref_bits: 32 }, 32: AlignSpec { abi_bits: 32, pref_bits: 32 }, 48: AlignSpec { abi_bits: 64, pref_bits: 64 }, 64: AlignSpec { abi_bits: 64, pref_bits: 64 }, 96: AlignSpec { abi_bits: 128, pref_bits: 128 }, 128: AlignSpec { abi_bits: 128, pref_bits: 128 }, 192: AlignSpec { abi_bits: 256, pref_bits: 256 }, 256: AlignSpec { abi_bits: 256, pref_bits: 256 }, 512: AlignSpec { abi_bits: 512, pref_bits: 512 }, 1024: AlignSpec { abi_bits: 1024, pref_bits: 1024 }}, aggregate: AlignSpec { abi_bits: 0, pref_bits: 64 }, native_ints: [8, 16, 32], stack_align_bits: None, alloca_space: 0, program_space: 0, globals_space: 0, mangling: None, fn_ptr_align: None, non_integral: [] } +%t3 = type <{ <4 x float> }> +%t5 = type %t3 (i32) +%t6 = type float (i32) +%t8 = type <4 x float> (<4 x float>, i32, ptr addrspace(2), ptr addrspace(2)) +%t9 = type i32 (float) +%t11 = type [2 x i32] +%t16 = type { i32, i32 } ; "struct.Shape" +c7 = %t11 [27, 0] +c23 = <2 x float> [0x40000000, 0x40000000] +c24 = <2 x float> [0xBF800000, 0xBF800000] +c27 = <4 x i32> [0, 1, poison, poison] +c31 = <4 x float> [poison, poison, 0x3F000000, 0x3F800000] +c32 = <4 x i32> [0, 1, 6, 7] + +define %t5 @f0 "xrr_vertex" memory(NoModRef, NoModRef, NoModRef) "approx-func-fp-math"="true" "frame-pointer"="all" "min-legal-vector-width"="0" "no-builtins"="" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="true" { +bb0: + %i0 = shl i32 %a0, i32 1 + %i1 = and i32 %i0, i32 2 + %i2 = tail call reassoc nnan ninf nsz arcp contract afn float @f1 [air Convert(Convert { dst: NumTy { elem: F32, lanes: 1 }, dst_kind: Float, src: NumTy { elem: I32, lanes: 1 }, src_kind: Unsigned, src_fp8: None })](%i1) + %i3 = insertelement <2 x float> undef, %i2, i64 0 + %i4 = and i32 %a0, i32 2 + %i5 = tail call reassoc nnan ninf nsz arcp contract afn float @f1 [air Convert(Convert { dst: NumTy { elem: F32, lanes: 1 }, dst_kind: Float, src: NumTy { elem: I32, lanes: 1 }, src_kind: Unsigned, src_fp8: None })](%i4) + %i6 = insertelement %i3, %i5, i64 1 + %i7 = fmul reassoc nnan ninf nsz arcp contract afn <2 x float> %i6, <2 x float> c23 + %i8 = fadd reassoc nnan ninf nsz arcp contract afn <2 x float> %i7, <2 x float> c24 + %i9 = shufflevector <4 x float> %i8, <2 x float> poison, <0, 1, poison, poison> + %i10 = shufflevector <4 x float> %i9, <4 x float> c31, <0, 1, 6, 7> + %i11 = insertvalue %t3 undef %i10, 0 + ret %i11 +} + +declare %t6 @f1 "air.convert.f.f32.u.i32" memory(NoModRef, NoModRef, NoModRef) + +define %t8 @f2 "xrr_samples" memory(NoModRef, NoModRef, NoModRef) "approx-func-fp-math"="true" "frame-pointer"="all" "min-legal-vector-width"="128" "no-builtins"="" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="true" %a2( Ref nocapture "air-buffer-no-alias"="" ) %a3( align 4 dereferenceable(8) Ref nocapture "air-buffer-no-alias"="" ) { +bb0: + %i0 = extractelement %a0, i64 1 + %i1 = tail call i32 @f3 [air Convert(Convert { dst: NumTy { elem: I32, lanes: 1 }, dst_kind: Unsigned, src: NumTy { elem: F32, lanes: 1 }, src_kind: Float, src_fp8: None })](%i0) + %i2 = getelementptr inbounds %t16, %a3, i64 0, i32 0 + %i3 = load i32, %i2, align 4 + %i4 = mul i32 %i3, %i1 + %i5 = extractelement %a0, i64 0 + %i6 = tail call i32 @f3 [air Convert(Convert { dst: NumTy { elem: I32, lanes: 1 }, dst_kind: Unsigned, src: NumTy { elem: F32, lanes: 1 }, src_kind: Float, src_fp8: None })](%i5) + %i7 = add i32 %i4, %i6 + %i8 = getelementptr inbounds %t16, %a3, i64 0, i32 1 + %i9 = load i32, %i8, align 4 + %i10 = mul i32 %i7, %i9 + %i11 = add i32 %i10, %a1 + %i12 = zext %i11 to i64 + %i13 = getelementptr inbounds <4 x float>, %a2, %i12 + %i14 = load <4 x float>, %i13, align 16 + ret %i14 +} + +declare %t9 @f3 "air.convert.u.i32.f.f32" memory(NoModRef, NoModRef, NoModRef) +!md0 = !"SDK Version" +!md1 = !"wchar_size" +!md2 = !"frame-pointer" +!md3 = !"air.max_device_buffers" +!md4 = !"air.max_constant_buffers" +!md5 = !"air.max_threadgroup_buffers" +!md6 = !"air.max_textures" +!md7 = !"air.max_read_write_textures" +!md8 = !"air.max_samplers" +!md9 = !"air.position" +!md10 = !"air.arg_type_name" +!md11 = !"float4" +!md12 = !"air.arg_name" +!md13 = !"position" +!md14 = !"air.vertex_id" +!md15 = !"uint" +!md16 = !"id" +!md17 = !"air.render_target" +!md18 = !"air.center" +!md19 = !"air.no_perspective" +!md20 = !"air.sample_id" +!md21 = !"sample" +!md22 = !"air.buffer" +!md23 = !"air.location_index" +!md24 = !"air.read" +!md25 = !"air.address_space" +!md26 = !"air.arg_type_size" +!md27 = !"air.arg_type_align_size" +!md28 = !"colors" +!md29 = !"air.buffer_size" +!md30 = !"air.struct_type_info" +!md31 = !"width" +!md32 = !"samples" +!md33 = !"Shape" +!md34 = !"shape" +!md35 = !"air.compile.denorms_disable" +!md36 = !"air.compile.fast_math_enable" +!md37 = !"air.compile.framebuffer_fetch_enable" +!md38 = !"Apple metal version 32023.921 (metalfe-32023.921.6)" +!md39 = !"Metal" +!md40 = i32 2 +!md41 = %t11 c7 +!md42 = i32 1 +!md43 = i32 4 +!md44 = i32 7 +!md45 = i32 31 +!md46 = i32 128 +!md47 = i32 8 +!md48 = i32 16 +!md49 = ptr addrspace(0) @f0 +!md50 = i32 0 +!md51 = ptr addrspace(0) @f2 +!md52 = i32 3 +!md53 = !{!md40, !md0, !md41} +!md54 = !{!md42, !md1, !md43} +!md55 = !{!md44, !md2, !md40} +!md56 = !{!md44, !md3, !md45} +!md57 = !{!md44, !md4, !md45} +!md58 = !{!md44, !md5, !md45} +!md59 = !{!md44, !md6, !md46} +!md60 = !{!md44, !md7, !md47} +!md61 = !{!md44, !md8, !md48} +!md62 = !{!md9, !md10, !md11, !md12, !md13} +!md63 = !{!md62} +!md64 = !{!md50, !md14, !md10, !md15, !md12, !md16} +!md65 = !{!md64} +!md66 = !{!md49, !md63, !md65} +!md67 = !{!md17, !md50, !md50, !md10, !md11} +!md68 = !{!md67} +!md69 = !{!md50, !md9, !md18, !md19, !md10, !md11, !md12, !md13} +!md70 = !{!md42, !md20, !md10, !md15, !md12, !md21} +!md71 = !{!md40, !md22, !md23, !md50, !md42, !md24, !md25, !md40, !md26, !md48, !md27, !md48, !md10, !md11, !md12, !md28} +!md72 = !{!md50, !md43, !md50, !md15, !md31, !md43, !md43, !md50, !md15, !md32} +!md73 = !{!md52, !md22, !md29, !md47, !md23, !md42, !md42, !md24, !md25, !md40, !md30, !md72, !md26, !md47, !md27, !md43, !md10, !md33, !md12, !md34} +!md74 = !{!md69, !md70, !md71, !md73} +!md75 = !{!md51, !md68, !md74} +!md76 = !{!md35} +!md77 = !{!md36} +!md78 = !{!md37} +!md79 = !{!md38} +!md80 = !{!md40, !md47, !md50} +!md81 = !{!md39, !md43, !md50, !md50} +!"llvm.module.flags" = !{!md53, !md54, !md55, !md56, !md57, !md58, !md59, !md60, !md61} +!"air.vertex" = !{!md66} +!"air.fragment" = !{!md75} +!"air.compile_options" = !{!md76, !md77, !md78} +!"llvm.ident" = !{!md79} +!"air.version" = !{!md80} +!"air.language_version" = !{!md81} diff --git a/crates/metal2vulkan/tests/api_surface.rs b/crates/metal2vulkan/tests/api_surface.rs index 02582820e..2b3b921fe 100644 --- a/crates/metal2vulkan/tests/api_surface.rs +++ b/crates/metal2vulkan/tests/api_surface.rs @@ -677,6 +677,7 @@ surface! { fn chroma_decode_module; enum ChromaDecode N; fn mesh_scan_module; + fn mesh_object_arguments_module; struct MeshScanModule N; fn mesh_arguments_module; fn fold_object_grid; diff --git a/crates/metal2vulkan/tests/public_fixture_expectations_engine.tsv b/crates/metal2vulkan/tests/public_fixture_expectations_engine.tsv index 86371930f..df49cc8d3 100644 --- a/crates/metal2vulkan/tests/public_fixture_expectations_engine.tsv +++ b/crates/metal2vulkan/tests/public_fixture_expectations_engine.tsv @@ -2559,6 +2559,10 @@ engine/xr_planes.air.ll xr_planes_join ok ok ok ok ok ok ok ok ok ok ok ok ok ok engine/xr_planes.air.ll xr_planes_split ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok NeedsInput{StorageTextureFormat { slot: SlotRef { stage: Kernel, class: Texture, index: 1 } }} ok NeedsInput{StorageTextureFormat { slot: SlotRef { stage: Kernel, class: Texture, index: 1 } }} engine/xr_planes.ll xr_planes_join ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok NeedsInput{StorageTextureFormat { slot: SlotRef { stage: Kernel, class: Texture, index: 2 } }} ok NeedsInput{StorageTextureFormat { slot: SlotRef { stage: Kernel, class: Texture, index: 2 } }} engine/xr_planes.ll xr_planes_split ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok NeedsInput{StorageTextureFormat { slot: SlotRef { stage: Kernel, class: Texture, index: 1 } }} ok NeedsInput{StorageTextureFormat { slot: SlotRef { stage: Kernel, class: Texture, index: 1 } }} +engine/xr_resolve.air.ll xrr_vertex ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok +engine/xr_resolve.air.ll xrr_samples ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok Unsupported{SampleRateShading; AnyOf[[Feature(SampleRateShading)]]} +engine/xr_resolve.ll xrr_vertex ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok +engine/xr_resolve.ll xrr_samples ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok Unsupported{SampleRateShading; AnyOf[[Feature(SampleRateShading)]]} engine/xr_samples.air.ll xr_sample_runtime ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok engine/xr_samples.air.ll xr_sample_runtime_half ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok engine/xr_samples.air.ll xr_sample_constexpr ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok diff --git a/docs/API.md b/docs/API.md index 19f6b3860..85ddff10a 100644 --- a/docs/API.md +++ b/docs/API.md @@ -110,7 +110,10 @@ compile does. `DevicePolicy::default()` is `DevicePolicy::UNTRUSTED`: format has Metal's rule at its sample count by that rule in one more render pass instance after the pass (`shader-resolve`). On MoltenVK the device's resolve is Metal's own under either value, and an attachment a fetching pass's sample planes hold as it ends resolves from them by Metal's - rule under either. + rule under either. An extended-range attachment (`BGR10_XR`, `BGRA10_XR`, their sRGB twins, + `RGB10A2Unorm_sRGB`), held in raw codes no device averages, resolves after the pass under either + value, on every device: a linear form's colors by Metal's rule, its alpha and an sRGB form's + colors by a near-equivalent (`extended-range-resolve`). - **Batches of a queue ordered by their ends** (`BatchOrderPolicy::Ends`, the runtime's choice; no pipeline differs). On ANV, RADV and NVIDIA's driver, each measured to start no kernel submission of a `VkQueue` before the one before it completed, each batch of command buffers ends with a @@ -598,6 +601,16 @@ through `StatusBits::MESH_GRID_PAST_LIMITS`, or a fold of more pieces than A direct object grid past the task limits of a device that does not fold is refused naming the limit. +Without the extension, an indirect draw with an object function first dispatches an object +arguments pass (`MeshDispatch::object_arguments`, `bind::mesh_object_arguments_module`, one +invocation over the scan's bindings): it reads Metal's arguments, reserves the object threadgroups' +slots in the command buffer's records pool, and writes the object function's +`VkDispatchIndirectCommand` into the work buffer (`MeshDispatch::OBJECT_DISPATCH_OFFSET`). A grid +Metal's GPU discards sets `StatusBits::MESH_GRID_DISCARDED`; one past the device's compute limits, +or whose threads per grid wrap along an axis (Metal reports the wrapped grid, which the object +dispatch cannot), sets `MESH_GRID_PAST_LIMITS`; slots the rest of the pool cannot hold set +`MESH_RECORDS_OVERFLOW`. Each draws nothing. + ### Tile pipelines `Device::compile_tile_pipeline` compiles a `TileRenderPipelineDescriptor` (the tile function and the @@ -1511,6 +1524,19 @@ fast forms record, and each `PrecisionNote`'s rustdoc states its bound. equal depths is measured at 2 and 4 samples. Cost: the resolve applies the rules Metal's resolve follows at 2 and 4 samples (or the device's average, for a format without them), which no Metal answer confirms at this count. +- `metal2vulkan-degrade-extended-range-resolve` (precision). `ExtendedRangeResolve`: A multisample + resolve of an extended-range color attachment whose resolve Metal averages from values finer than + the codes the attachment holds (`BGRA10_XR`'s alpha, an `_sRGB` twin's color, + `RGB10A2Unorm_sRGB`'s channels): the crate-owned resolve writes a near-equivalent from the codes + where a pixel's samples differ, and Metal's code where they hold one. Measured against Metal's + resolve on the M3 Max under macOS 27.0.1 (4096 texels per format at 2 and 4 samples, each sample + its own value): `BGRA10_XR`'s alpha Metal's in 84% and 88% of texels and within a code in every + one; an `_sRGB` twin's color in 81% and 85% of channels and within a code in 99.5%, at most 7 + codes off where the samples' values nearly cancel; `RGB10A2Unorm_sRGB`'s colors in 83% and 87%, + within 2, and its alpha in 94% and 97%, within one. A linear form's color is Metal's rule, every + texel. Cost: where a pixel's samples differ, a resolved alpha, or an sRGB color, can differ from + Metal's by a code (an sRGB color by a few where the samples' values nearly cancel): Metal averages + values finer than the codes the attachment holds. - `metal2vulkan-degrade-dont-care-store` (precision). `DontCareStore`: An attachment stored with `DontCare` (or the multisampled attachment of `MultisampleResolve`) is Vulkan's `DONT_CARE`, where Apple's GPU keeps the earlier texels unless its tiler overflows. Not a texture over a buffer: Metal @@ -3055,7 +3081,11 @@ each item named states the rule in full. host, holding the batches after it on its queue (and those on other queues that use what the loop uses), and nothing encoded before the loop runs again. A loop without bound runs on, as Metal's does, after the program let go of its queue and device too, until the process ends or - the device is lost. Work inside a loop the runtime records apart (an indirect dispatch or + the device is lost. A loop running again stops, as Metal's does, at the GPU's recovery from a + fault or a hang of another queue's command buffer (primitive type 9; one behind the loop on + its own queue waits for it, a known gap in docs/FAST-PATHS.md): a fault's fails its command + buffer as a victim (`GpuRecoveryVictim`), a hang's ends it with no error, and nothing after the + loop runs. Work inside a loop the runtime records apart (an indirect dispatch or an indirect command buffer's execution a host step records) is recorded again in each such run, after another round trip to the host where its first recording waited for the work before it. A condition word past its buffer reads @@ -3137,6 +3167,14 @@ each item named states the rule in full. where the GPU ran just before (127 of 142), run where it was idle before (the first fault after 3 s idle), and run in part in some shapes (an encoder after an event signal, a command buffer committed right after). The runtime does not model the GPU's idle state. +- **A fault that later failing encoders follow fails with the fault's error, in their time**: it + reads `Scheduled` no sooner than 6.86 ms after the GPU reached the fault, and completes no + sooner than 6.86 ms after that for each later fault, then 27.5 ms for a hang, past which + nothing adds; its queue's command buffers committed meanwhile run nothing where a hang follows + the fault, as during a hang. On an M3 Max (macOS 27.0.1, 88 command buffers) Metal's read + `Scheduled` 14.3 to 21.0 ms after its commit, once the GPU recovered from the fault, and + completed 25.8 to 29.1 ms after that where a hang followed the fault. One that hangs first fails + as the hang alone does (30 of 30), the GPU never reaching the fault. - **A queue's second caused GPU error revokes it, as Metal's does**, and only an event wait held across the revocation is answered unmeasured. Measured on the M3 Max (macOS 27.0.1, about sixty command buffers): page faults and hangs (`CommandBufferError::PageFault`, `GpuHang`) count diff --git a/docs/FAST-PATHS.md b/docs/FAST-PATHS.md index 14f27c166..5720918b9 100644 --- a/docs/FAST-PATHS.md +++ b/docs/FAST-PATHS.md @@ -305,6 +305,12 @@ driver's. Each is open work. then, fails the command buffer as the encoder's draw does (`render/executions.rs`); failing it from inside the host step that meets the record, its earlier encoders run, is not built. +- **A command buffer committed behind a running predicated loop on the loop's own queue waits for + the loop to end**, as every batch of a queue waits for the ones before it, where Metal's GPU + runs it meanwhile: a fault or hang in it ends the loop there on Metal (`recovery.rs`), and in + the runtime it waits, for good behind a loop without bound. A fault or hang on another queue + ends the loop as Metal's does. + - **A no-copy buffer imported by its pointer follows a remap of its pages** on a driver whose pointer imports follow their address (`DriverFact::PointerImportsFollowTheirAddress`: ANV on i915, RADV, lavapipe): pages mapped over the buffer's addresses after it was made (`mmap` with @@ -444,9 +450,11 @@ driver's. Each is open work. `drawIndirectCount` (no committed profile), an indirect draw's object grid past the task stage's limits fails its command buffer (`CommandBufferError::MeshGridPastLimits`, drawing nothing) and a direct one is refused (`Unsupported{MeshShading}` naming the limit). The emulation (MoltenVK, - ANV on the Iris Xe) refuses an indirect draw with an object function - (`NotImplemented(MeshShading)`) and a direct object grid past the compute stage's limits or - whose work buffer passes `maxStorageBufferRange` (`Unsupported{MeshShading}` naming the limit). + ANV on the Iris Xe) refuses a direct object grid past the compute stage's limits or whose work + buffer passes `maxStorageBufferRange` (`Unsupported{MeshShading}` naming the limit), and fails + the command buffer of an indirect one past the compute limits, or whose threads per grid wrap + along an axis (its object dispatch cannot report Metal's wrapped grid), with + `CommandBufferError::MeshGridPastLimits`. - **An object threadgroup that sets a mesh grid Metal launches nothing for keeps its own writes.** On the M3 Max such a threadgroup's device writes (an atomic add before the set) do not land either, while the draw's other threadgroups run; the runtime runs the threadgroup and launches diff --git a/docs/METAL-COVERAGE.md b/docs/METAL-COVERAGE.md index f011fd028..eb1e886c2 100644 --- a/docs/METAL-COVERAGE.md +++ b/docs/METAL-COVERAGE.md @@ -2073,7 +2073,7 @@ Cheap items a plain app calls first, then medium pieces by how often a plain app | `MTLRenderCommandEncoder.setMeshSamplerStates:lodMinClamps:lodMaxClamps:withRange:` | method | implemented | `RenderCommandEncoder::set_mesh_sampler_states` (runtime) | | `MTLRenderCommandEncoder.drawMeshThreadgroups:threadsPerObjectThreadgroup:threadsPerMeshThreadgroup:` | method | implemented | `RenderCommandEncoder::draw_mesh_threadgroups` (runtime) | | `MTLRenderCommandEncoder.drawMeshThreads:threadsPerObjectThreadgroup:threadsPerMeshThreadgroup:` | method | implemented | `RenderCommandEncoder::draw_mesh_threads` (runtime) | -| `MTLRenderCommandEncoder.drawMeshThreadgroupsWithIndirectBuffer:indirectBufferOffset:threadsPerObjectThreadgroup:threadsPerMeshThreadgroup:` | method | implemented | `RenderCommandEncoder::draw_mesh_threadgroups_indirect` (runtime): an object grid of 2^29 threadgroups or more fails the command buffer (`MeshGridPastLimits`, as Metal's GPU fails it), and so does one past the task limits where the device does not fold object grids; refused `NotImplemented(MeshShading)` with an object function where mesh draws are emulated | +| `MTLRenderCommandEncoder.drawMeshThreadgroupsWithIndirectBuffer:indirectBufferOffset:threadsPerObjectThreadgroup:threadsPerMeshThreadgroup:` | method | implemented | `RenderCommandEncoder::draw_mesh_threadgroups_indirect` (runtime): an object grid of more than 2^29 threadgroups draws nothing and fails the command buffer with Metal's error (`GpuRecoveryVictim`, as Metal's GPU discards it); one the device cannot launch fails it with `MeshGridPastLimits`: past the task limits where the device does not fold object grids, or, where mesh draws are emulated, past the compute limits or wrapping its threads per grid along an axis | | `MTLRenderCommandEncoder.drawPrimitives:vertexStart:vertexCount:instanceCount:` | method | implemented | `RenderCommandEncoder::draw_primitives` (runtime) | | `MTLRenderCommandEncoder.drawPrimitives:vertexStart:vertexCount:` | method | implemented | `RenderCommandEncoder::draw_primitives` (runtime) | | `MTLRenderCommandEncoder.drawIndexedPrimitives:indexCount:indexType:indexBuffer:indexBufferOffset:instanceCount:` | method | implemented | `RenderCommandEncoder::draw_indexed_primitives` (runtime) | diff --git a/docs/REFUSALS.md b/docs/REFUSALS.md index 1e4c60cd0..f0a15a654 100644 --- a/docs/REFUSALS.md +++ b/docs/REFUSALS.md @@ -14,14 +14,14 @@ Columns: - `none`: no public API path: malformed or non-Metal input, Apple-private calls, or a cap no valid program of ordinary size meets; - `?`: not assessed yet. -Generated at `ae010017d`. +Generated at `5ad0f9d06`. ## Totals | Kind | Variants | With a site | Reach system | Reach app | Reach rare | Reach none | Unassessed | |---|---|---|---|---|---|---|---| -| Translator and front-end refusals | 125 | 125 | 6 | 33 | 69 | 17 | 0 | -| Runtime gaps | 66 | 66 | 1 | 8 | 43 | 14 | 0 | +| Translator and front-end refusals | 126 | 126 | 6 | 33 | 70 | 17 | 0 | +| Runtime gaps | 67 | 67 | 1 | 8 | 43 | 15 | 0 | | Apple-only calls | 5 | 5 | 0 | 0 | 0 | 5 | 0 | | Binder refusals at a device limit | 9 | 9 | 0 | 1 | 7 | 1 | 0 | | Translation caps | 14 | 14 | 0 | 0 | 7 | 7 | 0 | @@ -65,7 +65,7 @@ Generated at `ae010017d`. | `Int64Atomics` | 64-bit atomics | devices short of a Vulkan feature the site names; devices without buffer device addresses (`addressed_needs`) | 2: `crates/metal2vulkan/src/lower/access/atomic.rs:624`, `crates/metal2vulkan/src/lower/access/atomic.rs:633` | `rare`: 64-bit atomics | | `ImageAtomics` | Image atomics beyond 32-bit integers | devices without a capability the site computes (`gaps`); every device (no Vulkan mechanism) | 3: `crates/metal2vulkan-runtime/src/families/formats.rs:464`, `crates/metal2vulkan-runtime/src/families/formats.rs:468` (+1) | `rare`: texture atomics beyond 32-bit integers | | `DescriptorCount` | Too many descriptors of one kind in a stage or pipeline | devices short of a device limit the site names; devices without VkLimit::MaxUniformBufferRange | 3: `crates/metal2vulkan/src/lower/access/mod.rs:1688`, `crates/metal2vulkan/src/lower/select.rs:1641` (+1) | `app`: many textures or buffers in one stage on a smaller device | -| `BufferRange` | A buffer window beyond the descriptor range limits | devices without a capability the site computes (`needs`); devices without buffer device addresses (`addressed_needs`); every device (no Vulkan mechanism) | 7: `crates/metal2vulkan-runtime/src/function_table.rs:569`, `crates/metal2vulkan/src/bind/graphics.rs:3772` (+5) | `app`: a buffer window past a device's descriptor range | +| `BufferRange` | A buffer window beyond the descriptor range limits | devices without a capability the site computes (`needs`); devices without buffer device addresses (`addressed_needs`); every device (no Vulkan mechanism) | 7: `crates/metal2vulkan-runtime/src/function_table.rs:569`, `crates/metal2vulkan/src/bind/graphics.rs:3842` (+5) | `app`: a buffer window past a device's descriptor range | | `Int64Arithmetic` | 64-bit integer arithmetic | devices without VkFeature::ShaderInt64 | 2: `crates/metal2vulkan/src/lower/arith/legal.rs:582`, `crates/metal2vulkan/src/lower/select.rs:1133` | `rare`: 64-bit integers on a device without shaderInt64 | | `Float64Arithmetic` | 64-bit float arithmetic | devices without VkFeature::ShaderFloat64 | 2: `crates/metal2vulkan/src/device/metal.rs:230`, `crates/metal2vulkan/src/lower/arith/legal.rs:587` | `rare`: doubles (MSL has none outside Apple's own code) | | `Format` | A pixel format not supported for the required use | devices without VkFeature::ShaderStorageImageExtendedFormats; devices without a capability the site computes; devices without a capability the site computes (`alternatives`); devices without a capability the site computes (`c`); devices without a capability the site computes (`missing`); devices without a capability the site computes (`routes`); devices without a format's usage; every device (no Vulkan mechanism); every device (not implemented) | 121: `crates/metal2vulkan-runtime/src/binding_view.rs:146`, `crates/metal2vulkan-runtime/src/blit_plan.rs:523` (+119) | `system`: pixel formats a device lacks for a use (CoreVideo's 4:2:x and 10-bit formats among them) | @@ -84,22 +84,22 @@ Generated at `ae010017d`. | `PixelSamplerCompare` | A constexpr sampler with pixel coordinates and a compare function, which Apple's compiler rejects ("invalid values combination in sampler... | every device (no Vulkan mechanism) | 1: `crates/metal2vulkan/src/lower/sampler/constexpr.rs:115` | `none`: Apple's compiler rejects it | | `TexelBuffer` | Texture buffers beyond the device's texel-buffer limits | devices without a format's usage; every device (no Vulkan mechanism) | 3: `crates/metal2vulkan/src/bind/instantiate.rs:882`, `crates/metal2vulkan/src/bind/instantiate.rs:888` (+1) | `app`: texture buffers past a device's texel-buffer limits | | `RasterOrderGroups` | Raster order groups without fragment shader interlock | devices without VkFeature::FragmentShaderPixelInterlock; devices without VkFeature::FragmentShaderSampleInterlock; devices without a capability the site computes (`alternatives`); every device (not implemented) | 4: `crates/metal2vulkan/src/device/metal.rs:242`, `crates/metal2vulkan/src/lower/fragment/rog.rs:151` (+2) | `rare`: raster order groups | -| `FramebufferFetch` | Framebuffer fetch without an ordered form on the device (rasterization-order attachment access, or the pixel interlock's storage form where the... | devices short of a Vulkan property the site names; devices without VkFeature::FragmentShaderPixelInterlock; devices without VkFeature::RasterizationOrderColorAttachmentAccess; devices without VkFeature::SampleRateShading; devices without a capability the site computes; devices without a capability the site computes (`alternatives`); devices without a capability the site computes (`c`); devices without a capability the site computes (`capability`); devices without a capability the site computes (`missing`); devices without a format's usage; drivers with a defect; every device (not implemented) | 23: `crates/metal2vulkan-runtime/src/families/features.rs:1018`, `crates/metal2vulkan-runtime/src/render.rs:5894` (+21) | `system`: programmable blending (framebuffer fetch); macOS 26.6.2's login reaches it (two WindowServer and RenderBox pipelines fetch RGB10A8_2P_XR10 attachments, the consumer's boots) | +| `FramebufferFetch` | Framebuffer fetch without an ordered form on the device (rasterization-order attachment access, or the pixel interlock's storage form where the... | devices short of a Vulkan property the site names; devices without VkFeature::FragmentShaderPixelInterlock; devices without VkFeature::RasterizationOrderColorAttachmentAccess; devices without VkFeature::SampleRateShading; devices without a capability the site computes; devices without a capability the site computes (`alternatives`); devices without a capability the site computes (`c`); devices without a capability the site computes (`capability`); devices without a capability the site computes (`missing`); devices without a format's usage; drivers with a defect; every device (not implemented) | 23: `crates/metal2vulkan-runtime/src/families/features.rs:1018`, `crates/metal2vulkan-runtime/src/render.rs:5895` (+21) | `system`: programmable blending (framebuffer fetch); macOS 26.6.2's login reaches it (two WindowServer and RenderBox pipelines fetch RGB10A8_2P_XR10 attachments, the consumer's boots) | | `PrimitiveId` | `[[primitive_id]]` in a fragment function | devices without a capability the site computes; every device (not implemented) | 3: `crates/metal2vulkan-runtime/src/families/features.rs:1127`, `crates/metal2vulkan/src/lower/stage_io/plan.rs:3211` (+1) | `rare`: primitive_id on a device without geometry or tessellation shaders, in an indexed draw or behind a mesh function | | `PrivatePrimitives` | One of Metal's private primitive types (a line loop, a triangle fan, quads, a quad strip) drawn in the pulled list form... | - | via a helper: 1: `crates/metal2vulkan/src/lower/stage_io/plan.rs:2601` | `rare`: a private primitive type drawn in the pulled list form (a vertex function that writes memory or the primitive_id varying, a vertex start past 2^31) on a device without device addresses | -| `VertexAmplification` | Vertex amplification | devices without VkFeature::Multiview; devices without VkFeature::MultiviewTessellationShader; devices without VkLimit::MaxMultiviewInstanceIndex; devices without a capability the site computes (`needs`); every device (not implemented) | 5: `crates/metal2vulkan/src/bind/graphics.rs:4113`, `crates/metal2vulkan/src/lower/stage_io/plan.rs:1312` (+3) | `rare`: vertex amplification | -| `LayeredRendering` | Layered rendering (`render_target_array_index`, `viewport_array_index`) | devices without VkFeature::ImageView2DOn3DImage; devices without VkFeature::MultiViewport; devices without VkFeature::ShaderOutputLayer; devices without VkFeature::ShaderOutputViewportIndex; devices without a capability the site computes (`needs`); every device (not implemented) | 7: `crates/metal2vulkan-runtime/src/render_pass.rs:1673`, `crates/metal2vulkan-runtime/src/render_state.rs:1107` (+5) | `rare`: layered rendering on a device without its features | -| `ClipDistance` | Clip or cull distances | devices without VkFeature::ShaderClipDistance; devices without VkLimit::MaxClipDistances | 2: `crates/metal2vulkan/src/lower/mesh/mod.rs:956`, `crates/metal2vulkan/src/lower/mesh/mod.rs:964` | `rare`: clip distances on a device without them | +| `VertexAmplification` | Vertex amplification | devices without VkFeature::Multiview; devices without VkFeature::MultiviewTessellationShader; devices without VkLimit::MaxMultiviewInstanceIndex; devices without a capability the site computes (`needs`); every device (not implemented) | 5: `crates/metal2vulkan/src/bind/graphics.rs:4183`, `crates/metal2vulkan/src/lower/stage_io/plan.rs:1312` (+3) | `rare`: vertex amplification | +| `LayeredRendering` | Layered rendering (`render_target_array_index`, `viewport_array_index`) | devices without VkFeature::ImageView2DOn3DImage; devices without VkFeature::MultiViewport; devices without VkFeature::ShaderOutputLayer; devices without VkFeature::ShaderOutputViewportIndex; devices without a capability the site computes (`needs`); every device (not implemented) | 7: `crates/metal2vulkan-runtime/src/render_pass.rs:1669`, `crates/metal2vulkan-runtime/src/render_state.rs:1107` (+5) | `rare`: layered rendering on a device without its features | +| `ClipDistance` | Clip or cull distances | devices without VkFeature::ShaderClipDistance; devices without VkLimit::MaxClipDistances | 2: `crates/metal2vulkan/src/lower/mesh/mod.rs:958`, `crates/metal2vulkan/src/lower/mesh/mod.rs:966` | `rare`: clip distances on a device without them | | `DualSourceBlending` | Dual-source blending | devices without VkFeature::DualSrcBlend; devices without VkLimit::MaxFragmentDualSrcAttachments | 5: `crates/metal2vulkan-runtime/src/families/formats.rs:386`, `crates/metal2vulkan/src/metal/state.rs:37` (+3) | `rare`: dual-source blending on a device without it | | `Barycentrics` | Barycentric coordinates | devices without VkFeature::FragmentShaderBarycentric; devices without VkFeature::GeometryShader; devices without a capability the site computes (`needs`); drivers with a defect; every device (not implemented) | 5: `crates/metal2vulkan/src/device/metal.rs:263`, `crates/metal2vulkan/src/lower/stage_io/plan.rs:1924` (+3) | `rare`: barycentric coordinates | -| `StencilExport` | Stencil export | devices without VkExtension::ExtShaderStencilExport; every device (not implemented) | 6: `crates/metal2vulkan-runtime/src/families/features.rs:1114`, `crates/metal2vulkan/src/bind/graphics.rs:2719` (+4) | `rare`: stencil from the shader | +| `StencilExport` | Stencil export | devices without VkExtension::ExtShaderStencilExport; every device (not implemented) | 6: `crates/metal2vulkan-runtime/src/families/features.rs:1114`, `crates/metal2vulkan/src/bind/graphics.rs:2751` (+4) | `rare`: stencil from the shader | | `SampleRateShading` | Per-sample shading | devices without VkFeature::SampleRateShading; devices without a capability the site computes (`needs`); every device (not implemented) | 3: `crates/metal2vulkan/src/pipeline/link/graphics.rs:844`, `crates/metal2vulkan/src/pipeline/link/graphics.rs:846` (+1) | `rare`: per-sample shading | | `PixelCoverageAtSampleRate` | The pixel's coverage (`[[sample_mask]]` read) in a fragment function that runs once per sample | drivers with a defect; every device (no Vulkan mechanism); every device (not implemented) | 3: `crates/metal2vulkan/src/lower/fragment/coverage.rs:296`, `crates/metal2vulkan/src/lower/simd/mod.rs:754` (+1) | `rare`: coverage read at sample rate | | `InterfaceComponents` | Too many interface components or locations | devices short of a device limit the site names; devices without VkLimit::MaxColorAttachments; devices without VkLimit::MaxVertexInputAttributes | 4: `crates/metal2vulkan/src/pipeline/compile/color_group.rs:202`, `crates/metal2vulkan/src/pipeline/link/graphics.rs:301` (+2) | `rare`: too many varyings or attachments for a device | | `UnmatchedVarying` | A fragment input without a vertex producer (a Metal link error) | every device (no Vulkan mechanism) | 3: `crates/metal2vulkan/src/pipeline/link/varyings.rs:318`, `crates/metal2vulkan/src/pipeline/link/varyings.rs:537` (+1) | `none`: a Metal link error | | `KernelStageIn` | Kernel `[[stage_in]]` | every device (not implemented) | 3: `crates/metal2vulkan-runtime/src/indirect_execute.rs:376`, `crates/metal2vulkan/src/bind/dispatch.rs:871` (+1) | `rare`: kernel stage-in combinations Metal leaves unestablished | | `Tessellation` | Tessellation | devices without VkLimit::MaxPushConstantsSize; devices without VkLimit::MaxStorageBufferRange; devices without VkLimit::MaxTessellationGenerationLevel; every device (not implemented) | 13: `crates/metal2vulkan-air/src/canon/mod.rs:1256`, `crates/metal2vulkan-air/src/canon/mod.rs:1347` (+11) | `rare`: tessellation | -| `MeshShading` | | devices short of a device limit the site names; devices without VkLimit::MaxMeshOutputLayers; devices without VkLimit::MaxTaskPayloadSize; devices without a capability the site computes (`missing`); every device (not implemented) | 7: `crates/metal2vulkan/src/bind/graphics.rs:1630`, `crates/metal2vulkan/src/bind/graphics.rs:3095` (+5) | `rare`: mesh pipelines | +| `MeshShading` | | devices short of a device limit the site names; devices without VkLimit::MaxMeshOutputLayers; devices without VkLimit::MaxTaskPayloadSize; devices without a capability the site computes (`missing`); every device (not implemented) | 7: `crates/metal2vulkan/src/bind/graphics.rs:1662`, `crates/metal2vulkan/src/bind/graphics.rs:3130` (+5) | `rare`: mesh pipelines | | `TileShading` | | devices without VkLimit::MaxStorageBufferRange; devices without a format's usage; every device (not implemented) | 5: `crates/metal2vulkan-runtime/src/render/tile_dispatch.rs:520`, `crates/metal2vulkan/src/bind/plan/compute.rs:237` (+3) | `rare`: tile shaders (Apple GPU families) | | `Imageblocks` | An imageblock outside the forms implemented | devices without VkFeature::SampleRateShading; devices without a capability the site computes (`missing`); drivers with a defect; every device (not implemented) | 10: `crates/metal2vulkan/src/lower/access/imageblock.rs:98`, `crates/metal2vulkan/src/lower/access/mod.rs:908` (+8) | `rare`: imageblocks (Apple GPU families) | | `RayTracing` | | devices without a capability the site computes (`missing`); every device (no Vulkan mechanism); every device (not implemented) | 12: `crates/metal2vulkan/src/bind/acceleration.rs:202`, `crates/metal2vulkan/src/bind/acceleration.rs:216` (+10) | `rare`: ray tracing (out of scope by ruling) | @@ -122,7 +122,7 @@ Generated at `ae010017d`. | `SamplerBicubicFilter` | A use of Metal's bicubic filter that no Metal reading establishes | every device (not implemented) | 5: `crates/metal2vulkan/src/bind/heap.rs:997`, `crates/metal2vulkan/src/bind/plan/resources.rs:1876` (+3) | `system`: bicubic filtering forms Metal does not establish; macOS 26.6.2 makes a runtime sampler with MTLSamplerMinMagFilterCubic (the consumer's boots), whose mip-filtered form is refused | | `GroupCount` | A dispatch whose threadgroup count on `axis` exceeds `maxComputeWorkGroupCount` by more than the binder splits into regions (`None` | every device (no Vulkan mechanism) | 5: `crates/metal2vulkan/src/bind/dispatch.rs:379`, `crates/metal2vulkan/src/bind/dispatch.rs:455` (+3) | `rare`: more threadgroups than a device dispatches, past the binder's split | | `IntersectionFunctionTable` | A ray intersection through intersection functions | every device (no Vulkan mechanism); every device (not implemented) | 9: `crates/metal2vulkan/src/bind/acceleration.rs:177`, `crates/metal2vulkan/src/bind/acceleration.rs:183` (+7) | `rare`: ray tracing (out of scope by ruling) | -| `IndependentBlending` | Color attachments whose write masks or blend states differ, as Metal sets them per attachment, on a device without `independentBlend`, where no... | devices without VkFeature::IndependentBlend | 2: `crates/metal2vulkan-runtime/src/render.rs:2173`, `crates/metal2vulkan/src/pipeline/link/graphics.rs:1017` | `rare`: per-attachment blending on a device without independentBlend | +| `IndependentBlending` | Color attachments whose write masks or blend states differ, as Metal sets them per attachment, on a device without `independentBlend`, where no... | devices without VkFeature::IndependentBlend | 2: `crates/metal2vulkan-runtime/src/render.rs:2174`, `crates/metal2vulkan/src/pipeline/link/graphics.rs:1017` | `rare`: per-attachment blending on a device without independentBlend | | `RasterSampleCount` | A `rasterSampleCount` outside the device's framebuffer sample counts for the pipeline's attachments (`framebuffer*SampleCounts`), and, for a color... | devices short of a Vulkan property the site names; devices without a capability the site computes | 2: `crates/metal2vulkan-runtime/src/families/limits.rs:1063`, `crates/metal2vulkan/src/pipeline/graphics.rs:563` | `app`: a sample count a device lacks for the attachments | | `TriangleFillLines` | The render encoder's `MTLTriangleFillModeLines` (`polygonMode` `LINE`) on a device without `fillModeNonSolid` | - | via a helper: 1: `crates/metal2vulkan/src/metal/state.rs:347` | `app`: wireframe on a device without fillModeNonSolid | | `DepthClipClamp` | The render encoder's `MTLDepthClipModeClamp` (`depthClampEnable`) on a device without `depthClamp` | - | via a helper: 1: `crates/metal2vulkan/src/metal/state.rs:363` | `app`: depth clamp on a device without depthClamp | @@ -131,11 +131,11 @@ Generated at `ae010017d`. | `SparseTexture` | A sparse texture (`MTLTexture.isSparse`) bound at `slot`, where a function observes the residency of its accesses (`sparse_color::resident()`) and... | - | via a helper: 2: `crates/metal2vulkan/src/bind/plan/slots.rs:583`, `crates/metal2vulkan/src/bind/plan/slots.rs:607` | `rare`: sparse residency reads | | `TextureSize` | A texture whose extent, array layers, or level count is past what the device takes for its format, type, and usage (`Capability::Limit` names the... | devices short of a device limit the site names | 1: `crates/metal2vulkan-runtime/src/image_plan.rs:1196` | `app`: a texture past a device's image limits | | `TextureSampleCount` | A texture sample count the device does not take for its format, type, and usage | devices short of a Vulkan property the site names; devices without VkFeature::MultisampleArrayImage; every device (no Vulkan mechanism) | 3: `crates/metal2vulkan-runtime/src/image_plan.rs:1244`, `crates/metal2vulkan-runtime/src/image_plan.rs:598` (+1) | `app`: a sample count a device lacks for the texture | -| `TextureView` | A texture view Vulkan cannot make exactly on this image | every device (no Vulkan mechanism); every device (not implemented) | 7: `crates/metal2vulkan-runtime/src/binding_view.rs:156`, `crates/metal2vulkan-runtime/src/texture.rs:5180` (+5) | `app`: a texture view Vulkan cannot make exactly | -| `TextureSwizzle` | A texture swizzle whose Metal behavior is not measured | devices short of a Vulkan feature the site names; every device (not implemented) | 7: `crates/metal2vulkan-runtime/src/binding_view.rs:167`, `crates/metal2vulkan-runtime/src/texture.rs:998` (+5) | `app`: texture swizzles whose Metal behaviour is unmeasured | -| `MipmapGeneration` | `generateMipmapsForTexture:` where the device's filter is not shown to give Metal's answer | devices without VkFeature::ShaderInt64; devices without a format's usage; every device (not implemented) | 7: `crates/metal2vulkan-runtime/src/blit_texture.rs:1890`, `crates/metal2vulkan-runtime/src/mipmap_pick.rs:37` (+5) | `app`: generateMipmapsForTexture: where the device's filter is not Metal's | +| `TextureView` | A texture view Vulkan cannot make exactly on this image | every device (no Vulkan mechanism); every device (not implemented) | 7: `crates/metal2vulkan-runtime/src/binding_view.rs:156`, `crates/metal2vulkan-runtime/src/texture.rs:5136` (+5) | `app`: a texture view Vulkan cannot make exactly | +| `TextureSwizzle` | A texture swizzle whose Metal behavior is not measured | devices short of a Vulkan feature the site names; every device (not implemented) | 7: `crates/metal2vulkan-runtime/src/binding_view.rs:167`, `crates/metal2vulkan-runtime/src/texture.rs:996` (+5) | `app`: texture swizzles whose Metal behaviour is unmeasured | +| `MipmapGeneration` | `generateMipmapsForTexture:` where the device's filter is not shown to give Metal's answer | devices without VkFeature::ShaderInt64; devices without a format's usage; every device (not implemented) | 7: `crates/metal2vulkan-runtime/src/blit_texture.rs:1818`, `crates/metal2vulkan-runtime/src/mipmap_pick.rs:37` (+5) | `app`: generateMipmapsForTexture: where the device's filter is not Metal's | | `HostMemory` | A buffer over the caller's host memory without a copy (`newBufferWithBytesNoCopy:`) | devices without VkExtension::ExtExternalMemoryHost; every device (no Vulkan mechanism); every device (not implemented) | 5: `crates/metal2vulkan-runtime/src/host_memory.rs:430`, `crates/metal2vulkan-runtime/src/host_memory.rs:470` (+3) | `system`: newBufferWithBytesNoCopy: where the device cannot import the memory | -| `GpuTimes` | A command buffer's GPU times (`GPUStartTime`, `GPUEndTime`) on a device whose queue family writes no timestamps (`timestampValidBits` 0) | every device (no Vulkan mechanism) | 1: `crates/metal2vulkan-runtime/src/command_buffer/mod.rs:2854` | `rare`: GPU times on a queue without timestamps | +| `GpuTimes` | A command buffer's GPU times (`GPUStartTime`, `GPUEndTime`) on a device whose queue family writes no timestamps (`timestampValidBits` 0) | every device (no Vulkan mechanism) | 1: `crates/metal2vulkan-runtime/src/command_buffer/mod.rs:2793` | `rare`: GPU times on a queue without timestamps | | `CountingVisibility` | A `Counting` visibility result (`MTLVisibilityResultModeCounting`) on a device without `occlusionQueryPrecise` | devices without VkFeature::OcclusionQueryPrecise | 1: `crates/metal2vulkan-runtime/src/visibility.rs:452` | `rare`: counting occlusion queries on a device without precise queries | | `ViewFormatReinterpretation` | A texture view whose format has other components, or components of other widths, than its texture's (`RGBA8Unorm` as `R32Uint`), on a device whose... | every device (no Vulkan mechanism) | 1: `crates/metal2vulkan-runtime/src/view_plan.rs:570` | `app`: a view of another component layout on a portability subset (MoltenVK) | | `SeparateMultisampledDepthStencil` | A render pass whose depth and stencil attachments are separate multisampled textures that it loads or may store, on a device without maintenance8,... | - | via a helper: 7: `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:188`, `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:294` (+5) | `rare`: separate multisampled depth and stencil textures | @@ -143,16 +143,17 @@ Generated at `ae010017d`. | `CentroidVarying` | A centroid varying (`[[centroid_perspective]]`, `[[centroid_no_perspective]]`) in a fragment function of a pipeline of more than one sample | drivers with a defect | 1: `crates/metal2vulkan/src/pipeline/link/graphics.rs:801` | `rare`: centroid varyings in a multisampled pipeline | | `PrivateMemory` | A stage whose private memory (its `thread` variables and arrays, and the constants it holds per thread) takes more Function storage a thread than... | - | via a helper: 1: `crates/metal2vulkan/src/lower/select.rs:1171` | `rare`: very large per-thread arrays | | `SparseTextures` | A sparse heap (`MTLHeapTypeSparse`), or a texture made from one, on a device without what a sparse resident image of it needs, which `missing` names | every device (no Vulkan mechanism) | 1: `crates/metal2vulkan-runtime/src/sparse/texture.rs:32` | `rare`: sparse heaps on a device without sparse images | +| `SparseMapping` | A sparse texture's mapping update (`updateTextureMapping:` and its array form, or a move of mappings) that covers part of one of the device's... | every device (no Vulkan mechanism) | 1: `crates/metal2vulkan-runtime/src/sparse/encoder.rs:469` | `rare`: sparse mappings off the device's blocks | | `TimelineSemaphores` | Command buffers and events, which the runtime completes and signals through timeline semaphores (core in Vulkan 1.2), on a device whose... | every device (no Vulkan mechanism) | 1: `crates/metal2vulkan-runtime/src/device/create.rs:1115` | `none`: a device below the runtime's floor | | `Reflection` | Reflection of an argument whose answer Metal's has not been measured for (`reflection`) | every device (not implemented) | 9: `crates/metal2vulkan/src/bind/argument_buffer.rs:626`, `crates/metal2vulkan/src/reflection/derive.rs:178` (+7) | `rare`: reflection of argument kinds Metal's answer is unmeasured for | -| `HeapTextureTiling` | A texture of a heap whose memory the device's optimal images do not take (a `Shared` heap on a device whose optimal images take no host-visible... | every device (no Vulkan mechanism) | 1: `crates/metal2vulkan-runtime/src/texture/heap.rs:630` | `app`: textures in Shared heaps on a device whose optimal images take no host memory | +| `HeapTextureTiling` | A texture of a heap whose memory the device's optimal images do not take (a `Shared` heap on a device whose optimal images take no host-visible... | every device (no Vulkan mechanism) | 1: `crates/metal2vulkan-runtime/src/texture/heap.rs:628` | `app`: textures in Shared heaps on a device whose optimal images take no host memory | | `ViewportDepthRange` | A viewport depth range past `[0, 1]` (`setViewport:`), which Metal takes and the runtime draws natively (`VK_EXT_depth_range_unrestricted`) or... | drivers with a defect | 1: `crates/metal2vulkan-runtime/src/render_state.rs:1216` | `rare`: viewport depth outside [0, 1] | | `UndeclaredTextureUsage` | A shader write to a texture made without `ShaderWrite` (or `ShaderAtomic`), or a read of one made without `ShaderRead`, which plain Metal runs,... | every device (not implemented) | 2: `crates/metal2vulkan-runtime/src/binding_view.rs:141`, `crates/metal2vulkan-runtime/src/texture/usage_shadow.rs:72` | `app`: a shader write to a texture made without ShaderWrite, which plain Metal runs | -| `RenderTargetSize` | A render pass whose render area or layers are past the device's framebuffer limits (`Capability::Limit` names `MaxFramebufferWidth`,... | devices short of a device limit the site names | 1: `crates/metal2vulkan-runtime/src/render_pass.rs:1275` | `rare`: a render area past a device's framebuffer limits | +| `RenderTargetSize` | A render pass whose render area or layers are past the device's framebuffer limits (`Capability::Limit` names `MaxFramebufferWidth`,... | devices short of a device limit the site names | 1: `crates/metal2vulkan-runtime/src/render_pass.rs:1271` | `rare`: a render area past a device's framebuffer limits | | `IndirectRenderState` | A render state a function sets on an indirect render command (`render_command::set_cull_mode`, `set_front_facing_winding`,... | every device (not implemented) | 1: `crates/metal2vulkan/src/lower/access/encode.rs:568` | `rare`: render state set by a kernel on an indirect command | | `GlobalBuiltinInFragment` | A fragment function's read of a Metal 3.1 program-scope built-in variable that Metal does not lower there | every device (not implemented) | 1: `crates/metal2vulkan/src/lower/select.rs:912` | `rare`: Metal 3.1 global built-ins in fragment functions | | `PrivateRenderState` | A private fixed-function property of Metal's pipeline descriptor (Apple SPI, OpenGL on Metal's) set to a value whose effect the translation has... | devices without VkFeature::LogicOp; every device (not implemented) | 7: `crates/metal2vulkan/src/bind/heap.rs:1300`, `crates/metal2vulkan/src/bind/plan/resources.rs:887` (+5) | `none`: Apple-private pipeline fields of OpenGL on Metal (no public header) | -| `ExtendedRangeBlend` | Metal's blend into an extended-range attachment (`BGRA10_XR`, `BGR10_XR`, `RGB10A8_2P_XR10` and their `_sRGB` twins), which the function computes... | every device (not implemented) | 6: `crates/metal2vulkan/src/lower/arith/extended_range/blend.rs:305`, `crates/metal2vulkan/src/lower/fragment/fetch.rs:1578` (+4) | `system`: the parts of a blend into an extended-range (XR10) attachment the measured model does not hold (second-source factors, the color blend color difference, a one-color-channel mask, float4 and sRGB outside the measured forms); the consumer's guests blend RGB10A8_2P_XR10 attachments | +| `ExtendedRangeBlend` | Metal's blend into an extended-range attachment (`BGRA10_XR`, `BGR10_XR`, `RGB10A8_2P_XR10` and their `_sRGB` twins), which the function computes... | every device (not implemented) | 4: `crates/metal2vulkan/src/lower/arith/extended_range/blend.rs:305`, `crates/metal2vulkan/src/lower/fragment/fetch.rs:1629` (+2) | `system`: the parts of a blend into an extended-range (XR10) attachment the measured model does not hold (second-source factors, the color blend color difference, a one-color-channel mask, float4 and sRGB outside the measured forms); the consumer's guests blend RGB10A8_2P_XR10 attachments | | `TileReach` | The tiles a render pass's primitives reach, binned on the device ([`tile_reach_module`](crate::bind::tile_reach_module)), on a device without what... | devices short of a Vulkan feature the site names; devices without a capability the site computes (`vec![int64]`); every device (not implemented) | 3: `crates/metal2vulkan/src/bind/tile_reach.rs:270`, `crates/metal2vulkan/src/lower/stage_io/plan.rs:2517` (+1) | `app`: the tiles a pass's draws reach, binned on a device without shaderInt64 | | `ProgramScopeBinding` | A program-scope buffer binding of MSL 3.2 (macOS 15 and later), `constant T* constant p [[buffer(n)]];` in Apple's `!air.global_bindings` list,... | - | via a helper: 2: `crates/metal2vulkan-air/src/abi/module.rs:77`, `crates/metal2vulkan/src/error/mod.rs:267` | `app`: MSL 3.2 program-scope buffer bindings (macOS 15 and later) | | `SeqCstFence` | A sequentially consistent fence (`seq_cst` `atomic_thread_fence`, an LLVM `fence seq_cst`, or a `seq_cst` barrier ordering device memory), whose... | devices short of a Vulkan feature the site names | 1: `crates/metal2vulkan/src/lower/sync/barrier.rs:443` | `rare`: a seq_cst fence in a vertex or fragment stage without its stores and atomics | @@ -164,15 +165,15 @@ Generated at `ae010017d`. |---|---|---|---|---| | `Textures` | Textures and texture buffers | every device (runtime piece not built) | 9: `crates/metal2vulkan-runtime/src/blit_texture.rs:163`, `crates/metal2vulkan-runtime/src/buffer_texture.rs:1563` (+7) | `rare`: texture forms the runtime has not built (texture buffers of some forms, X24Stencil8 views) | | `ResourceHeap` | The resource-ID heap, descriptor set 1 | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/binding.rs:1982` | `rare`: the resource-ID heap's remaining forms | -| `SparseHeaps` | Sparse heaps and their textures | every device (runtime piece not built) | 3: `crates/metal2vulkan-runtime/src/sparse/encoder.rs:440`, `crates/metal2vulkan-runtime/src/texture.rs:1684` (+1) | `rare`: sparse heaps | -| `SparseTileMaps` | What the runtime's emulation of sparse textures does not build yet | every device (runtime piece not built) | 4: `crates/metal2vulkan-runtime/src/binding.rs:562`, `crates/metal2vulkan-runtime/src/sparse/texture.rs:30` (+2) | `rare`: sparse texture emulation's unbuilt pieces | +| `SparseHeaps` | Sparse heaps and their textures | every device (runtime piece not built) | 3: `crates/metal2vulkan-runtime/src/sparse/encoder.rs:461`, `crates/metal2vulkan-runtime/src/texture.rs:1674` (+1) | `rare`: sparse heaps | +| `SparseTileMaps` | What the runtime's emulation of sparse textures does not build yet | every device (runtime piece not built) | 3: `crates/metal2vulkan-runtime/src/binding.rs:562`, `crates/metal2vulkan-runtime/src/sparse/texture.rs:30` (+1) | `rare`: sparse texture emulation's unbuilt pieces | | `HeapPastMaxBufferSize` | A heap larger than the device's `maxBufferSize`, which the device can allocate | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/heap.rs:714` | `rare`: a heap past maxBufferSize | -| `HeapTextureAlignment` | A heap texture whose image needs an alignment past the heap memory's base alignment (256 KiB) | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/texture/heap.rs:1071` | `rare`: a heap texture needing more than 256 KiB alignment | -| `HeapTextureMemory` | A heap texture whose image the heap's memory type does not take | every device (runtime piece not built) | 5: `crates/metal2vulkan-runtime/src/texture/heap.rs:1510`, `crates/metal2vulkan-runtime/src/texture/heap.rs:1517` (+3) | `app`: a heap texture the heap's memory type does not take | +| `HeapTextureAlignment` | A heap texture whose image needs an alignment past the heap memory's base alignment (256 KiB) | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/texture/heap.rs:1069` | `rare`: a heap texture needing more than 256 KiB alignment | +| `HeapTextureMemory` | A heap texture whose image the heap's memory type does not take | every device (runtime piece not built) | 5: `crates/metal2vulkan-runtime/src/texture/heap.rs:1508`, `crates/metal2vulkan-runtime/src/texture/heap.rs:1515` (+3) | `app`: a heap texture the heap's memory type does not take | | `FunctionTablePastMaxBufferLength` | A visible-function table of more entries than one buffer of the device's `max_buffer_length` holds words for, or than its size word holds | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/function_table.rs:622` | `none`: a function table past one buffer | -| `IndirectCommandBufferPastMaxBufferLength` | An indirect command buffer of more commands than one buffer of the device's `max_buffer_length` holds the records of | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs:523` | `none`: an ICB past one buffer | -| `IndirectRenderCommands` | What indirect command buffers lack of their render commands | every device (runtime piece not built) | 15: `crates/metal2vulkan-runtime/src/compute.rs:1291`, `crates/metal2vulkan-runtime/src/compute.rs:1376` (+13) | `rare`: indirect render commands' remaining pieces | -| `IndirectImageblockSize` | An indirect compute command's imageblock side past 65535, which Metal keeps | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs:3397` | `none`: an imageblock side past 65535 | +| `IndirectCommandBufferPastMaxBufferLength` | An indirect command buffer of more commands than one buffer of the device's `max_buffer_length` holds the records of | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs:522` | `none`: an ICB past one buffer | +| `IndirectRenderCommands` | What indirect command buffers lack of their render commands | every device (runtime piece not built) | 16: `crates/metal2vulkan-runtime/src/compute.rs:1144`, `crates/metal2vulkan-runtime/src/compute.rs:1225` (+14) | `rare`: indirect render commands' remaining pieces | +| `IndirectImageblockSize` | An indirect compute command's imageblock side past 65535, which Metal keeps | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs:3363` | `none`: an imageblock side past 65535 | | `CommandReplay` | The device replay of indirect command buffers | every device (runtime piece not built) | 2: `crates/metal2vulkan-runtime/src/binding.rs:723`, `crates/metal2vulkan-runtime/src/binding.rs:726` | `rare`: the device replay of indirect command buffers | | `RenderAttachments` | Render attachments and their binding forms | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/binding.rs:1794` | `rare`: render attachment forms not built | | `AccelerationStructures` | Acceleration structures | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/binding.rs:1797` | `rare`: ray tracing (out of scope by ruling) | @@ -181,17 +182,17 @@ Generated at `ae010017d`. | `Render` | Render pipelines, passes and draws | every device (runtime piece not built) | 23: `crates/metal2vulkan-runtime/src/attachment_stand_in.rs:404`, `crates/metal2vulkan-runtime/src/attachment_stand_in.rs:460` (+21) | `system`: render pass, resolve and attachment forms not built (20 sites: see the appendix) | | `TexelsPastBufferLength` | A 2D array over a buffer whose texels run past the buffer's length, which Metal makes over bytes its buffer's allocation has past the length | every device (runtime piece not built) | 2: `crates/metal2vulkan-runtime/src/buffer_texture.rs:261`, `crates/metal2vulkan-runtime/src/texture/surface_depth.rs:105` | `rare`: a 2D array over a buffer past its length | | `OverlappingSurfaceRows` | A texture of an IOSurface plane (`Buffer::new_texture_with_iosurface_plane`, the stand-in for `newTextureWithDescriptor:iosurface:plane:`) whose... | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/buffer_texture.rs:263` | `rare`: an IOSurface plane whose rows overlap | -| `SamplePositionsAtBegin` | A render pass whose custom sample positions Vulkan takes only through what the runtime does not build | every device (runtime piece not built) | 3: `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:145`, `crates/metal2vulkan-runtime/src/render_pass.rs:1865` (+1) | `rare`: custom sample positions Vulkan takes only at begin | +| `SamplePositionsAtBegin` | A render pass whose custom sample positions Vulkan takes only through what the runtime does not build | every device (runtime piece not built) | 3: `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:145`, `crates/metal2vulkan-runtime/src/render_pass.rs:1861` (+1) | `rare`: custom sample positions Vulkan takes only at begin | | `SharedEventAcrossDevices` | A shared event handle opened on a device other than its event's | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/event.rs:385` | `rare`: a shared event opened on another device | | `ViewportDepthRange` | A viewport depth range past `[0, 1]`, which Metal takes, on a device without the features to take it natively or by the vertex stage's... | every device (runtime piece not built) | 7: `crates/metal2vulkan-runtime/src/render/draw_shape.rs:341`, `crates/metal2vulkan-runtime/src/render_state.rs:1039` (+5) | `rare`: viewport depth outside [0, 1] without the device features | | `NonFiniteDepthBias` | NaN or infinite depth bias factors whose effect differs between flat and sloped triangles, or a draw whose bias adds a clamp that moves a... | every device (runtime piece not built) | 5: `crates/metal2vulkan-runtime/src/render_state.rs:1603`, `crates/metal2vulkan-runtime/src/render_state.rs:1606` (+3) | `rare`: NaN or infinite depth bias | | `DepthNeverWithoutAttachment` | A draw under a depth compare of `Never` in a pass without a depth attachment, which fails every fragment, whose fragment function writes color... | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/depth_stencil.rs:147` | `rare`: depth compare Never with no depth attachment | -| `HiddenDepthStencil` | A draw whose depth/stencil state uses depth or the stencil that the pass lacks, which plain Metal tests against a hidden `float` depth of 1.0 and... | every device (runtime piece not built) | 2: `crates/metal2vulkan-runtime/src/attachment_stand_in.rs:563`, `crates/metal2vulkan-runtime/src/render.rs:6617` | `app`: a depth-stencil state using depth or stencil the pass lacks | -| `IndirectDrawArguments` | An indirect draw whose arguments the binding plan asks to read on the CPU (`DrawCommands::indirect_needs_arguments`) | every device (runtime piece not built) | 5: `crates/metal2vulkan-runtime/src/index_bounds.rs:91`, `crates/metal2vulkan-runtime/src/render.rs:3302` (+3) | `rare`: indirect draws whose arguments the CPU must read | +| `HiddenDepthStencil` | A draw whose depth/stencil state uses depth or the stencil that the pass lacks, which plain Metal tests against a hidden `float` depth of 1.0 and... | every device (runtime piece not built) | 2: `crates/metal2vulkan-runtime/src/attachment_stand_in.rs:563`, `crates/metal2vulkan-runtime/src/render.rs:6618` | `app`: a depth-stencil state using depth or stencil the pass lacks | +| `IndirectDrawArguments` | An indirect draw whose arguments the binding plan asks to read on the CPU (`DrawCommands::indirect_needs_arguments`) | every device (runtime piece not built) | 5: `crates/metal2vulkan-runtime/src/index_bounds.rs:91`, `crates/metal2vulkan-runtime/src/render.rs:3303` (+3) | `rare`: indirect draws whose arguments the CPU must read | | `DepthStencilResolve` | A depth/stencil resolve no Vulkan resolve mode of the device states | every device (runtime piece not built) | 7: `crates/metal2vulkan-runtime/src/depth_stencil_resolve.rs:441`, `crates/metal2vulkan-runtime/src/resolve.rs:1388` (+5) | `rare`: depth/stencil resolve modes a device lacks | -| `TileAtSampleCount` | The tile memory of a render pass of a sample count Apple's GPUs lack (theirs are 1, 2 and 4), which a Vulkan device may have | every device (runtime piece not built) | 2: `crates/metal2vulkan-runtime/src/render_pass.rs:1615`, `crates/metal2vulkan-runtime/src/render_pass.rs:937` | `none`: tile memory at a sample count Apple's GPUs lack | -| `ImageblockMasters` | A draw or tile dispatch whose imageblock is of another size than the pass's, or a draw whose fragment function's layouts are of another alignment... | every device (runtime piece not built) | 2: `crates/metal2vulkan-runtime/src/render.rs:7350`, `crates/metal2vulkan-runtime/src/render/tile_dispatch.rs:929` | `rare`: imageblocks of mixed sizes in one pass | -| `TileAndFragmentImageblocks` | A render pass that reaches its imageblock storage, from a draw whose fragment function declares an explicit imageblock or a tile dispatch whose... | every device (runtime piece not built) | 3: `crates/metal2vulkan-runtime/src/render.rs:7342`, `crates/metal2vulkan-runtime/src/render/tile_dispatch.rs:796` (+1) | `rare`: explicit imageblocks shared by tile and fragment functions | +| `TileAtSampleCount` | The tile memory of a render pass of a sample count Apple's GPUs lack (theirs are 1, 2 and 4), which a Vulkan device may have | every device (runtime piece not built) | 2: `crates/metal2vulkan-runtime/src/render_pass.rs:1611`, `crates/metal2vulkan-runtime/src/render_pass.rs:937` | `none`: tile memory at a sample count Apple's GPUs lack | +| `ImageblockMasters` | A draw or tile dispatch whose imageblock is of another size than the pass's, or a draw whose fragment function's layouts are of another alignment... | every device (runtime piece not built) | 2: `crates/metal2vulkan-runtime/src/render.rs:7351`, `crates/metal2vulkan-runtime/src/render/tile_dispatch.rs:929` | `rare`: imageblocks of mixed sizes in one pass | +| `TileAndFragmentImageblocks` | A render pass that reaches its imageblock storage, from a draw whose fragment function declares an explicit imageblock or a tile dispatch whose... | every device (runtime piece not built) | 3: `crates/metal2vulkan-runtime/src/render.rs:7343`, `crates/metal2vulkan-runtime/src/render/tile_dispatch.rs:796` (+1) | `rare`: explicit imageblocks shared by tile and fragment functions | | `Metal4Api` | Metal 4's API (`MTL4CommandQueue`, `MTL4CommandBuffer`, `MTL4ArgumentTable`, `MTL4Compiler` and the rest), with the features only its programming... (not scheduled) | every device (runtime piece not built) | family audit only: 3: `crates/metal2vulkan-runtime/src/families/features.rs:1487`, `crates/metal2vulkan-runtime/src/families/limits.rs:1026` (+1) | `app`: Metal 4 (the API is missing: METAL-COVERAGE.md) | | `CounterSampleBuffers` | Counter sample buffers (`MTLCounterSampleBuffer`) and the commands that sample into them (not scheduled) | every device (runtime piece not built) | family audit only: 1: `crates/metal2vulkan-runtime/src/families/limits.rs:1017` | `app`: GPU counters and timestamps by sample buffer (missing API) | | `ResidencySets` | Residency sets (`MTLResidencySet`) (not scheduled) | every device (runtime piece not built) | family audit only: 2: `crates/metal2vulkan-runtime/src/families/features.rs:1469`, `crates/metal2vulkan-runtime/src/families/limits.rs:1019` | `app`: residency sets (missing API) | @@ -206,37 +207,38 @@ Generated at `ae010017d`. | `RateMapRegions` | A draw in a rate-mapped pass that the region path does not draw, for the compile layer's reason (`rate_mapped_pass.rs`) | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/rate_mapped_pass.rs:349` | `rare`: draws in rate-mapped passes the region path does not draw | | `LayeredPass` | A layered render pass (`renderTargetArrayLength` 2 or more) that needs a step of one layer | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/color_resolve.rs:890` | `rare`: layered passes needing a per-layer color resolve | | `FunctionOptions` | A function descriptor's options beyond `CompileToBinary` and `StoreFunctionInMetalPipelinesScript` (`Library::new_function_with_descriptor`) | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/library.rs:215` | `rare`: function descriptor options beyond CompileToBinary | -| `OverlappingTextureCopies` | A blit copy between overlapping regions of one texture's texels (`copyFromTexture:...` with the source's region meeting the destination's, through... (not scheduled) | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/blit_texture.rs:1340` | `rare`: overlapping texture copies (Metal races) | -| `RebindTextures` | `Buffer::rebind_bytes_no_copy` of a no-copy buffer with a live texture over its bytes, given memory at another offset in its page than the old | every device (runtime piece not built) | 5: `crates/metal2vulkan-runtime/src/buffer_descriptor.rs:637`, `crates/metal2vulkan-runtime/src/texture/heap.rs:2739` (+3) | `none`: a runtime extension's rebind with a live texture | -| `PvrtcBlockOrder` | A PVRTC texture's blocks in a Metal block order the runtime does not lay out | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/texture.rs:5819` | `rare`: PVRTC regions off whole levels | -| `DecodedHeapTexture` | A heap's or a sparse heap's texture of an ASTC format on a device without that ASTC format (`astc.rs`), or a sparse heap's texture of an ETC2 or... | every device (runtime piece not built) | 2: `crates/metal2vulkan-runtime/src/texture.rs:1692`, `crates/metal2vulkan-runtime/src/texture/heap.rs:1373` | `app`: an ASTC texture in a heap on a device without ASTC | +| `OverlappingTextureCopies` | A blit copy between overlapping regions of one texture's texels (`copyFromTexture:...` with the source's region meeting the destination's, through... (not scheduled) | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/blit_texture.rs:1273` | `rare`: overlapping texture copies (Metal races) | +| `RebindTextures` | `Buffer::rebind_bytes_no_copy` of a no-copy buffer with a live texture over its bytes, given memory at another offset in its page than the old | every device (runtime piece not built) | 5: `crates/metal2vulkan-runtime/src/buffer_descriptor.rs:637`, `crates/metal2vulkan-runtime/src/texture/heap.rs:2724` (+3) | `none`: a runtime extension's rebind with a live texture | +| `PvrtcBlockOrder` | A PVRTC texture's blocks in a Metal block order the runtime does not lay out | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/texture.rs:5761` | `rare`: PVRTC regions off whole levels | +| `DecodedHeapTexture` | A heap's or a sparse heap's texture of an ASTC format on a device without that ASTC format (`astc.rs`), or a sparse heap's texture of an ETC2 or... | every device (runtime piece not built) | 2: `crates/metal2vulkan-runtime/src/texture.rs:1682`, `crates/metal2vulkan-runtime/src/texture/heap.rs:1371` | `app`: an ASTC texture in a heap on a device without ASTC | | `VertexFetchPast4GiB` | A draw (`drawPrimitives:` and its forms, or an indirect command buffer's command) that may read a vertex attribute the pipeline fetches in its... | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/render/vertex_reach.rs:72` | `rare`: vertex fetch past 4 GiB of a bind offset | | `StageInFetchPast4GiB` | A dispatch (`dispatchThreads:threadsPerThreadgroup:` and its forms, or an indirect command buffer's command) whose kernel may read a... | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/fetch_reach.rs:126` | `rare`: stage-in fetch past 4 GiB of a bind offset | | `MappedTextureSampling` | A command that would sample a texture of an address-mode map (`TextureDescriptor::address_mode_map`) where the runtime cannot map it at bind... | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/address_map.rs:158` | `none`: a runtime extension's texture (address_mode_map) sampled where the runtime cannot map it; no Metal API path | | `LibrarySource` | A library compiled from Metal Shading Language source | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/library.rs:107` | `app`: a library compiled from Metal source (newLibraryWithSource:); the runtime takes metallibs and AIR | | `RestartedStrip` | An indexed strip after `set_primitive_restart_enabled` with an index Vulkan does not restart at, which the runtime draws as a list an index... | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/render/restart.rs:71` | `none`: a strip after the Apple-private setPrimitiveRestartEnabled:index: whose rewrite pass cannot run as Metal draws | -| `PrivatePrimitives` | A draw of one of Metal's private primitive types (`DrawPrimitiveType` | every device (runtime piece not built) | 2: `crates/metal2vulkan-runtime/src/render.rs:8026`, `crates/metal2vulkan-runtime/src/render/restart.rs:72` | `none`: a draw of an Apple-private primitive type (OpenGL on Metal's quads and kin) whose list cannot draw as Metal draws: a list past a u32 or one storage range, indices or arguments an unordered earlier draw wrote | +| `PrivatePrimitives` | A draw of one of Metal's private primitive types (`DrawPrimitiveType` | every device (runtime piece not built) | 2: `crates/metal2vulkan-runtime/src/render.rs:7986`, `crates/metal2vulkan-runtime/src/render/restart.rs:72` | `none`: a draw of an Apple-private primitive type (OpenGL on Metal's quads and kin) whose list cannot draw as Metal draws: a list past a u32 or one storage range, indices or arguments an unordered earlier draw wrote | | `ProvokingVertex` | A draw under Apple's last provoking vertex (`setProvokingVertexMode:` 1) on a device without `VK_EXT_provoking_vertex`'s last vertex, which the... | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/render/restart.rs:73` | `none`: a draw after the Apple-private setProvokingVertexMode: 1, on a device without the last provoking vertex, whose rotated list cannot draw as Metal draws | -| `PrimitiveIdIndices` | An indexed draw (`drawIndexedPrimitives:`) of a pipeline whose fragment function reads `[[primitive_id]]` on a device whose fragment stage cannot... | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/render.rs:8036` | `rare`: an indexed draw of a primitive_id pipeline, on a device without geometry or tessellation shaders, whose indices the encoder wrote since its last barrier | -| `RotatedTexture` | A rotated texture (`TextureDescriptor::rotation`) where the runtime does not build what Metal does | every device (runtime piece not built) | 9: `crates/metal2vulkan-runtime/src/blit_texture.rs:1669`, `crates/metal2vulkan-runtime/src/buffer_texture.rs:715` (+7) | `rare`: a rotated drawable's views, blits with images over overlapping rows, rows past its buffer | +| `PrimitiveIdIndices` | An indexed draw (`drawIndexedPrimitives:`) of a pipeline whose fragment function reads `[[primitive_id]]` on a device whose fragment stage cannot... | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/render.rs:7996` | `rare`: an indexed draw of a primitive_id pipeline, on a device without geometry or tessellation shaders, whose indices the encoder wrote since its last barrier | +| `RotatedTexture` | A rotated texture (`TextureDescriptor::rotation`) where the runtime does not build what Metal does | every device (runtime piece not built) | 9: `crates/metal2vulkan-runtime/src/blit_texture.rs:1602`, `crates/metal2vulkan-runtime/src/buffer_texture.rs:715` (+7) | `rare`: a rotated drawable's views, blits with images over overlapping rows, rows past its buffer | | `DetachTextures` | A texture over a no-copy buffer's or heap's bytes (a heap's texture, or a texture over the buffer or over one of the heap's buffers) that no... | every device (runtime piece not built) | 8: `crates/metal2vulkan-runtime/src/buffer_descriptor.rs:641`, `crates/metal2vulkan-runtime/src/buffer_texture.rs:622` (+6) | `none`: a runtime extension's detach with a texture no stand-in presents exactly | | `TextureBufferLevels` | A texture buffer of more than one level (`TextureDescriptor::mipmap_level_count`, up to its width's full chain) from the device's, a heap's or the... | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/texture_descriptor.rs:540` | `rare`: a texture buffer of more than one level (public, unusual) | | `WriteSwizzle` | A texture of `TextureDescriptor::write_swizzle_enabled` whose swizzle is not the default, with `ShaderWrite` or `RenderTarget` usage, from the... | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/texture_descriptor.rs:547` | `none`: Apple-private writeSwizzleEnabled with a swizzle that writes | -| `DetachedTexelAccess` | `Texture::replace_region` or `get_bytes` of a texture whose bytes (a no-copy buffer's or heap's) are detached (`detach_backing`) | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/texture.rs:4968` | `none`: CPU texel access while a runtime extension detached the bytes | +| `DetachedTexelAccess` | `Texture::replace_region` or `get_bytes` of a texture whose bytes (a no-copy buffer's or heap's) are detached (`detach_backing`) | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/texture.rs:4924` | `none`: CPU texel access while a runtime extension detached the bytes | | `SurfaceDepthStencil` | A use of a texture of a depth or stencil format (`Depth16Unorm`, `Depth32Float`, `Depth32Float_Stencil8`, `Stencil8`, `X32_Stencil8`) over a plane... | every device (runtime piece not built) | 2: `crates/metal2vulkan-runtime/src/blit_texture.rs:269`, `crates/metal2vulkan-runtime/src/texture/surface_depth.rs:57` | `rare`: a blit of the stencil of a Depth32Float_Stencil8 texture over a plane of an IOSurface with planes, or a pass on an X32_Stencil8 one's view as Depth32Float_Stencil8 | | `ExtendedRangeResolve` | The multisample resolve (`MultisampleResolve`, `StoreAndMultisampleResolve`) of a color attachment of an extended-range format (`BGRA10_XR`,... | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/resolve.rs:604` | `rare`: a multisample resolve of a BGRA10_XR, BGR10_XR or sRGB twin attachment (EDR content drawn multisampled) | -| `MultisampledBufferCopy` | A blit copy between a buffer and a multisampled texture (`copyFromBuffer:...toTexture:` into, or `copyFromTexture:...toBuffer:` out of, a texture... | every device (runtime piece not built) | 2: `crates/metal2vulkan-runtime/src/blit_texture.rs:536`, `crates/metal2vulkan-runtime/src/blit_texture.rs:693` | `rare`: a buffer<->multisampled-texture copy on a device without sample-rate shading, an integer multisample attachment at the count, or the copy format's storage; and, where maintenance8's depth/colour copies are missing or wrong, what the sample-rate draws cannot move: a 16-bit depth, or a depth or stencil texture they cannot sample or render to (emulated elsewhere; the consumer's Maps pans and screensaver make the copy) | -| `MultisampledBufferLayout` | A blit copy between a buffer and a multisampled texture (as for `MultisampledBufferCopy`) in one of two buffer layouts that plain Metal copies by... | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/sample_interleave.rs:1029` | `rare`: a buffer<->multisampled-texture copy at a bytesPerRow of 0 from an offset that is a multiple of 16, or of pixels of 32 bytes or more at a pitch below a row or off the pixel: Metal copies these by rules not yet reduced, and its API validation rejects them | +| `PredicationDropsUngatedWork` | An unbalanced command-predication record (`ComputeCommandEncoder::encode_end_if` and the other ends, or `encode_start_else`, with no block open;... | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/predication.rs:762` | `none`: an unbalanced Apple-private command-predication record as its unit's first, after dispatches of the unit | +| `MultisampledBufferCopy` | A blit copy between a buffer and a multisampled texture (`copyFromBuffer:...toTexture:` into, or `copyFromTexture:...toBuffer:` out of, a texture... | every device (runtime piece not built) | 2: `crates/metal2vulkan-runtime/src/blit_texture.rs:527`, `crates/metal2vulkan-runtime/src/blit_texture.rs:674` | `rare`: a buffer<->multisampled-texture copy on a device without sample-rate shading, an integer multisample attachment at the count, or the copy format's storage; and, where maintenance8's depth/colour copies are missing or wrong, what the sample-rate draws cannot move: a 16-bit depth, or a depth or stencil texture they cannot sample or render to (emulated elsewhere; the consumer's Maps pans and screensaver make the copy) | +| `MultisampledBufferLayout` | A blit copy between a buffer and a multisampled texture (as for `MultisampledBufferCopy`) in one of two buffer layouts that plain Metal copies by... | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/sample_interleave.rs:1020` | `rare`: a buffer<->multisampled-texture copy at a bytesPerRow of 0 from an offset that is a multiple of 16, or of pixels of 32 bytes or more at a pitch below a row or off the pixel: Metal copies these by rules not yet reduced, and its API validation rejects them | | `ColorAttachmentGroups` | What a render pass the device draws in color groups does not build | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/render/color_groups.rs:106` | `app`: in a render pass of more color attachments than the device draws at once (five or more on a device of four), or one at an index past them: a pipeline state of other colors, a tile state, an execution of render commands, a draw reading another group's attachment | ## 3. Apple-only calls (`Error::AppleOnly`) | Variant | What it blocks | Where | Sites | Reach | |---|---|---|---|---| -| `ProtectedContent` | Protection options whose answer on Metal is not measured (`command_buffer/protection.rs`) | every device (Apple-private, Metal's answer not measured) | 3: `crates/metal2vulkan-runtime/src/command_buffer/mod.rs:2412`, `crates/metal2vulkan-runtime/src/command_buffer/protection.rs:126` (+1) | `none`: Apple-private (no public header) | +| `ProtectedContent` | Protection options whose answer on Metal is not measured (`command_buffer/protection.rs`) | every device (Apple-private, Metal's answer not measured) | 3: `crates/metal2vulkan-runtime/src/command_buffer/mod.rs:2368`, `crates/metal2vulkan-runtime/src/command_buffer/protection.rs:126` (+1) | `none`: Apple-private (no public header) | | `LineWidth` | A line width other than 1 (`setLineWidth:`) | every device (Apple-private, Metal's answer not measured) | 1: `crates/metal2vulkan-runtime/src/apple_only.rs:189` | `none`: Apple-private (no public header) | | `ViewportTransformDisabled` | The viewport transform turned off (`setViewportTransformEnabled:NO`) | every device (Apple-private, Metal's answer not measured) | 1: `crates/metal2vulkan-runtime/src/apple_only.rs:191` | `none`: Apple-private (no public header) | -| `VertexAmplificationMode` | `setVertexAmplificationMode:value:` of a count (the value's set bits in mode 1, else the value) of 0, whose copies change from run to run on... | every device (Apple-private, Metal's answer not measured) | 2: `crates/metal2vulkan-runtime/src/apple_only.rs:195`, `crates/metal2vulkan-runtime/src/apple_only.rs:320` | `none`: Apple-private (no public header) | +| `VertexAmplificationMode` | `setVertexAmplificationMode:value:` of a count (the value's set bits in mode 1, else the value) of 0, whose copies change from run to run on... | every device (Apple-private, Metal's answer not measured) | 2: `crates/metal2vulkan-runtime/src/apple_only.rs:195`, `crates/metal2vulkan-runtime/src/apple_only.rs:312` | `none`: Apple-private (no public header) | | `SurfaceClientDirection` | A texture over an IOSurface made with `kIOSurfaceClientDirection` (`newTextureWithDescriptor:iosurface:plane:` of such a surface) | every device (Apple-private, Metal's answer not measured) | 1: `crates/metal2vulkan-runtime/src/buffer_texture.rs:417` | `none`: an IOSurface key in no public header | ## 4. Binder refusals at a device limit (`BindError`) @@ -246,9 +248,9 @@ Generated at `ae010017d`. | `DescriptorRangeExceeded` | A descriptor-form slot's window exceeds the descriptor range limit (Profile F) | at the device's limit | 1: `crates/metal2vulkan/src/bind/instantiate.rs:655` | `app`: a buffer window past a device's descriptor range | | `TexelBufferTooLarge` | A texel buffer exceeds `maxTexelBufferElements` | at the device's limit | 1: `crates/metal2vulkan/src/bind/instantiate.rs:894` | `rare`: a texture buffer past maxTexelBufferElements | | `HeapTooLarge` | The set-1 heap's elements (one per resident texture a handle can name, plus the null element) exceed the pipeline's heap capacity | at the device's limit | 7: `crates/metal2vulkan/src/bind/heap.rs:1014`, `crates/metal2vulkan/src/bind/heap.rs:1748` (+5) | `rare`: more resident textures than the pipeline's heap holds (bindless at scale) | -| `TessellationFactorRange` | The tessellation factors a draw reads span more bytes (`needed`) than one storage-buffer descriptor can bind (`limit`, `maxStorageBufferRange`),... | at the device's limit | 1: `crates/metal2vulkan/src/bind/graphics.rs:3767` | `rare`: tessellation factors past one storage descriptor | -| `PatchIndexRange` | The patch indices a draw reads span more bytes (`needed`) than one storage-buffer descriptor can bind (`limit`, `maxStorageBufferRange`) | at the device's limit | 1: `crates/metal2vulkan/src/bind/graphics.rs:3811` | `rare`: patch indices past one storage descriptor | -| `ControlPointIndexRange` | The control-point indices a draw reads span more bytes (`needed`) than one storage-buffer descriptor can bind (`limit`, `maxStorageBufferRange`) | at the device's limit | 1: `crates/metal2vulkan/src/bind/graphics.rs:3849` | `rare`: control-point indices past one storage descriptor | +| `TessellationFactorRange` | The tessellation factors a draw reads span more bytes (`needed`) than one storage-buffer descriptor can bind (`limit`, `maxStorageBufferRange`),... | at the device's limit | 1: `crates/metal2vulkan/src/bind/graphics.rs:3837` | `rare`: tessellation factors past one storage descriptor | +| `PatchIndexRange` | The patch indices a draw reads span more bytes (`needed`) than one storage-buffer descriptor can bind (`limit`, `maxStorageBufferRange`) | at the device's limit | 1: `crates/metal2vulkan/src/bind/graphics.rs:3881` | `rare`: patch indices past one storage descriptor | +| `ControlPointIndexRange` | The control-point indices a draw reads span more bytes (`needed`) than one storage-buffer descriptor can bind (`limit`, `maxStorageBufferRange`) | at the device's limit | 1: `crates/metal2vulkan/src/bind/graphics.rs:3919` | `rare`: control-point indices past one storage descriptor | | `MissingStageInRegion` | The kernel reads the compute encoder's stage-in region (a `[[stage_in]]` attribute stepping by thread position, or `[[grid_origin]]` or... | at the device's limit | 1: `crates/metal2vulkan/src/bind/dispatch.rs:796` | `none`: a stage-in region never set, which Metal leaves undefined | | `UniformViewAliased` | A `device` buffer slot the pipeline reads through a uniform view (Profile F's per-stage storage-buffer fallback,... | at the device's limit | 1: `crates/metal2vulkan/src/bind/instantiate.rs:609` | `rare`: Profile F's uniform-view fallback aliased by a write | | `MissingDeviceAddress` | A device-address slot received a buffer without a device address | at the device's limit | 1: `crates/metal2vulkan/src/bind/plan/slots.rs:133` | `rare`: a slot reached through a pointer loaded from memory, bound with inline bytes or on a device without device addresses | @@ -325,10 +327,10 @@ Each refusal's sites, with the function that builds it. - `feature::Int64Atomics`: `crates/metal2vulkan/src/lower/access/atomic.rs:624 (select)`; `crates/metal2vulkan/src/lower/access/atomic.rs:633 (select)` - `feature::ImageAtomics`: `crates/metal2vulkan-runtime/src/families/formats.rs:464 (atomic_gap)`; `crates/metal2vulkan-runtime/src/families/formats.rs:468 (atomic_gap)`; `crates/metal2vulkan/src/lower/texture/slot.rs:900 (atomic_format)` - `feature::DescriptorCount`: `crates/metal2vulkan/src/lower/access/mod.rs:1688 (accept_placement)`; `crates/metal2vulkan/src/lower/select.rs:1641 (finish)`; `crates/metal2vulkan/src/pipeline/link.rs:1135 (limit_error)` -- `feature::BufferRange`: `crates/metal2vulkan-runtime/src/function_table.rs:569 (past_storage_buffer_range)`; `crates/metal2vulkan/src/bind/graphics.rs:3772 (patch_binding)`; `crates/metal2vulkan/src/bind/graphics.rs:3816 (patch_binding)`; `crates/metal2vulkan/src/bind/graphics.rs:3854 (patch_binding)`; `crates/metal2vulkan/src/bind/instantiate.rs:661 (bind_buffers)`; `crates/metal2vulkan/src/lower/access/function_table.rs:226 (select)`; `crates/metal2vulkan/src/lower/access/mod.rs:1184 (place_slots)` +- `feature::BufferRange`: `crates/metal2vulkan-runtime/src/function_table.rs:569 (past_storage_buffer_range)`; `crates/metal2vulkan/src/bind/graphics.rs:3842 (patch_binding)`; `crates/metal2vulkan/src/bind/graphics.rs:3886 (patch_binding)`; `crates/metal2vulkan/src/bind/graphics.rs:3924 (patch_binding)`; `crates/metal2vulkan/src/bind/instantiate.rs:661 (bind_buffers)`; `crates/metal2vulkan/src/lower/access/function_table.rs:226 (select)`; `crates/metal2vulkan/src/lower/access/mod.rs:1184 (place_slots)` - `feature::Int64Arithmetic`: `crates/metal2vulkan/src/lower/arith/legal.rs:582 (check_scalar)`; `crates/metal2vulkan/src/lower/select.rs:1133 (selector_form)` - `feature::Float64Arithmetic`: `crates/metal2vulkan/src/device/metal.rs:230 (unsupported_features)`; `crates/metal2vulkan/src/lower/arith/legal.rs:587 (check_scalar)` -- `feature::Format`: `crates/metal2vulkan-runtime/src/binding_view.rs:146 (binding_view)`; `crates/metal2vulkan-runtime/src/blit_plan.rs:523 (check_formats)`; `crates/metal2vulkan-runtime/src/blit_plan.rs:530 (check_formats)`; `crates/metal2vulkan-runtime/src/blit_plan.rs:545 (check_formats)`; `crates/metal2vulkan-runtime/src/blit_plan.rs:602 (pair_unit)`; `crates/metal2vulkan-runtime/src/blit_plan.rs:694 (plan_levels_copy)`; `crates/metal2vulkan-runtime/src/blit_texture.rs:2206 (through_buffer)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:519 (make_texture_over)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:582 (make_texture_over)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:614 (make_texture_over)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:851 (texture_buffer_texel)`; `crates/metal2vulkan-runtime/src/copy_plan.rs:270 (colour_unit)`; `crates/metal2vulkan-runtime/src/copy_plan.rs:298 (copy_unit)`; `crates/metal2vulkan-runtime/src/copy_plan.rs:344 (copy_unit)`; `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:346 (scratch)`; `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:526 (usable_twin)`; `crates/metal2vulkan-runtime/src/families/features.rs:1625 (read_write_tier)`; `crates/metal2vulkan-runtime/src/families/formats.rs:1628 (sparse_missing)`; `crates/metal2vulkan-runtime/src/families/formats.rs:227 (none)`; `crates/metal2vulkan-runtime/src/families/formats.rs:271 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:291 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:306 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:353 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:392 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:474 (atomic_gap)`; `crates/metal2vulkan-runtime/src/families/formats.rs:508 (lacking)`; `crates/metal2vulkan-runtime/src/families/formats.rs:522 (unsupported)`; `crates/metal2vulkan-runtime/src/image_plan.rs:544 (check_own_memory)`; `crates/metal2vulkan-runtime/src/image_plan.rs:670 (plan_held)`; `crates/metal2vulkan-runtime/src/image_plan.rs:787 (plan_held)`; `crates/metal2vulkan-runtime/src/image_plan.rs:907 (plan_held)`; `crates/metal2vulkan-runtime/src/render.rs:2292 (viewing)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1031 (check_target)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1373 (layout)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1713 (target)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1806 (attachment_format)`; `crates/metal2vulkan-runtime/src/resolve.rs:409 (unmodelled_resolve)`; `crates/metal2vulkan-runtime/src/resolve.rs:616 (color)`; `crates/metal2vulkan-runtime/src/sample_copy.rs:176 (checked_twin)`; `crates/metal2vulkan-runtime/src/sample_copy.rs:204 (plan)`; `crates/metal2vulkan-runtime/src/sample_interleave.rs:303 (interleave_merge)`; `crates/metal2vulkan-runtime/src/shadow.rs:649 (unmerged)`; `crates/metal2vulkan-runtime/src/shadow.rs:656 (unmerged)`; `crates/metal2vulkan-runtime/src/texture.rs:2083 (texture_as)`; `crates/metal2vulkan-runtime/src/texture.rs:3632 (two_planes_refused)`; `crates/metal2vulkan-runtime/src/texture/decoded_twin.rs:498 (astc_texels)`; `crates/metal2vulkan-runtime/src/texture/decoded_twin.rs:534 (etc_texels)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:1949 (planned_heap_texture)`; `crates/metal2vulkan-runtime/src/texture/surface_two_planes.rs:80 (refused)`; `crates/metal2vulkan-runtime/src/texture/ycbcr_image.rs:115 (converted_storage)`; `crates/metal2vulkan-runtime/src/texture/ycbcr_image.rs:278 (ycbcr_write_shadow)`; `crates/metal2vulkan-runtime/src/texture/ycbcr_image.rs:384 (new_render_shadow)`; `crates/metal2vulkan-runtime/src/two_planes.rs:150 (unmeasured)`; `crates/metal2vulkan-runtime/src/view_plan.rs:380 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:393 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:400 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:412 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:422 (check_format)`; `crates/metal2vulkan-runtime/src/ycbcr.rs:285 (refused)`; `crates/metal2vulkan/src/bind/extended_shadow.rs:184 (extended_shadow_module)`; `crates/metal2vulkan/src/bind/plan/resources.rs:1134 (plain_texture)`; `crates/metal2vulkan/src/bind/plan/resources.rs:1814 (extended_sampler)`; `crates/metal2vulkan/src/bind/plan/resources.rs:193 (require_filter_features)`; `crates/metal2vulkan/src/bind/plan/resources.rs:959 (plain_texture)`; `crates/metal2vulkan/src/bind/sample_interleave.rs:304 (finish)`; `crates/metal2vulkan/src/bind/sample_interleave.rs:328 (interleave_split_module)`; `crates/metal2vulkan/src/bind/shadow_copy_in.rs:259 (shadow_copy_in_module)`; `crates/metal2vulkan/src/bind/unused_bits.rs:687 (unused_bits_module)`; `crates/metal2vulkan/src/lower/access/tile.rs:1029 (storage_format)`; `crates/metal2vulkan/src/lower/fragment/color.rs:160 (select_param)`; `crates/metal2vulkan/src/lower/fragment/color.rs:166 (select_param)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1202 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1223 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1229 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1235 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1260 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1437 (plan)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1873 (select_read)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1979 (select_output)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:2006 (select_output)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:2025 (select_output)`; `crates/metal2vulkan/src/lower/sampler/select.rs:1093 (select_extended)`; `crates/metal2vulkan/src/lower/sampler/select.rs:691 (texel_in)`; `crates/metal2vulkan/src/lower/stage_io/extended_color.rs:77 (plan)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:2355 (entry)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:896 (zeroed_output)`; `crates/metal2vulkan/src/lower/stage_io/word_color.rs:83 (plan)`; `crates/metal2vulkan/src/lower/texture/mod.rs:2360 (select)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3002 (cross_class)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3174 (select_image)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3344 (select_read_as)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3381 (select_read_as)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3714 (select_write)`; `crates/metal2vulkan/src/lower/texture/slot.rs:1035 (declare_slot)`; `crates/metal2vulkan/src/lower/texture/slot.rs:1048 (declare_slot)`; `crates/metal2vulkan/src/lower/texture/slot.rs:1054 (declare_slot)`; `crates/metal2vulkan/src/lower/texture/slot.rs:739 (storage_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:742 (storage_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:753 (storage_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:771 (storage_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:791 (storage_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:815 (ulong_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:826 (ulong_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:873 (ulong_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:908 (atomic_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:917 (atomic_format)`; `crates/metal2vulkan/src/metal/format/mod.rs:1693 (vk_format)`; `crates/metal2vulkan/src/metal/format/mod.rs:1695 (vk_format)`; `crates/metal2vulkan/src/metal/format/mod.rs:1825 (candidates)`; `crates/metal2vulkan/src/metal/format/mod.rs:2783 (storage_choice_viewed)`; `crates/metal2vulkan/src/metal/format/mod.rs:2801 (held_storage_choice)`; `crates/metal2vulkan/src/metal/format/mod.rs:2809 (held_storage_choice)`; `crates/metal2vulkan/src/metal/format/mod.rs:2906 (held_storage_choice)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:1100 (extended_write_mask)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:428 (graphics_state)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:474 (graphics_state)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:546 (graphics_state)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:969 (reads_alpha_to_coverage)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:990 (reads_alpha_to_coverage)`; `crates/metal2vulkan/src/pipeline/rotated_blend.rs:449 (rotated_blend)`; `crates/metal2vulkan/src/pipeline/rotated_blend.rs:593 (alpha_in_red_blend)` +- `feature::Format`: `crates/metal2vulkan-runtime/src/binding_view.rs:146 (binding_view)`; `crates/metal2vulkan-runtime/src/blit_plan.rs:523 (check_formats)`; `crates/metal2vulkan-runtime/src/blit_plan.rs:530 (check_formats)`; `crates/metal2vulkan-runtime/src/blit_plan.rs:545 (check_formats)`; `crates/metal2vulkan-runtime/src/blit_plan.rs:602 (pair_unit)`; `crates/metal2vulkan-runtime/src/blit_plan.rs:694 (plan_levels_copy)`; `crates/metal2vulkan-runtime/src/blit_texture.rs:2118 (through_buffer)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:519 (make_texture_over)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:582 (make_texture_over)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:614 (make_texture_over)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:851 (texture_buffer_texel)`; `crates/metal2vulkan-runtime/src/copy_plan.rs:270 (colour_unit)`; `crates/metal2vulkan-runtime/src/copy_plan.rs:298 (copy_unit)`; `crates/metal2vulkan-runtime/src/copy_plan.rs:344 (copy_unit)`; `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:346 (scratch)`; `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:526 (usable_twin)`; `crates/metal2vulkan-runtime/src/families/features.rs:1625 (read_write_tier)`; `crates/metal2vulkan-runtime/src/families/formats.rs:1628 (sparse_missing)`; `crates/metal2vulkan-runtime/src/families/formats.rs:227 (none)`; `crates/metal2vulkan-runtime/src/families/formats.rs:271 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:291 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:306 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:353 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:392 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:474 (atomic_gap)`; `crates/metal2vulkan-runtime/src/families/formats.rs:508 (lacking)`; `crates/metal2vulkan-runtime/src/families/formats.rs:522 (unsupported)`; `crates/metal2vulkan-runtime/src/image_plan.rs:544 (check_own_memory)`; `crates/metal2vulkan-runtime/src/image_plan.rs:670 (plan_held)`; `crates/metal2vulkan-runtime/src/image_plan.rs:787 (plan_held)`; `crates/metal2vulkan-runtime/src/image_plan.rs:907 (plan_held)`; `crates/metal2vulkan-runtime/src/render.rs:2293 (viewing)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1031 (check_target)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1369 (layout)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1709 (target)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1802 (attachment_format)`; `crates/metal2vulkan-runtime/src/resolve.rs:409 (unmodelled_resolve)`; `crates/metal2vulkan-runtime/src/resolve.rs:616 (color)`; `crates/metal2vulkan-runtime/src/sample_copy.rs:176 (checked_twin)`; `crates/metal2vulkan-runtime/src/sample_copy.rs:204 (plan)`; `crates/metal2vulkan-runtime/src/sample_interleave.rs:301 (interleave_merge)`; `crates/metal2vulkan-runtime/src/shadow.rs:648 (unmerged)`; `crates/metal2vulkan-runtime/src/shadow.rs:655 (unmerged)`; `crates/metal2vulkan-runtime/src/texture.rs:2047 (texture_as)`; `crates/metal2vulkan-runtime/src/texture.rs:3588 (two_planes_refused)`; `crates/metal2vulkan-runtime/src/texture/decoded_twin.rs:498 (astc_texels)`; `crates/metal2vulkan-runtime/src/texture/decoded_twin.rs:534 (etc_texels)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:1947 (planned_heap_texture)`; `crates/metal2vulkan-runtime/src/texture/surface_two_planes.rs:80 (refused)`; `crates/metal2vulkan-runtime/src/texture/ycbcr_image.rs:115 (converted_storage)`; `crates/metal2vulkan-runtime/src/texture/ycbcr_image.rs:278 (ycbcr_write_shadow)`; `crates/metal2vulkan-runtime/src/texture/ycbcr_image.rs:384 (new_render_shadow)`; `crates/metal2vulkan-runtime/src/two_planes.rs:122 (unmeasured)`; `crates/metal2vulkan-runtime/src/view_plan.rs:380 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:393 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:400 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:412 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:422 (check_format)`; `crates/metal2vulkan-runtime/src/ycbcr.rs:285 (refused)`; `crates/metal2vulkan/src/bind/extended_shadow.rs:184 (extended_shadow_module)`; `crates/metal2vulkan/src/bind/plan/resources.rs:1134 (plain_texture)`; `crates/metal2vulkan/src/bind/plan/resources.rs:1814 (extended_sampler)`; `crates/metal2vulkan/src/bind/plan/resources.rs:193 (require_filter_features)`; `crates/metal2vulkan/src/bind/plan/resources.rs:959 (plain_texture)`; `crates/metal2vulkan/src/bind/sample_interleave.rs:304 (finish)`; `crates/metal2vulkan/src/bind/sample_interleave.rs:328 (interleave_split_module)`; `crates/metal2vulkan/src/bind/shadow_copy_in.rs:259 (shadow_copy_in_module)`; `crates/metal2vulkan/src/bind/unused_bits.rs:687 (unused_bits_module)`; `crates/metal2vulkan/src/lower/access/tile.rs:1029 (storage_format)`; `crates/metal2vulkan/src/lower/fragment/color.rs:160 (select_param)`; `crates/metal2vulkan/src/lower/fragment/color.rs:166 (select_param)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1193 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1214 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1220 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1226 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1251 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1428 (plan)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1844 (select_read)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1952 (select_output)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1979 (select_output)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1998 (select_output)`; `crates/metal2vulkan/src/lower/sampler/select.rs:1093 (select_extended)`; `crates/metal2vulkan/src/lower/sampler/select.rs:691 (texel_in)`; `crates/metal2vulkan/src/lower/stage_io/extended_color.rs:77 (plan)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:2355 (entry)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:896 (zeroed_output)`; `crates/metal2vulkan/src/lower/stage_io/word_color.rs:83 (plan)`; `crates/metal2vulkan/src/lower/texture/mod.rs:2360 (select)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3002 (cross_class)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3174 (select_image)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3344 (select_read_as)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3381 (select_read_as)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3714 (select_write)`; `crates/metal2vulkan/src/lower/texture/slot.rs:1035 (declare_slot)`; `crates/metal2vulkan/src/lower/texture/slot.rs:1048 (declare_slot)`; `crates/metal2vulkan/src/lower/texture/slot.rs:1054 (declare_slot)`; `crates/metal2vulkan/src/lower/texture/slot.rs:739 (storage_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:742 (storage_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:753 (storage_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:771 (storage_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:791 (storage_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:815 (ulong_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:826 (ulong_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:873 (ulong_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:908 (atomic_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:917 (atomic_format)`; `crates/metal2vulkan/src/metal/format/mod.rs:1693 (vk_format)`; `crates/metal2vulkan/src/metal/format/mod.rs:1695 (vk_format)`; `crates/metal2vulkan/src/metal/format/mod.rs:1825 (candidates)`; `crates/metal2vulkan/src/metal/format/mod.rs:2783 (storage_choice_viewed)`; `crates/metal2vulkan/src/metal/format/mod.rs:2801 (held_storage_choice)`; `crates/metal2vulkan/src/metal/format/mod.rs:2809 (held_storage_choice)`; `crates/metal2vulkan/src/metal/format/mod.rs:2906 (held_storage_choice)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:1100 (extended_write_mask)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:428 (graphics_state)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:474 (graphics_state)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:546 (graphics_state)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:969 (reads_alpha_to_coverage)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:990 (reads_alpha_to_coverage)`; `crates/metal2vulkan/src/pipeline/rotated_blend.rs:449 (rotated_blend)`; `crates/metal2vulkan/src/pipeline/rotated_blend.rs:593 (alpha_in_red_blend)` - `feature::DivergentImplicitLod`: `crates/metal2vulkan/src/lower/sampler/select.rs:352 (select_sampling)` - `feature::ImplicitLodOutsideFragment`: `crates/metal2vulkan/src/lower/sampler/constexpr.rs:136 (query_min_level)`; `crates/metal2vulkan/src/lower/sampler/select.rs:229 (query_level_measured)`; `crates/metal2vulkan/src/lower/sampler/select.rs:255 (query_min_level)` - `feature::MinLodClamp`: `crates/metal2vulkan/src/lower/sampler/select.rs:1572 (select_one)`; `crates/metal2vulkan/src/lower/sampler/select.rs:973 (min_lod)` @@ -344,22 +346,22 @@ Each refusal's sites, with the function that builds it. - `feature::PixelSamplerCompare`: `crates/metal2vulkan/src/lower/sampler/constexpr.rs:115 (lowered)` - `feature::TexelBuffer`: `crates/metal2vulkan/src/bind/instantiate.rs:882 (texel_ranges)`; `crates/metal2vulkan/src/bind/instantiate.rs:888 (texel_ranges)`; `crates/metal2vulkan/src/bind/plan/resources.rs:1147 (plain_texture)` - `feature::RasterOrderGroups`: `crates/metal2vulkan/src/device/metal.rs:242 (unsupported_features)`; `crates/metal2vulkan/src/lower/fragment/rog.rs:151 (mode)`; `crates/metal2vulkan/src/lower/fragment/rog.rs:172 (mode)`; `crates/metal2vulkan/src/lower/fragment/snapshot.rs:158 (finish)` -- `feature::FramebufferFetch`: `crates/metal2vulkan-runtime/src/families/features.rs:1018 (state)`; `crates/metal2vulkan-runtime/src/render.rs:5894 (next_instance)`; `crates/metal2vulkan-runtime/src/sample_planes.rs:120 (lacks)`; `crates/metal2vulkan-runtime/src/sample_planes.rs:147 (new)`; `crates/metal2vulkan-runtime/src/sample_planes.rs:518 (planes_merge)`; `crates/metal2vulkan/src/bind/extended_shadow.rs:190 (extended_shadow_module)`; `crates/metal2vulkan/src/bind/sample_planes.rs:477 (finish)`; `crates/metal2vulkan/src/device/metal.rs:252 (unsupported_features)`; `crates/metal2vulkan/src/lower/arith/extended_range/blend.rs:1218 (unorm8)`; `crates/metal2vulkan/src/lower/arith/extended_range/blend.rs:1236 (unorm8)`; `crates/metal2vulkan/src/lower/arith/extended_range/blend.rs:1250 (unorm8)`; `crates/metal2vulkan/src/lower/arith/extended_range/blend.rs:1293 (packed16)`; `crates/metal2vulkan/src/lower/fragment/color.rs:215 (select_param)`; `crates/metal2vulkan/src/lower/fragment/color.rs:279 (unordered)`; `crates/metal2vulkan/src/lower/fragment/depth_test.rs:195 (not_implemented)`; `crates/metal2vulkan/src/lower/fragment/depth_test.rs:272 (depth_test_form)`; `crates/metal2vulkan/src/lower/fragment/depth_test.rs:318 (stencil_test_form)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1087 (storage_form)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1178 (storage_form)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1215 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1827 (plan_sample)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:789 (not_implemented)`; `crates/metal2vulkan/src/pipeline/link/fetch.rs:164 (storage_attachments)` +- `feature::FramebufferFetch`: `crates/metal2vulkan-runtime/src/families/features.rs:1018 (state)`; `crates/metal2vulkan-runtime/src/render.rs:5895 (next_instance)`; `crates/metal2vulkan-runtime/src/sample_planes.rs:120 (lacks)`; `crates/metal2vulkan-runtime/src/sample_planes.rs:147 (new)`; `crates/metal2vulkan-runtime/src/sample_planes.rs:518 (planes_merge)`; `crates/metal2vulkan/src/bind/extended_shadow.rs:190 (extended_shadow_module)`; `crates/metal2vulkan/src/bind/sample_planes.rs:477 (finish)`; `crates/metal2vulkan/src/device/metal.rs:252 (unsupported_features)`; `crates/metal2vulkan/src/lower/arith/extended_range/blend.rs:1222 (unorm8)`; `crates/metal2vulkan/src/lower/arith/extended_range/blend.rs:1240 (unorm8)`; `crates/metal2vulkan/src/lower/arith/extended_range/blend.rs:1254 (unorm8)`; `crates/metal2vulkan/src/lower/arith/extended_range/blend.rs:1297 (packed16)`; `crates/metal2vulkan/src/lower/fragment/color.rs:215 (select_param)`; `crates/metal2vulkan/src/lower/fragment/color.rs:279 (unordered)`; `crates/metal2vulkan/src/lower/fragment/depth_test.rs:195 (not_implemented)`; `crates/metal2vulkan/src/lower/fragment/depth_test.rs:272 (depth_test_form)`; `crates/metal2vulkan/src/lower/fragment/depth_test.rs:318 (stencil_test_form)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1078 (storage_form)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1169 (storage_form)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1206 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1798 (plan_sample)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:785 (not_implemented)`; `crates/metal2vulkan/src/pipeline/link/fetch.rs:164 (storage_attachments)` - `feature::PrimitiveId`: `crates/metal2vulkan-runtime/src/families/features.rs:1127 (state)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:3211 (finish)`; `crates/metal2vulkan/src/pipeline/link/varyings.rs:240 (check_primitive_id)` - `feature::PrivatePrimitives`: `crates/metal2vulkan/src/lower/stage_io/plan.rs:2601 (indices_feature)` -- `feature::VertexAmplification`: `crates/metal2vulkan/src/bind/graphics.rs:4113 (multiview_instances)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:1312 (own_index_store)`; `crates/metal2vulkan/src/lower/tessellation/mod.rs:718 (select_param)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:258 (vertex_amplification)`; `crates/metal2vulkan/src/pipeline/link/tessellation/mod.rs:228 (control_plan)` -- `feature::LayeredRendering`: `crates/metal2vulkan-runtime/src/render_pass.rs:1673 (target)`; `crates/metal2vulkan-runtime/src/render_state.rs:1107 (needs_viewports)`; `crates/metal2vulkan/src/lower/mesh/mod.rs:796 (target_index)`; `crates/metal2vulkan/src/lower/mesh/mod.rs:815 (target_index)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:1313 (own_index_store)`; `crates/metal2vulkan/src/pipeline/link/geometry.rs:150 (not_implemented)`; `crates/metal2vulkan/src/pipeline/link/geometry.rs:172 (refused)` -- `feature::ClipDistance`: `crates/metal2vulkan/src/lower/mesh/mod.rs:956 (select)`; `crates/metal2vulkan/src/lower/mesh/mod.rs:964 (select)` +- `feature::VertexAmplification`: `crates/metal2vulkan/src/bind/graphics.rs:4183 (multiview_instances)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:1312 (own_index_store)`; `crates/metal2vulkan/src/lower/tessellation/mod.rs:718 (select_param)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:258 (vertex_amplification)`; `crates/metal2vulkan/src/pipeline/link/tessellation/mod.rs:228 (control_plan)` +- `feature::LayeredRendering`: `crates/metal2vulkan-runtime/src/render_pass.rs:1669 (target)`; `crates/metal2vulkan-runtime/src/render_state.rs:1107 (needs_viewports)`; `crates/metal2vulkan/src/lower/mesh/mod.rs:798 (target_index)`; `crates/metal2vulkan/src/lower/mesh/mod.rs:817 (target_index)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:1313 (own_index_store)`; `crates/metal2vulkan/src/pipeline/link/geometry.rs:150 (not_implemented)`; `crates/metal2vulkan/src/pipeline/link/geometry.rs:172 (refused)` +- `feature::ClipDistance`: `crates/metal2vulkan/src/lower/mesh/mod.rs:958 (select)`; `crates/metal2vulkan/src/lower/mesh/mod.rs:966 (select)` - `feature::DualSourceBlending`: `crates/metal2vulkan-runtime/src/families/formats.rs:386 (answers)`; `crates/metal2vulkan/src/metal/state.rs:37 (blend_factor)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:1157 (check_outputs)`; `crates/metal2vulkan/src/pipeline/rotated_blend.rs:463 (rotated_blend)`; `crates/metal2vulkan/src/pipeline/rotated_blend.rs:538 (rotated_blend)` - `feature::Barycentrics`: `crates/metal2vulkan/src/device/metal.rs:263 (unsupported_features)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:1924 (input_builtin)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:745 (param)`; `crates/metal2vulkan/src/pipeline/link/geometry.rs:148 (not_implemented)`; `crates/metal2vulkan/src/pipeline/link/geometry.rs:170 (refused)` -- `feature::StencilExport`: `crates/metal2vulkan-runtime/src/families/features.rs:1114 (state)`; `crates/metal2vulkan/src/bind/graphics.rs:2719 (shadow_stencil_words)`; `crates/metal2vulkan/src/lower/fragment/stencil.rs:157 (device_form)`; `crates/metal2vulkan/src/lower/fragment/stencil.rs:168 (not_implemented)`; `crates/metal2vulkan/src/pipeline/link/stencil.rs:55 (shadow_stencil)`; `crates/metal2vulkan/src/pipeline/link/stencil.rs:73 (shadow_stencil)` +- `feature::StencilExport`: `crates/metal2vulkan-runtime/src/families/features.rs:1114 (state)`; `crates/metal2vulkan/src/bind/graphics.rs:2751 (shadow_stencil_words)`; `crates/metal2vulkan/src/lower/fragment/stencil.rs:157 (device_form)`; `crates/metal2vulkan/src/lower/fragment/stencil.rs:168 (not_implemented)`; `crates/metal2vulkan/src/pipeline/link/stencil.rs:55 (shadow_stencil)`; `crates/metal2vulkan/src/pipeline/link/stencil.rs:73 (shadow_stencil)` - `feature::SampleRateShading`: `crates/metal2vulkan/src/pipeline/link/graphics.rs:844 (sample_invocations)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:846 (sample_invocations)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:928 (sample_invocations)` - `feature::PixelCoverageAtSampleRate`: `crates/metal2vulkan/src/lower/fragment/coverage.rs:296 (finish)`; `crates/metal2vulkan/src/lower/simd/mod.rs:754 (select_param)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:879 (sample_invocations)` - `feature::InterfaceComponents`: `crates/metal2vulkan/src/pipeline/compile/color_group.rs:202 (refusal)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:301 (graphics_state)`; `crates/metal2vulkan/src/pipeline/link/varyings.rs:409 (assign)`; `crates/metal2vulkan/src/pipeline/link/varyings.rs:90 (limit_error)` - `feature::UnmatchedVarying`: `crates/metal2vulkan/src/pipeline/link/varyings.rs:318 (mesh_fragment)`; `crates/metal2vulkan/src/pipeline/link/varyings.rs:537 (varyings)`; `crates/metal2vulkan/src/pipeline/link/varyings.rs:548 (varyings)` - `feature::KernelStageIn`: `crates/metal2vulkan-runtime/src/indirect_execute.rs:376 (record)`; `crates/metal2vulkan/src/bind/dispatch.rs:871 (instantiate)`; `crates/metal2vulkan/src/lower/stage_io/stage_in.rs:133 (select)` -- `feature::Tessellation`: `crates/metal2vulkan-air/src/canon/mod.rs:1256 (post_check)`; `crates/metal2vulkan-air/src/canon/mod.rs:1347 (post_check)`; `crates/metal2vulkan/src/bind/graphics.rs:3970 (tessellation_dispatch)`; `crates/metal2vulkan/src/lower/stage_io/fetch.rs:519 (select)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:1508 (primitive_id_output)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:1794 (input_builtin)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:828 (param)`; `crates/metal2vulkan/src/lower/tessellation/mod.rs:150 (not_implemented)`; `crates/metal2vulkan/src/lower/tessellation/mod.rs:489 (plan_entry)`; `crates/metal2vulkan/src/metal/vertex.rs:219 (fetch_as)`; `crates/metal2vulkan/src/pipeline/link/tessellation/mod.rs:212 (control_plan)`; `crates/metal2vulkan/src/pipeline/link/tessellation/mod.rs:292 (check_fragment)`; `crates/metal2vulkan/src/pipeline/link/tessellation/mod.rs:316 (push_offset)` -- `feature::MeshShading`: `crates/metal2vulkan/src/bind/graphics.rs:1630 (plan)`; `crates/metal2vulkan/src/bind/graphics.rs:3095 (mesh_limit)`; `crates/metal2vulkan/src/lower/mesh/mod.rs:517 (check_payload)`; `crates/metal2vulkan/src/lower/mesh/mod.rs:556 (plan_entry)`; `crates/metal2vulkan/src/lower/mesh/mod.rs:590 (plan_entry)`; `crates/metal2vulkan/src/memory/plan.rs:2056 (reprs)`; `crates/metal2vulkan/src/pipeline/link/mesh.rs:102 (records)` +- `feature::Tessellation`: `crates/metal2vulkan-air/src/canon/mod.rs:1256 (post_check)`; `crates/metal2vulkan-air/src/canon/mod.rs:1347 (post_check)`; `crates/metal2vulkan/src/bind/graphics.rs:4040 (tessellation_dispatch)`; `crates/metal2vulkan/src/lower/stage_io/fetch.rs:519 (select)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:1508 (primitive_id_output)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:1794 (input_builtin)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:828 (param)`; `crates/metal2vulkan/src/lower/tessellation/mod.rs:150 (not_implemented)`; `crates/metal2vulkan/src/lower/tessellation/mod.rs:489 (plan_entry)`; `crates/metal2vulkan/src/metal/vertex.rs:219 (fetch_as)`; `crates/metal2vulkan/src/pipeline/link/tessellation/mod.rs:212 (control_plan)`; `crates/metal2vulkan/src/pipeline/link/tessellation/mod.rs:292 (check_fragment)`; `crates/metal2vulkan/src/pipeline/link/tessellation/mod.rs:316 (push_offset)` +- `feature::MeshShading`: `crates/metal2vulkan/src/bind/graphics.rs:1662 (plan)`; `crates/metal2vulkan/src/bind/graphics.rs:3130 (mesh_limit)`; `crates/metal2vulkan/src/lower/mesh/mod.rs:519 (check_payload)`; `crates/metal2vulkan/src/lower/mesh/mod.rs:558 (plan_entry)`; `crates/metal2vulkan/src/lower/mesh/mod.rs:592 (plan_entry)`; `crates/metal2vulkan/src/memory/plan.rs:2056 (reprs)`; `crates/metal2vulkan/src/pipeline/link/mesh.rs:102 (records)` - `feature::TileShading`: `crates/metal2vulkan-runtime/src/render/tile_dispatch.rs:520 (scratch)`; `crates/metal2vulkan/src/bind/plan/compute.rs:237 (tile_memory)`; `crates/metal2vulkan/src/lower/access/tile.rs:151 (not_implemented)`; `crates/metal2vulkan/src/lower/sync/barrier.rs:275 (tile_shading)`; `crates/metal2vulkan/src/pipeline/compile/api.rs:702 (tile_pipeline)` - `feature::Imageblocks`: `crates/metal2vulkan/src/lower/access/imageblock.rs:98 (imageblocks)`; `crates/metal2vulkan/src/lower/access/mod.rs:908 (select_param)`; `crates/metal2vulkan/src/lower/fragment/imageblock.rs:104 (require)`; `crates/metal2vulkan/src/lower/fragment/imageblock.rs:412 (reach)`; `crates/metal2vulkan/src/lower/fragment/imageblock.rs:554 (plan_tests)`; `crates/metal2vulkan/src/lower/fragment/imageblock.rs:578 (plan_tests)`; `crates/metal2vulkan/src/lower/fragment/imageblock.rs:86 (not_implemented)`; `crates/metal2vulkan/src/lower/texture/mod.rs:2370 (select)`; `crates/metal2vulkan/src/lower/texture/slice.rs:139 (imageblocks)`; `crates/metal2vulkan/src/pipeline/link/imageblock.rs:50 (fragment_imageblock)` - `feature::RayTracing`: `crates/metal2vulkan/src/bind/acceleration.rs:202 (instance_record)`; `crates/metal2vulkan/src/bind/acceleration.rs:216 (instance_record)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs:1087 (primitive_data_read)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs:1202 (instance_count)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs:1245 (intersect)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs:1257 (intersect)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs:1282 (intersect)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs:1297 (intersect)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs:1312 (intersect)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs:344 (slot_of)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs:385 (select_param)`; `crates/metal2vulkan/src/lower/select.rs:899 (route_air)` @@ -374,15 +376,15 @@ Each refusal's sites, with the function that builds it. - `feature::SubgroupOperations`: `crates/metal2vulkan-runtime/src/families/features.rs:1713 (simd)`; `crates/metal2vulkan/src/lower/simd/mod.rs:407 (finish)`; `crates/metal2vulkan/src/lower/simd/mod.rs:466 (full_quads)`; `crates/metal2vulkan/src/lower/simd/mod.rs:990 (select_group)` - `feature::DirectCall`: `crates/metal2vulkan-air/src/canon/mod.rs:1319 (post_check)` - `feature::WideSwitchLiteral`: `crates/metal2vulkan/src/structurize/emit.rs:207 (check_tree)` -- `feature::Lowering`: `crates/metal2vulkan/src/bind/plan/resources.rs:762 (level_views)`; `crates/metal2vulkan/src/lower/access/handle.rs:1062 (texture_target)`; `crates/metal2vulkan/src/lower/access/handle.rs:1073 (sampler_target)`; `crates/metal2vulkan/src/lower/access/handle.rs:318 (domain_kind)`; `crates/metal2vulkan/src/lower/access/imageblock.rs:175 (operand)`; `crates/metal2vulkan/src/lower/access/mod.rs:571 (not_lowered)`; `crates/metal2vulkan/src/lower/access/pulled.rs:76 (share)`; `crates/metal2vulkan/src/lower/arith/legal.rs:53 (not_lowered)`; `crates/metal2vulkan/src/lower/dispatch.rs:114 (not_lowered)`; `crates/metal2vulkan/src/lower/fragment/discard.rs:144 (not_lowered)`; `crates/metal2vulkan/src/lower/fragment/discard.rs:653 (plan)`; `crates/metal2vulkan/src/lower/fragment/mod.rs:123 (not_lowered)`; `crates/metal2vulkan/src/lower/fragment/snapshot.rs:168 (finish)`; `crates/metal2vulkan/src/lower/mesh/mod.rs:149 (not_lowered)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs:126 (not_lowered)`; `crates/metal2vulkan/src/lower/sampler/mod.rs:212 (refuse)`; `crates/metal2vulkan/src/lower/sampler/select.rs:30 (refuse)`; `crates/metal2vulkan/src/lower/select.rs:829 (not_lowered)`; `crates/metal2vulkan/src/lower/select.rs:918 (route_air)`; `crates/metal2vulkan/src/lower/simd/mod.rs:136 (not_lowered)`; `crates/metal2vulkan/src/lower/simd/mod.rs:747 (select_param)`; `crates/metal2vulkan/src/lower/simd/workgroup.rs:353 (check)`; `crates/metal2vulkan/src/lower/stage_io/fetch.rs:96 (not_lowered)`; `crates/metal2vulkan/src/lower/stage_io/mod.rs:182 (not_lowered)`; `crates/metal2vulkan/src/lower/sync/barrier.rs:72 (not_lowered)`; `crates/metal2vulkan/src/lower/sync/memory_model.rs:269 (not_implemented)`; `crates/metal2vulkan/src/lower/sync/memory_model.rs:310 (select)`; `crates/metal2vulkan/src/lower/tessellation/mod.rs:146 (not_lowered)`; `crates/metal2vulkan/src/lower/texture/mod.rs:180 (refuse)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3683 (select_write)`; `crates/metal2vulkan/src/memory/alloca.rs:54 (not_lowered)`; `crates/metal2vulkan/src/memory/leaf.rs:183 (not_lowered)`; `crates/metal2vulkan/src/memory/plan.rs:490 (not_lowered)`; `crates/metal2vulkan/src/memory/provenance.rs:665 (not_lowered)`; `crates/metal2vulkan/src/pipeline/link/tessellation/mod.rs:96 (patch_fetch_projection)` +- `feature::Lowering`: `crates/metal2vulkan/src/bind/plan/resources.rs:762 (level_views)`; `crates/metal2vulkan/src/lower/access/handle.rs:1062 (texture_target)`; `crates/metal2vulkan/src/lower/access/handle.rs:1073 (sampler_target)`; `crates/metal2vulkan/src/lower/access/handle.rs:318 (domain_kind)`; `crates/metal2vulkan/src/lower/access/imageblock.rs:175 (operand)`; `crates/metal2vulkan/src/lower/access/mod.rs:571 (not_lowered)`; `crates/metal2vulkan/src/lower/access/pulled.rs:76 (share)`; `crates/metal2vulkan/src/lower/arith/legal.rs:53 (not_lowered)`; `crates/metal2vulkan/src/lower/dispatch.rs:114 (not_lowered)`; `crates/metal2vulkan/src/lower/fragment/discard.rs:144 (not_lowered)`; `crates/metal2vulkan/src/lower/fragment/discard.rs:653 (plan)`; `crates/metal2vulkan/src/lower/fragment/mod.rs:123 (not_lowered)`; `crates/metal2vulkan/src/lower/fragment/snapshot.rs:168 (finish)`; `crates/metal2vulkan/src/lower/mesh/mod.rs:151 (not_lowered)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs:126 (not_lowered)`; `crates/metal2vulkan/src/lower/sampler/mod.rs:212 (refuse)`; `crates/metal2vulkan/src/lower/sampler/select.rs:30 (refuse)`; `crates/metal2vulkan/src/lower/select.rs:829 (not_lowered)`; `crates/metal2vulkan/src/lower/select.rs:918 (route_air)`; `crates/metal2vulkan/src/lower/simd/mod.rs:136 (not_lowered)`; `crates/metal2vulkan/src/lower/simd/mod.rs:747 (select_param)`; `crates/metal2vulkan/src/lower/simd/workgroup.rs:353 (check)`; `crates/metal2vulkan/src/lower/stage_io/fetch.rs:96 (not_lowered)`; `crates/metal2vulkan/src/lower/stage_io/mod.rs:182 (not_lowered)`; `crates/metal2vulkan/src/lower/sync/barrier.rs:72 (not_lowered)`; `crates/metal2vulkan/src/lower/sync/memory_model.rs:269 (not_implemented)`; `crates/metal2vulkan/src/lower/sync/memory_model.rs:310 (select)`; `crates/metal2vulkan/src/lower/tessellation/mod.rs:146 (not_lowered)`; `crates/metal2vulkan/src/lower/texture/mod.rs:180 (refuse)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3683 (select_write)`; `crates/metal2vulkan/src/memory/alloca.rs:54 (not_lowered)`; `crates/metal2vulkan/src/memory/leaf.rs:183 (not_lowered)`; `crates/metal2vulkan/src/memory/plan.rs:490 (not_lowered)`; `crates/metal2vulkan/src/memory/provenance.rs:665 (not_lowered)`; `crates/metal2vulkan/src/pipeline/link/tessellation/mod.rs:96 (patch_fetch_projection)` - `feature::SamplerAddressMode`: `crates/metal2vulkan/src/lower/sampler/constexpr.rs:176`; `crates/metal2vulkan/src/metal/sampler.rs:251 (check_sampler)` - `feature::AlphaToOne`: `crates/metal2vulkan/src/pipeline/link/graphics.rs:282 (graphics_state)` - `feature::StageStoresAndAtomics`: `crates/metal2vulkan/src/lower/access/tile_memory.rs:72 (written)` - `feature::FunctionConstantArgument`: `crates/metal2vulkan-air/src/canon/interface.rs:899 (absent_values)`; `crates/metal2vulkan/src/lower/access/absent.rs:100 (require)` - `feature::SamplerBicubicFilter`: `crates/metal2vulkan/src/bind/heap.rs:997 (new)`; `crates/metal2vulkan/src/bind/plan/resources.rs:1876 (bicubic_texels)`; `crates/metal2vulkan/src/bind/plan/slots.rs:503 (cubic_variant)`; `crates/metal2vulkan/src/lower/sampler/bicubic.rs:120 (refuse)`; `crates/metal2vulkan/src/lower/sampler/select.rs:35 (bicubic_refused)` -- `feature::GroupCount`: `crates/metal2vulkan/src/bind/dispatch.rs:379 (product)`; `crates/metal2vulkan/src/bind/dispatch.rs:455`; `crates/metal2vulkan/src/bind/dispatch.rs:953 (instantiate)`; `crates/metal2vulkan/src/bind/graphics.rs:3384 (mesh_draw)`; `crates/metal2vulkan/src/bind/graphics.rs:3437 (emulated_draw)` +- `feature::GroupCount`: `crates/metal2vulkan/src/bind/dispatch.rs:379 (product)`; `crates/metal2vulkan/src/bind/dispatch.rs:455`; `crates/metal2vulkan/src/bind/dispatch.rs:953 (instantiate)`; `crates/metal2vulkan/src/bind/graphics.rs:3426 (mesh_draw)`; `crates/metal2vulkan/src/bind/graphics.rs:3483 (emulated_draw)` - `feature::IntersectionFunctionTable`: `crates/metal2vulkan/src/bind/acceleration.rs:177 (geometry_table_offset)`; `crates/metal2vulkan/src/bind/acceleration.rs:183 (geometry_table_offset)`; `crates/metal2vulkan/src/bind/acceleration.rs:188 (geometry_table_offset)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs:1222 (null_table)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs:1251 (intersect)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs:1272 (intersect)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs:406 (table_of)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs:422 (select_table)`; `crates/metal2vulkan/src/lower/select.rs:885 (route_air)` -- `feature::IndependentBlending`: `crates/metal2vulkan-runtime/src/render.rs:2173 (check_pipeline)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:1017 (uniform_blend)` +- `feature::IndependentBlending`: `crates/metal2vulkan-runtime/src/render.rs:2174 (check_pipeline)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:1017 (uniform_blend)` - `feature::RasterSampleCount`: `crates/metal2vulkan-runtime/src/families/limits.rs:1063 (sample_count)`; `crates/metal2vulkan/src/pipeline/graphics.rs:563 (sample_count_properties)` - `feature::TriangleFillLines`: `crates/metal2vulkan/src/metal/state.rs:347 (polygon_mode)` - `feature::DepthClipClamp`: `crates/metal2vulkan/src/metal/state.rs:363 (depth_clamp_enable)` @@ -391,11 +393,11 @@ Each refusal's sites, with the function that builds it. - `feature::SparseTexture`: `crates/metal2vulkan/src/bind/plan/slots.rs:583 (check_sparse_textures)`; `crates/metal2vulkan/src/bind/plan/slots.rs:607 (check_sparse_textures)` - `feature::TextureSize`: `crates/metal2vulkan-runtime/src/image_plan.rs:1196 (check_image_limits)` - `feature::TextureSampleCount`: `crates/metal2vulkan-runtime/src/image_plan.rs:1244 (check_image_limits)`; `crates/metal2vulkan-runtime/src/image_plan.rs:598 (plan_held)`; `crates/metal2vulkan-runtime/src/image_plan.rs:608 (plan_held)` -- `feature::TextureView`: `crates/metal2vulkan-runtime/src/binding_view.rs:156 (binding_view)`; `crates/metal2vulkan-runtime/src/texture.rs:5180 (view)`; `crates/metal2vulkan-runtime/src/texture/decoded_twin.rs:1427 (make_second_twin)`; `crates/metal2vulkan-runtime/src/texture/view_shadow.rs:298 (apart_refusal)`; `crates/metal2vulkan-runtime/src/view_plan.rs:433 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:483 (check_view)`; `crates/metal2vulkan-runtime/src/view_plan.rs:505 (check_view)` -- `feature::TextureSwizzle`: `crates/metal2vulkan-runtime/src/binding_view.rs:167 (binding_view)`; `crates/metal2vulkan-runtime/src/texture.rs:998 (may_view)`; `crates/metal2vulkan/src/bind/plan/resources.rs:1102 (plain_texture)`; `crates/metal2vulkan/src/lower/sampler/select.rs:2587 (select_one)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3409 (select_read_as)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3756 (select_write)`; `crates/metal2vulkan/src/lower/texture/slice.rs:307 (select)` -- `feature::MipmapGeneration`: `crates/metal2vulkan-runtime/src/blit_texture.rs:1890 (mipmaps)`; `crates/metal2vulkan-runtime/src/mipmap_pick.rs:37 (pick_mipmaps)`; `crates/metal2vulkan-runtime/src/mipmap_plan.rs:262 (plan_mipmaps)`; `crates/metal2vulkan-runtime/src/mipmap_plan.rs:270 (plan_mipmaps)`; `crates/metal2vulkan-runtime/src/mipmap_plan.rs:275 (plan_mipmaps)`; `crates/metal2vulkan-runtime/src/mipmap_plan.rs:304 (plan_mipmaps)`; `crates/metal2vulkan/src/bind/mipmap_filter.rs:973 (mipmap_filter_module)` +- `feature::TextureView`: `crates/metal2vulkan-runtime/src/binding_view.rs:156 (binding_view)`; `crates/metal2vulkan-runtime/src/texture.rs:5136 (view)`; `crates/metal2vulkan-runtime/src/texture/decoded_twin.rs:1427 (make_second_twin)`; `crates/metal2vulkan-runtime/src/texture/view_shadow.rs:298 (apart_refusal)`; `crates/metal2vulkan-runtime/src/view_plan.rs:433 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:483 (check_view)`; `crates/metal2vulkan-runtime/src/view_plan.rs:505 (check_view)` +- `feature::TextureSwizzle`: `crates/metal2vulkan-runtime/src/binding_view.rs:167 (binding_view)`; `crates/metal2vulkan-runtime/src/texture.rs:996 (may_view)`; `crates/metal2vulkan/src/bind/plan/resources.rs:1102 (plain_texture)`; `crates/metal2vulkan/src/lower/sampler/select.rs:2587 (select_one)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3409 (select_read_as)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3756 (select_write)`; `crates/metal2vulkan/src/lower/texture/slice.rs:307 (select)` +- `feature::MipmapGeneration`: `crates/metal2vulkan-runtime/src/blit_texture.rs:1818 (mipmaps)`; `crates/metal2vulkan-runtime/src/mipmap_pick.rs:37 (pick_mipmaps)`; `crates/metal2vulkan-runtime/src/mipmap_plan.rs:262 (plan_mipmaps)`; `crates/metal2vulkan-runtime/src/mipmap_plan.rs:270 (plan_mipmaps)`; `crates/metal2vulkan-runtime/src/mipmap_plan.rs:275 (plan_mipmaps)`; `crates/metal2vulkan-runtime/src/mipmap_plan.rs:304 (plan_mipmaps)`; `crates/metal2vulkan/src/bind/mipmap_filter.rs:973 (mipmap_filter_module)` - `feature::HostMemory`: `crates/metal2vulkan-runtime/src/host_memory.rs:430 (not_importable)`; `crates/metal2vulkan-runtime/src/host_memory.rs:470 (refuse_unwritable)`; `crates/metal2vulkan-runtime/src/host_memory.rs:689 (new)`; `crates/metal2vulkan-runtime/src/host_memory.rs:694 (new)`; `crates/metal2vulkan-runtime/src/host_memory.rs:712 (new)` -- `feature::GpuTimes`: `crates/metal2vulkan-runtime/src/command_buffer/mod.rs:2854 (gpu_times)` +- `feature::GpuTimes`: `crates/metal2vulkan-runtime/src/command_buffer/mod.rs:2793 (gpu_times)` - `feature::CountingVisibility`: `crates/metal2vulkan-runtime/src/visibility.rs:452 (check_mode)` - `feature::ViewFormatReinterpretation`: `crates/metal2vulkan-runtime/src/view_plan.rs:570 (reinterpretation_refused)` - `feature::SeparateMultisampledDepthStencil`: `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:188 (sampled_candidate)`; `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:294 (by_draws)`; `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:336 (scratch)`; `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:376 (scratch)`; `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:777 (plan)`; `crates/metal2vulkan-runtime/src/nan_clear.rs:658 (nan_write)`; `crates/metal2vulkan-runtime/src/texture/signed_depth.rs:191 (sample_strip)` @@ -403,50 +405,51 @@ Each refusal's sites, with the function that builds it. - `feature::CentroidVarying`: `crates/metal2vulkan/src/pipeline/link/graphics.rs:801 (split_pixel_fragments)` - `feature::PrivateMemory`: `crates/metal2vulkan/src/lower/select.rs:1171 (function_storage)` - `feature::SparseTextures`: `crates/metal2vulkan-runtime/src/sparse/texture.rs:32 (sparse_refusal)` +- `feature::SparseMapping`: `crates/metal2vulkan-runtime/src/sparse/encoder.rs:469 (splits_a_unit)` - `feature::TimelineSemaphores`: `crates/metal2vulkan-runtime/src/device/create.rs:1115 (timeline_difference)` - `feature::Reflection`: `crates/metal2vulkan/src/bind/argument_buffer.rs:626 (unmeasured)`; `crates/metal2vulkan/src/reflection/derive.rs:178 (specialized_reads)`; `crates/metal2vulkan/src/reflection/derive.rs:212 (read_attributes)`; `crates/metal2vulkan/src/reflection/derive.rs:239 (gap_at)`; `crates/metal2vulkan/src/reflection/function.rs:172 (unmeasured)`; `crates/metal2vulkan/src/reflection/function.rs:366 (attribute)`; `crates/metal2vulkan/src/reflection/function.rs:437 (module_constants)`; `crates/metal2vulkan/src/reflection/linked.rs:125 (function)`; `crates/metal2vulkan/src/reflection/mod.rs:249 (stage)` -- `feature::HeapTextureTiling`: `crates/metal2vulkan-runtime/src/texture/heap.rs:630 (tiling_refusal)` +- `feature::HeapTextureTiling`: `crates/metal2vulkan-runtime/src/texture/heap.rs:628 (tiling_refusal)` - `feature::ViewportDepthRange`: `crates/metal2vulkan-runtime/src/render_state.rs:1216 (depth_ranges_refused)` - `feature::UndeclaredTextureUsage`: `crates/metal2vulkan-runtime/src/binding_view.rs:141 (binding_view)`; `crates/metal2vulkan-runtime/src/texture/usage_shadow.rs:72 (refused)` -- `feature::RenderTargetSize`: `crates/metal2vulkan-runtime/src/render_pass.rs:1275 (framebuffer_fits)` +- `feature::RenderTargetSize`: `crates/metal2vulkan-runtime/src/render_pass.rs:1271 (framebuffer_fits)` - `feature::IndirectRenderState`: `crates/metal2vulkan/src/lower/access/encode.rs:568 (select_command)` - `feature::GlobalBuiltinInFragment`: `crates/metal2vulkan/src/lower/select.rs:912 (route_air)` - `feature::PrivateRenderState`: `crates/metal2vulkan/src/bind/heap.rs:1300 (array)`; `crates/metal2vulkan/src/bind/plan/resources.rs:887 (write_rounding)`; `crates/metal2vulkan/src/lower/sampler/select.rs:2710 (clamps_reference)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:3438 (alpha_test_refused)`; `crates/metal2vulkan/src/lower/texture/mod.rs:2920 (mode_rounded_write)`; `crates/metal2vulkan/src/pipeline/private_state.rs:378 (logic_operation)`; `crates/metal2vulkan/src/pipeline/private_state.rs:97 (refused)` -- `feature::ExtendedRangeBlend`: `crates/metal2vulkan/src/lower/arith/extended_range/blend.rs:305 (refused)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1578 (plan)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1581 (plan)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1658 (plan)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1661 (plan)`; `crates/metal2vulkan/src/lower/fragment/input_blend.rs:153 (plan)` +- `feature::ExtendedRangeBlend`: `crates/metal2vulkan/src/lower/arith/extended_range/blend.rs:305 (refused)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1629 (plan)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1632 (plan)`; `crates/metal2vulkan/src/lower/fragment/input_blend.rs:153 (plan)` - `feature::TileReach`: `crates/metal2vulkan/src/bind/tile_reach.rs:270 (tile_reach_module)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:2517 (capture)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:2543 (capture)` - `feature::ProgramScopeBinding`: `crates/metal2vulkan-air/src/abi/module.rs:77 (decode)`; `crates/metal2vulkan/src/error/mod.rs:267 (from)` - `feature::SeqCstFence`: `crates/metal2vulkan/src/lower/sync/barrier.rs:443 (require_seq_cst)` - `feature::PostDepthCoverage`: `crates/metal2vulkan-runtime/src/families/features.rs:1219 (state)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:783 (param)` -- `gap::Textures`: `crates/metal2vulkan-runtime/src/blit_texture.rs:163 (check_depth_view)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:1563 (view_usage)`; `crates/metal2vulkan-runtime/src/pipeline/mod.rs:1625 (compile_error)`; `crates/metal2vulkan-runtime/src/texture.rs:1463 (image_error)`; `crates/metal2vulkan-runtime/src/texture.rs:2257 (storage_over_buffer)`; `crates/metal2vulkan-runtime/src/texture.rs:3077 (new_image_starting)`; `crates/metal2vulkan-runtime/src/texture.rs:4122 (image)`; `crates/metal2vulkan-runtime/src/texture.rs:5747 (host_copy)`; `crates/metal2vulkan-runtime/src/texture/surface_two_planes.rs:207 (new_surface_planes_texture)` +- `gap::Textures`: `crates/metal2vulkan-runtime/src/blit_texture.rs:163 (check_depth_view)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:1563 (view_usage)`; `crates/metal2vulkan-runtime/src/pipeline/mod.rs:1625 (compile_error)`; `crates/metal2vulkan-runtime/src/texture.rs:1461 (image_error)`; `crates/metal2vulkan-runtime/src/texture.rs:2221 (storage_over_buffer)`; `crates/metal2vulkan-runtime/src/texture.rs:3036 (new_image_starting)`; `crates/metal2vulkan-runtime/src/texture.rs:4078 (image)`; `crates/metal2vulkan-runtime/src/texture.rs:5689 (host_copy)`; `crates/metal2vulkan-runtime/src/texture/surface_two_planes.rs:207 (new_surface_planes_texture)` - `gap::ResourceHeap`: `crates/metal2vulkan-runtime/src/binding.rs:1982 (descriptor)` -- `gap::SparseHeaps`: `crates/metal2vulkan-runtime/src/sparse/encoder.rs:440 (first_slice)`; `crates/metal2vulkan-runtime/src/texture.rs:1684 (plan_sparse_texture)`; `crates/metal2vulkan-runtime/src/texture.rs:4870 (make_aliasable)` -- `gap::SparseTileMaps`: `crates/metal2vulkan-runtime/src/binding.rs:562 (slot_tile_map)`; `crates/metal2vulkan-runtime/src/sparse/texture.rs:30 (sparse_refusal)`; `crates/metal2vulkan-runtime/src/texture.rs:1742 (sparse_zeroing)`; `crates/metal2vulkan-runtime/src/texture.rs:1746 (sparse_zeroing)` +- `gap::SparseHeaps`: `crates/metal2vulkan-runtime/src/sparse/encoder.rs:461 (first_slice)`; `crates/metal2vulkan-runtime/src/texture.rs:1674 (plan_sparse_texture)`; `crates/metal2vulkan-runtime/src/texture.rs:4826 (make_aliasable)` +- `gap::SparseTileMaps`: `crates/metal2vulkan-runtime/src/binding.rs:562 (slot_tile_map)`; `crates/metal2vulkan-runtime/src/sparse/texture.rs:30 (sparse_refusal)`; `crates/metal2vulkan-runtime/src/texture.rs:1707 (plan_sparse_texture)` - `gap::HeapPastMaxBufferSize`: `crates/metal2vulkan-runtime/src/heap.rs:714 (heap_size)` -- `gap::HeapTextureAlignment`: `crates/metal2vulkan-runtime/src/texture/heap.rs:1071 (check_heap_base)` -- `gap::HeapTextureMemory`: `crates/metal2vulkan-runtime/src/texture/heap.rs:1510 (heap_plan)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:1517 (heap_plan)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2059 (host_heap_plan)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2291 (memory_shadow)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:554 (memory_refusal)` +- `gap::HeapTextureAlignment`: `crates/metal2vulkan-runtime/src/texture/heap.rs:1069 (check_heap_base)` +- `gap::HeapTextureMemory`: `crates/metal2vulkan-runtime/src/texture/heap.rs:1508 (heap_plan)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:1515 (heap_plan)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2057 (host_heap_plan)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2289 (memory_shadow)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:552 (memory_refusal)` - `gap::FunctionTablePastMaxBufferLength`: `crates/metal2vulkan-runtime/src/function_table.rs:622 (past_limit)` -- `gap::IndirectCommandBufferPastMaxBufferLength`: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs:523 (new_indirect_command_buffer)` -- `gap::IndirectRenderCommands`: `crates/metal2vulkan-runtime/src/compute.rs:1291 (execute_range)`; `crates/metal2vulkan-runtime/src/compute.rs:1376 (execute_indirect_range)`; `crates/metal2vulkan-runtime/src/depth_stencil.rs:85 (gpu_resource_id)`; `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs:4422 (render_state)`; `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs:518 (new_indirect_command_buffer)`; `crates/metal2vulkan-runtime/src/pipeline/mod.rs:1632 (compile_error)`; `crates/metal2vulkan-runtime/src/render.rs:7196 (draw_resident)`; `crates/metal2vulkan-runtime/src/render.rs:7731 (draw_resident)`; `crates/metal2vulkan-runtime/src/render.rs:8188 (draw_resident)`; `crates/metal2vulkan-runtime/src/render.rs:8738 (draw_resident)`; `crates/metal2vulkan-runtime/src/render/executions.rs:1126 (back_memoryless)`; `crates/metal2vulkan-runtime/src/render/executions.rs:2941 (record_forms)`; `crates/metal2vulkan-runtime/src/render/executions.rs:393 (execute_range)`; `crates/metal2vulkan-runtime/src/render/executions.rs:461 (execute_indirect_range)`; `crates/metal2vulkan-runtime/src/render/executions.rs:476 (execute_indirect_range)` -- `gap::IndirectImageblockSize`: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs:3397 (set_imageblock_size)` +- `gap::IndirectCommandBufferPastMaxBufferLength`: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs:522 (new_indirect_command_buffer)` +- `gap::IndirectRenderCommands`: `crates/metal2vulkan-runtime/src/compute.rs:1144 (execute_range)`; `crates/metal2vulkan-runtime/src/compute.rs:1225 (execute_indirect_range)`; `crates/metal2vulkan-runtime/src/depth_stencil.rs:85 (gpu_resource_id)`; `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs:4358 (render_state)`; `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs:517 (new_indirect_command_buffer)`; `crates/metal2vulkan-runtime/src/pipeline/mod.rs:1632 (compile_error)`; `crates/metal2vulkan-runtime/src/render.rs:7197 (draw_resident)`; `crates/metal2vulkan-runtime/src/render.rs:7691 (draw_resident)`; `crates/metal2vulkan-runtime/src/render.rs:8148 (draw_resident)`; `crates/metal2vulkan-runtime/src/render.rs:8697 (draw_resident)`; `crates/metal2vulkan-runtime/src/render/executions.rs:1106 (back_memoryless)`; `crates/metal2vulkan-runtime/src/render/executions.rs:2057 (record)`; `crates/metal2vulkan-runtime/src/render/executions.rs:2906 (record_forms)`; `crates/metal2vulkan-runtime/src/render/executions.rs:382 (execute_range)`; `crates/metal2vulkan-runtime/src/render/executions.rs:441 (execute_indirect_range)`; `crates/metal2vulkan-runtime/src/render/executions.rs:456 (execute_indirect_range)` +- `gap::IndirectImageblockSize`: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs:3363 (set_imageblock_size)` - `gap::CommandReplay`: `crates/metal2vulkan-runtime/src/binding.rs:723 (bind_into)`; `crates/metal2vulkan-runtime/src/binding.rs:726 (bind_into)` - `gap::RenderAttachments`: `crates/metal2vulkan-runtime/src/binding.rs:1794 (unexpected)` - `gap::AccelerationStructures`: `crates/metal2vulkan-runtime/src/binding.rs:1797 (unexpected)` - `gap::FeatureEnable`: `crates/metal2vulkan-runtime/src/enables.rs:1166 (of)` - `gap::ExtensionEnable`: `crates/metal2vulkan-runtime/src/enables.rs:1157 (of)` -- `gap::Render`: `crates/metal2vulkan-runtime/src/attachment_stand_in.rs:404 (stand_in_as)`; `crates/metal2vulkan-runtime/src/attachment_stand_in.rs:460 (stand_in_as)`; `crates/metal2vulkan-runtime/src/attachment_stand_in.rs:684 (check_copies)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:796 (attachment_twin)`; `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:283 (check_sizes)`; `crates/metal2vulkan-runtime/src/kept_bytes.rs:138 (settle)`; `crates/metal2vulkan-runtime/src/linear_attachment.rs:293 (settle)`; `crates/metal2vulkan-runtime/src/nan_clear.rs:204 (plan)`; `crates/metal2vulkan-runtime/src/pipeline/render.rs:1169 (imageblock_sample_length)`; `crates/metal2vulkan-runtime/src/render.rs:2223 (check_pipeline)`; `crates/metal2vulkan-runtime/src/render.rs:5940 (next_instance)`; `crates/metal2vulkan-runtime/src/render.rs:7825 (draw_resident)`; `crates/metal2vulkan-runtime/src/render/tile_dispatch.rs:516 (scratch)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1317 (layout)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1680 (target)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1734 (target)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1795 (attachment_format)`; `crates/metal2vulkan-runtime/src/render_pass.rs:2028 (depth_stencil)`; `crates/metal2vulkan-runtime/src/resolve.rs:1035 (attach)`; `crates/metal2vulkan-runtime/src/resolve.rs:1103 (color_copy)`; `crates/metal2vulkan-runtime/src/resolve.rs:1150 (destination)`; `crates/metal2vulkan-runtime/src/resolve.rs:1167 (destination)`; `crates/metal2vulkan-runtime/src/resolve.rs:1232 (destination)` +- `gap::Render`: `crates/metal2vulkan-runtime/src/attachment_stand_in.rs:404 (stand_in_as)`; `crates/metal2vulkan-runtime/src/attachment_stand_in.rs:460 (stand_in_as)`; `crates/metal2vulkan-runtime/src/attachment_stand_in.rs:684 (check_copies)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:796 (attachment_twin)`; `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:283 (check_sizes)`; `crates/metal2vulkan-runtime/src/kept_bytes.rs:138 (settle)`; `crates/metal2vulkan-runtime/src/linear_attachment.rs:293 (settle)`; `crates/metal2vulkan-runtime/src/nan_clear.rs:204 (plan)`; `crates/metal2vulkan-runtime/src/pipeline/render.rs:1169 (imageblock_sample_length)`; `crates/metal2vulkan-runtime/src/render.rs:2224 (check_pipeline)`; `crates/metal2vulkan-runtime/src/render.rs:5941 (next_instance)`; `crates/metal2vulkan-runtime/src/render.rs:7785 (draw_resident)`; `crates/metal2vulkan-runtime/src/render/tile_dispatch.rs:516 (scratch)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1313 (layout)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1676 (target)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1730 (target)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1791 (attachment_format)`; `crates/metal2vulkan-runtime/src/render_pass.rs:2024 (depth_stencil)`; `crates/metal2vulkan-runtime/src/resolve.rs:1035 (attach)`; `crates/metal2vulkan-runtime/src/resolve.rs:1103 (color_copy)`; `crates/metal2vulkan-runtime/src/resolve.rs:1150 (destination)`; `crates/metal2vulkan-runtime/src/resolve.rs:1167 (destination)`; `crates/metal2vulkan-runtime/src/resolve.rs:1232 (destination)` - `gap::TexelsPastBufferLength`: `crates/metal2vulkan-runtime/src/buffer_texture.rs:261 (refusal_error)`; `crates/metal2vulkan-runtime/src/texture/surface_depth.rs:105 (surface_depth_twin)` - `gap::OverlappingSurfaceRows`: `crates/metal2vulkan-runtime/src/buffer_texture.rs:263 (refusal_error)` -- `gap::SamplePositionsAtBegin`: `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:145 (stencil_scratch)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1865 (positioned_stand_in)`; `crates/metal2vulkan-runtime/src/sample_positions.rs:185 (grid)` +- `gap::SamplePositionsAtBegin`: `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:145 (stencil_scratch)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1861 (positioned_stand_in)`; `crates/metal2vulkan-runtime/src/sample_positions.rs:185 (grid)` - `gap::SharedEventAcrossDevices`: `crates/metal2vulkan-runtime/src/event.rs:385 (new_shared_event_with_handle)` - `gap::ViewportDepthRange`: `crates/metal2vulkan-runtime/src/render/draw_shape.rs:341 (settings)`; `crates/metal2vulkan-runtime/src/render_state.rs:1039`; `crates/metal2vulkan-runtime/src/render_state.rs:1208 (depth_ranges_refused)`; `crates/metal2vulkan-runtime/src/render_state.rs:1575 (bias_holds)`; `crates/metal2vulkan-runtime/src/render_state.rs:1594 (collapses)`; `crates/metal2vulkan-runtime/src/render_state.rs:527 (depth_range)`; `crates/metal2vulkan-runtime/src/render_state.rs:755 (compensation)` - `gap::NonFiniteDepthBias`: `crates/metal2vulkan-runtime/src/render_state.rs:1603 (collapses)`; `crates/metal2vulkan-runtime/src/render_state.rs:1606 (collapses)`; `crates/metal2vulkan-runtime/src/render_state.rs:365 (set_depth_bias)`; `crates/metal2vulkan-runtime/src/render_state.rs:463 (draw_viewports)`; `crates/metal2vulkan-runtime/src/render_state.rs:605 (compensation)` - `gap::DepthNeverWithoutAttachment`: `crates/metal2vulkan-runtime/src/depth_stencil.rs:147 (failing_draw)` -- `gap::HiddenDepthStencil`: `crates/metal2vulkan-runtime/src/attachment_stand_in.rs:563 (hidden)`; `crates/metal2vulkan-runtime/src/render.rs:6617 (hidden_depth_stencil)` -- `gap::IndirectDrawArguments`: `crates/metal2vulkan-runtime/src/index_bounds.rs:91 (new)`; `crates/metal2vulkan-runtime/src/render.rs:3302 (draw_indexed_primitives_indirect)`; `crates/metal2vulkan-runtime/src/render.rs:7521 (draw_resident)`; `crates/metal2vulkan-runtime/src/render.rs:7635 (draw_resident)`; `crates/metal2vulkan-runtime/src/render.rs:7666 (draw_resident)` +- `gap::HiddenDepthStencil`: `crates/metal2vulkan-runtime/src/attachment_stand_in.rs:563 (hidden)`; `crates/metal2vulkan-runtime/src/render.rs:6618 (hidden_depth_stencil)` +- `gap::IndirectDrawArguments`: `crates/metal2vulkan-runtime/src/index_bounds.rs:91 (new)`; `crates/metal2vulkan-runtime/src/render.rs:3303 (draw_indexed_primitives_indirect)`; `crates/metal2vulkan-runtime/src/render.rs:7526 (draw_resident)`; `crates/metal2vulkan-runtime/src/render.rs:7595 (draw_resident)`; `crates/metal2vulkan-runtime/src/render.rs:7626 (draw_resident)` - `gap::DepthStencilResolve`: `crates/metal2vulkan-runtime/src/depth_stencil_resolve.rs:441 (draws_run)`; `crates/metal2vulkan-runtime/src/resolve.rs:1388 (plan)`; `crates/metal2vulkan-runtime/src/resolve.rs:787 (depth_stencil)`; `crates/metal2vulkan-runtime/src/resolve.rs:885 (steps)`; `crates/metal2vulkan-runtime/src/resolve.rs:905 (steps)`; `crates/metal2vulkan-runtime/src/resolve.rs:946 (split_steps)`; `crates/metal2vulkan-runtime/src/resolve.rs:958 (split_steps)` -- `gap::TileAtSampleCount`: `crates/metal2vulkan-runtime/src/render_pass.rs:1615 (layout)`; `crates/metal2vulkan-runtime/src/render_pass.rs:937` -- `gap::ImageblockMasters`: `crates/metal2vulkan-runtime/src/render.rs:7350 (draw_resident)`; `crates/metal2vulkan-runtime/src/render/tile_dispatch.rs:929 (dispatch_tiles_resident)` -- `gap::TileAndFragmentImageblocks`: `crates/metal2vulkan-runtime/src/render.rs:7342 (draw_resident)`; `crates/metal2vulkan-runtime/src/render/tile_dispatch.rs:796 (dispatch_tiles_resident)`; `crates/metal2vulkan-runtime/src/render/tile_dispatch.rs:921 (dispatch_tiles_resident)` +- `gap::TileAtSampleCount`: `crates/metal2vulkan-runtime/src/render_pass.rs:1611 (layout)`; `crates/metal2vulkan-runtime/src/render_pass.rs:937` +- `gap::ImageblockMasters`: `crates/metal2vulkan-runtime/src/render.rs:7351 (draw_resident)`; `crates/metal2vulkan-runtime/src/render/tile_dispatch.rs:929 (dispatch_tiles_resident)` +- `gap::TileAndFragmentImageblocks`: `crates/metal2vulkan-runtime/src/render.rs:7343 (draw_resident)`; `crates/metal2vulkan-runtime/src/render/tile_dispatch.rs:796 (dispatch_tiles_resident)`; `crates/metal2vulkan-runtime/src/render/tile_dispatch.rs:921 (dispatch_tiles_resident)` - `gap::Metal4Api`: `crates/metal2vulkan-runtime/src/families/features.rs:1487 (state)`; `crates/metal2vulkan-runtime/src/families/limits.rs:1026 (state)`; `crates/metal2vulkan-runtime/src/families/mod.rs:362 (audit)` - `gap::CounterSampleBuffers`: `crates/metal2vulkan-runtime/src/families/limits.rs:1017 (state)` - `gap::ResidencySets`: `crates/metal2vulkan-runtime/src/families/features.rs:1469 (state)`; `crates/metal2vulkan-runtime/src/families/limits.rs:1019 (state)` @@ -461,39 +464,40 @@ Each refusal's sites, with the function that builds it. - `gap::RateMapRegions`: `crates/metal2vulkan-runtime/src/rate_mapped_pass.rs:349 (refusal)` - `gap::LayeredPass`: `crates/metal2vulkan-runtime/src/color_resolve.rs:890 (plan)` - `gap::FunctionOptions`: `crates/metal2vulkan-runtime/src/library.rs:215 (new_function_with_descriptor)` -- `gap::OverlappingTextureCopies`: `crates/metal2vulkan-runtime/src/blit_texture.rs:1340 (texture_copies_of_bytes)` -- `gap::RebindTextures`: `crates/metal2vulkan-runtime/src/buffer_descriptor.rs:637 (rebind_host_pages)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2739 (rebound_heap_images)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2754 (rebound_heap_images)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2765 (rebound_heap_images)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2808 (dma_buf_heap_images_again)` -- `gap::PvrtcBlockOrder`: `crates/metal2vulkan-runtime/src/texture.rs:5819 (host_copy)` -- `gap::DecodedHeapTexture`: `crates/metal2vulkan-runtime/src/texture.rs:1692 (plan_sparse_texture)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:1373 (heap_plan)` +- `gap::OverlappingTextureCopies`: `crates/metal2vulkan-runtime/src/blit_texture.rs:1273 (texture_copies_of_bytes)` +- `gap::RebindTextures`: `crates/metal2vulkan-runtime/src/buffer_descriptor.rs:637 (rebind_host_pages)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2724 (rebound_heap_images)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2739 (rebound_heap_images)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2750 (rebound_heap_images)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2793 (dma_buf_heap_images_again)` +- `gap::PvrtcBlockOrder`: `crates/metal2vulkan-runtime/src/texture.rs:5761 (host_copy)` +- `gap::DecodedHeapTexture`: `crates/metal2vulkan-runtime/src/texture.rs:1682 (plan_sparse_texture)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:1371 (heap_plan)` - `gap::VertexFetchPast4GiB`: `crates/metal2vulkan-runtime/src/render/vertex_reach.rs:72 (check_vertex_reach)` - `gap::StageInFetchPast4GiB`: `crates/metal2vulkan-runtime/src/fetch_reach.rs:126 (check_stage_in_reach)` - `gap::MappedTextureSampling`: `crates/metal2vulkan-runtime/src/address_map.rs:158 (resolve)` - `gap::LibrarySource`: `crates/metal2vulkan-runtime/src/library.rs:107 (new_library_with_source)` - `gap::RestartedStrip`: `crates/metal2vulkan-runtime/src/render/restart.rs:71 (gap)` -- `gap::PrivatePrimitives`: `crates/metal2vulkan-runtime/src/render.rs:8026 (draw_resident)`; `crates/metal2vulkan-runtime/src/render/restart.rs:72 (gap)` +- `gap::PrivatePrimitives`: `crates/metal2vulkan-runtime/src/render.rs:7986 (draw_resident)`; `crates/metal2vulkan-runtime/src/render/restart.rs:72 (gap)` - `gap::ProvokingVertex`: `crates/metal2vulkan-runtime/src/render/restart.rs:73 (gap)` -- `gap::PrimitiveIdIndices`: `crates/metal2vulkan-runtime/src/render.rs:8036 (draw_resident)` -- `gap::RotatedTexture`: `crates/metal2vulkan-runtime/src/blit_texture.rs:1669 (texel_copies)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:715 (turned_plane)`; `crates/metal2vulkan-runtime/src/rotated.rs:185 (new)`; `crates/metal2vulkan-runtime/src/rotated.rs:201 (new)`; `crates/metal2vulkan-runtime/src/shadow.rs:643 (unmerged)`; `crates/metal2vulkan-runtime/src/texture.rs:5138 (view)`; `crates/metal2vulkan-runtime/src/texture/rotation.rs:100 (check_rotated_reach)`; `crates/metal2vulkan-runtime/src/texture/rotation.rs:322 (copied_image)`; `crates/metal2vulkan-runtime/src/texture/usage_shadow.rs:238 (new_usage_shadow)` -- `gap::DetachTextures`: `crates/metal2vulkan-runtime/src/buffer_descriptor.rs:641 (rebind_host_pages)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:622 (make_texture_over)`; `crates/metal2vulkan-runtime/src/detach.rs:172 (detach_host_pages)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2948 (heap_texture_at)`; `crates/metal2vulkan-runtime/src/texture/stand_in.rs:143 (new_stand_in)`; `crates/metal2vulkan-runtime/src/texture/stand_in.rs:248 (stand_in_while_detached)`; `crates/metal2vulkan-runtime/src/texture/stand_in.rs:298 (stand_ins)`; `crates/metal2vulkan-runtime/src/texture/stand_in.rs:304 (stand_ins)` +- `gap::PrimitiveIdIndices`: `crates/metal2vulkan-runtime/src/render.rs:7996 (draw_resident)` +- `gap::RotatedTexture`: `crates/metal2vulkan-runtime/src/blit_texture.rs:1602 (texel_copies)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:715 (turned_plane)`; `crates/metal2vulkan-runtime/src/rotated.rs:185 (new)`; `crates/metal2vulkan-runtime/src/rotated.rs:201 (new)`; `crates/metal2vulkan-runtime/src/shadow.rs:642 (unmerged)`; `crates/metal2vulkan-runtime/src/texture.rs:5094 (view)`; `crates/metal2vulkan-runtime/src/texture/rotation.rs:100 (check_rotated_reach)`; `crates/metal2vulkan-runtime/src/texture/rotation.rs:322 (copied_image)`; `crates/metal2vulkan-runtime/src/texture/usage_shadow.rs:238 (new_usage_shadow)` +- `gap::DetachTextures`: `crates/metal2vulkan-runtime/src/buffer_descriptor.rs:641 (rebind_host_pages)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:622 (make_texture_over)`; `crates/metal2vulkan-runtime/src/detach.rs:172 (detach_host_pages)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2933 (heap_texture_at)`; `crates/metal2vulkan-runtime/src/texture/stand_in.rs:143 (new_stand_in)`; `crates/metal2vulkan-runtime/src/texture/stand_in.rs:248 (stand_in_while_detached)`; `crates/metal2vulkan-runtime/src/texture/stand_in.rs:298 (stand_ins)`; `crates/metal2vulkan-runtime/src/texture/stand_in.rs:304 (stand_ins)` - `gap::TextureBufferLevels`: `crates/metal2vulkan-runtime/src/texture_descriptor.rs:540 (check_made)` - `gap::WriteSwizzle`: `crates/metal2vulkan-runtime/src/texture_descriptor.rs:547 (check_made)` -- `gap::DetachedTexelAccess`: `crates/metal2vulkan-runtime/src/texture.rs:4968 (refuse_detached_texels)` +- `gap::DetachedTexelAccess`: `crates/metal2vulkan-runtime/src/texture.rs:4924 (refuse_detached_texels)` - `gap::SurfaceDepthStencil`: `crates/metal2vulkan-runtime/src/blit_texture.rs:269 (unit)`; `crates/metal2vulkan-runtime/src/texture/surface_depth.rs:57 (surface_depth_twin)` - `gap::ExtendedRangeResolve`: `crates/metal2vulkan-runtime/src/resolve.rs:604 (color)` -- `gap::MultisampledBufferCopy`: `crates/metal2vulkan-runtime/src/blit_texture.rs:536 (copy_from_buffer_to_texture)`; `crates/metal2vulkan-runtime/src/blit_texture.rs:693 (copy_from_texture_to_buffer)` -- `gap::MultisampledBufferLayout`: `crates/metal2vulkan-runtime/src/sample_interleave.rs:1029 (plan)` +- `gap::PredicationDropsUngatedWork`: `crates/metal2vulkan-runtime/src/predication.rs:762 (unbalanced)` +- `gap::MultisampledBufferCopy`: `crates/metal2vulkan-runtime/src/blit_texture.rs:527 (copy_from_buffer_to_texture)`; `crates/metal2vulkan-runtime/src/blit_texture.rs:674 (copy_from_texture_to_buffer)` +- `gap::MultisampledBufferLayout`: `crates/metal2vulkan-runtime/src/sample_interleave.rs:1020 (plan)` - `gap::ColorAttachmentGroups`: `crates/metal2vulkan-runtime/src/render/color_groups.rs:106 (gap)` -- `apple::ProtectedContent`: `crates/metal2vulkan-runtime/src/command_buffer/mod.rs:2412 (commit_now)`; `crates/metal2vulkan-runtime/src/command_buffer/protection.rs:126 (refuse_protected_state_encoder)`; `crates/metal2vulkan-runtime/src/command_buffer/protection.rs:52 (set)` +- `apple::ProtectedContent`: `crates/metal2vulkan-runtime/src/command_buffer/mod.rs:2368 (commit_now)`; `crates/metal2vulkan-runtime/src/command_buffer/protection.rs:126 (refuse_protected_state_encoder)`; `crates/metal2vulkan-runtime/src/command_buffer/protection.rs:52 (set)` - `apple::LineWidth`: `crates/metal2vulkan-runtime/src/apple_only.rs:189 (check)` - `apple::ViewportTransformDisabled`: `crates/metal2vulkan-runtime/src/apple_only.rs:191 (check)` -- `apple::VertexAmplificationMode`: `crates/metal2vulkan-runtime/src/apple_only.rs:195 (check)`; `crates/metal2vulkan-runtime/src/apple_only.rs:320 (set_vertex_amplification_mode)` +- `apple::VertexAmplificationMode`: `crates/metal2vulkan-runtime/src/apple_only.rs:195 (check)`; `crates/metal2vulkan-runtime/src/apple_only.rs:312 (set_vertex_amplification_mode)` - `apple::SurfaceClientDirection`: `crates/metal2vulkan-runtime/src/buffer_texture.rs:417 (new_texture_with_iosurface_plane)` - `bind::DescriptorRangeExceeded`: `crates/metal2vulkan/src/bind/instantiate.rs:655 (bind_buffers)` - `bind::TexelBufferTooLarge`: `crates/metal2vulkan/src/bind/instantiate.rs:894 (texel_ranges)` - `bind::HeapTooLarge`: `crates/metal2vulkan/src/bind/heap.rs:1014 (new)`; `crates/metal2vulkan/src/bind/heap.rs:1748 (directory_bytes)`; `crates/metal2vulkan/src/bind/heap.rs:1863 (listed_sampler_tables)`; `crates/metal2vulkan/src/bind/heap.rs:1913 (placed)`; `crates/metal2vulkan/src/bind/heap.rs:2069 (heap_elements)`; `crates/metal2vulkan/src/bind/heap.rs:949 (new)`; `crates/metal2vulkan/src/bind/heap.rs:965 (new)` -- `bind::TessellationFactorRange`: `crates/metal2vulkan/src/bind/graphics.rs:3767 (patch_binding)` -- `bind::PatchIndexRange`: `crates/metal2vulkan/src/bind/graphics.rs:3811 (patch_binding)` -- `bind::ControlPointIndexRange`: `crates/metal2vulkan/src/bind/graphics.rs:3849 (patch_binding)` +- `bind::TessellationFactorRange`: `crates/metal2vulkan/src/bind/graphics.rs:3837 (patch_binding)` +- `bind::PatchIndexRange`: `crates/metal2vulkan/src/bind/graphics.rs:3881 (patch_binding)` +- `bind::ControlPointIndexRange`: `crates/metal2vulkan/src/bind/graphics.rs:3919 (patch_binding)` - `bind::MissingStageInRegion`: `crates/metal2vulkan/src/bind/dispatch.rs:796 (instantiate)` - `bind::UniformViewAliased`: `crates/metal2vulkan/src/bind/instantiate.rs:609 (check_uniform_aliasing)` - `bind::MissingDeviceAddress`: `crates/metal2vulkan/src/bind/plan/slots.rs:133 (plan_buffer)` diff --git a/scripts/metal-coverage/coverage.tsv b/scripts/metal-coverage/coverage.tsv index d07527a53..6a10f4cdf 100644 --- a/scripts/metal-coverage/coverage.tsv +++ b/scripts/metal-coverage/coverage.tsv @@ -1629,7 +1629,7 @@ MTLRenderCommandEncoder.h MTLRenderCommandEncoder method setMeshSamplerState:lod MTLRenderCommandEncoder.h MTLRenderCommandEncoder method setMeshSamplerStates:lodMinClamps:lodMaxClamps:withRange: I runtime RenderCommandEncoder::set_mesh_sampler_states MTLRenderCommandEncoder.h MTLRenderCommandEncoder method drawMeshThreadgroups:threadsPerObjectThreadgroup:threadsPerMeshThreadgroup: I runtime RenderCommandEncoder::draw_mesh_threadgroups MTLRenderCommandEncoder.h MTLRenderCommandEncoder method drawMeshThreads:threadsPerObjectThreadgroup:threadsPerMeshThreadgroup: I runtime RenderCommandEncoder::draw_mesh_threads -MTLRenderCommandEncoder.h MTLRenderCommandEncoder method drawMeshThreadgroupsWithIndirectBuffer:indirectBufferOffset:threadsPerObjectThreadgroup:threadsPerMeshThreadgroup: I runtime RenderCommandEncoder::draw_mesh_threadgroups_indirect an object grid of 2^29 threadgroups or more fails the command buffer (`MeshGridPastLimits`, as Metal's GPU fails it), and so does one past the task limits where the device does not fold object grids; refused `NotImplemented(MeshShading)` with an object function where mesh draws are emulated +MTLRenderCommandEncoder.h MTLRenderCommandEncoder method drawMeshThreadgroupsWithIndirectBuffer:indirectBufferOffset:threadsPerObjectThreadgroup:threadsPerMeshThreadgroup: I runtime RenderCommandEncoder::draw_mesh_threadgroups_indirect an object grid of more than 2^29 threadgroups draws nothing and fails the command buffer with Metal's error (`GpuRecoveryVictim`, as Metal's GPU discards it); one the device cannot launch fails it with `MeshGridPastLimits`: past the task limits where the device does not fold object grids, or, where mesh draws are emulated, past the compute limits or wrapping its threads per grid along an axis MTLRenderCommandEncoder.h MTLRenderCommandEncoder method drawPrimitives:vertexStart:vertexCount:instanceCount: I runtime RenderCommandEncoder::draw_primitives MTLRenderCommandEncoder.h MTLRenderCommandEncoder method drawPrimitives:vertexStart:vertexCount: I runtime RenderCommandEncoder::draw_primitives MTLRenderCommandEncoder.h MTLRenderCommandEncoder method drawIndexedPrimitives:indexCount:indexType:indexBuffer:indexBufferOffset:instanceCount: I runtime RenderCommandEncoder::draw_indexed_primitives diff --git a/scripts/refusal-surface/reach.tsv b/scripts/refusal-surface/reach.tsv index 8db0652b8..8907683c4 100644 --- a/scripts/refusal-surface/reach.tsv +++ b/scripts/refusal-surface/reach.tsv @@ -222,7 +222,6 @@ gap PrivatePrimitives none a draw of an Apple-private primitive type (OpenGL on gap PrimitiveIdIndices rare an indexed draw of a primitive_id pipeline, on a device without geometry or tessellation shaders, whose indices the encoder wrote since its last barrier feature PrivateRenderState none Apple-private pipeline fields of OpenGL on Metal (no public header) gap SurfaceDepthStencil rare a blit of the stencil of a Depth32Float_Stencil8 texture over a plane of an IOSurface with planes, or a pass on an X32_Stencil8 one's view as Depth32Float_Stencil8 -gap ExtendedRangeResolve rare a multisample resolve of a BGRA10_XR, BGR10_XR or sRGB twin attachment (EDR content drawn multisampled) feature ExtendedRangeBlend system the parts of a blend into an extended-range (XR10) attachment the measured model does not hold (second-source factors, the color blend color difference, a one-color-channel mask, float4 and sRGB outside the measured forms); the consumer's guests blend RGB10A8_2P_XR10 attachments feature TileReach app the tiles a pass's draws reach, binned on a device without shaderInt64 feature CommandPredication none Apple-private command predication on a device without buffer device addresses