diff --git a/crates/metal2vulkan-runtime/README.md b/crates/metal2vulkan-runtime/README.md index 970543f9d..ee776736d 100644 --- a/crates/metal2vulkan-runtime/README.md +++ b/crates/metal2vulkan-runtime/README.md @@ -796,23 +796,21 @@ state's creation waits `DevicePolicy::pipeline_creation_wait`, 4.5 s by default, pipeline it hands to the runtime's pool): the command buffer completes later, as on a slower GPU, and renders and writes what Metal's does. `commit` and every other call return as before; only calls that wait for the GPU (its completion or scheduling, an event it signals, a new command -buffer of a queue whose most are all uncompleted) wait for it. One draw is still dropped, an open -gap: a draw of an execution's replay whose making the replay waits for itself, still being -made `DevicePolicy::pipeline_commit_wait` (4.5 s by default) after the commit, runs nothing, its -command buffer running on, and the command buffers after it draw with the pipeline once made. -While it waits, another queue's command buffer committed after it goes first, even over a tracked +buffer of a queue whose most are all uncompleted) wait for it. No draw or dispatch is dropped for +its making's time. While it waits, another queue's command buffer committed after it goes first, even over a tracked resource the two share, and the waiting one runs after it, as an x86 Mac's GPU may take a later commit of another queue first; a fence the two share keeps commit order. One call so waits for the driver's makings at most: a state's creation, its creation wait; a `commit`, -until its commit plus its commit wait, for a pass that executes render commands the CPU writes, -which it leaves to its host step past that (the commit records there only what it can); neither +until its commit plus its commit wait (`DevicePolicy::pipeline_commit_wait`, 4.5 s by default), +for a pass that executes render commands the CPU writes, its pipelines and those its executions' +replay begins itself, which it leaves to its host step past that (the commit records there only +what it can; the step records the pass once they are made, and waits on its own thread for a +making it begins itself); neither waits on the other's bound, so a host step that creates a state and commits waits 9 s at most by default. Made until made under either value, in the call that makes them: a draw that records nothing, a draw in a pass of custom sample positions or recorded again into another instance of its pass (in the draw's call or an execution's replay), a device replay's draws -(in its `commit`), and a making that failed, made again by its command's recording. The open gap's -draw is named by `dropped_draw` with the error `VK_TIMEOUT`, counted: -`WorkCounts::draws_dropped_still_making`, announced `draw-dropped-still-making`. +(in its `commit`), and a making that failed, made again by its command's recording. `PipelineWaitPolicy::Exact` waits until the pipeline is made, the creation too. ## A lost device diff --git a/crates/metal2vulkan-runtime/src/command_buffer/mod.rs b/crates/metal2vulkan-runtime/src/command_buffer/mod.rs index d62dfeb48..8f7f23348 100644 --- a/crates/metal2vulkan-runtime/src/command_buffer/mod.rs +++ b/crates/metal2vulkan-runtime/src/command_buffer/mod.rs @@ -94,6 +94,7 @@ use super::merge_scratch::MergeScratch; use super::pass_runs::{PassRuns, RunKeep, RunPoint}; use super::pipeline::budget::Urgency; use super::pipeline::kept::StepNumbers; +use super::pipeline::{Pending, RawPipeline}; use super::predication::{Event, Predication}; use super::program_objects; use super::queue::{QueueGen, Slot}; @@ -274,6 +275,11 @@ pub(super) struct CommandBufferShared { /// a guest's command buffer encoding made (the guest's 10 s FIFO check ended its task); /// docs/FAST-PATHS.md holds the row. making_deadline: OnceLock, + /// The makings an execution's replay in its `commit` began itself and found still being + /// made at [`making_deadline`](Self::making_deadline) (`render/pending.rs`), until the pass it + /// replays for takes them and is left to its host step (`DeferredPass::left_for_makings`). + /// Apart from the state, as `own_textures`. + unmade: Mutex>>, /// The textures its encoders made for their own commands (`Device::new_planned_texture`), /// held from their making until it completes, whichever of its commands use them (its /// first batch takes them, `submit.rs`). The device's next submission moves each one's image @@ -2428,6 +2434,7 @@ impl CommandBuffer { relayed: Arc::default(), step_numbers: OnceLock::new(), making_deadline: OnceLock::new(), + unmade: Mutex::new(Vec::new()), own_textures: Mutex::new(Vec::new()), fill_slot: Mutex::new([0; 16]), merge_scratch: Arc::default(), @@ -3497,7 +3504,7 @@ impl CommandBuffer { ) -> Result<(), Error> { let device = &self.0.device; let committed = Instant::now(); - // From here its draws' pipelines still being made are waited for a bound at most: a + // From here its `commit` waits for a pipeline still being made a bound at most: a // driver's cold compile can outlast a guest's watchdog (`PipelineWaitPolicy`). let policy = device.compile_device().policy(); if policy.pipeline_waits == PipelineWaitPolicy::Bounded { @@ -4044,12 +4051,9 @@ impl CommandBuffer { /// draw returned (the runtime makes a draw's pipeline while the draw goes on, /// `render/pending.rs`): the draw ran nothing, the command buffer running on, without error. /// Named as [`failed_pipeline`](Self::failed_pipeline) names a dispatch. Counted, each such - /// draw: `WorkCounts::draws_dropped_unmade`. Under `PipelineWaitPolicy::Bounded` (the - /// default), also the first draw of an execution's replay whose `VkPipeline` the replay began - /// making itself and that was still being made once the command buffer's bound passed, with - /// the error `VK_TIMEOUT`: `WorkCounts::draws_dropped_still_making` (`render/pending.rs`). - /// Every other draw and dispatch waits for its making. No Metal counterpart: Metal makes a - /// state's pipelines as it makes the state. + /// draw: `WorkCounts::draws_dropped_unmade`. Every draw and dispatch waits for its making, + /// however long it takes (`render/pending.rs`). No Metal counterpart: Metal makes a state's + /// pipelines as it makes the state. pub fn dropped_draw(&self) -> Option { self.settle_ended(); self.state().dropped_draw.clone() @@ -4104,33 +4108,6 @@ impl CommandBuffer { self.keep_dropped(failed); } - /// Note `late`, a draw of an execution's replay whose making the replay waits for itself - /// and that was still being made once the command buffer's bound passed - /// ([`making_deadline`](Self::making_deadline)), whose recording drops the draw (the open gap, - /// `render/pending.rs`): kept where it is the first, its error `VK_TIMEOUT`, which no - /// driver's creation returns; counted (`WorkCounts::draws_dropped_still_making`), and - /// announced (`draw-dropped-still-making`) where its recording runs, in the program's - /// `commit` or a host step. - pub(super) fn drop_late_draw(&self, late: FailedPipeline) { - let device = self.device(); - device.shared().counts.draw_dropped_still_making(); - let (encoder, draw) = (late.encoder, late.draw); - device.degrade(Degradation::DrawDroppedStillMaking, || { - ( - format!("draw {draw} of render encoder {encoder} of a command buffer"), - format!( - "its pipeline was still being made {} ms after the command buffer's commit", - device - .compile_device() - .policy() - .pipeline_commit_wait - .as_millis() - ), - ) - }); - self.keep_dropped(late); - } - /// Keep `dropped` as the command buffer's first draw that ran nothing, unless one /// was kept already: the recordings run in encoding order. fn keep_dropped(&self, dropped: FailedPipeline) { @@ -4141,14 +4118,27 @@ impl CommandBuffer { } /// Until when its `commit` waits for the pipelines of a pass that executes render commands the - /// CPU writes, which it leaves to its host step past it, and an execution's replay for a - /// making it begins itself (`render/pending.rs`): set at its commit under + /// CPU writes, and an execution's replay in its `commit` for a making it begins itself, which + /// leave the pass to its host step past it (`render/pending.rs`): set at its commit under /// `PipelineWaitPolicy::Bounded`, none before it or under `Exact`. Every other making its /// commands record is waited for until made, under either. pub(crate) fn making_deadline(&self) -> Option { self.0.making_deadline.get().copied() } + /// Keep `making`, which an execution's replay in its `commit` began itself and found still + /// being made at [`making_deadline`](Self::making_deadline), for the pass it replays for + /// (`DeferredPass::left_for_makings`), whose recording it ends. + pub(crate) fn leave_unmade(&self, making: Pending) { + lock(&self.0.unmade).push(making); + } + + /// The makings [`leave_unmade`](Self::leave_unmade) kept since the last call: none where the + /// recording of the pass that takes them ended for another cause. + pub(crate) fn take_unmade(&self) -> Vec> { + lock(&self.0.unmade).drain(..).collect() + } + /// What the command buffer's execution status words report, once it completed: resident-set /// misses of argument-buffer pointers, and the other conditions [`StatusReport`] names. They /// are facts of the run, not errors; `None` before completion and when the command buffer diff --git a/crates/metal2vulkan-runtime/src/deferred.rs b/crates/metal2vulkan-runtime/src/deferred.rs index 1e345b689..b5ad08e84 100644 --- a/crates/metal2vulkan-runtime/src/deferred.rs +++ b/crates/metal2vulkan-runtime/src/deferred.rs @@ -398,26 +398,30 @@ impl Deferred { } // A pass of draws whose pipelines are being made, or one of which failed, is // recorded by a host step once they are made, which drops the draw of a failed one - // (`render/pending.rs`). One whose executions read the CPU's records as - // they stand now waits for them first. + // (`render/pending.rs`). One whose executions read the CPU's records as they stand now + // waits for them first, until the command buffer's bound at most; so does its + // executions' replay for a making it begins itself, which leaves the pass to the host + // step past that bound (`DeferredPass::left_for_makings`). Deferred::RenderPass(pass) => { + let left = Prepared { + recorded: None, + for_good: false, + inputs: StepInputs::RenderPass, + retained: None, + pipelines: true, + bound: None, + held: false, + }; if pass.reads_at_commit() { let deadline = command_buffer.making_deadline(); commit_times::phase(Phase::PipelineWait, || pass.wait_made(deadline)); } if pass.making() || pass.failed() { - return Ok(Prepared { - recorded: None, - for_good: false, - inputs: StepInputs::RenderPass, - retained: None, - pipelines: true, - bound: None, - held: false, - }); + return Ok(left); } let recorded = match pass.record(command_buffer, false) { Ok(recorded) => recorded, + Err(_) if pass.left_for_makings(command_buffer) => return Ok(left), // Held for its host step (`held`), as a step's pass is prepared above. Err(error) => { let residency = command_buffer.residency()?; diff --git a/crates/metal2vulkan-runtime/src/degradation.rs b/crates/metal2vulkan-runtime/src/degradation.rs index 9a7d9674c..658a0d381 100644 --- a/crates/metal2vulkan-runtime/src/degradation.rs +++ b/crates/metal2vulkan-runtime/src/degradation.rs @@ -2188,22 +2188,6 @@ degradations! { a queue's next one run with its own, before the batch before them is submitted; \ their commands, barriers and GPU times are unchanged; CompletionPolicy::Exact \ submits and checks each batch alone"; - /// A draw of an execution's replay (render commands of an indirect command buffer - /// replayed on the CPU) whose `VkPipeline` the replay waits for itself (a making its commit's - /// settle left no host step to wait for), and the driver was still making once its command - /// buffer's bound passed (`PipelineWaitPolicy::Bounded`, the default: its commit plus the - /// policy's `pipeline_commit_wait`, 4.5 s by default, `render/pending.rs`) ran nothing: - /// its recording records nothing of it, and the command buffer runs on without error. - /// Every other draw and dispatch waits for its making, its command buffer completing - /// later. Metal makes a render state's pipelines inside `newRenderPipelineState`, so every - /// draw it encodes runs: this is an open gap, not a choice (`docs/FAST-PATHS.md`). - /// Announced where the draw is recorded: in the program's `commit`, or the command - /// buffer's host step. - DrawDroppedStillMaking = "draw-dropped-still-making", Precision, - "the draw's commands ran nothing, where Metal's draw renders; the command buffers \ - committed after the pipeline is made draw with it; CommandBuffer::dropped_draw \ - names the first such draw with the error VK_TIMEOUT; PipelineWaitPolicy::Exact \ - waits until the pipeline is made"; /// A draw whose `VkPipeline` the driver failed to make after the draw returned (the /// runtime makes a draw's pipeline while the draw goes on, `render/pending.rs`) ran /// nothing: its recording records the barriers and the visibility query around it and no diff --git a/crates/metal2vulkan-runtime/src/executed_commands.rs b/crates/metal2vulkan-runtime/src/executed_commands.rs index 995565e90..a2192b252 100644 --- a/crates/metal2vulkan-runtime/src/executed_commands.rs +++ b/crates/metal2vulkan-runtime/src/executed_commands.rs @@ -13,7 +13,8 @@ //! records, on the thread that reads them ([`RecordsRead`]), with no lock of the command buffer //! held. An execution `commit` recorded from the CPU's records whose buffer an encoder makes //! resident for writing before its batch is submitted is read again in its host step, and the -//! handler sees it again. An execution in an encoder the command buffer's failure runs nothing +//! handler sees it again; so is one whose render pass `commit` left to its host step for a +//! pipeline its replay met still being made at the command buffer's bound. An execution in an encoder the command buffer's failure runs nothing //! of (`commit_failed`) is never read. //! - **Its cost.** None without a handler but one lock of the command buffer's state per //! execution read; with one, the facts are gathered from what the reading resolved already. diff --git a/crates/metal2vulkan-runtime/src/indirect_command_buffer.rs b/crates/metal2vulkan-runtime/src/indirect_command_buffer.rs index 357c2763b..baa3f53aa 100644 --- a/crates/metal2vulkan-runtime/src/indirect_command_buffer.rs +++ b/crates/metal2vulkan-runtime/src/indirect_command_buffer.rs @@ -4323,11 +4323,11 @@ fn low_bits(size: Size) -> [u32; 3] { /// command's index in the buffer and the command as [`IndirectCommandBuffer::commands`] reads it /// then: at `commit`, on the thread that commits, where it records the execution from the CPU's /// records as they stand then; in a host step, on the thread that runs the step, where the step -/// records it from the records as the GPU and the CPU left them. An execution `commit` recorded -/// that a host step records again before its batch is submitted (an encoder made its buffer -/// resident for writing since, or a route outgrew its render pass's form on the GPU) is checked -/// again there. Neither calls it -/// where what the records may hold leaves it nothing to see ([`IndirectCommandCheckNeeds`]). A +/// records it from the records as the GPU and the CPU left them. An execution whose records +/// `commit` read that a host step records again before its batch is submitted (an encoder made +/// its buffer resident for writing since, a route outgrew its render pass's form on the GPU, or a +/// draw of its pass's replay at commit met its pipeline still being made at the command buffer's +/// bound) is checked again there. Neither calls it where what the records may hold leaves it nothing to see ([`IndirectCommandCheckNeeds`]). A /// command whose record faulted runs nothing and is not checked; nor is any where the buffer's /// header faulted. The check may end the process, and must not unwind; returning lets the commands /// run. A command buffer dropped before its host step never calls the step's check. diff --git a/crates/metal2vulkan-runtime/src/pipeline/render.rs b/crates/metal2vulkan-runtime/src/pipeline/render.rs index d774769c3..97dcafb76 100644 --- a/crates/metal2vulkan-runtime/src/pipeline/render.rs +++ b/crates/metal2vulkan-runtime/src/pipeline/render.rs @@ -3159,8 +3159,8 @@ impl RenderVariant { /// (`render/executions.rs`), against `render_pass`: from the memo, the making in flight for /// it, or begun now as a draw's is ([`begin_graphics_pipeline`](Self::begin_graphics_pipeline): /// linked here where its shaders' libraries are made, else handed to `device`'s pool), so the - /// commit compiles nothing on the program's thread; the host step's draw of the key waits for - /// it until its command buffer's bound at most (`render.rs`). Under + /// commit compiles nothing on the program's thread; the host step records the draw of the key + /// once it is made (`render.rs`). Under /// `PipelineWaitPolicy::Exact` made now ([`graphics_pipeline`](Self::graphics_pipeline)). pub(crate) fn settle_graphics_pipeline( self: &Arc, diff --git a/crates/metal2vulkan-runtime/src/render.rs b/crates/metal2vulkan-runtime/src/render.rs index d8c12dde6..030464356 100644 --- a/crates/metal2vulkan-runtime/src/render.rs +++ b/crates/metal2vulkan-runtime/src/render.rs @@ -1713,10 +1713,6 @@ pub(crate) struct RenderLowering { /// The heap set versions the plain draws it replayed bound (`heap_sets::Bound`), each once, /// which a kept recording of them binds again (`kept_commands::KeptEffects`). replayed_heaps: Vec>, - /// The place among the command buffer's ended encoders of the encoder whose execution it - /// replays (`RenderExecution`), which names a draw of the commands it drops - /// (`CommandBuffer::drop_late_draw`); `None` where it replays none. - executing_encoder: Option, /// The encoder records the current instance's draws again into an instance that leaves more /// colors out of its subpass (`render/reroute.rs`): a draw that would record elsewhere, or /// whose variant the interlocked storage form refuses, fails the reroute. @@ -2473,7 +2469,6 @@ impl RenderLowering { replay_plain: false, plain_drawn: false, replayed_heaps: Vec::new(), - executing_encoder: None, rerouting: false, forms: BufferForms::Bound, replayed: None, @@ -9866,13 +9861,15 @@ impl RenderLowering { None => { let watch = EachWatch::start(); let key = draw_key(); - // An execution's replay records now: under its command buffer's bound its draw - // waits for its making on the device's pool (most begun by the settle at commit, - // `RenderExecution::settle`) until the bound at most, past which it records - // nothing. Not a device replay's draw, of one recording for every command. + // An execution's replay in `commit` records now: under its command buffer's + // bound its draw waits for its making on the device's pool until the bound at + // most, past which the replay leaves the pass to the host step + // (`render/pending.rs`). A host step's waits until it is made, on the step's + // thread, as does a device replay's draw, of one recording for every command. let bounded = (self.replaying && self.replayed.is_none() && !self.rerouting) && !(empty || culled) - && self.layout.sample_positions.is_empty(); + && self.layout.sample_positions.is_empty() + && !crate::exit_guard::in_host_step(); let deadline = match bounded { true => self.core.command_buffer().making_deadline(), false => None, @@ -9906,12 +9903,16 @@ impl RenderLowering { )?; (DrawPipeline::Made(made), own) } - // Still being made at the bound: the draw records nothing, - // before anything of it is tracked, as a draw whose pipeline - // a capture misses does; later command buffers draw with it. + // Still being made at the bound: the replay stops, before + // anything of the draw is tracked, and its pass is left to + // the host step, which waits for the making + // (`DeferredPass::left_for_makings`). None => { - self.drop_late_replayed_draw(&variant, specialization)?; - return Ok(()); + self.core.command_buffer().leave_unmade(making); + return Err(internal( + "a replayed draw's pipeline still being made at its \ + command buffer's bound", + )); } } } diff --git a/crates/metal2vulkan-runtime/src/render/executions.rs b/crates/metal2vulkan-runtime/src/render/executions.rs index fa1996dae..e289b2206 100644 --- a/crates/metal2vulkan-runtime/src/render/executions.rs +++ b/crates/metal2vulkan-runtime/src/render/executions.rs @@ -778,7 +778,6 @@ impl RenderLowering { .map_or(IndirectCommandCheckNeeds::ALL, |(_, needs)| *needs), check: check.map(|(check, _)| Mutex::new(check)), read_at: AtomicU64::new(indirect_execute::NOT_READ), - encoder: self.core.command_buffer().state().open_encoder_place(), }); // Its commands may name any pipeline state, reading handles in any stage. self.command_encoded(every_render_stage()); @@ -986,9 +985,6 @@ pub(crate) struct RenderExecution { /// read them after (`IndirectCommandBuffer::cpu_writes`); `indirect_execute::NOT_READ` until /// then ([`rewritten`](Self::rewritten)). read_at: AtomicU64, - /// Its encoder's place among the command buffer's ended encoders, which names a draw of its - /// commands that its replay drops (`CommandBuffer::drop_late_draw`). - encoder: usize, } /// The encoder's state an execution's draws take: as the call found it, its tables only where @@ -2559,7 +2555,6 @@ impl RenderExecution { replay_plain: true, plain_drawn: false, replayed_heaps: Vec::new(), - executing_encoder: Some(self.encoder), rerouting: false, forms, replayed: None, @@ -2819,8 +2814,9 @@ pub(crate) struct DeferredPass { /// What the commit made ahead for the host step that records it (`ahead.rs`), once made. ahead: OnceLock>, /// The makings its executions' settle at commit handed to the device's pool - /// ([`settle`](Self::settle)), which its host step waits for, until its command buffer's bound - /// at most, as for its draws' pipelines. + /// ([`settle`](Self::settle)), and those its replay at commit began and found still being + /// made at its command buffer's bound ([`left_for_makings`](Self::left_for_makings)): its + /// host step records the pass once they are made, as for its draws' pipelines. settled: Mutex>>, /// Where `commit` recorded the pass with executions in their GPU form (`gpu.rs`), what each /// such execution's buffer's records may hold as the decision found it: a route encoded @@ -3066,6 +3062,20 @@ impl DeferredPass { } } + /// Take the makings `command_buffer`'s recording of the pass at commit left unmade + /// (`CommandBuffer::leave_unmade`): its executions' replay began them and found them still + /// being made at the command buffer's bound, so the pass is left to its host step, which + /// records it from the records as they stand then once they are made + /// ([`making`](Self::making), [`when_made`](Self::when_made)), as `commit` leaves a pass whose + /// settled makings it found still being made. Whether it took any: a recording that took + /// none failed for another cause. + pub(crate) fn left_for_makings(&self, command_buffer: &CommandBuffer) -> bool { + let unmade = command_buffer.take_unmade(); + let left = !unmade.is_empty(); + lock(&self.settled).extend(unmade); + left + } + /// Run the makings of the pipelines its draws and tile dispatches record before the /// device's pool's pieces of a lower rank than `urgency`: a submission waits for them. pub(crate) fn hasten(&self, urgency: Urgency) { @@ -3181,7 +3191,15 @@ impl DeferredPass { let rule = "a pipeline state the pass draws with is being made or failed to make"; return declined(HostStepCause::Rule(rule)); } - let recorded = self.record_forms(command_buffer, false, &forms)?; + let recorded = match self.record_forms(command_buffer, false, &forms) { + Ok(recorded) => recorded, + Err(_) if self.left_for_makings(command_buffer) => { + let rule = "a pipeline state the pass's executions draw with was still being made \ + at the command buffer's bound"; + return declined(HostStepCause::Rule(rule)); + } + Err(error) => return Err(error), + }; let decided = (self.executions.iter().zip(&forms)).filter_map(|(execution, form)| { Some((Arc::clone(execution.icb.written()), form.as_ref()?.decided)) }); @@ -3585,8 +3603,8 @@ impl DeferredPass { /// creation compiled its variant in the large-buffer form, which the commit looks up, and the /// commit begins the `VkPipeline`s: under `PipelineWaitPolicy::Bounded` (the default) each /// making is handed to the device's pool (`RenderVariant::settle_graphics_pipeline`), kept here - /// for the host step to wait for until its command buffer's bound at most, so the commit - /// compiles none on the program's thread; under `Exact` made now. It compiles a variant only + /// for the host step to wait for until it is made, so the commit compiles none on the + /// program's thread; under `Exact` made now. It compiles a variant only /// where the encoder's state asks for another, and the step only where a command's own buffers /// or strides ask for another, or the draw records into a run of another shape. Returns what it /// made, which the command buffer holds until it completes; what it cannot settle, the step diff --git a/crates/metal2vulkan-runtime/src/render/pending.rs b/crates/metal2vulkan-runtime/src/render/pending.rs index fc0e20b80..5e80d8b95 100644 --- a/crates/metal2vulkan-runtime/src/render/pending.rs +++ b/crates/metal2vulkan-runtime/src/render/pending.rs @@ -37,31 +37,30 @@ //! (the host step, or `commit` for records the CPU writes), so it takes no pending recording: //! its pipeline, most begun on the device's pool by the execution's settle at commit //! (`RenderExecution::settle`), which the batch's host step waits for as for a pending draw's. -//! A making the replay waits for itself, one the settle left the host step no wait for, is -//! waited for until its command buffer's bound at most, and one still being made then makes the draw record -//! nothing, before anything of it is tracked, named by its execution's encoder's place and its -//! order among the replay's draws with the error `VK_TIMEOUT`, counted -//! (`WorkCounts::draws_dropped_still_making`) and announced (`draw-dropped-still-making`, -//! [`RenderLowering::drop_late_replayed_draw`]): the open gap (`docs/FAST-PATHS.md`). A device -//! replay's draw, one recording for every command, waits until the pipeline is made. +//! A making the replay begins itself, one the settle did not foresee, is waited for in a host +//! step until it is made, on the step's thread; in `commit`, until its command buffer's bound +//! at most, past which the replay stops, before anything of the draw is tracked, and leaves +//! the pass to the host step, which records it once that making is made +//! (`CommandBuffer::leave_unmade`, `DeferredPass::left_for_makings`). A device replay's draw, +//! one recording for every command, waits until the pipeline is made. //! - **Recorded once.** A pass recorded at commit and again by a host step (an execution's //! buffer the GPU may write since) records each such draw once, its secondary executed by the //! recording that is submitted. use super::bound::{Bound, Recorded}; -use super::{DrawState, Recording, RenderLowering}; +use super::{DrawState, Recording}; use crate::binding::PushWrite; use crate::command_buffer::CommandBuffer; use crate::device::lock; use crate::draw_source::IndexBind; use crate::dynamic_state::ExtendedDynamicState; -use crate::error::{internal, vulkan, Error, FailedPipeline, FailedState}; -use crate::pipeline::{Pending, RawPipeline, RenderPipelineState, RenderVariant}; +use crate::error::{vulkan, Error, FailedPipeline, FailedState}; +use crate::pipeline::{Pending, RawPipeline, RenderPipelineState}; use crate::render_target; use crate::tracker::LegacyBarrier; use crate::visibility::Lent; use ash::vk; -use metal2vulkan::cache::{SpecializationKey, VariantKey}; +use metal2vulkan::cache::VariantKey; use metal2vulkan::pipeline::SpecKey; use std::sync::Mutex; @@ -245,30 +244,3 @@ impl PendingDraw { Ok(()) } } - -impl RenderLowering { - /// Drop a draw of an execution's replay whose `VkPipeline` of `variant` under - /// `specialization` was still being made at its command buffer's bound (the module docs): - /// named by its execution's encoder's place and its order among the replay's draws, its error - /// `VK_TIMEOUT`; counted and announced as any draw past the bound - /// (`CommandBuffer::drop_late_draw`). - pub(super) fn drop_late_replayed_draw( - &self, - variant: &RenderVariant, - specialization: &SpecializationKey, - ) -> Result<(), Error> { - let state = self - .pipeline - .clone() - .ok_or_else(|| internal("a draw without its pipeline state"))?; - self.core.command_buffer().drop_late_draw(FailedPipeline { - encoder: self.executing_encoder.unwrap_or_default(), - draw: self.draw_calls, - state: FailedState::Render(state), - variant: variant.key().clone(), - specialization: variant.constants(specialization), - error: vulkan(vk::Result::TIMEOUT), - }); - Ok(()) - } -} diff --git a/crates/metal2vulkan-runtime/src/tests/deferred_calls.rs b/crates/metal2vulkan-runtime/src/tests/deferred_calls.rs index 1bf3b95e8..00f974aff 100644 --- a/crates/metal2vulkan-runtime/src/tests/deferred_calls.rs +++ b/crates/metal2vulkan-runtime/src/tests/deferred_calls.rs @@ -1473,8 +1473,8 @@ fn held_past_its_bound(device: &Device, command_buffer: &CommandBuffer, committe /// is not completed a second past its own bound (the policy's commit wait as set, /// [`COMMIT_WAIT`]) while another queue's command buffer completes meanwhile; once the hold goes, /// the making lands and the command buffer completes without error, the rectangle drawn, -/// `dropped_draw` naming nothing, nothing counted in `draws_dropped_still_making` and no -/// `draw-dropped-still-making` announced. +/// `dropped_draw` naming nothing, nothing counted in `draws_dropped_unmade` and no +/// `draw-dropped-unmade` announced. #[test] fn a_draw_whose_pipeline_is_still_being_made_past_its_bound_renders_once_made() { let scratch = Scratch::new("deferred-making-bound"); @@ -1525,30 +1525,27 @@ fn a_draw_whose_pipeline_is_still_being_made_past_its_bound_renders_once_made() "the rectangle, drawn" ); let after = device.work_counts(); - assert_eq!( - after.draws_dropped_still_making, - counts.draws_dropped_still_making - ); assert_eq!(after.draws_dropped_unmade, counts.draws_dropped_unmade); assert!( !(heard.lock().unwrap().iter()) - .any(|notice| notice.degradation == Degradation::DrawDroppedStillMaking), + .any(|notice| notice.degradation == Degradation::DrawDroppedUnmade), "a draw was dropped" ); } -/// The open gap (`docs/FAST-PATHS.md`): a draw of an execution's replay whose pipeline is still -/// being made at its command buffer's bound runs nothing, under `PipelineWaitPolicy::Bounded` (the -/// default), the slow compile the pool's test hold (`pool::held`), no sleep. The commit replays the -/// records the CPU wrote as it reads them, so the draw takes no pending recording: the replay -/// waits for its making, held in the pool, until the bound, then records nothing. The commit returns once the bound passed, within the -/// 10 s a guest's FIFO check allows, and the command buffer completes without error, its pass -/// clearing its target and the blit after it copying it: `dropped_draw` names the draw (its -/// execution's encoder 0, draw 0, `VK_TIMEOUT`), `failed_pipeline` nothing, counted -/// `draws_dropped_still_making` and announced `draw-dropped-still-making`. Once the hold goes the -/// making lands, and a later command buffer draws the rectangle. +/// A draw of an execution's replay whose pipeline is still being made at its command buffer's +/// bound renders once its making lands, under `PipelineWaitPolicy::Bounded` (the default), the +/// slow compile the pool's test hold (`pool::held`), no sleep. The commit replays the records the +/// CPU wrote as it reads them, so the draw takes no pending recording: the replay waits for its +/// making, held in the pool, until the bound, then leaves the pass to the host step +/// (`DeferredPass::left_for_makings`). The commit returns once the bound passed, within the 10 s +/// a guest's FIFO check allows; the command buffer is not completed a second past its bound +/// while another queue's command buffer completes meanwhile; once the hold goes, the making lands +/// and the command buffer completes without error, the rectangle drawn and copied by the blit +/// after its pass, `dropped_draw` and `failed_pipeline` naming nothing, nothing counted in +/// `draws_dropped_unmade` and no `draw-dropped-unmade` announced. #[test] -fn a_replayed_draw_whose_pipeline_is_still_being_made_at_its_bound_runs_nothing() { +fn a_replayed_draw_whose_pipeline_is_still_being_made_at_its_bound_renders_once_made() { use super::encoder_holds::library; use crate::{IndirectCommandBufferDescriptor, PipelineOptions}; use metal2vulkan::metal::{IndirectCommandType, RenderStages, ResourceUsage}; @@ -1615,46 +1612,31 @@ fn a_replayed_draw_whose_pipeline_is_still_being_made_at_its_bound_runs_nothing( let back = replayed(&command_buffer); let committing = Instant::now(); command_buffer.commit().unwrap(); - command_buffer - .wait_until_completed_for(GUEST_WATCHDOG) - .expect("the command buffer completes at its bound with its draw's making held"); - let waited = committing.elapsed(); + let took = committing.elapsed(); assert!( - (COMMIT_WAIT..GUEST_WATCHDOG).contains(&waited), - "completed after {waited:?}, not its own bound" + (COMMIT_WAIT..GUEST_WATCHDOG).contains(&took), + "the commit took {took:?}, not its own bound" ); + held_past_its_bound(&device, &command_buffer, committing); + drop(hold); + command_buffer + .wait_until_completed_for(WAIT) + .expect("the command buffer completes once its replayed draw's making lands"); assert_eq!(command_buffer.status(), CommandBufferStatus::Completed); assert_eq!(command_buffer.error(), None); assert!(command_buffer.failed_pipeline().is_none()); - let dropped = command_buffer - .dropped_draw() - .expect("the replayed draw dropped is named"); - assert_eq!((dropped.encoder, dropped.draw), (0, 0)); - assert_eq!(dropped.error, vulkan(vk::Result::TIMEOUT)); - assert!(words_of(&back).iter().all(|&w| w == 0), "the draw drew"); - let after = device.work_counts(); - assert_eq!( - after.draws_dropped_still_making - counts.draws_dropped_still_making, - 1 - ); + assert!(command_buffer.dropped_draw().is_none()); assert!( - (heard.lock().unwrap().iter()) - .any(|notice| notice.degradation == Degradation::DrawDroppedStillMaking), - "no notice of the dropped draw" + words_of(&back).iter().all(|&w| w == PACKED), + "the rectangle, drawn" + ); + let after = device.work_counts(); + assert_eq!(after.draws_dropped_unmade, counts.draws_dropped_unmade); + assert!( + !(heard.lock().unwrap().iter()) + .any(|notice| notice.degradation == Degradation::DrawDroppedUnmade), + "a draw was dropped" ); - drop(hold); - // The making lands for the command buffers after it. - let deadline = Instant::now() + WAIT; - loop { - let command_buffer = queue.command_buffer().unwrap(); - let back = replayed(&command_buffer); - let words = committed(&command_buffer, &back); - if command_buffer.dropped_draw().is_none() { - assert!(words.iter().all(|&w| w == PACKED), "the rectangle, drawn"); - break; - } - assert!(Instant::now() < deadline, "the making never landed"); - } } /// A compute dispatch whose pipeline is still being made past its command buffer's bound runs @@ -1675,7 +1657,6 @@ fn a_dispatch_whose_pipeline_is_still_being_made_past_its_bound_runs_once_made() let queue = device.new_command_queue().unwrap(); let state = state(&device); let buffers = Buffers::new(&device); - let counts = device.work_counts(); let hold = held::hold(); let command_buffer = dispatch(&queue, &state, &buffers, Grid::One(Size::new(64, 1, 1))); let committing = Instant::now(); @@ -1701,11 +1682,6 @@ fn a_dispatch_whose_pipeline_is_still_being_made_past_its_bound_runs_once_made() buffers.written(64), "the dispatch wrote what Metal's writes" ); - let after = device.work_counts(); - assert_eq!( - after.draws_dropped_still_making, - counts.draws_dropped_still_making - ); } /// A compute state whose descriptor requires a threadgroup size predicts its first dispatch's @@ -1799,10 +1775,7 @@ fn under_the_exact_wait_a_held_making_holds_its_command_buffer_until_it_lands() assert!(command_buffer.dropped_draw().is_none()); assert!(words_of(&back).contains(&PACKED), "the line, drawn"); let after = device.work_counts(); - assert_eq!( - after.draws_dropped_still_making, - counts.draws_dropped_still_making - ); + assert_eq!(after.draws_dropped_unmade, counts.draws_dropped_unmade); assert!(!(heard.lock().unwrap().iter()) - .any(|notice| notice.degradation == Degradation::DrawDroppedStillMaking)); + .any(|notice| notice.degradation == Degradation::DrawDroppedUnmade)); } diff --git a/crates/metal2vulkan-runtime/src/tests/icon_coverage.rs b/crates/metal2vulkan-runtime/src/tests/icon_coverage.rs index 0b99d11cf..d18cd9992 100644 --- a/crates/metal2vulkan-runtime/src/tests/icon_coverage.rs +++ b/crates/metal2vulkan-runtime/src/tests/icon_coverage.rs @@ -433,7 +433,7 @@ fn expected((clear, stencil_tests): (Option<[f32; 2]>, bool), (x, y): (u64, u64) /// The counts that say how the passes ran: render pass instances, splits for the interlocked /// writes, storage forms taken, textures over bytes shadowed, linear merges recorded, shadow /// copies; variant pipelines made, host steps recorded, splits for a pipeline still being made, -/// draws dropped while their pipeline was being made. +/// draws dropped for a pipeline the driver did not make. fn moved(before: &WorkCounts, after: &WorkCounts) -> [u64; 10] { [ after.render_passes_begun_instances - before.render_passes_begun_instances, @@ -445,7 +445,7 @@ fn moved(before: &WorkCounts, after: &WorkCounts) -> [u64; 10] { after.variant_pipelines_made - before.variant_pipelines_made, after.host_steps_recorded - before.host_steps_recorded, after.instance_splits_pending_pipeline - before.instance_splits_pending_pipeline, - after.draws_dropped_still_making - before.draws_dropped_still_making, + after.draws_dropped_unmade - before.draws_dropped_unmade, ] } diff --git a/crates/metal2vulkan-runtime/src/work_counts.rs b/crates/metal2vulkan-runtime/src/work_counts.rs index 45b07dee5..4ce6e82c6 100644 --- a/crates/metal2vulkan-runtime/src/work_counts.rs +++ b/crates/metal2vulkan-runtime/src/work_counts.rs @@ -117,7 +117,6 @@ pub(crate) struct Counters { variants_taken_back: AtomicU64, unlisted_argument_sampler_buffers: AtomicU64, draws_dropped_unmade: AtomicU64, - draws_dropped_still_making: AtomicU64, host_step_sampler_sets_made: AtomicU64, host_steps_recorded: AtomicU64, host_step_nanos: AtomicU64, @@ -2332,13 +2331,6 @@ impl Counters { self.draws_dropped_unmade.fetch_add(1, Ordering::Relaxed); } - /// A draw of an execution's replay whose making the replay waits for itself was still - /// being made at its command buffer's bound and ran nothing (`CommandBuffer::drop_late_draw`). - pub(crate) fn draw_dropped_still_making(&self) { - self.draws_dropped_still_making - .fetch_add(1, Ordering::Relaxed); - } - /// `bytes` of an indirect command buffer's records were copied out of its storage /// (`indirect_command_buffer.rs`). pub(crate) fn indirect_record_bytes_copied(&self, bytes: u64) { @@ -5501,13 +5493,6 @@ pub struct WorkCounts { /// a draw's pipeline while the draw goes on): each ran nothing, its command buffer running on /// without error (`CommandBuffer::dropped_draw` names the first of a command buffer). pub draws_dropped_unmade: u64, - /// Draws of executions' replays whose `VkPipeline` the replay waits for itself and that was - /// still being made once their command buffer's bound passed (`PipelineWaitPolicy::Bounded`, - /// the default: its commit plus the policy's `pipeline_commit_wait`; the open gap): each ran - /// nothing, its command buffer running on without error, and the command buffers after it draw - /// with the pipeline once it is made (`CommandBuffer::dropped_draw` names the first of a command - /// buffer, with the error `VK_TIMEOUT`). Every other draw and dispatch waits for its making. - pub draws_dropped_still_making: u64, /// Immutable sampler sets a command buffer's host step made, counting samplers on the /// scheduler's thread, because the device's map held no set of its variant's samplers: the /// open break (a render execution's step drawing a state made after its commit, on the variant @@ -9391,7 +9376,6 @@ impl Device { .unlisted_argument_sampler_buffers .load(Ordering::Relaxed), draws_dropped_unmade: counters.draws_dropped_unmade.load(Ordering::Relaxed), - draws_dropped_still_making: counters.draws_dropped_still_making.load(Ordering::Relaxed), host_step_sampler_sets_made: counters .host_step_sampler_sets_made .load(Ordering::Relaxed), diff --git a/crates/metal2vulkan-validation/src/runtime_lane/degrade_notices.rs b/crates/metal2vulkan-validation/src/runtime_lane/degrade_notices.rs index 32b836e1c..efd0e474f 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/degrade_notices.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/degrade_notices.rs @@ -600,7 +600,7 @@ fn every_kind_has_a_site_a_lane_test_takes() { &KEPT_BYTES, &DELAYED_DEALLOCATORS, &MISPLACED, - &STILL_MAKING, + &UNMADE, &COPIED_PAGES, &OVERFLOWED, &LEAST_PLANS, @@ -807,18 +807,11 @@ fn an_anisotropic_state_without_mips_is_announced_through_metals_sampler() { /// takes its site, as a build without debug assertions does. const MISPLACED: [Degradation; 1] = [Degradation::MisplacedNotice]; -/// The kinds a draw of an execution's replay takes whose making the replay waits for itself -/// and that was still being made once its command buffer's bound passed -/// (`PipelineWaitPolicy::Bounded`, `pipeline_commit_wait` after its commit: the runtime's open -/// gap), and a draw whose pipeline the driver failed to make. No lane meets them: a lane holds -/// none of the runtime's pipeline makings, a driver's compile outlasting the bound is a timing no -/// lane may count on, and no lane's pipeline fails. The runtime's own test -/// `a_draw_whose_pipeline_was_not_made_runs_nothing_and_its_command_buffer_runs_on` takes the -/// second's site, its failure injected. -const STILL_MAKING: [Degradation; 2] = [ - Degradation::DrawDroppedStillMaking, - Degradation::DrawDroppedUnmade, -]; +/// The kind a draw takes whose pipeline the driver failed to make. No lane meets it: no lane's +/// pipeline fails. The runtime's own test +/// `a_draw_whose_pipeline_was_not_made_runs_nothing_and_its_command_buffer_runs_on` takes its +/// site, its failure injected. +const UNMADE: [Degradation; 1] = [Degradation::DrawDroppedUnmade]; /// The kind a no-copy buffer takes whose import of the caller's pages the caller's gate /// (`HostMemory::with_import_gate`) refused, or whose import the gate and the device admitted and diff --git a/crates/metal2vulkan-validation/src/runtime_lane/framebuffer_fetch/coverage_chain.rs b/crates/metal2vulkan-validation/src/runtime_lane/framebuffer_fetch/coverage_chain.rs index 18b2258ef..a1d342b60 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/framebuffer_fetch/coverage_chain.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/framebuffer_fetch/coverage_chain.rs @@ -781,7 +781,7 @@ fn a_coverage_chain_through_fetch_keeps_every_block() { ran(|c| c.instance_splits_interlocked_writes), ran(|c| c.instance_splits_barrier), ran(|c| c.instance_splits_memoryless_write), - ran(|c| c.draws_dropped_still_making + c.draws_dropped_unmade), + ran(|c| c.draws_dropped_unmade), ); if count != 0 { failed.push(case.name); diff --git a/crates/metal2vulkan-validation/src/runtime_lane/host_replay_frames.rs b/crates/metal2vulkan-validation/src/runtime_lane/host_replay_frames.rs index 0b326773e..4800bf3bf 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/host_replay_frames.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/host_replay_frames.rs @@ -411,8 +411,8 @@ fn counters(before: &WorkCounts, after: &WorkCounts) -> String { format!( "host steps {} taking {:.2} ms, making {} pipelines; heads held for host steps {}, at \ their gate {}, behind earlier commits {}; variant pipelines made {}, render pipeline \ - create {:.1} ms, graphics pipelines looked up {}, draws settled {}, draws dropped still \ - making {}; records read {}", + create {:.1} ms, graphics pipelines looked up {}, draws settled {}, draws dropped \ + unmade {}; records read {}", delta(|c| c.host_steps_recorded), delta(|c| c.host_step_nanos) as f64 / 1e6, delta(|c| c.host_step_pipelines_made), @@ -423,7 +423,7 @@ fn counters(before: &WorkCounts, after: &WorkCounts) -> String { delta(|c| c.render_pipeline_create_nanos) as f64 / 1e6, delta(|c| c.graphics_pipelines_looked_up), delta(|c| c.draws_settled), - delta(|c| c.draws_dropped_still_making), + delta(|c| c.draws_dropped_unmade), delta(|c| c.indirect_records_read), ) } diff --git a/crates/metal2vulkan/src/device/policy.rs b/crates/metal2vulkan/src/device/policy.rs index 916902b5c..0855483b3 100644 --- a/crates/metal2vulkan/src/device/policy.rs +++ b/crates/metal2vulkan/src/device/policy.rs @@ -74,10 +74,11 @@ pub struct DevicePolicy { /// (the default), or converts and filters every tap as Metal does, exactly. Changes emitted /// code: the profile carries it. pub ycbcr_in_place_reads: YCbCrInPlacePolicy, - /// Whether a render or compute state's creation, and a committed command buffer, wait a - /// bound for a pipeline the driver is still making, the command buffer then dropping the - /// draws and dispatches whose pipeline is not made (the default), or until it is made. The - /// bounds are the two fields below. The runtime's choice alone: no emitted code changes. + /// Whether a render or compute state's creation, and a `commit` that records a pass whose + /// executions read the CPU's records, wait a bound for a pipeline the driver is still making + /// (the default), or until it is made. A committed command buffer waits for its draws' and + /// dispatches' pipelines until they are made under either. The bounds are the two fields + /// below. The runtime's choice alone: no emitted code changes. pub pipeline_waits: PipelineWaitPolicy, /// Under [`PipelineWaitPolicy::Bounded`], the longest a render or compute state's creation /// waits for the pipelines it hands to the runtime's pool, one deadline for all of them from @@ -88,9 +89,9 @@ pub struct DevicePolicy { pub pipeline_creation_wait: Duration, /// Under [`PipelineWaitPolicy::Bounded`], how long after its commit a command buffer's /// `commit` waits for the pipelines of a pass that executes render commands the CPU writes, - /// leaving the pass to its host step past it, and how long an execution's replay waits for a - /// making it waits for itself, past which that draw records as nothing (the open gap, - /// `draw-dropped-still-making`). Every other command's making is waited for until made. 4.5 s + /// and for those its executions' replay begins itself, leaving the pass to its host step past + /// it, which records it once they are made. Every other command's making is waited for until + /// made. 4.5 s /// by default (as the creation wait, above). Unread under `Exact`. The runtime's alone: no /// emitted code changes. pub pipeline_commit_wait: Duration, @@ -489,10 +490,10 @@ pub enum PipelineWaitPolicy { /// most (4.5 s by default), then returns with it still being made. A committed command buffer /// waits for its draws' and dispatches' pipelines still being made until they are made, under /// either value, on the runtime's scheduler thread, which no program call waits for: it - /// completes later, and no command is dropped, but one, an open gap: a draw of an - /// execution's replay whose making the replay waits for itself, still being made at its - /// commit plus [`DevicePolicy::pipeline_commit_wait`] (4.5 s by default), records nothing, the - /// command buffer running on, counted, named, announced `draw-dropped-still-making`. + /// completes later, and no command is dropped. A `commit` that records a pass whose + /// executions read the CPU's records waits for its pipelines, and for those its executions' + /// replay begins itself, until its commit plus [`DevicePolicy::pipeline_commit_wait`] (4.5 s + /// by default) at most, and leaves the pass to its host step past it. /// /// What one call blocks for, waiting for the driver's makings: a state's creation, its /// creation wait; a `commit`, which records there what it can (a pass whose pipelines are diff --git a/crates/metal2vulkan/tests/api_signatures.tsv b/crates/metal2vulkan/tests/api_signatures.tsv index c10720d2a..406c7d6f5 100644 --- a/crates/metal2vulkan/tests/api_signatures.tsv +++ b/crates/metal2vulkan/tests/api_signatures.tsv @@ -2806,7 +2806,6 @@ field metal2vulkan-runtime::WorkCounts.draws_carry_stopped_attached pub draws_ca field metal2vulkan-runtime::WorkCounts.draws_carry_stopped_other pub draws_carry_stopped_other: u64 field metal2vulkan-runtime::WorkCounts.draws_carry_stopped_stale pub draws_carry_stopped_stale: u64 field metal2vulkan-runtime::WorkCounts.draws_counted_past_early_masks pub draws_counted_past_early_masks: u64 -field metal2vulkan-runtime::WorkCounts.draws_dropped_still_making pub draws_dropped_still_making: u64 field metal2vulkan-runtime::WorkCounts.draws_dropped_unmade pub draws_dropped_unmade: u64 field metal2vulkan-runtime::WorkCounts.draws_moved pub draws_moved: u64 field metal2vulkan-runtime::WorkCounts.draws_moved_inside pub draws_moved_inside: u64 @@ -5617,7 +5616,6 @@ macro-member metal2vulkan-runtime::Degradation::DontCareLoadTiles DontCareLoadTi macro-member metal2vulkan-runtime::Degradation::DontCareStandIn DontCareStandIn = "dont-care-stand-in", Performance, macro-member metal2vulkan-runtime::Degradation::DontCareStore DontCareStore = "dont-care-store", Precision, macro-member metal2vulkan-runtime::Degradation::DontCareUnstoredLoad DontCareUnstoredLoad = "dont-care-unstored-load", Precision, -macro-member metal2vulkan-runtime::Degradation::DrawDroppedStillMaking DrawDroppedStillMaking = "draw-dropped-still-making", Precision, macro-member metal2vulkan-runtime::Degradation::DrawDroppedUnmade DrawDroppedUnmade = "draw-dropped-unmade", Precision, macro-member metal2vulkan-runtime::Degradation::DrawnDepthCopy DrawnDepthCopy = "drawn-depth-copy", Precision, macro-member metal2vulkan-runtime::Degradation::DriverPipelineCacheKept DriverPipelineCacheKept = "driver-pipeline-cache-kept", Performance, diff --git a/docs/API.md b/docs/API.md index 523db1350..005240aec 100644 --- a/docs/API.md +++ b/docs/API.md @@ -190,15 +190,13 @@ compile does. `DevicePolicy::default()` is `DevicePolicy::UNTRUSTED`: made, however long that takes, and records them then: each renders and writes what Metal's does, its command buffer completing later, as on a slower GPU. `commit` waits for none of them but a pass that executes render commands the CPU writes, until its commit plus - `DevicePolicy::pipeline_commit_wait` at most, which it leaves to the command buffer's host step - past that; no other program call blocks for a making but those that wait for the GPU (a wait - for the command buffer's completion or scheduling, an event it signals, a new command buffer - of a queue whose most are all uncompleted). One draw is still dropped, an open gap: an - execution's replayed draw whose making the replay waits for itself (one the commit's settle - left the host step no wait for), still being made at that bound (`draw-dropped-still-making`, named by - `CommandBuffer::dropped_draw` with `VK_TIMEOUT`, counted - `WorkCounts::draws_dropped_still_making`). Meanwhile it holds back only its own queue's later - command buffers: one of + `DevicePolicy::pipeline_commit_wait` at most, for its pipelines and for those its executions' + replay begins itself, which it leaves to the command buffer's host step past that; the step + records the pass once they are made. No other program call blocks for a making but those that + wait for the GPU (a wait for the command buffer's completion or scheduling, an event it + signals, a new command buffer of a queue whose most are all uncompleted); a host step that + meets a making of its own waits for it on its step's thread. No draw or dispatch is dropped + for its making's time. Meanwhile it holds back only its own queue's later command buffers: one of another queue committed after it goes first, even where the two touch one tracked resource that one of them writes, and the waiting one runs after it, as an x86 Mac's GPU may take a later commit of another queue first (`metal2vulkan-conformance`'s @@ -3561,20 +3559,6 @@ bound. and the submission checks of the batches behind a queue's next one run with its own, before the batch before them is submitted; their commands, barriers and GPU times are unchanged; `CompletionPolicy::Exact` submits and checks each batch alone. -- `metal2vulkan-degrade-draw-dropped-still-making` (precision). `DrawDroppedStillMaking`: A draw - of an execution's replay (render commands of an indirect command buffer replayed on the CPU) - whose `VkPipeline` the replay waits for itself (a making its commit's settle left no host step - to wait for), and the driver was still making once its command buffer's bound passed - (`PipelineWaitPolicy::Bounded`, the default: its commit plus - `DevicePolicy::pipeline_commit_wait`, 4.5 s by default) ran nothing: its recording records - nothing of it, and the command buffer runs on without error. Every other draw and dispatch waits - for its making, its command buffer completing later. Metal makes a render state's pipelines - inside `newRenderPipelineState`, so every draw it encodes runs: this is an open gap, not a - choice (`docs/FAST-PATHS.md`). Announced where the draw is recorded: in the program's `commit`, - or the command buffer's host step. Cost: the draw's commands ran nothing, where Metal's draw - renders; the command buffers committed after the pipeline is made draw with it; - `CommandBuffer::dropped_draw` names the first such draw with the error VK_TIMEOUT; - `PipelineWaitPolicy::Exact` waits until the pipeline is made. - `metal2vulkan-degrade-draw-dropped-unmade` (precision). `DrawDroppedUnmade`: A draw whose `VkPipeline` the driver failed to make after the draw returned (the runtime makes a draw's pipeline while the draw goes on, `render/pending.rs`) ran nothing: its recording records the diff --git a/docs/FAST-PATHS.md b/docs/FAST-PATHS.md index 0990aa06d..f1a11fbe1 100644 --- a/docs/FAST-PATHS.md +++ b/docs/FAST-PATHS.md @@ -40,7 +40,7 @@ three consumer pipelines: A2X (`a2x-s4`, `a2x-s96`), Xgc14 (`xgc14-bgra8`) and X | Command queues on a device whose GPU idles when consecutive work comes from another `VkQueue` share `VkQueue`s by choice (`queue_share.rs`): the runtime's own self-check, not a `DriverFact` row, measures that idling once per driver, release and runtime on a thread of its own and keeps its verdict (`Idles`, `DoesNotIdle`, `Unchecked`) in the shader cache's directory, as the in-place check keeps its own (`queue_switch_check.rs`: 48.7 to 51.3 us a switch on the RTX 5080 Laptop GPU, NVIDIA 615.71.09, `Idles` above 20 us). A command queue that makes a command buffer while it holds no other uncompleted one moves onto the busy `VkQueue` of its family whose oldest batch has run under 0.5 ms, the most batches in flight first, so short command buffers of several queues run with no switch between them. A queue one of whose command buffers ran on the GPU for over 2 ms, by its own timestamps (not the host's view of how long it ran as its `VkQueue`'s oldest, which also holds its wait for the GPU to start it and the waiter's lateness to see it complete), or held its `VkQueue` for over 2 ms from the submission of a batch that waited on the GPU for another `VkQueue`'s work (an `MTLEvent`'s signal, the tracker's wait, new resources' first work) to its own GPU end, is long: no queue joins its `VkQueue` while it lives, and it moves once more, at its next idle point, to an idle `VkQueue` no long or unshared queue holds. A queue whose command buffers must never wait behind another queue's (a compositor's beside an application's) is made with `Device::new_command_queue_unshared`: it never moves and no queue joins its `VkQueue`. Under either value, as a queue is made, it takes the round robin's `VkQueue` the fewest live command queues hold, of those no unshared queue holds, in turn among equals, and an unshared queue one no command queue holds where one is free (one pass over the `VkQueue`s' counts; one that finds none shares the one the fewest hold, `WorkCounts::unshared_queues_sharing_a_vk_queue`). Presenting queues and a queue that lent its `VkQueue` (`with_vk_queue`) never move. Before the verdict, and where it is not `Idles` or there are no two `VkQueue`s of one family (MoltenVK, RADV, lavapipe), every queue keeps the `VkQueue` it took at its creation; so does every queue of a device whose command buffers write no GPU timestamps it reads (`gpu_times_from_host`, or a driver whose timestamps wait for every queue's), which does not share and is counted (`WorkCounts::queue_sharing_untimed`). The runtime's: no pipeline differs. | `queue_sharing = QueueSharingPolicy::Adaptive` | `queue_sharing = QueueSharingPolicy::PerQueue`: each command queue keeps the `VkQueue` it took at its creation (the fewest live queues' as above), and the check does not run | A command buffer waits behind the command buffers of the queues sharing its `VkQueue`, where Metal's queues wait for each other only inside one command. The residual stall: once per logical queue that goes long, for a queue that joined its `VkQueue` during its short phase, about one long command buffer's length: the command buffers committed behind that queue's first long one there wait for its whole length (and those behind its later ones while it holds work, until its next idle point). Measured on the RTX 5080 Laptop GPU beside an application that alternates draws with 30 ms command buffers: a shared compositor's commits at 4,800 a second had 64 completions over 10 ms, at most 26.4 to 30.1 ms, in each of 3 runs of each of two such shapes (one join each), against none over 10 ms under `PerQueue` in those 6 runs (at most 5.6 to 9.7 ms); with 2 ms of draws between long command buffers, none over 10 ms in 3 runs (at most 5.7 to 9.8 ms) against 7, 0 and 0 under `PerQueue` (at most 6.9 to 11.2 ms). On an unshared queue, 0 over 10 ms in every run. A command buffer's GPU start time includes the other queues' work before it. `QueueSharing` (`queue-sharing`), at the device's first join | Command buffers a second on the RTX 5080 Laptop GPU, one-draw command buffers, each thread its own queue, the default against `PerQueue`, runs after a lock hold's first: 8 threads with 3 in flight 50.7k to 54.7k against 27.4k to 28.0k (5 runs each); 8 threads with 1 in flight 47.0k to 50.1k against 13.9k to 14.3k (5); 2 threads with 3 in flight 28.0k to 53.7k against 21.4k to 28.0k (10 each, in turn, the default above `PerQueue` in each pair; no thread's queue marked long), and beside another process's 30 ms command buffers 5.1k to 6.7k against 4.0k to 4.1k (3 each; the host's view marked a thread's queue long in 1 of 3 runs, which then ran at `PerQueue`'s 4.1k); 2 threads with 1 in flight 16.9k to 20.7k against 10.1k to 11.5k (5); one thread over 16 queues in turn 21.7k to 43.3k against 10.2k to 11.1k, over 2,048 20.0k to 39.2k against 10.2k to 11.2k (4). Beside an application whose queue never shared with the compositor (isolation, 300 and 30 dispatches), both 0 over 10 ms | | A chain of `half` additions, subtractions and products on a device without `shaderFloat16` (vk12-floor, SwiftShader, Pascal; capability emulation: the module computes each in `float` and rounds it by the device's `OpQuantizeToF16`): an operation whose flags hold `contract` and `reassoc` and whose result only such operations read is held at `float` precision unrounded, so the chain rounds where a value leaves it (a store, an output, a conversion, a comparison, a call, a phi, a vector move, an operation without both flags), one quantize per exit instead of one per operation (`lower::arith::half_chain`). A device with `shaderFloat16` computes `half` alike under either value. | `half_chains = HalfChainPolicy::AtExits` | `half_chains = HalfChainPolicy::EachOperation`: every operation's result rounded to `half`, as the AIR computes it | The result may differ from the rounded operations' by the roundings the chain skips, each within half a unit in the last place of a `half` at its step, compounded along the chain; a value inside the chain past `half`'s range (65504) stays finite where the rounded operations reach infinity. Within the AIR's flags, which let a compiler regroup and fuse such operations. `FastMathRewrites` (`fast-math-rewrites`) | Not timed. Size on vk12-floor (the fixtures' SPIR-V words, the default against the accurate form): `hfb_filter_bank` 121,270 against 131,766 (1,024 quantizes against 2,464), `grd_half_many_samples` 82,019 against 84,627, `nan_half_fast` 9,808 against 9,832 | | A texture that samples, reads, renders into it or is written through a shader (`ShaderWrite` or `ShaderAtomic` usage, of texels of 1, 2, 4, 8 or 16 bytes) over host pages (a no-copy buffer's, or a no-copy heap's buffer's, imported by their pointer or as dma-bufs; or a buffer in fresh pages; or a copied host buffer's copy of them, `copied.rs`, its image bound in the copy's memory where the check passed for the pages, and for the copy's fresh pages or, for a `DRM_FORMAT_MOD_LINEAR` image in memory the device allocates, its pooled memory, `WorkCounts::copied_textures_in_place`) is a linear image aliasing the pages in place, where the device makes the image (its format and usage linear, at the pages' pitch) and its own check shows that the operations Vulkan lets read and write every byte bound to it leave every byte alone while the CPU writes beside it: the image's first move (`VUID-VkImageCreateInfo-pNext-01443` makes such an image start `UNDEFINED`), and for one that renders a render pass's load and store operations and its moves into `ATTACHMENT_FEEDBACK_LOOP_OPTIMAL_EXT` and back, and for one a shader writes a kernel's storage writes of its texels (which of a linear image a driver may widen past a texel), each access checked apart (a shader's writes of 1- or 2-byte texels apart from those of wider ones, which a driver may store through a wider access), and each apart for texels that share a line of the device's memory (`nonCoherentAtomSize`, "the size and alignment in bytes that bounds concurrent access to host-mapped device memory") with bytes beside them and for texels that share none (their start, their end and, with bytes between rows, each row's start and end on a line; `in_place::RowEnds`): a byte changed beside texels that share none fails both, one changed beside texels that share one fails those alone (the Iris Xe, ANV, Mesa 26.2.6, whose clear and store, and draws, write back whole the 64-byte line that holds a row's last texels, fails renders, and writes, for rows that end inside a line, a byte between rows changed, and passes both for rows that end on one: a 3840x2160 `BGRA8Unorm` surface's 15360-byte rows are 240 lines each). A kernel's writes of a texture over a buffer's rows (no IOSurface plane's) whose rows, each to its pitch, start and end on a line, its buffer holding the last row to its pitch, take a verdict of their own from the same rounds, which a round that changed only bytes of its rows' padding (after a row's last texel, before its pitch, the last row's included) passes (`in_place::Padding`, `Access::BufferWrites`): Metal leaves those bytes to the GPU there (an Intel UHD Graphics 630 under macOS 26.7.1 wrote older values back over the CPU's writes to them under a kernel's writes of a texture over a buffer, the last row's included, where an M3 Max under macOS 27.0.1 and a Radeon Pro 5300M kept them, and all three kept them under draws, clears and stores and over IOSurfaces; `crates/metal2vulkan-conformance/probes/row_padding_writes.m`), and the rule follows the x86 Macs' envelope (docs/API.md, section 10, **Kernels**), so the Iris Xe's written textures over a buffer take the image in place whatever their rows' ends. A deliberate, scoped exception to relying on documented Vulkan behaviour alone, the owner's rulings (2026-10-26, and 2026-10-27 and 2026-11-07 for render targets and written textures: the GPU works on the caller's pages in place as a Mac's does, whatever a linear image costs it, on a discrete GPU too; `in_place.rs`). A texture over a buffer of the runtime's pooled memory whose rows the device's own linear image lays out otherwise (a padded pitch the driver does not take: ANV lays linear rows tight; rows apart only over a buffer that declares them unobserved, `BufferDescriptor::padding_unobserved`) is, by the same rule, a `DRM_FORMAT_MOD_LINEAR` image at Metal's pitch bound in the buffer's memory, at any size, where the device makes one (no external memory, which Vulkan allows: `VUID-VkImageCreateInfo-tiling-02261`, `VUID-vkBindImageMemory-image-01445`), made `UNDEFINED` (`VUID-VkImageCreateInfo-initialLayout-12478`), whose first move the check's pooled class judges (`PagesClass::Pooled`: a buffer of that memory, its images at Metal's pitch alone; `WorkCounts::pooled_pitched_images`); a texture made before that class's verdict is a shadow that moves to that image once the verdict passes, as one over host pages moves in place (below; `WorkCounts::pooled_textures_moved_in_place`, `pooled_texture_shadows_freed_after_move`). A texture over a buffer whose memory the runtime exports (`exported_memory.rs`: a block that exportable buffers of one handle type share) is, by the same rule, the device's linear image or that `DRM_FORMAT_MOD_LINEAR` image made for the memory's handle type, which an image bound there must name (`VUID-vkBindImageMemory-memory-02728`), and so made `UNDEFINED` (`VUID-VkImageCreateInfo-pNext-01443`), whose first move the check's exported classes judge, one per handle type (`PagesClass::ExportedFd`, `PagesClass::ExportedDmaBuf`: an exportable buffer of that handle type, its textures taking the product's image), a texture made before their verdicts moving to it once they pass as over the pooled memory; a shadow, its notice naming why, where the memory is a buffer's dedicated allocation (`VUID-vkBindImageMemory-memory-10926`) or the device's image format query (`VkPhysicalDeviceExternalImageFormatInfo`) takes the handle type for no such image without a dedicated allocation. A texture over a buffer in a block of the runtime's buffers allocated exportable as an opaque file descriptor and never exported (`memory.rs`'s "Buffers in exportable blocks") is the device's linear image made for that handle type, made `UNDEFINED`, and never a `DRM_FORMAT_MOD_LINEAR` one (RADV asks a dedicated allocation of one made for any handle type), whose first move and accesses the check's class of such blocks judges (`PagesClass::FdBlocks`: a buffer in such a block, its textures taking the product's images, made only where such a block holds every image a texture over a plain block's buffer that keeps its padding takes in place, `texture/fd_blocks_cover.rs`); the device's buffers lie there only where those verdicts give every texture over one what it takes over a plain block's buffer (`in_place::fd_blocks_take`), in plain blocks until they are known, and a buffer that declares its padding unobserved lies in a plain block wherever, so that a texture over it whose rows lie apart keeps its `DRM_FORMAT_MOD_LINEAR` image. A texture that renders over a buffer that declares its padding unobserved, its rows each to its pitch sharing no line with bytes past them, takes the verdict of renders that lets a byte of its rows' padding change (`Access::UnobservedRenders`, `Padding::Unobserved`), which the renders' own rounds give as the writes' give theirs: the declaration lets a pass's load and store write those bytes (the Iris Xe's clear and store write back the 64-byte line that holds a row's last texels whole), and a byte past the last row's pitch, or a texel, fails it. The check runs once per driver and driver version (its record named by the driver and the check's own version, not the runtime release), per class of pages, access and row ends, on a thread of its own, the verdicts it measured kept in the shader cache's directory with those it could not check for a cause that lasts for the driver (the device lacks an extension, a feature, an import, a format or an image of the shape), while one it could not check for a cause that may pass (pages or memory not made, an import refused, its writer thread not started, a move or the stores that failed) is checked again by the next device, its reason noted; a texture made before its verdict is a shadow, made without waiting for the check (its rounds take seconds on some devices and builds; `host_texture_shadows_check_pending`), and moves in place once its class's verdicts pass, at the commit of the device's only uncommitted command buffer, with no copy (`host_textures_moved_in_place`), its shadow's image freed once the command buffer that took the move completed (`host_texture_shadows_freed_after_move`), or, where a view made before the move presents it, a shadow made over it holds it as its truth, or the texture is untracked, once those and the texture went. A texture a shader writes of texels of a width no check stores (none of 1, 2, 4, 8 and 16 bytes), a check that failed or made no image, and a format, usage or pitch no image takes keep the shadow (`shadowed-texture`, its reason named, `WorkCounts::host_texture_shadows_*`, those that render and those a shader writes counted apart in `host_texture_shadows_render_target` and `host_texture_shadows_shader_write`). On a discrete GPU a `Shared` texture and an IOSurface's are in place too, read across the bus, never copied to the device's memory for speed; a `Managed` no-copy buffer there is two copies (`managed_copy.rs`, the **Costs of matching Metal** bullet), and a texture over its bytes is over its GPU copy, no texture over host pages; a `Managed` texture over the bytes of a no-copy buffer that lies in its pages there (its GPU copy found no room, or Metal's private option bit 24 drops its GPU writes) that only samples or reads, over memory that carries a log of its writes, is a device copy instead (`WorkCounts::device_copy_textures`), the GPU's copy of the two Metal keeps of a `Managed` resource on a Mac with a discrete GPU, its copies in only the rows the log reports changed. | `host_page_textures = HostPageTexturePolicy::InPlace` | `host_page_textures = HostPageTexturePolicy::Shadow`: every texture over host pages a shadow, its texels copied in before each command buffer that uses it and merged back after each write (the host-pages bullet under **Costs of matching Metal**) | Exact where the driver keeps what its check showed: the check covers texels, the bytes between rows and those after the image, of 1, 2, 4, 8 and 16-byte texels and a 3840x2160 surface, three rounds each, for an image that reads and one that renders (its pass a clear at load and a store, then a draw over its last column in a pass that loads and stores it; a resolve into it is not among the rounds), the CPU writing beside the texels sweep after sweep until each step completed, so that a device that writes back bytes it read beside them, wherever in the step, puts back an older value the check finds, and, for one a shader writes, of 4, 8 and 16-byte texels, rows apart (of widths no multiple of 4 and odd heights among them) or tight, and 1920x1080, and apart of 1- and 2-byte texels, rows apart at a 256-byte pitch (of rows that end inside a 4-byte word and odd heights) or tight, and 1024x64, each texel stored by a kernel through an unsigned-integer view (a program's atomics, and its stores through a float view, are not among the rounds); a driver whose operations changed a byte outside every round's window would undo a CPU write made meanwhile. A kernel's writes of a texture over a buffer whose padding is free may change that padding, as an x86 Mac's GPU's do (above). Not announced where the check passed. A CPU write reaches the image's reads as it reaches the buffer's (Host Write Ordering Guarantees) | See **Costs of matching Metal** (host pages): the shadow copies a sampled 3840x2160 surface in whole each command buffer, and a render target's shadow copies it in, keeps it and merges it back at each render pass instance | -| A render or compute state's creation hands the driver's making of its predicted pipeline (`pipeline/predicted.rs`, `pipeline/dispatch_making.rs`) to the runtime's pool, kept by the state as a draw's or dispatch's making is, and waits for it `pipeline_creation_wait` at most, returning with it in flight. A committed command buffer's draws and dispatches (a compute encoder's, a render pass's tile dispatches, an execution's replayed draws, whose pipelines the commit's settle hands to the pool) wait for their pipelines until they are made, however long that takes: the batch is held in its queue's line (`Segment::steps_after_pipelines`), on the scheduler's thread, which no call waits for, and records them once made, so no command is dropped for its making's time and the command buffer completes later, as on a slower GPU. A `commit` waits for the pipelines of a pass that executes render commands the CPU writes until its commit plus `pipeline_commit_wait` at most, and leaves the pass to its host step past that. Metal compiles inside `newRenderPipelineState`; a host that creates a state inside a command buffer's encoding (the consumer creates a guest's state at an execution's first lookup of it) held that execution through the driver's whole compile: 11.59 s inside one execution on an M2 Pro (MoltenVK 1.4.2, a cold Metal compiler service; a sample of such a stall finds the compile's thread waiting in `MVKMetalCompiler::compile` for Metal's compiler). Each bound is 4.5 s: a creation and a commit may fall in one step of the guest's FIFO, and no runtime call waits for both, so one step's calls wait 9 s at most for makings. A creation waits on no command buffer's deadline and a `commit` on no creation's; every other recording runs on the scheduler's thread, a host step's on one of the steps' threads. Made until made under either value, in the call that makes them: a draw that records nothing, one in a pass of custom sample positions and one recorded again into another instance of its pass (each in the draw's call or an execution's replay), a device replay's draws (in its `commit`), and a failed making made again (`PipelineWaitPolicy`'s docs). The runtime's: no pipeline differs. An open gap, not a choice: a draw of an execution's replay whose making the replay waits for itself (one the commit's settle left the host step no wait for, as for a state whose creation's own making is still in flight), still being made at its command buffer's commit plus `pipeline_commit_wait`, records nothing (`render/pending.rs`) | `pipeline_waits = PipelineWaitPolicy::Bounded`, `pipeline_creation_wait = 4.5 s`, `pipeline_commit_wait = 4.5 s` | `pipeline_waits = PipelineWaitPolicy::Exact`: the creation makes its predicted pipeline before it returns (a render state's first key on its own thread, the rest on the pool, joined; a compute state's on its own thread), an execution's settle makes its replayed draws' pipelines at the commit, and a command buffer waits for each draw's and dispatch's pipeline until it is made | A creation returns after `pipeline_creation_wait` at most with its making in flight (`WorkCounts::creations_left_making`), where Metal's returns with it made, and a command buffer whose draw or dispatch takes a making still in flight completes once it lands: its completion, and the calls that wait for the GPU (a wait for its completion or scheduling, an event it signals, a new command buffer of a queue whose most are all uncompleted), wait up to the rest of the compile; nothing renders or writes otherwise. Only its queue's later command buffers wait behind it. `deferred_calls::a_draw_whose_pipeline_is_still_being_made_past_its_bound_renders_once_made`, `a_dispatch_whose_pipeline_is_still_being_made_past_its_bound_runs_once_made`, `a_compute_state_s_creation_waits_its_bound_for_its_predicted_making` and `under_the_exact_wait_a_held_making_holds_its_command_buffer_until_it_lands`. The open gap's draw renders nothing in that command buffer (only there: later ones draw it), where Metal's renders: `DrawDroppedStillMaking` (`draw-dropped-still-making`), at each such draw where `DeviceOptions::announce_each` asks, else once per device; `CommandBuffer::dropped_draw` names the first with `VK_TIMEOUT`; `WorkCounts::draws_dropped_still_making`; `deferred_calls::a_replayed_draw_whose_pipeline_is_still_being_made_at_its_bound_runs_nothing` | No GPU cost. The exact form holds the creating thread for the whole compile: up to 11.59 s on the M2 Pro's cold boot (that boot's 2,483 render state creations, translation included: 300 over 16 ms, 151 over 100 ms, 14 over 250 ms, 3 over 1 s, the longest 11.59 s, 5.82 s and 1.17 s), where the default holds a creation for 4.5 s at most. Under either value a command buffer committed before its making lands completes when it lands, its queue's later command buffers after it: a guest's kernel of 4.5 M SPIR-V words took 116 s to make on the RX 7900 XTX (RADV) | +| A render or compute state's creation hands the driver's making of its predicted pipeline (`pipeline/predicted.rs`, `pipeline/dispatch_making.rs`) to the runtime's pool, kept by the state as a draw's or dispatch's making is, and waits for it `pipeline_creation_wait` at most, returning with it in flight. A committed command buffer's draws and dispatches (a compute encoder's, a render pass's tile dispatches, an execution's replayed draws, whose pipelines the commit's settle hands to the pool) wait for their pipelines until they are made, however long that takes: the batch is held in its queue's line (`Segment::steps_after_pipelines`), on the scheduler's thread, which no call waits for, and records them once made, so no command is dropped for its making's time and the command buffer completes later, as on a slower GPU. A `commit` waits for the pipelines of a pass that executes render commands the CPU writes, and for those its executions' replay begins itself, until its commit plus `pipeline_commit_wait` at most, and leaves the pass to its host step past that, which records it once they are made (`DeferredPass::left_for_makings`); a host step waits on its own thread for a making it begins itself. Metal compiles inside `newRenderPipelineState`; a host that creates a state inside a command buffer's encoding (the consumer creates a guest's state at an execution's first lookup of it) held that execution through the driver's whole compile: 11.59 s inside one execution on an M2 Pro (MoltenVK 1.4.2, a cold Metal compiler service; a sample of such a stall finds the compile's thread waiting in `MVKMetalCompiler::compile` for Metal's compiler). Each bound is 4.5 s: a creation and a commit may fall in one step of the guest's FIFO, and no runtime call waits for both, so one step's calls wait 9 s at most for makings. A creation waits on no command buffer's deadline and a `commit` on no creation's; every other recording runs on the scheduler's thread, a host step's on one of the steps' threads. Made until made under either value, in the call that makes them: a draw that records nothing, one in a pass of custom sample positions and one recorded again into another instance of its pass (each in the draw's call or an execution's replay), a device replay's draws (in its `commit`), and a failed making made again (`PipelineWaitPolicy`'s docs). The runtime's: no pipeline differs. | `pipeline_waits = PipelineWaitPolicy::Bounded`, `pipeline_creation_wait = 4.5 s`, `pipeline_commit_wait = 4.5 s` | `pipeline_waits = PipelineWaitPolicy::Exact`: the creation makes its predicted pipeline before it returns (a render state's first key on its own thread, the rest on the pool, joined; a compute state's on its own thread), an execution's settle makes its replayed draws' pipelines at the commit, and a command buffer waits for each draw's and dispatch's pipeline until it is made | A creation returns after `pipeline_creation_wait` at most with its making in flight (`WorkCounts::creations_left_making`), where Metal's returns with it made, and a command buffer whose draw or dispatch takes a making still in flight completes once it lands: its completion, and the calls that wait for the GPU (a wait for its completion or scheduling, an event it signals, a new command buffer of a queue whose most are all uncompleted), wait up to the rest of the compile; nothing renders or writes otherwise. Only its queue's later command buffers wait behind it. `deferred_calls::a_draw_whose_pipeline_is_still_being_made_past_its_bound_renders_once_made`, `a_replayed_draw_whose_pipeline_is_still_being_made_at_its_bound_renders_once_made`, `a_dispatch_whose_pipeline_is_still_being_made_past_its_bound_runs_once_made`, `a_compute_state_s_creation_waits_its_bound_for_its_predicted_making` and `under_the_exact_wait_a_held_making_holds_its_command_buffer_until_it_lands` | No GPU cost. The exact form holds the creating thread for the whole compile: up to 11.59 s on the M2 Pro's cold boot (that boot's 2,483 render state creations, translation included: 300 over 16 ms, 151 over 100 ms, 14 over 250 ms, 3 over 1 s, the longest 11.59 s, 5.82 s and 1.17 s), where the default holds a creation for 4.5 s at most. Under either value a command buffer committed before its making lands completes when it lands, its queue's later command buffers after it: a guest's kernel of 4.5 M SPIR-V words took 116 s to make on the RX 7900 XTX (RADV) | | A line Apple's `setLineWidth:` widens (`w' = floor(16 w) / 16`, other than 1), and a triangle's edge in fill mode `Lines`, is drawn by the device's own lines at `w'` wherever it draws that width (`wideLines`, `w'` in `lineWidthRange` and above 0), where Metal draws the parallelogram Vulkan's non-strict wide lines may be (`render/line_width.rs`). No device's are taken as it, announced on every device: a strict device's rectangle with square ends (lavapipe, NVIDIA), lines Vulkan does not state as parallelograms (ANV, and every width below 1), a width rounded to the granularity, and a driver's parallelograms (`strictLines` unset, `nonStrictWideLinesUseParallelogram` set), whose ends the driver places (RADV on the Radeon RX 7900 XTX draws 21 of `runtime_lane::line_widths`'s 48 scattered lines at width 2.5 a row or a column off Metal's at an end). A mesh draw's lines and edges and a tessellated patch draw's edges take the device's lines under either value, the band not drawing them (at the nearest width they draw where they do not draw `w'`, announced `lines-at-nearest-width`: a known gap below). The runtime's: no pipeline's code differs. | `wide_lines = WideLinePolicy::Device` | `wide_lines = WideLinePolicy::Exact`: a draw of lines or edges the device's lines draw is the pipeline's band variant (`VariantKey::line_band`, `pipeline::link::band`) on a device with `tessellationShader` (the device's lines where it has none, or where the translator refuses the state's band or the draw's): two triangles over each line's parallelogram, and each triangle's three edges' parallelograms facing as the triangle, through a tessellation control and evaluation stage; every other width other than 1 is the band under either value | The lines can cover pixels the parallelogram does not, and miss others, at each end and along each edge: up to half the width past each end (square ends), a rounded width, and a row or a column at an end (a driver's parallelograms). `DeviceWideLines` (`device-wide-lines`), at each such draw where `DeviceOptions::announce_each` asks, else once per device; `WorkCounts::device_wide_line_draws`, `line_band_draws`, `nearest_width_line_draws`; `runtime_lane::line_widths` (the band matches Metal's maps of lines and of triangles' edges, their facing, culling, flat inputs, primitive IDs and depth on MoltenVK under both values, which has no `wideLines`; a band of edges under a depth bias is announced `wide-edge-depth-bias`) | Not measured. Expected from the band's form: a second pipeline variant made for each render state that draws such lines or edges (its two synthesized stages), each line tessellated as a patch of two control points into four corners and each triangle as a patch of three into 21 triangles (12 degenerate), and a strip, loop or fan drawn as the list of its primitives | | A blit or fill through a `BGRA10_XR` or `BGRA10_XR_sRGB` texture Metal keeps losslessly compressed (`allowGPUOptimizedContents`, 16 texels or more a side, neither `ShaderWrite` nor `PixelFormatView` usage, one sample, not over a buffer) is the device's copy, which keeps the bytes it moves, on every device: Metal's GPU blit into, out of or between such textures moves the texels through its compression, which writes each 16-bit field's low six bits cleared and the alpha code clamped to `[384, 894]`, and its fill clears the low six bits alone (an Apple M3 Max under macOS 27.0.1, every direction, storage mode, usage and size that decides the compression; CPU copies keep the bytes on Metal too). A pass's draws through such an attachment are the device-gap row below. The runtime's choice: no pipeline differs (`compressed_blit.rs`). | `extended_range_blits = ExtendedRangeBlitPolicy::Kept` | `extended_range_blits = ExtendedRangeBlitPolicy::Canonical`: after a blit writes such a texture's region, or a blit out of one writes a buffer's words, a texture over a buffer's or another texture's, a compute dispatch (`bind::extended_canonical_module`, `extended_canonical.rs`) rewrites the texels it wrote in Metal's encoding: in place in a buffer's bytes, an image's through a scratch buffer, a copy out and back around the dispatch; a fill's texel is encoded before it is written. A buffer whose words the device cannot bind (an offset or pitch off 4 bytes, a region past `maxStorageBufferRange`) and a texture over a buffer whose rows share bytes keep the bytes under either value, announced | Bytes no Metal write left (uploaded, CPU-copied or kernel-written texels: a field's low six bits, an alpha code outside `[384, 894]`) keep what Metal's blit would rewrite; a texel reads the same value either way, its low six bits unread and its alpha read clamped. `ExtendedRangeBitsKept` (`extended-range-bits-kept`), once per device; under `Canonical` not for the blits it makes exact; `runtime_lane::compressed_blits` (both values on MoltenVK), the conformance cases `compressed-blits-bgra10xr` and `compressed-blits-bgra10xr-srgb` | Measured, `Canonical` against `Kept`, on `Private` `BGRA10_XR` textures Metal keeps compressed (the sRGB twin and fills not measured), 256x256 and 2048x2048, one whole-texture blit a command buffer: p50 of 300 blits a run, the two values interleaved in one process, three runs a host. RTX 5080 Laptop (NVIDIA 615.71.09, the command buffer's GPU time): a buffer into the texture 23.5 against 11.5 us and 761 against 244 us from a `Private` buffer, 42 against 30 us and 1,945 against 1,176 us from a `Shared` one; the texture into a `Private` buffer 14.1 against 11.2 us and 287 against 246 us, into a `Shared` one, whose words the dispatch rewrites in system memory, 66 against 27 us and 3,386 against 1,182 us; texture into texture 22.5 against 9.7 us and 630 against 80 us. Apple M3 Max (MoltenVK 1.4.2, whose GPU times are the host's, so per blit of 16 in one command buffer), the same blits: into the texture +38 to +57 us and +536 to +548 us, out of it into a buffer +15 us and +84 to +94 us, texture into texture +46 to +48 us and +535 to +541 us. Every figure is above its `Kept` one in every run, by more than the runs' spread (under 1 us on the 5080): measurable at both sizes on both hosts. Into an image a blit adds a copy out into a scratch buffer of the region's size, the dispatch, a copy back and the barriers between them; into a buffer the dispatch and a barrier. The scratch is made without zeros, since the copy out writes every byte the dispatch and the copy back read; the figures above were taken while it was zeroed first, by a command buffer of its own (a fill on the 5080, a copy on MoltenVK). CPU from the command buffer's making through its commit, a blit alone: +1 to +3 us on the M3 Max, +1 to +127 us on the 5080, whose host other builds loaded; 16 blits into 2048x2048 images in one command buffer hold 16 scratch buffers of 32 MiB, and encoding each costs 141 to 165 us (5080) and 286 to 356 us (M3 Max), new memory blocks among it, against 2 to 6 us under `Kept`. Nothing for a texture Metal keeps uncompressed or of another format | | A colour attachment of a texture's own image (not over a buffer's bytes, not memoryless, resolving nothing) that a pass stores `DontCare` is stored as the driver stores it: `DONT_CARE` on a driver measured to keep one of Metal's two answers or to store as Metal's own (`DriverFact::DontCareStoreIsOneOfMetals`, `DontCareStoreIsMetals`), else `STORE`, the rendered texels (`render_target.rs`). Metal's documentation leaves the contents open (`MTLStoreAction.dontCare`: "You need to assume that GPU discarded the texture's contents"); Apple's GPU leaves the texels the attachment held before the pass, the pass's clear and draws both gone (the conformance case `pass-sequence-color-actions`, an M3 Max under macOS 27.0.1, eight runs alike), or the rendered ones where its tiler overflows. A pass MoltenVK runs as one instance is handed to Metal's own `DontCare` under either value. | `dont_care_colors = DontCareColorPolicy::Driver` | `dont_care_colors = DontCareColorPolicy::Kept`: the pass renders through a backing its command queue keeps, one image of the attachment's shape, into which a `Load` copies the texels first, and nothing is copied back, so the texture keeps its earlier texels exactly (`kept_bytes.rs`, `WorkCounts::kept_texels_passes`); where a format makes no such image, the pass stores as under `Driver`, announced | Under `Driver`, the attachment holds the rendered texels (`STORE`: NVIDIA, lavapipe) or what the driver's `DONT_CARE` leaves (RADV, ANV: measured to be one of Metal's two answers), where Metal's holds the earlier texels unless its tiler overflows; where the pass also loads it `DontCare` and the runtime clears it (`unstored_dont_care_loads`, below), a tile no draw touches holds zero or the clear value. `DontCareStore` (`dont-care-store`), once per device; under `Kept` not for the passes it keeps; `runtime_lane::dont_care_stores` (both values), the conformance case `pass-sequence-color-actions` | Measured, `Kept` against the same pass stored `Store`, one pass of one draw over an `RGBA8Unorm` texture a command buffer, commit to completion, the median of 300 interleaved (a scratch measurement, `rows3_cost`): RTX 5080 Laptop (NVIDIA 615.71.09), a `Load` pass 19 µs more at 1920x1080 and 10 µs at 256x256 (16 µs and 7 µs of GPU time), a `Clear` pass 3 µs; lavapipe (llvmpipe, LLVM 23.1.4), a `Load` pass 0.5 to 0.8 ms more at 1920x1080 and 30 µs at 256x256, a `Clear` pass within the runs' spread. Memory: one backing image of the attachment's shape per command queue |