diff --git a/crates/metal2vulkan-runtime/README.md b/crates/metal2vulkan-runtime/README.md index 28ab7a9bc..970543f9d 100644 --- a/crates/metal2vulkan-runtime/README.md +++ b/crates/metal2vulkan-runtime/README.md @@ -797,7 +797,7 @@ pipeline it hands to the runtime's pool): the command buffer completes later, as 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 pipeline the replay itself began making, still being +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 diff --git a/crates/metal2vulkan-runtime/src/command_buffer/mod.rs b/crates/metal2vulkan-runtime/src/command_buffer/mod.rs index 86bfd2d7b..d62dfeb48 100644 --- a/crates/metal2vulkan-runtime/src/command_buffer/mod.rs +++ b/crates/metal2vulkan-runtime/src/command_buffer/mod.rs @@ -4104,7 +4104,7 @@ impl CommandBuffer { self.keep_dropped(failed); } - /// Note `late`, a draw of an execution's replay whose pipeline the replay itself began making + /// 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 diff --git a/crates/metal2vulkan-runtime/src/degradation.rs b/crates/metal2vulkan-runtime/src/degradation.rs index 716928833..9a7d9674c 100644 --- a/crates/metal2vulkan-runtime/src/degradation.rs +++ b/crates/metal2vulkan-runtime/src/degradation.rs @@ -2189,8 +2189,8 @@ degradations! { 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 itself began making, of a key its - /// commit's settle did not foresee, and the driver was still making once its command + /// 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. diff --git a/crates/metal2vulkan-runtime/src/render/pending.rs b/crates/metal2vulkan-runtime/src/render/pending.rs index fa46513e1..fc0e20b80 100644 --- a/crates/metal2vulkan-runtime/src/render/pending.rs +++ b/crates/metal2vulkan-runtime/src/render/pending.rs @@ -37,8 +37,8 @@ //! (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 itself begins, of a key the settle did not foresee, is waited for until -//! its command buffer's bound at most, and one still being made then makes the draw record +//! 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`, diff --git a/crates/metal2vulkan-runtime/src/tests/deferred_calls.rs b/crates/metal2vulkan-runtime/src/tests/deferred_calls.rs index 5e3e36e1e..1bf3b95e8 100644 --- a/crates/metal2vulkan-runtime/src/tests/deferred_calls.rs +++ b/crates/metal2vulkan-runtime/src/tests/deferred_calls.rs @@ -1537,18 +1537,18 @@ fn a_draw_whose_pipeline_is_still_being_made_past_its_bound_renders_once_made() ); } -/// A draw of an execution's replay whose pipeline, settled at commit, is still being made past -/// 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 -/// settles the records the CPU wrote, the draw's making among them, held in the pool, and waits -/// for it until its bound at most, then leaves the pass to its host step: the commit returns -/// within the 10 s a guest's FIFO check allowed, and 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, -/// `dropped_draw` naming nothing, nothing counted in `draws_dropped_still_making` and no -/// `draw-dropped-still-making` announced. +/// 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. #[test] -fn a_replayed_draw_whose_pipeline_is_still_being_made_past_its_bound_renders_once_made() { +fn a_replayed_draw_whose_pipeline_is_still_being_made_at_its_bound_runs_nothing() { use super::encoder_holds::library; use crate::{IndirectCommandBufferDescriptor, PipelineOptions}; use metal2vulkan::metal::{IndirectCommandType, RenderStages, ResourceUsage}; @@ -1615,34 +1615,46 @@ fn a_replayed_draw_whose_pipeline_is_still_being_made_past_its_bound_renders_onc let back = replayed(&command_buffer); let committing = Instant::now(); command_buffer.commit().unwrap(); - let commit = committing.elapsed(); - assert!( - commit < GUEST_WATCHDOG, - "the commit took {commit:?}, past its 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 draw's making lands"); + .wait_until_completed_for(GUEST_WATCHDOG) + .expect("the command buffer completes at its bound with its draw's making held"); + let waited = committing.elapsed(); + assert!( + (COMMIT_WAIT..GUEST_WATCHDOG).contains(&waited), + "completed after {waited:?}, not its own bound" + ); assert_eq!(command_buffer.status(), CommandBufferStatus::Completed); assert_eq!(command_buffer.error(), None); assert!(command_buffer.failed_pipeline().is_none()); - assert!(command_buffer.dropped_draw().is_none()); - assert!( - words_of(&back).iter().all(|&w| w == PACKED), - "the rectangle, drawn" - ); + 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 + after.draws_dropped_still_making - counts.draws_dropped_still_making, + 1 ); assert!( - !(heard.lock().unwrap().iter()) + (heard.lock().unwrap().iter()) .any(|notice| notice.degradation == Degradation::DrawDroppedStillMaking), - "a draw was dropped" + "no notice of the dropped draw" ); + 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 diff --git a/crates/metal2vulkan-runtime/src/work_counts.rs b/crates/metal2vulkan-runtime/src/work_counts.rs index 3a8039539..45b07dee5 100644 --- a/crates/metal2vulkan-runtime/src/work_counts.rs +++ b/crates/metal2vulkan-runtime/src/work_counts.rs @@ -2332,7 +2332,7 @@ impl Counters { self.draws_dropped_unmade.fetch_add(1, Ordering::Relaxed); } - /// A draw of an execution's replay whose pipeline the replay itself began making was still + /// 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 @@ -5501,7 +5501,7 @@ 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 itself began making and that was + /// 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 diff --git a/crates/metal2vulkan-validation/src/runtime_lane/degrade_notices.rs b/crates/metal2vulkan-validation/src/runtime_lane/degrade_notices.rs index 29fd901a0..32b836e1c 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/degrade_notices.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/degrade_notices.rs @@ -807,7 +807,7 @@ 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 pipeline the replay itself began making +/// 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 diff --git a/crates/metal2vulkan/src/device/policy.rs b/crates/metal2vulkan/src/device/policy.rs index b8da46327..916902b5c 100644 --- a/crates/metal2vulkan/src/device/policy.rs +++ b/crates/metal2vulkan/src/device/policy.rs @@ -89,7 +89,7 @@ pub struct DevicePolicy { /// 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 began itself, past which that draw records as nothing (the open gap, + /// 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 /// by default (as the creation wait, above). Unread under `Exact`. The runtime's alone: no /// emitted code changes. @@ -490,7 +490,7 @@ pub enum PipelineWaitPolicy { /// 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 pipeline the replay itself began making, still being made at its + /// 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`. /// diff --git a/docs/API.md b/docs/API.md index 4cceec6e1..523db1350 100644 --- a/docs/API.md +++ b/docs/API.md @@ -194,8 +194,8 @@ compile does. `DevicePolicy::default()` is `DevicePolicy::UNTRUSTED`: 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 pipeline the replay itself began making, of a key the commit's - settle did not foresee, still being made at that bound (`draw-dropped-still-making`, named by + 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 @@ -3563,8 +3563,8 @@ bound. `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 itself began making, of a key its commit's settle did not foresee, - and the driver was still making once its command buffer's bound passed + 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 diff --git a/docs/FAST-PATHS.md b/docs/FAST-PATHS.md index df851a086..0990aa06d 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 pipeline the replay itself began making, of a key the commit's settle did not foresee, 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_replayed_draw_whose_pipeline_is_still_being_made_past_its_bound_renders_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` | 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 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 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 |