diff --git a/crates/metal2vulkan-runtime/src/buffer_texture.rs b/crates/metal2vulkan-runtime/src/buffer_texture.rs index 4fd3a77d0..0a56cc60f 100644 --- a/crates/metal2vulkan-runtime/src/buffer_texture.rs +++ b/crates/metal2vulkan-runtime/src/buffer_texture.rs @@ -1616,13 +1616,16 @@ impl Texels { self.texel_bytes } - /// How the texels lie in the device's lines of memory of `line` bytes over the caller's pages - /// themselves, from their address (`in_place::RowEnds::of`), and whether a shader's writes may - /// change their rows' padding there (`in_place::Padding::of`): as [`rows`](Self::rows) and - /// [`padding`](Self::padding) answer them over an import of the pages, which a copied host - /// buffer's rebind may make (`copied.rs`), where [`rows`](Self::rows) answers them in its copy. - /// `None` over no caller's pages. + /// Over a copied host buffer (`copied.rs`), how the texels lie in the device's lines of memory + /// of `line` bytes over the caller's pages themselves, from their address + /// (`in_place::RowEnds::of`), and whether a shader's writes may change their rows' padding + /// there (`in_place::Padding::of`): as [`rows`](Self::rows) and [`padding`](Self::padding) + /// answer them over an import of the pages, which the buffer's rebind may make, where + /// [`rows`](Self::rows) answers them in its copy. `None` over any other buffer. pub(super) fn over_caller_pages(&self, line: u64) -> Option<(RowEnds, Padding)> { + if !self.buffer.copied() { + return None; + } let start = self.buffer.contents()?.as_ptr().addr() as u64; let padding = Padding::of(start, &self.layout, line, self.padding_owned()); Some(( diff --git a/crates/metal2vulkan-runtime/src/copied.rs b/crates/metal2vulkan-runtime/src/copied.rs index 45110fe27..d525b5fdf 100644 --- a/crates/metal2vulkan-runtime/src/copied.rs +++ b/crates/metal2vulkan-runtime/src/copied.rs @@ -108,12 +108,14 @@ //! imports a read-only view of its pages (`read_only_view.rs`). //! - **Textures over a copy.** A texture made over a copied buffer is a linear image over the copy, //! bound in its memory at the texels' offset, where the device's in-place check passed for the -//! copy's memory and the caller's pages (a rebind may import them), for the texture's accesses -//! and how its texels lie in lines there (`in_place.rs`, `texture/route.rs`; counted: +//! caller's pages (a rebind may import them; and the device's store path, which renders and +//! writes into the copy take too) and the copy's memory, for the texture's accesses and how its +//! texels lie in lines there (`in_place.rs`, `texture/route.rs`; counted: //! `WorkCounts::copied_textures_in_place`): in fresh pages the runtime imported, the image made -//! for host allocations, as over the caller's pages; in memory the device allocates, the -//! driver's own linear image that starts `PREINITIALIZED`, else a `DRM_FORMAT_MOD_LINEAR` one at -//! Metal's pitch, under the check of the runtime's pooled memory (`PagesClass::Pooled`). Its +//! for host allocations, as over the caller's pages, under the fresh pages' check; in memory the +//! device allocates, the driver's own linear image that starts `PREINITIALIZED`, so its first +//! move keeps the copy's bytes, else a `DRM_FORMAT_MOD_LINEAR` one at Metal's pitch, made +//! `UNDEFINED`, under the check of the runtime's pooled memory too (`PagesClass::Pooled`). Its //! hazard identity is the buffer's, so its uses name the copy as the buffer's do: each commit //! copies the CPU's writes in, and each completion that may have written it merges the GPU's //! back. Elsewhere it is a shadow of the copy's bytes (`shadowed-texture`). diff --git a/crates/metal2vulkan-runtime/src/in_place.rs b/crates/metal2vulkan-runtime/src/in_place.rs index 55b939fe1..801b03eef 100644 --- a/crates/metal2vulkan-runtime/src/in_place.rs +++ b/crates/metal2vulkan-runtime/src/in_place.rs @@ -3,8 +3,9 @@ //! placed in fresh host pages, is a linear image aliasing those pages, where the device's own check //! shows that the operations that may touch bytes beside the texels leave every byte alone. Over a //! copied host buffer (`copied.rs`) the image aliases the copy the GPU uses in the pages' stead, -//! where the check passed for the copy's memory (fresh pages, or the runtime's pooled memory) and -//! for the pages, for texels that lie in lines as they lie in each (`texture/route.rs`). +//! where the check passed for the pages, and for fresh pages where the copy lies in them, for +//! texels that lie in lines as they lie in each (`texture/route.rs`); a `DRM_FORMAT_MOD_LINEAR` +//! image over a copy in memory the device allocates, for the runtime's pooled memory too. //! //! - **What Vulkan says.** An image bound to imported memory starts `UNDEFINED` //! (`VUID-VkImageCreateInfo-pNext-01443`: "If the pNext chain includes a diff --git a/crates/metal2vulkan-runtime/src/tests/copied_device.rs b/crates/metal2vulkan-runtime/src/tests/copied_device.rs index a3a288b02..2a52e34ca 100644 --- a/crates/metal2vulkan-runtime/src/tests/copied_device.rs +++ b/crates/metal2vulkan-runtime/src/tests/copied_device.rs @@ -1077,15 +1077,16 @@ fn copied_rebind_makes_a_texture_s_image_in_place_again_over_the_copy() { } /// Whether the device's check passed, for a texture of `usage` over `buffer` (a copied buffer, its -/// copy in memory the device allocates) at `pitch`, for its copy's memory (the runtime's pooled -/// memory) and the caller's pages, each for texels that lie in lines as they lie there: whether -/// the texture is to be an image over the copy (`texture/route.rs`). +/// copy in memory the device allocates) at `pitch`, for the caller's pages, for texels that lie in +/// lines as they lie in the copy and in the pages; and whether it passed for the runtime's pooled +/// memory, which a `DRM_FORMAT_MOD_LINEAR` image over the copy takes too (`texture/route.rs`, +/// `Device::copy_unplaced`). fn passed_over_copy( device: &Device, buffer: &Buffer, usage: metal2vulkan::metal::TextureUsage, pitch: usize, -) -> bool { +) -> (bool, bool) { use crate::in_place::{Access, PagesClass, RowEnds, Verdict}; let layout = crate::linear_plan::BufferLayout { offset: 0, @@ -1108,9 +1109,11 @@ fn passed_over_copy( device.in_place_verdict(class, access, rows) == Verdict::Passed }; let policy = device.compile_device().policy().host_page_textures; - policy == metal2vulkan::device::HostPageTexturePolicy::InPlace - && passes(PagesClass::Pooled, copy) - && passes(PagesClass::Pointer, caller) + let in_place = policy == metal2vulkan::device::HostPageTexturePolicy::InPlace; + ( + in_place && passes(PagesClass::Pointer, copy) && passes(PagesClass::Pointer, caller), + passes(PagesClass::Pooled, copy), + ) } /// A 16 x 16 RGBA8 texture of `usage` over `buffer` at 0, its rows `pitch` apart, and whether it @@ -1191,12 +1194,14 @@ fn clear_reaches_the_pages( ); } -/// A texture made over a copied buffer is an image over the copy where the device's check passed -/// for the copy's memory and the caller's pages (`texture/route.rs`), sampled and rendered into -/// alike; else a shadow. Either way it reads the caller's texels; a CPU write before a commit -/// reaches it; a blit into it, and for one that renders a render pass's clear, reach the texels' -/// bytes in the pages alone. Before textures took an image over a copy, each was a shadow: on a -/// device whose check passed (lavapipe, the Iris Xe) the answer the verdicts give fails it. +/// A texture made over a copied buffer (its copy in memory the device allocates) is an image over +/// the copy where the device's check passed for the caller's pages and, where its image is the +/// `DRM_FORMAT_MOD_LINEAR` one, for the runtime's pooled memory (`texture/route.rs`), sampled and +/// rendered into alike; never where the first did not pass; else a shadow. Either way it reads +/// the caller's texels; a CPU write before a commit reaches it; a blit into it, and for one that +/// renders a render pass's clear, reach the texels' bytes in the pages alone. Before textures took +/// an image over a copy, each was a shadow: on a device whose check passed both (lavapipe, the +/// Iris Xe) the test fails. #[test] fn a_texture_over_a_copied_buffer_is_an_image_over_the_copy_where_the_check_passed() { use metal2vulkan::metal::TextureUsage; @@ -1216,17 +1221,25 @@ fn a_texture_over_a_copied_buffer_is_an_image_over_the_copy_where_the_check_pass let asked: Arc>> = Arc::default(); let buffer = host.buffer(&device, Some(gate(&asked, false))); assert!(buffer.copied(), "the gate refused the import: a copy"); - let expected = passed_over_copy(&device, &buffer, usage, PITCH); + let (pages, pooled) = passed_over_copy(&device, &buffer, usage, PITCH); let (texture, over_copy) = texture_over_copy(&device, &buffer, usage, PITCH); eprintln!( - "COPIED-TEXTURE {name} on {}: the check passed {expected}, an image over the copy \ - {over_copy}", + "COPIED-TEXTURE {name} on {}: the check passed for the pages {pages} and the pooled \ + memory {pooled}, an image over the copy {over_copy}", device.name() ); - assert_eq!( - over_copy, expected, - "{name}: an image over the copy where the check passed" - ); + if pages && pooled { + assert!( + over_copy, + "{name}: an image over the copy where the check passed" + ); + } + if !pages { + assert!( + !over_copy, + "{name}: no image over the copy where the pages' check did not pass" + ); + } // A CPU write before a commit reaches the texture. let pattern = host.pattern(); assert_eq!( diff --git a/crates/metal2vulkan-runtime/src/texture/in_place_image.rs b/crates/metal2vulkan-runtime/src/texture/in_place_image.rs index fff0ecbc9..cd7245724 100644 --- a/crates/metal2vulkan-runtime/src/texture/in_place_image.rs +++ b/crates/metal2vulkan-runtime/src/texture/in_place_image.rs @@ -458,12 +458,12 @@ impl Device { let writable = !Access::Writes.takes(usage) && self.writes_reach(texels, class); let line = self.shared().in_place.line(); let rendered = Access::rendered(texels.padding(line)); - let renders = (self.shared().in_place).verdict(class, rendered, texels.rows(line)); + let renders = self.passes_over(texels, class, rendered); let own = texture_usage(usage, descriptor.swizzle); let lacking = [ (TextureUsage::SHADER_WRITE, writable), (TextureUsage::SHADER_READ, true), - (TextureUsage::RENDER_TARGET, renders == Verdict::Passed), + (TextureUsage::RENDER_TARGET, renders), ]; let lacking: Vec = (lacking.into_iter()) .filter(|&(metal, takes)| takes && !own.contains(metal)) @@ -489,14 +489,28 @@ impl Device { /// of `class`, may reach them in place: they are of a width the device's check's kernel stores /// (`in_place::STORED_TEXEL_BYTES`), and its check passed for such writes over the class, of /// texels of their width that lie in lines as these do, those that let their rows' padding - /// change where it is free (`in_place::Access::written`, as `in_place::in_place` asks it). + /// change where it is free (`in_place::Access::written`, as `in_place::in_place` asks it) + /// ([`passes_over`](Self::passes_over)). fn writes_reach(&self, texels: &Texels, class: PagesClass) -> bool { let line = self.shared().in_place.line(); let Some(written) = Access::written(texels.texel_bytes(), texels.padding(line)) else { return false; }; - let rows = texels.rows(line); - self.shared().in_place.verdict(class, written, rows) == Verdict::Passed + self.passes_over(texels, class, written) + } + + /// Whether the device's check passed for `access` over host pages of `class`, for texels that + /// lie in lines as `texels` do; over a copied host buffer's copy (`copied.rs`), for the + /// caller's pages too, for texels that lie in lines as they lie there, as the route asks + /// (`texture/route.rs`): a rebind may import the pages, and the image then lies over them + /// with the usage it was made with. + fn passes_over(&self, texels: &Texels, class: PagesClass, access: Access) -> bool { + let check = &self.shared().in_place; + let line = check.line(); + let passes = |class, rows| check.verdict(class, access, rows) == Verdict::Passed; + let caller = texels.over_caller_pages(line); + passes(class, texels.rows(line)) + && caller.is_none_or(|(rows, _)| passes(PagesClass::Pointer, rows)) } /// The image in place of `plan` over `texels`, host pages of `class`, made and checked before @@ -530,8 +544,12 @@ impl Device { /// (`copied.rs`), which the GPU uses in the stead of the pages: over a copy in fresh pages the /// runtime imported (`fresh_pages.rs`), the image made for host allocations, as over the /// caller's pages ([`host_unplaced`](Self::host_unplaced)); over one in memory the device - /// allocates, the image made for memory of its own ([`own_unbound`](Self::own_unbound)). Either - /// takes its place in the copy's memory, at the texels' offset ([`placed`]). + /// allocates, the image made for memory of its own ([`own_unbound`](Self::own_unbound)): the + /// driver's linear image, which keeps the copy's bytes at its first move, or else the + /// `DRM_FORMAT_MOD_LINEAR` one, made `UNDEFINED`, where the device's check passed for its + /// pooled memory and the image's accesses, as an image at Metal's pitch there takes it + /// (`Device::pooled_pitched_image`); refused for its pitch where it did not. Either takes its + /// place in the copy's memory, at the texels' offset ([`placed`]). fn copy_unplaced( &self, plan: &ImagePlan, @@ -549,6 +567,24 @@ impl Device { Ok(made) => made, Err(refused) => return Ok(Err(refused)), }; + let line = self.shared().in_place.line(); + let lies = ( + texels.rows(line), + texels.padding(line), + texels.texel_bytes(), + ); + if pitched && !self.class_takes(PagesClass::Pooled, plan, lies) { + // SAFETY: the image is live and unbound, and no command uses it. + unsafe { release::object(self.shared().vk(), made.raw) }; + let why = format!( + "the driver's linear image of the copy lays its rows otherwise than the texels' \ + {} bytes apart, and the device's check of its pooled memory, whose \ + DRM_FORMAT_MOD_LINEAR image at that pitch starts UNDEFINED, did not pass for the \ + image's accesses", + layout.row_pitch + ); + return Ok(Err((Refusal::Pitch, why))); + } if let Err(refused) = placed(&made.requirements, at, room, type_index) { // SAFETY: the image is live and unbound, and no command uses it. unsafe { release::object(self.shared().vk(), made.raw) }; @@ -1138,7 +1174,7 @@ impl Device { pub(crate) fn fresh_pages_take_images(&self, watches: &[InPlaceWatch]) -> bool { watches.iter().all(|watch| { watched(watch).is_none_or(|image| { - self.class_takes(PagesClass::Fresh, &image, self.watched_rows(watch)) + self.class_takes(PagesClass::Fresh, image.plan(), self.watched_rows(watch)) }) }) } @@ -1158,20 +1194,20 @@ impl Device { } /// Whether the device's check passed for `class` (fresh pages, or the runtime's pooled - /// memory), each of `image`'s accesses and texels of `texel` bytes that lie in lines as `rows` - /// says: an image of attachment usage renders, one of storage usage is written, one of neither - /// reads. The writes take the check of the texels' width (`in_place::Access::written`), and of + /// memory), each of the accesses of an image of `plan` and texels of `texel` bytes that lie in + /// lines as `rows` says: an image of attachment usage renders, one of storage usage is written, + /// one of neither reads. The writes take the check of the texels' width (`in_place::Access::written`), and of /// one that does not render whose rows' padding is free the form that lets it change /// (`in_place::in_place`); one that renders may hold the storage usage a render target takes /// where the form that keeps it passed (`in_place::storable`), which it asks. fn class_takes( &self, class: PagesClass, - image: &Image, + plan: &ImagePlan, (rows, padding, texel): (RowEnds, Padding, u64), ) -> bool { use metal2vulkan::vk::ImageUsageFlags; - let usage = image.plan().usage; + let usage = plan.usage; let renders = usage.contains(ImageUsageFlags::COLOR_ATTACHMENT); let writes = usage.contains(ImageUsageFlags::STORAGE); let padding = match renders { @@ -1226,7 +1262,7 @@ impl Device { .facts(self.compile_device().profile()); let made = match pages.over_own_pages() { true => { - if !self.class_takes(PagesClass::Fresh, &image, self.watched_rows(watch)) { + if !self.class_takes(PagesClass::Fresh, image.plan(), self.watched_rows(watch)) { return Err(refused()); } let Ok((made, _)) = self.in_place_unbound(image.plan(), layout, &facts)? else { @@ -1242,7 +1278,7 @@ impl Device { // passed for its pooled memory and the image's accesses, as an image at Metal's // pitch there takes it (`Device::pooled_pitched_image`). if pitched - && !self.class_takes(PagesClass::Pooled, &image, self.watched_rows(watch)) + && !self.class_takes(PagesClass::Pooled, image.plan(), self.watched_rows(watch)) { // SAFETY: the image is live and unbound, and no command uses it. unsafe { release::object(raw_device, made.raw) }; diff --git a/crates/metal2vulkan-runtime/src/texture/route.rs b/crates/metal2vulkan-runtime/src/texture/route.rs index d02191a4b..9f90fbb04 100644 --- a/crates/metal2vulkan-runtime/src/texture/route.rs +++ b/crates/metal2vulkan-runtime/src/texture/route.rs @@ -135,8 +135,8 @@ impl Device { /// where one serves; else the shadow where the bytes were detached; else as the device's /// policy, the texture's usage and the device's check of the pages' class for each access take /// it (`in_place.rs`), asking the verdicts (a pending one starts the check): over a copied host - /// buffer (`copied.rs`), the class of the copy's memory (fresh pages, or the runtime's pooled - /// memory) and the caller's pages', each for texels that lie in lines as they lie there. The + /// buffer (`copied.rs`), the caller's pages' class's for texels that lie in lines as they lie + /// in the copy and as they lie in the pages, and fresh pages' where the copy lies in them. The /// device's check's own textures take the image in place whatever the policy and the /// verdicts. pub(crate) fn route_over_buffer( @@ -154,11 +154,15 @@ impl Device { let copied = texels.buffer.copied(); let class = match texels.buffer.caller_memory() { // A copied host buffer's bytes the GPU uses lie in a copy of the caller's pages in - // memory of the device's own (`copied.rs`): fresh pages the runtime imported, or - // memory the device allocates, whose class's verdicts the image over it takes. + // memory of the device's own (`copied.rs`). In fresh pages the runtime imported, its + // image is made for host allocations, as over them, under their class's verdicts; in + // memory the device allocates, the driver's linear image, whose first move keeps the + // bytes, or else a `DRM_FORMAT_MOD_LINEAR` one under the check of the runtime's + // pooled memory too (`Device::copy_unplaced`), each of whose renders and writes take + // the device's store path that the check of the caller's pages measures. Some(CallerMemory::HostPages) if copied => match texels.copy_in_fresh_pages() { true => PagesClass::Fresh, - false => PagesClass::Pooled, + false => PagesClass::Pointer, }, Some(CallerMemory::HostPages) if texels.buffer.over_dma_buf() => PagesClass::DmaBuf, Some(CallerMemory::HostPages) => PagesClass::Pointer, @@ -226,10 +230,7 @@ impl Device { // the caller's pages' too, for texels that lie in lines as they lie there: a rebind may // import the pages by their pointer, the image made again over that import as an image in // place over them is (`Device::rebound_in_place_images`). - let caller = match copied { - true => texels.over_caller_pages(line), - false => None, - }; + let caller = texels.over_caller_pages(line); let decided = in_place::in_place(policy, usage, pages, verdict).and_then(|()| { caller.map_or(Ok(()), |(rows, padding)| { let pages = (PagesClass::Pointer, rows, pages.2, padding); diff --git a/crates/metal2vulkan-runtime/src/texture_placement.rs b/crates/metal2vulkan-runtime/src/texture_placement.rs index 1688a66be..53a8b3b5d 100644 --- a/crates/metal2vulkan-runtime/src/texture_placement.rs +++ b/crates/metal2vulkan-runtime/src/texture_placement.rs @@ -23,8 +23,8 @@ pub enum TexturePlacement { /// ([`InPlaceRefusal::Source`]) or the driver refuses its import ([`InPlaceRefusal::DmaBuf`]): /// the texture is then a shadow, its notice (`shadowed-texture`) naming why. Over a copied host /// buffer ([`HostBacking::Copied`](crate::HostBacking::Copied)), the image lies over the copy - /// the GPU uses in the pages' stead, in the copy's memory, where the check passed for that - /// memory's kind and the pages' (`WorkCounts::copied_textures_in_place`). + /// the GPU uses in the pages' stead, in the copy's memory, where the check passed for the + /// pages' kind and that memory's (`WorkCounts::copied_textures_in_place`). InPlace, /// A shadow now, as the device's check has not answered for the pages' kind and the /// texture's accesses: once it does, at the commit of the device's only uncommitted command diff --git a/crates/metal2vulkan-runtime/src/work_counts.rs b/crates/metal2vulkan-runtime/src/work_counts.rs index 3740d5e8a..93b8c8008 100644 --- a/crates/metal2vulkan-runtime/src/work_counts.rs +++ b/crates/metal2vulkan-runtime/src/work_counts.rs @@ -6306,8 +6306,9 @@ pub struct WorkCounts { pub fresh_page_textures_in_place: u64, /// Of `host_textures_in_place`, those over a copied host buffer (`copied.rs`): an image over /// the copy of the caller's pages the GPU uses in their stead, bound in the copy's memory where - /// the device's check passed for that memory's class (fresh pages the runtime imported, or its - /// pooled memory) and for the caller's pages', for the texture's accesses. Counted in neither + /// the device's check passed for the caller's pages and, for a copy in fresh pages the runtime + /// imported, for those (for a `DRM_FORMAT_MOD_LINEAR` image over a copy in memory the device + /// allocates, for its pooled memory), for the texture's accesses. Counted in neither /// `fresh_page_textures_in_place` nor `pitched_host_images`. pub copied_textures_in_place: u64, /// Of `host_textures_in_place`, those whose rows lie at Metal's pitch in a diff --git a/docs/FAST-PATHS.md b/docs/FAST-PATHS.md index 830b3d71e..88e23abb5 100644 --- a/docs/FAST-PATHS.md +++ b/docs/FAST-PATHS.md @@ -38,7 +38,7 @@ three consumer pipelines: A2X (`a2x-s4`, `a2x-s96`), Xgc14 (`xgc14-bgra8`) and X | Batches of command buffers on one `VkQueue`, on a driver measured to start no kernel submission of a queue before the one before it completed (ANV, RADV and NVIDIA's; `batch_order.rs`), are ordered by their ends: each ends with a barrier ordering its work before every later command of its `VkQueue` (the exact form's end orders it before the host's reads and writes alone), so a batch that depends on an earlier one there begins with no barrier of its own, often no command buffer of barriers, and its first encoder's GPU start is written at the bottom of the pipe, once everything before it completed. Metal starts an independent command buffer committed behind running work while that work runs (an M3 Max under macOS 27.0.1, probe `gpustart`); those drivers ran two batches of independent work one after the other under every shape measured (no end barrier, the host's or the widened one; in one `vkQueueSubmit` or two, merged into one kernel submission or not), where two dispatches of one command buffer ran side by side. The runtime's: no pipeline differs. | `batch_order = BatchOrderPolicy::Ends` | `batch_order = BatchOrderPolicy::Exact`: a barrier for each dependency of a batch's work on an earlier batch's of its `VkQueue`, the end's barrier to the host's reads and writes alone, the GPU start written at the top of the pipe; every other driver takes it under either value | None: on those drivers each batch starts once the one before it completed under either value, so the work's order, its results and its GPU times are the same, and a batch's GPU start is the end of the work before it, when such a driver starts it. Not announced; `runtime_lane::commit_work` and `runtime_lane::gpu_times` test both values | UHD 770 (ANV, RPL-S), the consumer's frame shape over 520 host imports, 67 command buffers a frame, Grouped completion, the widened end barrier against the exact form (a probe build of each): with no fill ahead of each command buffer, 67.0 command buffers submitted a frame against 129.3-129.7, the GPU's span a frame 1.84-1.90 ms against 1.99-2.06 ms, a frame through completion 2.13-2.22 ms against 2.27-2.38 ms; with a 1 MiB fill ahead of each, 134.0 against 262.9, 8.03-8.22 ms against 8.32-8.42 ms, 9.00-9.15 ms against 9.25-9.36 ms. Radeon 780M (RADV, Mesa 26.0.8), this switch: with no fill, 67.0 against 128.9-129.0, a frame through completion 48.3-48.6 ms against 42.6-47.0 ms; with a 16 MiB fill committed at once, 134.0 against 251.0-251.1, 50.6-50.8 ms against 50.8-57.3 ms; committed every 1 ms, 134.0 against 249.7-250.2, 71.3-83.6 ms against 106.3-113.6 ms (each kernel submission there leaves about 2.5 ms of the GPU idle over 520 host imports, which sets these frames) | | 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), 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`. 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, round robin, 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 that memory and for the pages, `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 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 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, its verdicts kept in the shader cache's directory; 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` texture over a no-copy buffer's bytes 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 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 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 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, its verdicts kept in the shader cache's directory; 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` texture over a no-copy buffer's bytes 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; a committed command buffer's recordings wait until its commit plus `pipeline_commit_wait` at most, one deadline its commands share, for its draws' and dispatches' (a compute encoder's, a render pass's tile dispatches) pipelines still being made (the scheduler wakes at the bound, `StepWaits::until`), an execution's replayed draws (`render/pending.rs`) among them, whose pipelines the commit's settle hands to the pool (a device replay's, one recording for every command, waits until made under either value), then record each such command as nothing: a draw's barriers and visibility query, a dispatch's barrier (a tile dispatch's copies into its scratch and back), no draw or dispatch, the command buffer running on without error. The making goes on, and the command buffers after it draw and dispatch with the pipeline once made. Metal compiles inside `newRenderPipelineState`, so no draw of a made state waits or is dropped; 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), past the guest's 10 s FIFO check, which ended the guest's task. Each bound is 4.5 s: a creation and a commit may fall in one step of the guest's FIFO (a task's jobs run one after another, and a draw's own variant waits under its command buffer's bound), and no runtime call waits for both, so one step waits 9 s at most for makings, under that 10 s check. A creation waits on no command buffer's deadline and a `commit` on no creation's; a `commit` waits until its own deadline at most (it records there what it can, an execution of render commands the CPU writes among them), every other recording 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 draw whose pipeline was still being made `pipeline_commit_wait` after its command buffer's commit renders nothing in that command buffer (only there: later ones draw it), where Metal's renders: content drawn once (a layer, a glyph cache) stays without it until redrawn. A creation returns after `pipeline_creation_wait` at most with its making in flight (`WorkCounts::creations_left_making`). `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_draw_whose_pipeline_is_still_being_made_at_its_bound_runs_nothing` and `under_the_exact_wait_a_held_making_holds_its_command_buffer_until_it_lands`. A dispatch whose pipeline was still being made then writes nothing in that command buffer, where Metal's runs: `DispatchDroppedStillMaking` (`dispatch-dropped-still-making`), `WorkCounts::dispatches_dropped_still_making`, the first named by `dropped_draw`; `deferred_calls::a_dispatch_whose_pipeline_is_still_being_made_at_its_bound_runs_nothing`, `a_compute_state_s_creation_waits_its_bound_for_its_predicted_making` and `a_replayed_draw_whose_pipeline_is_still_being_made_at_its_bound_runs_nothing` | No GPU cost. The exact form holds the creating thread, and the command buffer, 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 and a command buffer for 4.5 s from its commit, which drops the draws of the compiles that outlast those (2 of that boot's 2,483 were over 4.5 s) for the command buffers committed before they land; bounds of 1 s dropped 39 draws in a cold boot on the M2 Pro, and the guest's menu bar, drawn once, stayed half drawn | | 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`). They are exactly it on a non-strict device whose wide lines are parallelograms (`strictLines` unset, `nonStrictWideLinesUseParallelogram` set) at a width above 1 on its `lineWidthGranularity`, unannounced there; elsewhere they differ: 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. 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 otherwise than Metal 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), and a rounded width. `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 | diff --git a/docs/HOWTO.md b/docs/HOWTO.md index d4172115d..85cd30a82 100644 --- a/docs/HOWTO.md +++ b/docs/HOWTO.md @@ -470,12 +470,12 @@ publication (bounded) on the committing thread, and every copy compares every by commit and where a log answers `false`. The runtime reports to the log what the log cannot see: a copy's merge back, as the copy's own write, the GPU's writes into the pages through imports in place, and its own CPU writes into them. A texture over a copied buffer is a linear image over the -copy, bound in its memory, wherever the device's in-place check passed for that memory and for the -caller's pages, for the texture's accesses (`copied_textures_in_place`): in fresh pages the runtime -imported, an image made for host allocations, as over the pages; in memory the device allocates, -the driver's own linear image where it lays the rows at the texture's pitch, which starts +copy, bound in its memory, wherever the device's in-place check passed for the caller's pages, for +the texture's accesses (`copied_textures_in_place`): in fresh pages the runtime imported, an image +made for host allocations, as over the pages, under the fresh pages' check too; in memory the device +allocates, the driver's own linear image where it lays the rows at the texture's pitch, which starts `PREINITIALIZED` and so keeps the copy's bytes, else a `DRM_FORMAT_MOD_LINEAR` image at that pitch -under the check of the runtime's pooled memory. Elsewhere it is a shadow of the copy's bytes, its +under the check of the runtime's pooled memory too. Elsewhere it is a shadow of the copy's bytes, its notice naming why. The copy reads the pages through the kernel first, and where the kernel cannot read them, with plain loads where the process maps every page with read permission: on Linux the kernel's read pins each page, which a mapping of a dma-buf