From aa188702ad6337f2e65535ec73e236cd8ce2b15b Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Sun, 8 Nov 2026 11:25:45 -0800 Subject: [PATCH] In-place check: an unchecked verdict is no measurement, kept unmeasured and checked again On the Iris Xe (ANV) reims' arm-s boots made 890 shadows over guest RAM imported as dma-bufs, every one "the device's check made no image over host pages imported as dma-bufs" (Unchecked), small ShaderRead textures at offset 0 on whole pages among them, where a fresh check of the same driver passes the class's reads (aafecf768a, job 7667). The record kept every verdict the check gave, Unchecked among them, and every later device of that driver and check version recalled it and checked nothing: a refusal of the class's pages (or of its rounds' images) in one process, a transient one or one of that device's setup, answered for every boot after. And the check kept no reason for it: the class's pages and rounds that made no image returned unchecked with no note. - in_place::encode writes an unchecked verdict as unmeasured (a pending verdict's byte); decode reads that back pending and refuses an unchecked byte (never written). recall_in_place_checks recalls the measured verdicts (passed or failed, counted as recalled) and settles only where none is pending: the first texture that asks a pending one starts the check, which runs only the classes and accesses still pending, and its record replaces the old one. - CHECK_VERSION 12: a record of 11 may hold unchecked verdicts as answers, which no device now takes; reims' stale records are dropped by it. - Reasons, noted in the check's report after the verdicts: ClassPages::make answers why it made no pages (each step of ExportedPages::make for the dma-buf class: no host import, no dma-buf images, an export only as a dedicated allocation, no host-visible coherent type, the allocation, map or export failing; a no-copy buffer refused, copied, or imported otherwise), and a round that made no image says why (its making's error, the placement's answer for a texture not in place, its first move or pass failing), the first per class and access. - Tests: a_class_whose_pages_the_check_could_not_make_is_checked_again_by_the_next_device (device test: the pointer class's first import fails, so its reads are Unchecked and noted; the next device of the cache recalls every measured verdict, finds those reads pending, checks them again; the device after recalls them). Before this change the second device recalled the reads as Unchecked. The record round trip reads unchecked back pending; the in-place textures lane's record test recalls the measured verdicts and checks the rest again. - Docs: in_place.rs, in_place_check.rs, WorkCounts::in_place_checks_recalled, settle_in_place_checks, docs/API.md, docs/FAST-PATHS.md (the in-place row). Verified: cargo fmt; builds and tests run as potluck jobs after this commit. (cherry picked from commit 29f3114ca990382776e795f35ea9b81f8345399a) --- crates/metal2vulkan-runtime/src/dma_buf.rs | 45 +++-- crates/metal2vulkan-runtime/src/in_place.rs | 58 ++++-- .../src/in_place_check.rs | 190 +++++++++++++----- .../src/tests/in_place.rs | 12 +- .../src/tests/in_place_check.rs | 96 ++++++++- .../metal2vulkan-runtime/src/work_counts.rs | 4 +- .../src/runtime_lane/in_place_textures.rs | 34 +++- docs/API.md | 4 +- docs/FAST-PATHS.md | 2 +- 9 files changed, 345 insertions(+), 100 deletions(-) diff --git a/crates/metal2vulkan-runtime/src/dma_buf.rs b/crates/metal2vulkan-runtime/src/dma_buf.rs index 8f96478e0..1c6507bb3 100644 --- a/crates/metal2vulkan-runtime/src/dma_buf.rs +++ b/crates/metal2vulkan-runtime/src/dma_buf.rs @@ -1678,14 +1678,15 @@ impl ExportedPages { /// flag where the device enables `bufferDeviceAddress`, as each of the runtime's allocations /// and imports is: ANV (Mesa 26.2.6) refuses an import of a dma-buf of its own memory whose /// flag differs from the allocation's (`VK_ERROR_INVALID_EXTERNAL_HANDLE`, of every memory - /// type), which left the check's class unchecked there. `None` where the device imports no + /// type), which left the check's class unchecked there. Why not, where the device imports no /// dma-bufs, makes no images over them, exports no such memory but as a dedicated allocation, - /// or refuses it. - pub(super) fn make(device: &Device, length: u64) -> Option { + /// or refuses it (the check's note). + pub(super) fn make(device: &Device, length: u64) -> Result { let shared = device.shared(); - let importer = shared.host_import.as_ref().ok()?; + let importer = (shared.host_import.as_ref()) + .map_err(|_| "the device imports no host memory".to_owned())?; if !importer.makes_dma_buf_images() { - return None; + return Err("the device makes no images over dma-bufs".to_owned()); } // The device exports a buffer's memory as a dma-buf, not only a dedicated allocation. let query = vk::PhysicalDeviceExternalBufferInfo::default() @@ -1709,7 +1710,11 @@ impl ExportedPages { if !features.contains(vk::ExternalMemoryFeatureFlags::EXPORTABLE) || features.contains(vk::ExternalMemoryFeatureFlags::DEDICATED_ONLY) { - return None; + return Err(format!( + "the device exports a buffer's memory as a dma-buf only as a dedicated \ + allocation, or not at all (external memory features {:#x})", + features.as_raw() + )); } let wanted = vk::MemoryPropertyFlags::HOST_VISIBLE | vk::MemoryPropertyFlags::HOST_COHERENT; let type_index = { @@ -1726,7 +1731,8 @@ impl ExportedPages { flags.contains(vk::MemoryPropertyFlags::DEVICE_LOCAL), ) }) - .map(|&(index, _)| index)? + .map(|&(index, _)| index) + .ok_or_else(|| "the device has no host-visible, host-coherent memory".to_owned())? }; let raw_device = shared.vk(); let mut export = vk::ExportMemoryAllocateInfo::default().handle_types(DMA_BUF); @@ -1740,7 +1746,13 @@ impl ExportedPages { info = info.push_next(&mut flags); } // SAFETY: the device is live; the type exports dma-bufs of a buffer's memory (above). - let memory = unsafe { crate::creation::allocate_memory(raw_device, &info) }.ok()?; + let memory = + unsafe { crate::creation::allocate_memory(raw_device, &info) }.map_err(|error| { + format!( + "its exportable allocation of {length} bytes of type {type_index} failed: \ + {error:?}" + ) + })?; let free = || { // SAFETY: the allocation is unused. unsafe { release::object(raw_device, memory) }; @@ -1755,14 +1767,21 @@ impl ExportedPages { .and_then(|mapped| NonNull::new(mapped.cast::())) else { free(); - return None; + return Err(format!( + "its allocation of type {type_index} was not mapped" + )); }; // SAFETY: the importer is this device's; the allocation was made exportable as a dma-buf. - let Ok(fd) = (unsafe { importer.exported_dma_buf(raw_device, memory) }) else { - free(); - return None; + let fd = match unsafe { importer.exported_dma_buf(raw_device, memory) } { + Ok(fd) => fd, + Err(error) => { + free(); + return Err(format!( + "its allocation's dma-buf was not exported: {error:?}" + )); + } }; - Some(ExportedPages { + Ok(ExportedPages { device: device.clone(), memory, start, diff --git a/crates/metal2vulkan-runtime/src/in_place.rs b/crates/metal2vulkan-runtime/src/in_place.rs index 801b03eef..13b2277f9 100644 --- a/crates/metal2vulkan-runtime/src/in_place.rs +++ b/crates/metal2vulkan-runtime/src/in_place.rs @@ -92,7 +92,11 @@ //! check: the check's rounds take seconds on some devices and builds (1.8 s for the first //! texture, waited for, on a Radeon 780M in a debug build), past what a program's first texture //! may take, a guest's message that makes one among them. A device whose record holds the -//! verdicts knows them as it is made, and starts none; a program that will make such textures +//! verdicts knows them as it is made, and starts none: those its driver's earlier check +//! measured (passed or failed); one that check could not give (unchecked: it made no pages of +//! the class, or no image of its rounds, which a refusal in that one process may cause as well +//! as the driver) is no measurement, so the record keeps it pending and the next device's check +//! runs that class and access again (`encode`). A program that will make such textures //! starts the check earlier, where it likes, through `Device::settle_in_place_checks` (with no //! wait: a zero timeout). //! - **Visibility.** A command reads the image's texels in the memory a buffer over the same pages @@ -880,7 +884,7 @@ impl Drop for Waiting<'_> { /// differs, and so does the version it holds). The runtime's own version is not in the record: a /// release that changes none of these keeps the verdicts the driver gave, so a device made after /// it reads them again rather than checking anew. -pub(crate) const CHECK_VERSION: u32 = 11; +pub(crate) const CHECK_VERSION: u32 = 12; /// A record's first bytes. const MAGIC: [u8; 8] = *b"M2VINPL\0"; @@ -961,13 +965,21 @@ pub(crate) fn record_name(identity: &DriverIdentity) -> String { /// checksum 32 bytes SHA-256 of every byte before it /// ``` /// -/// Integers are little-endian. +/// Integers are little-endian. A record holds what the check measured: a verdict passed or +/// failed. An unchecked one (the check made no pages of its class, or no image of its rounds, +/// which a transient refusal or the device's setup in one process may cause as well as the +/// driver) is written as unmeasured, a pending one's byte, so the device made after it checks +/// that class, access and row ends again ([`Device::recall_in_place_checks`]). pub(crate) fn encode(identity: &DriverIdentity, verdicts: [Verdict; VERDICTS]) -> Vec { let mut bytes = Vec::with_capacity(RECORD_BYTES); bytes.extend_from_slice(&MAGIC); bytes.extend_from_slice(&CHECK_VERSION.to_le_bytes()); bytes.extend_from_slice(&identity.digest()); - bytes.extend(verdicts.map(Verdict::byte)); + let measured = |verdict| match verdict { + Verdict::Unchecked => Verdict::Pending, + verdict => verdict, + }; + bytes.extend(verdicts.map(|verdict| measured(verdict).byte())); let checksum: [u8; 32] = Sha256::digest(&bytes).into(); bytes.extend_from_slice(&checksum); bytes @@ -977,8 +989,9 @@ pub(crate) fn encode(identity: &DriverIdentity, verdicts: [Verdict; VERDICTS]) - const RECORD_BYTES: usize = 8 + 4 + 32 + VERDICTS + 32; /// The verdicts `bytes` record for `identity`: `None` for anything but a whole record of this -/// version and runtime, for this identity, whose checksum holds and whose every verdict is an -/// answer (a pending one is never written). +/// version and runtime, for this identity, whose checksum holds and whose every verdict is +/// measured (passed or failed) or unmeasured (pending, [`encode`]), the latter answered pending: +/// an unchecked verdict is never written. pub(crate) fn decode(identity: &DriverIdentity, bytes: &[u8]) -> Option<[Verdict; VERDICTS]> { if bytes.len() != RECORD_BYTES { return None; @@ -997,7 +1010,7 @@ pub(crate) fn decode(identity: &DriverIdentity, bytes: &[u8]) -> Option<[Verdict } let mut verdicts = [Verdict::Pending; VERDICTS]; for (verdict, &byte) in verdicts.iter_mut().zip(rest) { - *verdict = Verdict::of_byte(byte).filter(|&known| known != Verdict::Pending)?; + *verdict = Verdict::of_byte(byte).filter(|&known| known != Verdict::Unchecked)?; } Some(verdicts) } @@ -1040,10 +1053,11 @@ impl Device { } /// As the device is made: where its policy takes textures over host pages in place, its - /// verdicts from the record of its driver's identity where one holds them (counted as - /// recalled), settling them; else they wait for the check, which the first texture that asks - /// starts. A record that does not decode is no record: the check runs, and its verdicts - /// replace it. + /// verdicts from the record of its driver's identity where one holds them (each measured one + /// counted as recalled), settling them where none is unmeasured; else they wait for the check, + /// which the first texture that asks starts. The check then runs only the classes and accesses + /// whose verdicts are pending: of a record, those it could not measure ([`encode`]). A record + /// that does not decode is no record: the check runs, and its verdicts replace it. pub(crate) fn recall_in_place_checks(&self) { let shared = self.shared(); if self.compile_device().policy().host_page_textures != HostPageTexturePolicy::InPlace { @@ -1063,12 +1077,17 @@ impl Device { for access in Access::ALL { for rows in RowEnds::ALL { let verdict = verdicts[verdict_index(class, access, rows)]; + if verdict == Verdict::Pending { + continue; + } shared.in_place.set(class, access, rows, verdict); shared.counts.in_place_check_recalled(); } } } - shared.in_place.settle(None); + if !verdicts.contains(&Verdict::Pending) { + shared.in_place.settle(None); + } } } @@ -1104,12 +1123,15 @@ impl Device { /// check before it makes such textures and ask again later. Under /// `HostPageTexturePolicy::Shadow` no check runs and no verdict is known: `false` at once. /// - /// The verdicts go from pending to known once for each `VkDevice` behind the device. A GPU - /// recovery's new one (`Degradation::DeviceRecovered`) reads them again from the record the - /// check kept in the shader cache's directory as it is made, known at once, where the check - /// ended and wrote it; where the lost one's check had not ended, or the device keeps no record - /// (no shader cache directory, or `DeviceOptions::fail_in_place_check`), they are pending - /// again, and this answers `false` until the new one's check ends. Buffers made before a + /// The verdicts go from pending to known once for each `VkDevice` behind the device. A device + /// of a driver whose check ran before reads them from the record the check kept in the + /// shader cache's directory as it is made, known at once, where the check ended and wrote it: + /// the verdicts it measured (passed or failed), not those it could not check (no pages or no + /// image of their kind made), which stay pending until the new device's check answers them + /// again. A GPU recovery's new one (`Degradation::DeviceRecovered`) reads the record so too; + /// where the lost one's check had not ended, or the device keeps no record (no shader cache + /// directory, or `DeviceOptions::fail_in_place_check`), they are pending again, and this + /// answers `false` until the new one's check ends. Buffers made before a /// recovery are refused on the new device (`RuntimeGap::MadeBeforeRecovery`), so a program /// makes its textures over host pages again after one, and asks again. pub fn settle_in_place_checks(&self, timeout: Duration) -> bool { diff --git a/crates/metal2vulkan-runtime/src/in_place_check.rs b/crates/metal2vulkan-runtime/src/in_place_check.rs index 675d52aa3..63010e1e9 100644 --- a/crates/metal2vulkan-runtime/src/in_place_check.rs +++ b/crates/metal2vulkan-runtime/src/in_place_check.rs @@ -116,8 +116,13 @@ //! version and the device's UUID among it) and the check's version ([`record_name`]), not the //! runtime's: a device of the same driver and version reads them as it is made and runs no //! check, whatever runtime release made it, until the check itself changes -//! (`in_place::CHECK_VERSION`). A failed write leaves the verdicts for the device's life. A -//! forced failure is kept nowhere. +//! (`in_place::CHECK_VERSION`). The record keeps what the check measured: an unchecked verdict +//! (no pages of the class made, or no image of its rounds) is written unmeasured, so the next +//! device checks that class and access again, the rest recalled (`in_place::encode`); a page +//! or image refused once in one process, or by the setup of one device, then answers for no +//! later device. Each such refusal is noted with why (the report's lines after the verdicts). +//! A failed write leaves the verdicts for the device's life. A forced failure is kept +//! nowhere. //! - **Out of the device's way.** Before each round the thread steps aside for the device's //! allocations and frees on other threads (`step_aside.rs`): it goes on once none is in //! progress and none ended for `step_aside::QUIET`, at once while a call waits for its verdicts @@ -621,8 +626,15 @@ fn check_class( let line = device.shared().in_place.line(); let unchecked = || (vec![[Verdict::Unchecked; 2]; access.answered().len()], true); let length = class_bytes(class); - let Some(pages) = ClassPages::make(device, class, length) else { - return Some(unchecked()); + let pages = match ClassPages::make(device, class, length) { + Ok(pages) => pages, + Err(why) => { + device.shared().in_place.note(format!( + "{class:?} {}: no pages to check: {why}", + label(access) + )); + return Some(unchecked()); + } }; // The command queue an image that renders takes its passes on, the check's own, and the // draw it takes after them. @@ -662,6 +674,8 @@ fn check_class( let mut tally = Tally::default(); // The texel sizes of the shapes whose texels share a line made so far (`Shape::runs`). let mut made_sharing = Vec::new(); + // Whether a round that made no image was noted: the first is, with why. + let mut unmade_noted = false; for (shape, texel) in shapes { if shape.window(page) > length || !shape.runs(line, &made_sharing) { continue; @@ -696,7 +710,25 @@ fn check_class( made(&mut made_sharing); continue; } - Round::NotMade => break, + Round::NotMade(why) => { + if !unmade_noted { + unmade_noted = true; + let lines = match rows { + RowEnds::InLines => "", + RowEnds::OnLines => ", rows on lines", + }; + device.shared().in_place.note(format!( + "{class:?} {}{lines}: no {:?} image of {}x{} with rows {} bytes \ + apart: {why}", + label(access), + shape.format, + shape.width, + shape.height, + shape.bytes_per_row + )); + } + break; + } Round::Padded(changed) => { made(&mut made_sharing); // The first such round is noted; the rounds go on. @@ -749,6 +781,19 @@ fn check_class( Some((tally.verdicts(access, None, forced), true)) } +/// `access` in a note's words, as the report names its verdicts (`in_place_check_report`). +fn label(access: Access) -> &'static str { + match access { + Access::Reads => "reads", + Access::Renders => "renders", + Access::UnobservedRenders => "unobserved renders", + Access::Writes => "writes", + Access::BufferWrites => "buffer writes", + Access::NarrowWrites => "narrow writes", + Access::NarrowBufferWrites => "narrow buffer writes", + } +} + /// One verdict of the check: its class, access, row ends and answer, and whether every byte /// its class's rounds of the access found changed lay beside the texels (none was a texel). #[derive(Clone, Copy, Debug)] @@ -901,8 +946,8 @@ pub(crate) fn verdicts(made: [u32; 2], changed: Option, forced: bool) - pub(crate) enum Round { /// The image's move kept every byte. Kept, - /// The texture took no image in place (the device makes none of the shape there). - NotMade, + /// The texture took no image in place (the device makes none of the shape there), why. + NotMade(String), /// A byte of its shape's rows' padding read other than the CPU left it, where a round of /// storage writes or renders tells that padding apart ([`Shape::padding`]), and every other /// byte read right (each past the last row's pitch among them): where the first was, what was @@ -941,11 +986,9 @@ fn check_round( let texels = renders.as_ref().map(|_| shape); // The runtime's own texture: it takes no resource ID, so the program's IDs are Metal's // whether or when the check runs. - let Ok(texture) = pages - .buffer - .new_runtime_texture(&descriptor, 0, shape.bytes_per_row) - else { - return Round::NotMade; + let texture = match (pages.buffer).new_runtime_texture(&descriptor, 0, shape.bytes_per_row) { + Ok(texture) => texture, + Err(error) => return Round::NotMade(format!("its making failed: {error}")), }; let stop = AtomicBool::new(false); let started = Barrier::new(2); @@ -968,14 +1011,29 @@ fn check_round( drop(stopping); Some((settled, writer.join().ok()?)) }); - let Some((Some(Ok(())), written)) = outcome else { - return Round::NotMade; + let written = match outcome { + Some((Some(Ok(())), written)) => written, + Some((Some(Err(error)), _)) => { + return Round::NotMade(format!("its first move or pass failed: {error}")); + } + Some((None, _)) => return Round::NotMade(unplaced(pages, &descriptor, shape)), + None => return Round::NotMade("the round's writer did not run".to_owned()), }; drop(texture); let texels = texels.map(|shape| (shape, Due::Zero)); bytes.compare(&pattern, (texels, free), written) } +/// Why the check's texture of `shape` over `pages`, made with `descriptor`, took no image in +/// place: its placement's answer (`Buffer::texture_placement`), asked on the check's thread, as +/// its making asked the route. +fn unplaced(pages: &ClassPages, descriptor: &TextureDescriptor, shape: Shape) -> String { + match (pages.buffer).texture_placement(descriptor, 0, shape.bytes_per_row) { + Ok(placement) => format!("it took no image in place: {placement:?}"), + Err(error) => format!("it took no image in place, its placement refused: {error}"), + } +} + /// Stops the round's writer as it goes: once the round's step returned, or where it unwinds. struct Stopping<'a>(&'a AtomicBool); @@ -1008,11 +1066,9 @@ fn store_round( let mut descriptor = TextureDescriptor::texture_2d(shape.format, shape.width, shape.height, false); descriptor.usage = TextureUsage::SHADER_READ | TextureUsage::SHADER_WRITE; - let Ok(texture) = pages - .buffer - .new_runtime_texture(&descriptor, 0, shape.bytes_per_row) - else { - return Round::NotMade; + let texture = match (pages.buffer).new_runtime_texture(&descriptor, 0, shape.bytes_per_row) { + Ok(texture) => texture, + Err(error) => return Round::NotMade(format!("its making failed: {error}")), }; // The bytes the kernel stores, row after row, and the part it keeps them in too: buffers // outside the Metal address space, as the check's are (the module docs). A texel takes the @@ -1022,11 +1078,14 @@ fn store_round( let length = row * shape.height; let buffer = || device.new_buffer_placed(length, ResourceOptions::shared(), AddressPlacement::Outside); - let (Ok(source), Ok(kept)) = (buffer(), buffer()) else { - return Round::NotMade; + let (source, kept) = match (buffer(), buffer()) { + (Ok(source), Ok(kept)) => (source, kept), + (Err(error), _) | (_, Err(error)) => { + return Round::NotMade(format!("the kernel's buffers were refused: {error}")); + } }; let Some(words) = source.contents() else { - return Round::NotMade; + return Round::NotMade("the kernel's buffer has no contents".to_owned()); }; for y in 0..shape.height { let from = y * shape.bytes_per_row; @@ -1064,8 +1123,15 @@ fn store_round( drop(stopping); Some((done, writer.join().ok()?)) }); - let Some((Some(Ok(())), written)) = outcome else { - return Round::NotMade; + let written = match outcome { + Some((Some(Ok(())), written)) => written, + Some((Some(Err(error)), _)) => { + return Round::NotMade(format!( + "its first move or the kernel's stores failed: {error}" + )); + } + Some((None, _)) => return Round::NotMade(unplaced(pages, &descriptor, shape)), + None => return Round::NotMade("the round's writer did not run".to_owned()), }; drop(texture); bytes.compare(&pattern, (Some((shape, Due::Stored)), free), written) @@ -1123,9 +1189,11 @@ struct ClassPages { impl ClassPages { /// A buffer of `length` bytes in pages of `class` on `device`, where the device makes one - /// there; inside a section of its own. - fn make(device: &Device, class: PagesClass, length: u64) -> Option { - let _busy = exit_guard::enter()?; + /// there; inside a section of its own. Why not, where it does not (the check's note). + fn make(device: &Device, class: PagesClass, length: u64) -> Result { + let Some(_busy) = exit_guard::enter() else { + return Err("the process is exiting".to_owned()); + }; match class { PagesClass::Pointer => pointer_pages(device, length), // In fresh pages wherever the device takes them, whatever its submission checks @@ -1133,12 +1201,13 @@ impl ClassPages { // where this class passed (`buffer_descriptor.rs`'s `copied_pages`), the product's // long buffers where that cost is none (`fresh_pages.rs`). PagesClass::Fresh => { - let buffer = device.fresh_pages_check_buffer(length).ok()?; + let buffer = (device.fresh_pages_check_buffer(length)) + .map_err(|error| format!("its buffer was refused: {error}"))?; if !buffer.in_fresh_pages() { - return None; + return Err("its buffer lies in no fresh pages".to_owned()); } - let start = buffer.contents()?; - Some(ClassPages { buffer, start }) + let start = contents(&buffer)?; + Ok(ClassPages { buffer, start }) } PagesClass::DmaBuf => dma_buf_pages(device, length), // A buffer of the runtime's own in its pooled memory that declares the bytes between @@ -1147,50 +1216,60 @@ impl ClassPages { // `DRM_FORMAT_MOD_LINEAR` images. PagesClass::Pooled => { if !device.makes_modifier_images() { - return None; + return Err("the device makes no DRM_FORMAT_MOD_LINEAR images".to_owned()); } let shared = ResourceOptions::shared(); let outside = AddressPlacement::Outside; - let buffer = device.new_buffer_placed(length, shared, outside).ok()?; + let buffer = (device.new_buffer_placed(length, shared, outside)) + .map_err(|error| format!("its buffer was refused: {error}"))?; if buffer.in_fresh_pages() { - return None; + return Err("its buffer lies in fresh pages, not pooled memory".to_owned()); } buffer.declare_padding_unobserved(); - let start = buffer.contents()?; - Some(ClassPages { buffer, start }) + let start = contents(&buffer)?; + Ok(ClassPages { buffer, start }) } } } } +/// Where `buffer`'s byte 0 lies for the CPU; why not, where it has no contents. +fn contents(buffer: &Buffer) -> Result, String> { + (buffer.contents()).ok_or_else(|| "its buffer has no contents".to_owned()) +} + /// A no-copy buffer of `length` bytes over anonymous pages mapped for it, imported by their -/// pointer, which its keep-alive unmaps ([`Anonymous`]). `None` where the device makes none, or -/// does not import the pointer (dma-bufs, or a copied host buffer, `copied.rs`). +/// pointer, which its keep-alive unmaps ([`Anonymous`]). Why not, where the device makes none, +/// or does not import the pointer (dma-bufs, or a copied host buffer, `copied.rs`). #[cfg(unix)] -fn pointer_pages(device: &Device, length: u64) -> Option { - let start = map_anonymous(length)?; +fn pointer_pages(device: &Device, length: u64) -> Result { + let start = map_anonymous(length) + .ok_or_else(|| format!("no anonymous mapping of {length} bytes was made"))?; let pages: crate::KeepAlive = Box::new(Anonymous { start, length }); // SAFETY: the pages are this process's private anonymous mapping, readable and writable, // which stays until the keep-alive unmaps it, and which nothing else maps or frees. let memory = unsafe { HostMemory::new(start) }; let buffer = no_copy_kept(device, memory, length, pages)?; - if buffer.over_dma_buf() || buffer.copied() { - return None; + if buffer.over_dma_buf() { + return Err("the device imported its pages as dma-bufs, not by their pointer".to_owned()); } - Some(ClassPages { buffer, start }) + if buffer.copied() { + return Err("the device copied its pages, which it did not import".to_owned()); + } + Ok(ClassPages { buffer, start }) } /// A no-copy buffer of `length` bytes over `memory`, whose pages `pages` keeps mapped: a /// keep-alive, not a deallocator, so the buffer's release runs at Metal's moment and waits for no /// batch submitted before it (`HostPages`'s release), and `pages` goes once the import is freed -/// (`KeepAlive`). `None` where the device refuses the buffer, `pages` dropped with the refusal. +/// (`KeepAlive`). Why not, where the device refuses the buffer, `pages` dropped with the refusal. #[cfg(unix)] fn no_copy_kept( device: &Device, memory: HostMemory, length: u64, pages: crate::KeepAlive, -) -> Option { +) -> Result { let contents = BufferContents::NoCopy { memory, deallocator: None, @@ -1198,7 +1277,8 @@ fn no_copy_kept( }; let descriptor = BufferDescriptor::new(length, ResourceOptions::shared(), contents) .with_placement(AddressPlacement::Outside); - device.new_buffer_with_descriptor_now(descriptor).ok() + (device.new_buffer_with_descriptor_now(descriptor)) + .map_err(|error| format!("its no-copy buffer was refused: {error}")) } /// Anonymous pages [`map_anonymous`] mapped, unmapped as this goes: a check buffer's keep-alive. @@ -1248,21 +1328,21 @@ fn unmap(pointer: NonNull, length: u64) { /// No anonymous pages are mapped on this system: the class is unchecked. #[cfg(not(unix))] -fn pointer_pages(_device: &Device, _length: u64) -> Option { - None +fn pointer_pages(_device: &Device, _length: u64) -> Result { + Err("the system maps no anonymous pages for the check".to_owned()) } /// No dma-bufs on this system: the class is unchecked. #[cfg(not(unix))] -fn dma_buf_pages(_device: &Device, _length: u64) -> Option { - None +fn dma_buf_pages(_device: &Device, _length: u64) -> Result { + Err("the system has no dma-bufs".to_owned()) } /// A no-copy buffer of `length` bytes over pages the device refuses by their pointer, imported /// as dma-bufs: an allocation of the device's own, host-visible and exported as a dma-buf, mapped /// (the module docs). #[cfg(unix)] -fn dma_buf_pages(device: &Device, length: u64) -> Option { +fn dma_buf_pages(device: &Device, length: u64) -> Result { let exported = crate::dma_buf::ExportedPages::make(device, length)?; let start = exported.start(); let source = exported.source(); @@ -1276,9 +1356,13 @@ fn dma_buf_pages(device: &Device, length: u64) -> Option { let memory = unsafe { HostMemory::with_dma_buf(start, source) }.dma_buf_only(); let buffer = no_copy_kept(device, memory, length, pages)?; if !buffer.over_dma_buf() { - return None; + let how = match buffer.copied() { + true => "copied them", + false => "imported them otherwise", + }; + return Err(format!("the device {how}, not as their dma-buf")); } - Some(ClassPages { buffer, start }) + Ok(ClassPages { buffer, start }) } /// A window of a class's pages, from its byte 0. diff --git a/crates/metal2vulkan-runtime/src/tests/in_place.rs b/crates/metal2vulkan-runtime/src/tests/in_place.rs index 0f48bd90c..4586b0c6c 100644 --- a/crates/metal2vulkan-runtime/src/tests/in_place.rs +++ b/crates/metal2vulkan-runtime/src/tests/in_place.rs @@ -326,7 +326,12 @@ fn a_record_reads_back_for_its_identity_alone() { let verdicts: [Verdict; VERDICTS] = std::array::from_fn(|at| [Verdict::Passed, Verdict::Failed, Verdict::Unchecked][at % 3]); let bytes = encode(&identity, verdicts); - assert_eq!(decode(&identity, &bytes), Some(verdicts)); + // An unchecked verdict is no measurement: it reads back pending, for the next device's check. + let measured = verdicts.map(|verdict| match verdict { + Verdict::Unchecked => Verdict::Pending, + verdict => verdict, + }); + assert_eq!(decode(&identity, &bytes), Some(measured)); // Cut short at every length, or grown. for length in 0..bytes.len() { @@ -348,9 +353,10 @@ fn a_record_reads_back_for_its_identity_alone() { version[8..12].copy_from_slice(&(CHECK_VERSION + 1).to_le_bytes()); assert_eq!(decode(&identity, &rechecked(version)), None); - // A pending or unknown verdict, at any of their places, with a checksum that holds. + // An unchecked or unknown verdict, at any of their places, with a checksum that holds: never + // written. for at in 44..44 + VERDICTS { - for byte in [0u8, 4, 0xff] { + for byte in [3u8, 4, 0xff] { let mut verdict = bytes.clone(); verdict[at] = byte; assert_eq!( diff --git a/crates/metal2vulkan-runtime/src/tests/in_place_check.rs b/crates/metal2vulkan-runtime/src/tests/in_place_check.rs index e3956f0e7..e64f60836 100644 --- a/crates/metal2vulkan-runtime/src/tests/in_place_check.rs +++ b/crates/metal2vulkan-runtime/src/tests/in_place_check.rs @@ -220,6 +220,91 @@ fn the_in_place_check_checks_fresh_pages_where_held_imports_cost_submissions() { } } +/// A class whose pages the device's check could not make answers unchecked on that device, its +/// reason noted, and is no measurement: its record keeps it unmeasured (`in_place::encode`), so +/// the next device of the same driver and check version recalls every verdict its check +/// measured, finds that class's pending, and checks it again; the device after that recalls its +/// answer too. The pointer class's first buffer, of the check's reads, is refused here as an +/// import of the pages that fails (`Device::fail_next_host_imports`), which the device answers +/// with a copy of them (`copied.rs`), no pages of the class. Printed (`IN-PLACE-UNMADE`): the +/// note, and the verdicts each device gave the class's reads. +#[test] +fn a_class_whose_pages_the_check_could_not_make_is_checked_again_by_the_next_device() { + let scratch = Scratch::new("in-place-check-unmade-pages"); + let record = AnswersRecord::new(ANSWERS); + let pointer_reads = |device: &Device| { + let checks = &device.shared().in_place; + RowEnds::ALL.map(|rows| checks.verdict(PagesClass::Pointer, Access::Reads, rows)) + }; + let measured = |device: &Device| { + let verdicts = device.shared().in_place.verdicts(); + let measured = [InPlaceVerdict::Passed, InPlaceVerdict::Failed]; + verdicts.iter().filter(|v| measured.contains(v)).count() as u64 + }; + let (first_reads, first_measured, note) = { + let device = answering(&scratch, &record); + device.fail_next_host_imports(1); + assert!( + device.settle_in_place_checks(WAIT), + "the first check answered" + ); + let report = device.in_place_check_report(); + let note = (report.iter()) + .find(|line| line.starts_with("Pointer reads: no pages to check: ")) + .cloned(); + assert!( + note.is_some(), + "the refused pages' reason noted: {report:?}" + ); + (pointer_reads(&device), measured(&device), note) + }; + assert_eq!( + first_reads, + [InPlaceVerdict::Unchecked; 2], + "the pointer class's reads, whose pages were refused" + ); + let second_reads = { + let device = answering(&scratch, &record); + assert_eq!( + device.work_counts().in_place_checks_recalled, + first_measured, + "every verdict the first check measured recalled" + ); + assert_eq!( + pointer_reads(&device), + [InPlaceVerdict::Pending; 2], + "the unchecked reads not recalled" + ); + assert!( + device.settle_in_place_checks(WAIT), + "the second check answered" + ); + assert!( + device.work_counts().in_place_checks_run > 0, + "the second device checked" + ); + let reads = pointer_reads(&device); + assert!( + !reads.contains(&InPlaceVerdict::Unchecked), + "the pointer class's reads checked again: {reads:?}, {:?}", + device.in_place_check_report() + ); + reads + }; + let device = answering(&scratch, &record); + assert_eq!( + pointer_reads(&device), + second_reads, + "the third device recalls the reads the second measured" + ); + eprintln!( + "IN-PLACE-UNMADE on {}: {note:?}; Pointer reads {first_reads:?}, then {second_reads:?}; \ + recalled by the third device {}", + device.name(), + device.work_counts().in_place_checks_recalled + ); +} + /// A private 4x4 `RGBA8Unorm` texture of the program's, at a plain ID. fn texture(device: &Device) -> Texture { let mut descriptor = TextureDescriptor::texture_2d(PixelFormat::RGBA8Unorm, 4, 4, false); @@ -314,7 +399,16 @@ fn texture_ids_keep_metals_order_while_the_in_place_check_runs() { /// exports but refuses to import fail the test, as the check's class would stay unchecked. #[cfg(target_os = "linux")] fn exported_buffer(device: &Device, length: u64, only: bool) -> Option { - let exported = crate::dma_buf::ExportedPages::make(device, length)?; + let exported = match crate::dma_buf::ExportedPages::make(device, length) { + Ok(exported) => exported, + Err(why) => { + eprintln!( + "IN-PLACE-DMA-BUF on {}: no pages exported: {why}", + device.name() + ); + return None; + } + }; let start = exported.start(); let source = exported.source(); // SAFETY: the pages are the device's mapped allocation, readable and writable, which stays diff --git a/crates/metal2vulkan-runtime/src/work_counts.rs b/crates/metal2vulkan-runtime/src/work_counts.rs index 182fdfea6..01237cc50 100644 --- a/crates/metal2vulkan-runtime/src/work_counts.rs +++ b/crates/metal2vulkan-runtime/src/work_counts.rs @@ -6541,7 +6541,9 @@ pub struct WorkCounts { /// Of `in_place_checks_run`, those that made no image of the class for the access. pub in_place_checks_unchecked: u64, /// Classes, accesses and row ends whose verdict was read from the record of an earlier check - /// of the same driver, device and check: no check ran for them. + /// of the same driver, device and check: no check ran for them. Only measured verdicts + /// (passed or failed) are recalled: one the earlier check could not give (unchecked: no pages + /// or no image of its kind made) is checked again. pub in_place_checks_recalled: u64, /// Textures over host pages made shadows before their pages' in-place verdicts (counted in /// `host_texture_shadows_check_pending`) that moved in place once the verdicts passed, at diff --git a/crates/metal2vulkan-validation/src/runtime_lane/in_place_textures.rs b/crates/metal2vulkan-validation/src/runtime_lane/in_place_textures.rs index 864e226ca..db301018d 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/in_place_textures.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/in_place_textures.rs @@ -90,8 +90,9 @@ //! to fail its check (`DeviceOptions::fail_in_place_check`) answers failed or unchecked for every //! class and makes such a texture a shadow counted as the failed check's, never in place, and //! keeps no record: the next device on the same shader cache recalls nothing and runs the check, -//! whose record the device after it recalls for every class (`in_place_checks_recalled`), with -//! the same verdicts and no check run. +//! whose record the device after it recalls (`in_place_checks_recalled`): every verdict it +//! measured, passed or failed, with no check run where it measured all; one it could not check +//! (unchecked) is no measurement, which that device checks again, answering as before. //! - [`in_place_and_shadow_costs`], without the validation layer, report only (built in release for //! the numbers): a `BGRA8Unorm` surface over a no-copy buffer of anonymous pages, read by a //! fragment function each frame, under each setting: a 3840x2160 one through a 3840x32 strip, @@ -1323,19 +1324,34 @@ fn a_failed_check_keeps_the_shadow_and_no_record() { report.truncate(VERDICTS); report }; - // Its record is recalled whole by the device after it, which checks nothing. + // Its record is recalled by the device after it: each verdict it measured, which that device + // checks no more; one it could not check is no measurement, checked again. { let device = validated_device_with(TEST_DEVICE, &messages, cache.path(), in_place).unwrap(); let counts = device.work_counts(); // Each class's verdicts, for a texture that reads, one that renders and one a shader // writes (of 4-, 8- or 16-byte texels and of 1- or 2-byte ones, each with its padding // kept or free), each for texels that share a line with bytes beside them and for texels - // that share none. - assert_eq!(counts.in_place_checks_recalled, VERDICTS as u64); - assert_eq!(counts.in_place_checks_run, 0); - assert!(device.settle_in_place_checks(std::time::Duration::ZERO)); - assert_eq!(device.in_place_check_took(), None); - assert_eq!(device.in_place_check_report(), verdicts); + // that share none: those the check measured. + let measured = (verdicts.iter()) + .filter(|line| line.ends_with(": Passed") || line.ends_with(": Failed")) + .count(); + assert_eq!(counts.in_place_checks_recalled, measured as u64); + let report = match measured == VERDICTS { + true => { + assert_eq!(counts.in_place_checks_run, 0); + assert!(device.settle_in_place_checks(std::time::Duration::ZERO)); + assert_eq!(device.in_place_check_took(), None); + device.in_place_check_report() + } + false => { + settled(&device); + let mut report = device.in_place_check_report(); + report.truncate(VERDICTS); + report + } + }; + assert_eq!(report, verdicts); eprintln!( "IN-PLACE-RECORD on {}: recalled {verdicts:?}", device.name() diff --git a/docs/API.md b/docs/API.md index 6c149f368..f9b076d04 100644 --- a/docs/API.md +++ b/docs/API.md @@ -389,7 +389,9 @@ says which commits). It runs once per driver and driver version: its verdicts are kept in the shader cache's directory, named by the driver and the check's own version, not the runtime's (a device without one checks once per process), and recalled as the next device is made -(`WorkCounts::in_place_checks_run`, `_passed`, `_failed`, `_unchecked`, `_recalled`). Such a +(`WorkCounts::in_place_checks_run`, `_passed`, `_failed`, `_unchecked`, `_recalled`): those it +measured, passed or failed. A class it could not check (no pages or no image of its kind made, +its reason noted) is checked again by the next device. Such a texture's commands read and write the texels in the memory the buffer's commands read, so a CPU write reaches them as it reaches the buffer's. diff --git a/docs/FAST-PATHS.md b/docs/FAST-PATHS.md index d959a5cef..1ff2e6c0c 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 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 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, the verdicts it measured kept in the shader cache's directory (one it could not give, no pages or no image of its kind made, 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` 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 |