From 703eca0dba4e095675af488e4f68ab01aa4cd34f Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Sun, 8 Nov 2026 02:25:18 -0800 Subject: [PATCH] Pooled class: tests and docs The padding-unobserved device test settles the check and holds the answer to the making's (NotHostPages exactly where the texture aliases, else the shadow's cause); a new device test renders textures of the guests' cache shapes (64-aligned pitches, rows ending inside a 64-byte line) over declared buffers and checks that a pitched image appears only where the pooled class passed for reads and renders, that the CPU's texels read back through the texture, that a clear reaches the buffer's rows, and that the bytes after the last row keep the CPU's. The validation lane reads 48 verdicts. Docs: in_place.rs and in_place_check.rs module docs, FAST-PATHS row 41, API.md (placement answers, the shadow reasons), HOWTO's padding-unobserved paragraph, the runtime README, BufferDescriptor::padding_unobserved, TexturePlacement's NotHostPages and Pending (a pooled texture made before its verdicts stays a shadow). Verified: cargo fmt only; builds and the device runs follow. (cherry picked from commit ae31d0fd3841b136c692897cbdf425633e9344c3) --- crates/metal2vulkan-runtime/README.md | 6 +- .../src/buffer_descriptor.rs | 4 +- crates/metal2vulkan-runtime/src/in_place.rs | 11 + .../src/in_place_check.rs | 6 +- .../src/tests/padding_unobserved.rs | 189 ++++++++++++++++-- .../src/texture_placement.rs | 15 +- .../src/runtime_lane/in_place_textures.rs | 4 +- docs/API.md | 9 +- docs/FAST-PATHS.md | 2 +- docs/HOWTO.md | 13 +- 10 files changed, 227 insertions(+), 32 deletions(-) diff --git a/crates/metal2vulkan-runtime/README.md b/crates/metal2vulkan-runtime/README.md index a264cdb6a..c84fe0ed3 100644 --- a/crates/metal2vulkan-runtime/README.md +++ b/crates/metal2vulkan-runtime/README.md @@ -508,8 +508,10 @@ Calls Metal does not have, for a consumer that emulates a Metal device: the runtime's own memory declares that nothing reads the bytes between a texture's rows over it (each row's after its texels to its pitch, the last row's included) or between its slices, so such a texture is a linear image aliasing the buffer where the device lays one out at its - pitches, not a shadow, and those bytes may change whenever it is made or used; no other byte - does (`WorkCounts::unobserved_padding_aliases`). No Metal counterpart; refused + pitches, or else a `DRM_FORMAT_MOD_LINEAR` image at them where the device's in-place check + passed for its pooled memory (`WorkCounts::pooled_pitched_images`), not a shadow, and those + bytes may change whenever it is made or used; no other byte does + (`WorkCounts::unobserved_padding_aliases`). No Metal counterpart; refused (`PaddingUnobservedNoCopy`) with `NoCopy` contents. - `Buffer::texture_placement` and `texture_placement_with_iosurface_plane` (with `TexturePlacement` and `TextureShadowReason`): where a texture `new_texture` or diff --git a/crates/metal2vulkan-runtime/src/buffer_descriptor.rs b/crates/metal2vulkan-runtime/src/buffer_descriptor.rs index 88d9bcbc0..a73cfece6 100644 --- a/crates/metal2vulkan-runtime/src/buffer_descriptor.rs +++ b/crates/metal2vulkan-runtime/src/buffer_descriptor.rs @@ -128,7 +128,9 @@ pub struct BufferDescriptor<'a> { /// last row's included, and the bytes from a slice's last row's pitch to the next slice. A /// texture over the buffer whose rows (or slices) lie apart is then a linear image aliasing /// the buffer's memory where the device lays one out at its pitches, as one whose rows lie one - /// after another is, not a shadow: its image holds those bytes, and Vulkan lets the image's + /// after another is, or else a `DRM_FORMAT_MOD_LINEAR` image at them where the device makes + /// such images and its in-place check passed for its pooled memory + /// (`WorkCounts::pooled_pitched_images`), not a shadow: its image holds those bytes, and Vulkan lets the image's /// layout moves and a render pass's load and store operations write them, so they may change /// to any value whenever the texture is made or used. No other byte changes: one past the /// image's subresources is reached by no operation on it, and a texel's bytes are the diff --git a/crates/metal2vulkan-runtime/src/in_place.rs b/crates/metal2vulkan-runtime/src/in_place.rs index 0e51e12ef..80abf62a0 100644 --- a/crates/metal2vulkan-runtime/src/in_place.rs +++ b/crates/metal2vulkan-runtime/src/in_place.rs @@ -63,6 +63,17 @@ //! copies of both touch texels alone. //! Elsewhere the texture is a shadow (`shadow.rs`), its notice naming why ([`ShadowCause`]) and //! counted by cause (`WorkCounts::host_texture_shadows_*`, and those that render apart). +//! - **The runtime's pooled memory.** A texture over a buffer of the runtime's own in its pooled +//! memory whose rows the device's own linear image lays out otherwise (a pitch the driver does +//! not take: ANV lays linear rows tight, RADV at multiples of 256 bytes) takes a +//! `DRM_FORMAT_MOD_LINEAR` image at Metal's pitch bound in the buffer's memory, no external +//! memory, where the device makes one ([`PagesClass::Pooled`], `texture.rs`'s +//! `pooled_pitched_image`): Vulkan lets such an image be bound to memory of no external handle +//! type (`VUID-VkImageCreateInfo-tiling-02261`, `VUID-vkBindImageMemory-image-01445`), but it +//! starts `UNDEFINED` (`VUID-VkImageCreateInfo-initialLayout-12478`), so its first move may +//! discard the bytes as an image over host pages' may, and the same rule takes it: where the +//! device's policy and its check of that class pass for the texture's accesses. A texture made +//! there before the class's verdicts are known stays a shadow. //! - **Before the verdict.** A texture made before its class's verdict for its access is known //! waits for nothing: it is a shadow ([`ShadowCause::CheckPending`], counted apart), and the //! first such texture starts the check on a thread of its own. Once its class's verdicts are diff --git a/crates/metal2vulkan-runtime/src/in_place_check.rs b/crates/metal2vulkan-runtime/src/in_place_check.rs index 86efe03b9..eefd9f138 100644 --- a/crates/metal2vulkan-runtime/src/in_place_check.rs +++ b/crates/metal2vulkan-runtime/src/in_place_check.rs @@ -6,7 +6,11 @@ //! - **What it does.** For each class it makes a buffer as the product makes one there (a no-copy //! buffer over anonymous pages it maps, imported by their pointer; a buffer of the runtime's own //! longer than half a pooled block, in fresh pages; a no-copy buffer over pages the device -//! refuses by their pointer, imported as dma-bufs), fills a window of it with a pattern, and +//! refuses by their pointer, imported as dma-bufs; a buffer of the runtime's own in its pooled +//! memory, under half a block, that declares the bytes between a texture's rows unobserved, where +//! the device makes `DRM_FORMAT_MOD_LINEAR` images, its textures taking such an image at Metal's +//! pitch alone, `texture.rs`'s `alias_image`; a shape whose window passes that buffer, the +//! 3840x2160 surface's, is skipped there), fills a window of it with a pattern, and //! makes a texture over it as the program does (`Buffer::new_runtime_texture`): the texture takes //! the image in place exactly as the product's would ([`checking`](crate::in_place::checking) //! lets it whatever the verdict); the fresh-pages class's buffer in fresh pages wherever the diff --git a/crates/metal2vulkan-runtime/src/tests/padding_unobserved.rs b/crates/metal2vulkan-runtime/src/tests/padding_unobserved.rs index c0d719d77..44f243a00 100644 --- a/crates/metal2vulkan-runtime/src/tests/padding_unobserved.rs +++ b/crates/metal2vulkan-runtime/src/tests/padding_unobserved.rs @@ -3,11 +3,19 @@ //! //! - **Declared.** A `BGRA8Unorm` texture of 101x48 texels (404 bytes a row) over it at pitches //! past its rows (416, 448 and 512 bytes, the next multiples of 16, 64 and 256 that drivers lay -//! linear rows at: MoltenVK, llvmpipe and ANV, RADV and NVIDIA) answers `NotHostPages`, and its -//! making takes a linear image aliasing the buffer wherever the device lays one at the pitch, -//! counted in `WorkCounts::unobserved_padding_aliases` and not in `shadowed_textures`, else a -//! shadow; at least one pitch takes the image. Through such an image, a blit of the texture into +//! linear rows at: MoltenVK, llvmpipe and ANV, RADV and NVIDIA), once the device's check +//! settled, takes a linear image aliasing the buffer wherever the device lays one at the pitch, +//! or a `DRM_FORMAT_MOD_LINEAR` image at the pitch where its check passed for its pooled memory +//! (`WorkCounts::pooled_pitched_images`), counted in `WorkCounts::unobserved_padding_aliases` +//! and not in `shadowed_textures`, and answers `NotHostPages`; else a shadow, which answers its +//! cause; at least one pitch takes the image. Through such an image, a blit of the texture into //! a buffer reads the texels the CPU wrote into the declared buffer's rows, at its pitch. +//! - **Rendered at a pitch the linear image misses.** A texture that renders, over such a buffer +//! at a 64-aligned pitch whose rows end inside a 64-byte line (the guests' device caches), is an +//! aliasing image exactly where the device makes `DRM_FORMAT_MOD_LINEAR` images and its check +//! of its pooled memory passed for renders, else a shadow; through the image, the texels the CPU +//! wrote read back, a pass's clear reaches the buffer's rows, and the bytes after the last row +//! keep the CPU's. //! - **Undeclared.** The same texture over a buffer made without the declaration answers //! `Shadow(BytesBetweenRows)` and is a shadow (`shadowed_textures`), at every pitch. //! - **Over the caller's memory**, the declaration is refused: `Invalid` @@ -26,6 +34,9 @@ use crate::{ use metal2vulkan::metal::{PixelFormat, TextureUsage}; use std::time::Duration; +/// The longest the device's check may take to settle. +const CHECK_WAIT: Duration = Duration::from_secs(120); + /// The texture's texels a row, and its rows. const WIDTH: u64 = 101; const HEIGHT: u64 = 48; @@ -104,6 +115,10 @@ fn blitted(device: &Device, texture: &Texture) -> Vec { fn a_texture_over_unobserved_padding_aliases_its_buffer_and_over_observed_padding_is_a_shadow() { let scratch = Scratch::new("padding-unobserved"); let device = device(&scratch.0); + assert!( + device.settle_in_place_checks(CHECK_WAIT), + "the check settles" + ); let length = PITCHES[2] * HEIGHT; let descriptor = texture_descriptor(); let mut aliased = Vec::new(); @@ -132,11 +147,6 @@ fn a_texture_over_unobserved_padding_aliases_its_buffer_and_over_observed_paddin "a short buffer lies in no fresh pages" ); let answer = declared.texture_placement(&descriptor, 0, pitch).unwrap(); - assert_eq!( - answer, - TexturePlacement::NotHostPages, - "declared at {pitch}: the answer" - ); // SAFETY: the declared buffer's mapped bytes, which no command uses yet. let bytes = unsafe { std::slice::from_raw_parts_mut(declared.contents().unwrap().as_ptr(), length as usize) @@ -153,6 +163,15 @@ fn a_texture_over_unobserved_padding_aliases_its_buffer_and_over_observed_paddin texture.shadow().is_none(), "declared at {pitch}: an aliasing image or a shadow" ); + assert_eq!( + answer == TexturePlacement::NotHostPages, + aliases, + "declared at {pitch}: the answer {answer:?} is the making's" + ); + assert!( + aliases || matches!(answer, TexturePlacement::Shadow(_)), + "declared at {pitch}: a shadow's answer names its cause, not {answer:?}" + ); assert_eq!( after.unobserved_padding_aliases - before.unobserved_padding_aliases, u64::from(aliases), @@ -176,16 +195,17 @@ fn a_texture_over_unobserved_padding_aliases_its_buffer_and_over_observed_paddin if aliases { aliased.push(pitch); } + let pitched = after.pooled_pitched_images - before.pooled_pitched_images; eprintln!( "UNOBSERVED-PADDING on {}: {WIDTH}x{HEIGHT} BGRA8Unorm at {pitch}: undeclared a \ - shadow ({:?}); declared {} ({:?})", + shadow ({:?}); declared {} ({answer:?})", device.name(), TexturePlacement::Shadow(TextureShadowReason::BytesBetweenRows), - match aliases { - true => "an aliasing image", - false => "a shadow (the device lays no linear image at the pitch)", + match (aliases, pitched) { + (true, 0) => "the device's linear image", + (true, _) => "a DRM_FORMAT_MOD_LINEAR image at the pitch", + (false, _) => "a shadow", }, - TexturePlacement::NotHostPages, ); } assert!( @@ -195,6 +215,147 @@ fn a_texture_over_unobserved_padding_aliases_its_buffer_and_over_observed_paddin ); } +/// The guests' device caches' shapes: `BGRA8Unorm`, rows at a 64-aligned pitch that end inside a +/// 64-byte line: (width, height, pitch). +const CACHES: [(u64, u64, u64); 3] = [(61, 37, 256), (250, 25, 1024), (3662, 9, 14656)]; + +#[test] +fn a_rendered_texture_at_a_pitch_the_linear_image_misses_takes_a_pitched_image_where_the_pooled_check_passed( +) { + use crate::in_place::{Access, PagesClass, RowEnds, Verdict}; + let scratch = Scratch::new("padding-unobserved-pitched"); + let device = device(&scratch.0); + assert!( + device.settle_in_place_checks(CHECK_WAIT), + "the check settles" + ); + let queue = device.new_command_queue().unwrap(); + for (width, height, pitch) in CACHES { + let row = width * 4; + let length = pitch * height + 4096; + let buffer = own_buffer(&device, length, true); + // SAFETY: the buffer's mapped bytes, which no command uses yet. + let bytes = unsafe { + std::slice::from_raw_parts_mut(buffer.contents().unwrap().as_ptr(), length as usize) + }; + for (at, byte) in bytes.iter_mut().enumerate() { + *byte = texel_byte(at as u64 % pitch, at as u64 / pitch); + } + let mut descriptor = + TextureDescriptor::texture_2d(PixelFormat::BGRA8Unorm, width, height, false); + descriptor.usage = TextureUsage::SHADER_READ | TextureUsage::RENDER_TARGET; + descriptor.resource_options = ResourceOptions::shared(); + let answer = buffer.texture_placement(&descriptor, 0, pitch).unwrap(); + let before = device.work_counts(); + let texture = buffer.new_texture(&descriptor, 0, pitch).unwrap(); + let after = device.work_counts(); + let pitched = after.pooled_pitched_images - before.pooled_pitched_images; + let aliases = texture.aliases_buffer(); + let layout = crate::linear_plan::BufferLayout { + offset: 0, + row_pitch: pitch, + slice_pitch: pitch * height, + row_bytes: row, + rows: height, + slices: 1, + }; + let rows = RowEnds::of(0, &layout, device.shared().in_place.line()); + let verdicts = [Access::Reads, Access::Renders].map(|access| { + device + .shared() + .in_place + .verdict(PagesClass::Pooled, access, rows) + }); + let passed = verdicts == [Verdict::Passed; 2]; + assert_eq!( + answer == TexturePlacement::NotHostPages, + aliases, + "{width}x{height} at {pitch}: the answer {answer:?} is the making's" + ); + assert!( + pitched == 0 || (aliases && passed), + "{width}x{height} at {pitch}: a pitched image only where the pooled check passed \ + ({verdicts:?})" + ); + // Through the image (or the shadow), the CPU's texels. + let read = device + .new_buffer(row * height, ResourceOptions::shared()) + .unwrap(); + let command_buffer = queue.command_buffer().unwrap(); + let mut blit = command_buffer.blit_command_encoder().unwrap(); + blit.copy_from_texture_to_buffer( + &texture, + 0, + 0, + Origin::new(0, 0, 0), + Size::new(width, height, 1), + &read, + 0, + row, + row * height, + BlitOption::None, + ) + .unwrap(); + blit.end_encoding().unwrap(); + command_buffer.commit().unwrap(); + command_buffer.wait_until_completed_for(WAIT).unwrap(); + assert_eq!(command_buffer.error(), None); + // SAFETY: the read buffer's mapped bytes, which no command uses now. + let read = unsafe { + std::slice::from_raw_parts(read.contents().unwrap().as_ptr(), (row * height) as usize) + }; + for y in 0..height { + for x in 0..row { + assert_eq!( + read[(y * row + x) as usize], + texel_byte(x, y), + "{width}x{height} at {pitch}: byte {x} of row {y} read through the texture" + ); + } + } + // A pass's clear reaches the buffer's rows; the bytes after the last row keep the CPU's. + let command_buffer = queue.command_buffer().unwrap(); + let mut pass = crate::RenderPassDescriptor::new(); + let color = &mut pass.color_attachments[0]; + color.texture = Some(texture.clone()); + color.load_action = crate::LoadAction::Clear; + color.clear_color = crate::ClearColor::new(0.0, 0.0, 1.0, 1.0); + color.store_action = crate::StoreAction::Store; + let encoder = command_buffer.render_command_encoder(&pass).unwrap(); + encoder.end_encoding().unwrap(); + command_buffer.commit().unwrap(); + command_buffer.wait_until_completed_for(WAIT).unwrap(); + assert_eq!(command_buffer.error(), None); + for y in 0..height { + for x in 0..width { + let at = (y * pitch + x * 4) as usize; + assert_eq!( + bytes[at..at + 4], + [0xff, 0, 0, 0xff], + "{width}x{height} at {pitch}: texel {x} of row {y} after the clear" + ); + } + } + for at in pitch * height..length { + assert_eq!( + bytes[at as usize], + texel_byte(at % pitch, at / pitch), + "{width}x{height} at {pitch}: byte {at} after the last row" + ); + } + eprintln!( + "POOLED-PITCHED on {}: {width}x{height} BGRA8Unorm at {pitch} rendered: pooled \ + verdicts {verdicts:?} ({rows:?}); answer {answer:?}; {}", + device.name(), + match (aliases, pitched) { + (true, 0) => "the device's linear image", + (true, _) => "a DRM_FORMAT_MOD_LINEAR image at the pitch", + (false, _) => "a shadow", + }, + ); + } +} + #[test] fn padding_unobserved_is_refused_over_the_callers_memory() { let scratch = Scratch::new("padding-unobserved-no-copy"); diff --git a/crates/metal2vulkan-runtime/src/texture_placement.rs b/crates/metal2vulkan-runtime/src/texture_placement.rs index 80e714647..ed0dda095 100644 --- a/crates/metal2vulkan-runtime/src/texture_placement.rs +++ b/crates/metal2vulkan-runtime/src/texture_placement.rs @@ -27,7 +27,10 @@ pub enum TexturePlacement { /// texture's accesses: once it does, at the commit of the device's only uncommitted command /// buffer, the texture moves in place with no copy where the verdicts pass and the device /// makes its image in place (`WorkCounts::host_textures_moved_in_place`), and stays a shadow - /// where they do not or the device refuses the image, as one made then would be. + /// where they do not or the device refuses the image, as one made then would be. Over the + /// device's own memory (a `DRM_FORMAT_MOD_LINEAR` image at Metal's pitch, + /// [`NotHostPages`](Self::NotHostPages)) a texture made now stays a shadow for good; one made + /// once the check answered takes the image where its verdicts pass. /// [`Device::settle_in_place_checks`](crate::Device::settle_in_place_checks) starts the check /// and says when its verdicts are known; the same query then answers what a texture made after /// takes. @@ -37,9 +40,13 @@ pub enum TexturePlacement { /// (`shadowed-texture`) but for a device copy. Why. Shadow(TextureShadowReason), /// The buffer's bytes are no host pages (a buffer of the device's own memory, or the caller's - /// `VkBuffer`): the texture is a linear image aliasing the buffer's memory where the device - /// lays one out as Metal does, else a shadow. The device's check does not decide it. Its rows - /// (and slices) lie one after another, or the buffer declares the bytes between them + /// `VkBuffer`): the texture is a linear image aliasing the buffer's memory, the device's own + /// where it lays one out as Metal does, else, over the device's own memory, a + /// `DRM_FORMAT_MOD_LINEAR` image at Metal's pitch where the device makes one and its check of + /// such images over its pooled memory passed for the texture's accesses (the query made it + /// unbound and released it); a texture over the device's own memory that takes neither answers + /// its shadow's cause ([`TexturePlacement::Pending`] while that check has not answered). Its + /// rows (and slices) lie one after another, or the buffer declares the bytes between them /// unobserved ([`BufferDescriptor::padding_unobserved`](crate::BufferDescriptor::padding_unobserved)), /// which the image then holds; else the answer is /// [`TextureShadowReason::BytesBetweenRows`]. 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 08a91679e..beb23ef02 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/in_place_textures.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/in_place_textures.rs @@ -157,8 +157,8 @@ pub(super) fn writes_passed( pub(super) type Rows = (u64, u64, u64); /// The verdicts the device's check gives, each a line of its report before what it found -/// changed: three classes, six accesses, two row ends. -const VERDICTS: usize = 36; +/// changed: four classes, six accesses, two row ends. +const VERDICTS: usize = 48; /// The devices made again where load beside the submission checks split their import tax's tries /// ([`answered_device`]). diff --git a/docs/API.md b/docs/API.md index 21ff1db81..3162f4c9c 100644 --- a/docs/API.md +++ b/docs/API.md @@ -402,7 +402,9 @@ where the verdict passes; a shadow and why (`TextureShadowReason`: the policy, t check's failed or unchecked verdict with its access and row ends, a refusal, a tiled texture's levels, texels past the buffer's length, a device copy, and over the device's own memory rows with bytes between them the buffer does not declare unobserved, `BytesBetweenRows`); no host pages (an -image aliasing the buffer's memory where the device lays one out as Metal does); or a shape no +image aliasing the buffer's memory: the device's linear image where it lays one out as Metal does, +else a `DRM_FORMAT_MOD_LINEAR` image at Metal's pitch where the device's check passed for its pooled +memory; a texture over that memory that takes neither answers its shadow's cause); or a shape no image in place takes; `Buffer::tiled_texture_placement` answers it for `new_tiled_texture`'s. The making's own route answers it (`texture/route.rs`), after every check the making runs before it makes anything, so the same arguments are refused with the same errors; where the route is the image in @@ -1605,7 +1607,10 @@ bound. them as the program writes them, unless the buffer, of the runtime's own memory, declares them unobserved (`BufferDescriptor::padding_unobserved`, a runtime extension: they may then change, and no other byte does); or no linear image of the device lays its texels out as Metal - does in the buffer's memory, holding no byte past them; or the buffer is over the caller's + does in the buffer's memory, holding no byte past them, and no `DRM_FORMAT_MOD_LINEAR` image at + Metal's pitch serves (the device makes none, its policy is `HostPageTexturePolicy::Shadow`, or + its check of such images over its pooled memory has not passed for the texture's accesses: + pending, failed or unchecked, as over host pages); or the buffer is over the caller's `VkBuffer`, whose memory backs no image of the runtime's; or it is a tiled texture of more than one level (`Buffer::new_tiled_texture`), over any buffer: no image over the buffer's memory holds levels past the first, so one image of its own holds every level, its first level's texels diff --git a/docs/FAST-PATHS.md b/docs/FAST-PATHS.md index 23afac275..fb6e60f00 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) 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`). 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) 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 stays a shadow. 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 27a2e38b5..25bbde3f1 100644 --- a/docs/HOWTO.md +++ b/docs/HOWTO.md @@ -342,11 +342,14 @@ past a row, a signaling NaN's bits quieted) may write, where Metal leaves them a them. A consumer that owns every read of such a buffer's bytes (a cache it fills and reads back by rows of texels, say) may make it with `BufferDescriptor::with_padding_unobserved()`: a runtime extension, no Metal counterpart, refused over the caller's memory (`NoCopy` contents). A texture -over it is then a linear image at its pitch wherever the device lays one out so, its subresources -holding each row's bytes after its texels to its pitch (the last row's included) and nothing past -the last row's pitch; those bytes and the bytes between slices may change whenever the texture is -made or used, and no other byte does (`WorkCounts::unobserved_padding_aliases` counts such images; -`Buffer::texture_placement` answers `NotHostPages` for it, and +over it is then a linear image at its pitch wherever the device lays one out so, or else, where +the device makes `DRM_FORMAT_MOD_LINEAR` images (`VK_EXT_image_drm_format_modifier`), one at the +pitch where its in-place check passed for its pooled memory (`WorkCounts::pooled_pitched_images`; +`HostPageTexturePolicy::Shadow` turns it off), its subresources holding each row's bytes after its +texels to its pitch (the last row's included) and nothing past the last row's pitch; those bytes +and the bytes between slices may change whenever the texture is made or used, and no other byte +does (`WorkCounts::unobserved_padding_aliases` counts such images; `Buffer::texture_placement` +answers `NotHostPages` for such a texture, else the shadow's cause, and `Shadow(TextureShadowReason::BytesBetweenRows)` without the declaration). A blit that names a texture over a buffer runs on the buffers' bytes, a region per row where its