From 399e8d6d177b2fde56b10845d406689623ee5940 Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Wed, 11 Nov 2026 00:53:03 -0800 Subject: [PATCH] Runtime: a host-transfer image takes its class's own memory types, never overflow ones What: Memory::host_image_types (now the pure memory::host_image_types, with class_types beside it) returns the types of the image's class among those allowed, in both of its branches, instead of every allowed type. A `Shared` or `Managed` texture's image with host-transfer usage so never overflows into system memory: where none of its class's types has room, its placement fails and host_placed_image makes the image without the usage, which lies in device-local memory where that image has room (and overflows only where none has, as any image does). The unused Memory delegates host_cached_placement and host_incoherent go. Texture::placed_type and Memory::type_and_heap are test-only accessors for the new device test. Why: the RTX 3090 lanes (validation runtime_lane, round at 7d7085f9d0, gem10 and um870) announced device-memory-overflow for `Shared` Depth32Float textures in six tests. Those 3090s run without resizable BAR (NVIDIA 620.70.06, vulkaninfo on gem10: heap 2, DEVICE_LOCAL, 246 MiB; nvidia-smi BAR1 total 256 MiB), and NVIDIA places a host-transfer image in that BAR heap alone (type 5, its one device-local type for it), beside system types 3 and 4. With 16 lane tests at once, each device's 68 MiB block of such images fills the shared 246 MiB heap; the next process's depth texture then overflowed into types 3/4 while heap 0 (24 GiB, type 1, which the image without the usage takes) had room. Color textures there copy on the staging queue and take no host-transfer usage, which is why only depth textures overflowed. Tests: tests::memory::host_transfer_images_take_no_type_their_class_overflows_into (pure; on the 3090's memory types the image takes type 5 alone, where the old answer 3..5 overflowed into [3, 4]); tests::host_image_room (device: on a GPU whose host-transfer heap is at most 1 GiB, fills it with 16 MiB Shared Depth32Float textures, none may overflow, all lie device-local, CPU copies round-trip). Docs: host_copy.rs module docs, the FAST-PATHS device-gap row for the copies' submissions. Builds, clippy and the 3090 runs go to potluck after this commit. --- crates/metal2vulkan-runtime/src/memory.rs | 70 +++++++---- .../src/tests/host_image_room.rs | 115 ++++++++++++++++++ .../metal2vulkan-runtime/src/tests/memory.rs | 73 ++++++++++- crates/metal2vulkan-runtime/src/tests/mod.rs | 2 + crates/metal2vulkan-runtime/src/texture.rs | 19 ++- .../src/texture/host_copy.rs | 8 +- docs/FAST-PATHS.md | 1 + 7 files changed, 255 insertions(+), 33 deletions(-) create mode 100644 crates/metal2vulkan-runtime/src/tests/host_image_room.rs diff --git a/crates/metal2vulkan-runtime/src/memory.rs b/crates/metal2vulkan-runtime/src/memory.rs index b234d1aa8..c9a6963d4 100644 --- a/crates/metal2vulkan-runtime/src/memory.rs +++ b/crates/metal2vulkan-runtime/src/memory.rs @@ -658,6 +658,37 @@ pub(super) fn host_cached_placement( Some((class, cached)) } +/// The memory class and types among `types`, as bits, an image of `class` with host-transfer +/// usage whose requirements allow `allowed` takes (`texture/host_copy.rs`), on a device with +/// unified memory (`unified`) or without, and whether they are types the host caches: never one +/// the host maps without coherence ([`host_incoherent`]); those of the class the host caches where +/// the image may take one ([`host_cached_placement`]); else the class's types among those +/// allowed. Never a type the class overflows into ([`overflow_candidates`]): where none of the +/// class's types has room, the image is made without host-transfer usage, and that image lies in +/// device-local memory where a type of it has room. The types an image with the usage takes can +/// lie in a heap of their own: an RTX 3090 without resizable BAR (NVIDIA 620.70.06) places such +/// an image in its 246 MiB BAR heap alone, which every process's devices share, beside a +/// device-local heap of 24 GiB. +pub(super) fn host_image_types( + types: &[vk::MemoryType], + allowed: u32, + class: MemoryClass, + unified: bool, +) -> (MemoryClass, u32, bool) { + let allowed = allowed & !host_incoherent(types); + match host_cached_placement(types, allowed, class, unified) { + Some((class, cached)) => (class, class_types(types, cached, class, unified), true), + None => (class, class_types(types, allowed, class, unified), false), + } +} + +/// The memory types of `class` among `types` (the bits of `allowed`), as bits ([`candidates`]): +/// none it overflows into. +fn class_types(types: &[vk::MemoryType], allowed: u32, class: MemoryClass, unified: bool) -> u32 { + (candidates(types, allowed, class, unified).into_iter()) + .fold(0, |bits, index| bits | 1 << index) +} + /// The memory types `class` may use among `types` (the bits of `allowed`), best first, on a /// device with unified memory (`unified`, `DeviceProperties::has_unified_memory`) or without. /// Only `Memoryless` uses a lazily allocated type, which serves transient attachments alone, and @@ -2348,6 +2379,14 @@ impl Memory { self.frees = Some(frees); } + /// Memory type `type_index`'s properties and the size of its heap, for the crate's device + /// tests. + #[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))] + pub(super) fn type_and_heap(&self, type_index: u32) -> (vk::MemoryPropertyFlags, u64) { + let flags = self.types[type_index as usize].property_flags; + (flags, self.heaps[self.heap_of(type_index)].0) + } + /// The memory heap of memory type `type_index`. fn heap_of(&self, type_index: u32) -> usize { self.types[type_index as usize].heap_index as usize @@ -2544,36 +2583,15 @@ impl Memory { host_cached_placement(&self.types, u32::MAX, class, self.unified).is_some() } - /// The memory class an image of `class` with host-transfer usage takes in memory the host - /// caches, and its memory types among `allowed`, as bits ([`host_cached_placement`]). - pub(super) fn host_cached_placement( - &self, - allowed: u32, - class: MemoryClass, - ) -> Option<(MemoryClass, u32)> { - host_cached_placement(&self.types, allowed, class, self.unified) - } - - /// The memory types the host maps without coherence, as bits ([`host_incoherent`]). - pub(super) fn host_incoherent(&self) -> u32 { - host_incoherent(&self.types) - } - /// The memory class and types, as bits, an image of `class` with host-transfer usage whose - /// requirements allow `allowed` takes (`texture/host_copy.rs`), and whether they are types the - /// host caches: never one the host maps without coherence ([`host_incoherent`]); those the - /// host caches where the image may take one ([`host_cached_placement`]); else `class` and - /// every other type allowed. + /// requirements allow `allowed` takes, and whether they are types the host caches + /// ([`host_image_types`]). pub(super) fn host_image_types( &self, allowed: u32, class: MemoryClass, ) -> (MemoryClass, u32, bool) { - let allowed = allowed & !self.host_incoherent(); - match self.host_cached_placement(allowed, class) { - Some((class, types)) => (class, types, true), - None => (class, allowed, false), - } + host_image_types(&self.types, allowed, class, self.unified) } /// The pool a color texture's host-transfer image places in, found once, where `copies` (read @@ -2760,9 +2778,7 @@ impl Memory { /// The memory types of `class` among those `allowed` names, as bits. pub(super) fn class_types(&self, allowed: u32, class: MemoryClass) -> u32 { - candidates(&self.types, allowed, class, self.unified) - .into_iter() - .fold(0, |bits, index| bits | 1 << index) + class_types(&self.types, allowed, class, self.unified) } /// The index in `pools` of the pool of blocks of memory type `type_index` that hold `holds`. diff --git a/crates/metal2vulkan-runtime/src/tests/host_image_room.rs b/crates/metal2vulkan-runtime/src/tests/host_image_room.rs new file mode 100644 index 000000000..b2510fb66 --- /dev/null +++ b/crates/metal2vulkan-runtime/src/tests/host_image_room.rs @@ -0,0 +1,115 @@ +//! `Shared` depth textures past the room of the heap their host-transfer images lie in +//! (`memory::host_image_types`, `texture/host_copy.rs`). Such an image takes its class's own memory +//! types alone, never one the class overflows into: where none of them has room, the texture's +//! image is made without host-transfer usage, in device-local memory where that image has room. +//! An RTX 3090 without resizable BAR (NVIDIA 620.70.06) places a host-transfer image in its +//! 246 MiB BAR heap alone, which every process's devices share; past it such textures lay in +//! system memory (`device-memory-overflow`) while the 24 GiB device-local heap had room. +//! +//! Where the first texture's image takes the usage in a device-local type whose heap holds at most +//! [`FILLED_AT_MOST`], textures of [`SIDE`] squared `Depth32Float` texels are made until their +//! bytes pass the heap's size by two blocks of images: none overflows, each lies in device-local +//! memory, and the first and the last read back the depths their CPU copies wrote. Elsewhere +//! (no host copies, or the usage's heap is larger) the test says why and makes nothing more. The +//! textures made with and without the usage are printed (`HOST-IMAGE-ROOM`). +//! +//! A device test: compiled only under the GPU safety cfgs (`m2v_gpu`, `m2v_cpu_icd`). + +use super::blit_holds::{device, Scratch}; +use crate::device::lock; +use crate::memory::{BLOCK_BYTES, IMAGE_BLOCK_SLACK}; +use crate::{Region, ResourceOptions, Texture, TextureDescriptor}; +use ash::vk::MemoryPropertyFlags; +use metal2vulkan::metal::{PixelFormat, TextureUsage}; +use metal2vulkan::vk::ImageUsageFlags; + +/// The side of each texture: 16 MiB of `Depth32Float`, a quarter of a block of images. +const SIDE: u64 = 2048; + +/// The largest heap of host-transfer images the test fills. +const FILLED_AT_MOST: u64 = 1 << 30; + +/// Whether `texture`'s image takes host-transfer usage. +fn hosted(texture: &Texture) -> bool { + let usage = texture.image_plan().unwrap().usage; + usage.contains(ImageUsageFlags::HOST_TRANSFER) +} + +/// `depth` in each of the region's 4 x 4 texels at the texture's corner, written by +/// `replace_region` and read back by `get_bytes`. +fn round_trip(texture: &Texture, depth: f32) -> Vec { + let region = Region::new_2d(0, 0, 4, 4); + let bytes: Vec = (0..16).flat_map(|_| depth.to_le_bytes()).collect(); + texture.replace_region(region, 0, 0, &bytes, 16, 0).unwrap(); + let mut read = vec![0u8; bytes.len()]; + texture.get_bytes(&mut read, 16, 0, region, 0, 0).unwrap(); + (read.chunks_exact(4)) + .map(|word| f32::from_le_bytes(word.try_into().unwrap())) + .collect() +} + +#[test] +fn shared_depth_textures_past_their_host_transfer_heap_lie_in_device_local_memory() { + let scratch = Scratch::new("host-image-room"); + let device = device(&scratch.0); + let name = device.name(); + let mut descriptor = + TextureDescriptor::texture_2d(PixelFormat::Depth32Float, SIDE, SIDE, false); + descriptor.usage = TextureUsage::SHADER_READ | TextureUsage::RENDER_TARGET; + descriptor.resource_options = ResourceOptions::shared(); + let first = device.new_texture(&descriptor).unwrap(); + let kind = |texture: &Texture| { + let index = texture.placed_type().unwrap(); + lock(&device.shared().memory).type_and_heap(index) + }; + let (flags, heap) = kind(&first); + if !hosted(&first) || !flags.contains(MemoryPropertyFlags::DEVICE_LOCAL) { + println!( + "HOST-IMAGE-ROOM {name}: the first texture takes no host-transfer usage in \ + device-local memory (usage {}, type {flags:?}): nothing to fill", + hosted(&first) + ); + return; + } + if heap > FILLED_AT_MOST { + println!( + "HOST-IMAGE-ROOM {name}: host-transfer images lie in a heap of {heap} bytes, past \ + the {FILLED_AT_MOST} the test fills" + ); + return; + } + let bytes = SIDE * SIDE * 4; + let blocks = 2 * (BLOCK_BYTES + BLOCK_BYTES / IMAGE_BLOCK_SLACK); + let count = (heap + blocks).div_ceil(bytes) + 1; + let before = device.work_counts().device_memory_overflows; + let mut textures = vec![first]; + for _ in 1..count { + textures.push(device.new_texture(&descriptor).unwrap()); + } + let with = textures.iter().filter(|texture| hosted(texture)).count(); + let overflowed = textures + .iter() + .filter(|texture| texture.overflowed()) + .count(); + println!( + "HOST-IMAGE-ROOM {name}: a heap of {heap} bytes; {} textures of {bytes} bytes: {with} \ + with host-transfer usage, {} without, {overflowed} overflowed", + textures.len(), + textures.len() - with + ); + assert_eq!( + overflowed, 0, + "{name}: textures lay past device-local memory" + ); + assert_eq!(device.work_counts().device_memory_overflows, before); + for texture in &textures { + let (flags, _) = kind(texture); + assert!( + flags.contains(MemoryPropertyFlags::DEVICE_LOCAL), + "{name}: a texture lies in memory of {flags:?}" + ); + } + let last = textures.last().unwrap(); + assert_eq!(round_trip(&textures[0], 0.25), [0.25; 16]); + assert_eq!(round_trip(last, 0.75), [0.75; 16]); +} diff --git a/crates/metal2vulkan-runtime/src/tests/memory.rs b/crates/metal2vulkan-runtime/src/tests/memory.rs index f65feac44..2134d3665 100644 --- a/crates/metal2vulkan-runtime/src/tests/memory.rs +++ b/crates/metal2vulkan-runtime/src/tests/memory.rs @@ -1,6 +1,7 @@ use crate::memory::{ - candidates, fd_buffer_types, host_cached, host_cached_placement, host_incoherent, kept_budget, - overflow_candidates, MemoryClass, Pool, KEPT_EMPTY_BLOCKS, KEPT_EMPTY_BYTES, KEPT_EMPTY_FOR, + candidates, fd_buffer_types, host_cached, host_cached_placement, host_image_types, + host_incoherent, kept_budget, overflow_candidates, MemoryClass, Pool, KEPT_EMPTY_BLOCKS, + KEPT_EMPTY_BYTES, KEPT_EMPTY_FOR, }; use ash::vk; use std::time::Instant; @@ -461,6 +462,74 @@ fn host_transfer_images_prefer_host_cached_memory() { } } +/// A texture's image with host-transfer usage takes its class's own memory types alone, never one +/// the class overflows into past full device-local memory (`overflow_candidates`): where none of +/// them has room, the placement fails and the image is made without the usage +/// (`Device::host_placed_image`), which lies in device-local memory where a type of it has room +/// and overflows only where none has. On an RTX 3090 without resizable BAR (NVIDIA 620.70.06) the +/// one device-local type such an image takes, 5, lies in the 246 MiB BAR heap that every +/// process's devices share; with the system memory types 3 and 4 it also allows among its types, +/// a `Shared` `Depth32Float` texture past that heap lay in system memory, announced as +/// `device-memory-overflow`, while the 24 GiB heap of type 1, which the image without the usage +/// takes, had room. Unchanged: the host-cached types where the class has one, and the incoherent +/// ones left out. +#[test] +fn host_transfer_images_take_no_type_their_class_overflows_into() { + let types = |raw: &[u32]| -> Vec { + raw.iter() + .map(|&flags| ty(vk::MemoryPropertyFlags::from_raw(flags))) + .collect() + }; + let private = MemoryClass::Private; + let nvidia = types(&[0x0, 0x1, 0x1, 0x6, 0xe, 0x7]); + // Allowed: system memory (3, 4) and the BAR heap (5). The image takes 5 alone: nothing it + // could overflow into. + let (class, taken, cached) = host_image_types(&nvidia, 0b11_1000, private, false); + assert_eq!((class, taken, cached), (private, 0b10_0000, false)); + assert!(overflow_candidates(&nvidia, taken, class, false).is_empty()); + // What the allowed types alone would overflow into. + assert_eq!( + overflow_candidates(&nvidia, 0b11_1000, private, false), + [3, 4] + ); + // The image without the usage (an optimal depth image there: types 0 and 1) lies in the + // device-local type 1 and overflows into 0 only where 1 has no room. + assert_eq!(candidates(&nvidia, 0b11, private, false), [1]); + assert_eq!(overflow_candidates(&nvidia, 0b11, private, false), [0]); + // Allowed system memory alone: no type at all, so the placement fails before any allocation. + assert_eq!( + host_image_types(&nvidia, 0b1_1000, private, false), + (private, 0, false) + ); + // RADV on a discrete GPU (the 780M's types without unified memory): its device-local types + // alone, the host-cached system type 5 left out. + let radv = types(&[ + 0x1, 0x1, 0x6, 0x7, 0x7, 0xe, 0xe, 0x21, 0x21, 0x21, 0x21, 0x20, 0x20, 0xc1, 0xc6, 0xc7, + 0xce, + ]); + let allowed = 0b1_1100_0000_0010_1100; + let (class, taken, cached) = host_image_types(&radv, allowed, private, false); + assert_eq!((class, taken, cached), (private, 0b1000, false)); + assert!(overflow_candidates(&radv, taken, class, false).is_empty()); + // With unified memory nothing overflows, and the host-cached type stays the image's. + assert_eq!( + host_image_types(&radv, allowed, private, true), + (private, 0b10_0000, true) + ); + // A device-local type the host caches, beside a cached system one: the device-local one alone. + let cached_both = types(&[0x1, 0xe, 0xf]); + assert_eq!( + host_image_types(&cached_both, 0b111, private, false), + (private, 0b100, true) + ); + // ANV on Arrow Lake-S: the incoherent cached type 1 stays out. + let arl = types(&[0x7, 0xb, 0x21, 0x7]); + assert_eq!( + host_image_types(&arl, 0b1011, private, true), + (private, 0b1001, false) + ); +} + /// The memory log's line for a large pooled placement names what it is, its class where placed, /// its bytes and where it lies, in the words of the block's own lines (`memory_log.rs`). #[test] diff --git a/crates/metal2vulkan-runtime/src/tests/mod.rs b/crates/metal2vulkan-runtime/src/tests/mod.rs index e208f23cb..f0e830b3a 100644 --- a/crates/metal2vulkan-runtime/src/tests/mod.rs +++ b/crates/metal2vulkan-runtime/src/tests/mod.rs @@ -225,6 +225,8 @@ mod host_bytes; #[cfg(any(m2v_gpu, m2v_cpu_icd))] mod host_hold_filter; #[cfg(any(m2v_gpu, m2v_cpu_icd))] +mod host_image_room; +#[cfg(any(m2v_gpu, m2v_cpu_icd))] mod host_import_counts; mod host_memory; #[cfg(m2v_gpu)] diff --git a/crates/metal2vulkan-runtime/src/texture.rs b/crates/metal2vulkan-runtime/src/texture.rs index d30837cdf..430288cfd 100644 --- a/crates/metal2vulkan-runtime/src/texture.rs +++ b/crates/metal2vulkan-runtime/src/texture.rs @@ -3822,9 +3822,11 @@ impl Device { // host reads slowly where it does not cache it: such memory of the class where the // device has it, else `Shared` memory's with unified memory // (`memory::host_cached_placement`). Never memory the host maps without coherence, cached - // or not: the runtime flushes no mapped range (`memory::host_cached`). Where only such - // memory is allowed, the placement fails and `host_placed_image` makes the image without - // host-transfer usage, its copies through submissions, as on a device without host copies. + // or not: the runtime flushes no mapped range (`memory::host_cached`). Never a type its + // class overflows into (`Memory::host_image_types`). Where only such memory is allowed, or + // none of its types has room, the placement fails and `host_placed_image` makes the image + // without host-transfer usage, its copies through submissions, as on a device without host + // copies. let hosted = plan.usage.contains(ImageUsageFlags::HOST_TRANSFER); let (class, cached) = match hosted { true => { @@ -5443,6 +5445,17 @@ impl Texture { Ok(image.linear && lock(&image.detached).is_none()) } + /// The memory type of the runtime's own memory the texture's image lies in: `None` for an + /// image in a buffer's, a heap's or the caller's memory, and where [`image`](Self::image) + /// refuses. For the crate's device tests. + #[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))] + pub(super) fn placed_type(&self) -> Option { + match &self.image().ok()?.owner { + Owner::Runtime { placement, .. } => Some(placement.type_index()), + _ => None, + } + } + /// Whether the texture's image lies in memory of the runtime's own that overflowed past /// device-local memory into system memory (`memory.rs`'s `overflow_candidates`): false for an /// image in a buffer's, a heap's or the caller's memory, and where diff --git a/crates/metal2vulkan-runtime/src/texture/host_copy.rs b/crates/metal2vulkan-runtime/src/texture/host_copy.rs index 2fdb2d997..769b44f51 100644 --- a/crates/metal2vulkan-runtime/src/texture/host_copy.rs +++ b/crates/metal2vulkan-runtime/src/texture/host_copy.rs @@ -34,7 +34,13 @@ //! device with unified memory, `Shared` memory the host caches (a Radeon 780M's //! system memory, where its GPU uses the image as fast as in device-local memory or faster, and a //! 1080p `get_bytes` takes 2.6 ms where it took 108 ms from RADV's uncached device-local type); -//! else the class's memory as before, counted (`WorkCounts::uncached_host_images`). Where the +//! else the class's memory as before, counted (`WorkCounts::uncached_host_images`). Only the +//! class's own types, never one it overflows into past full device-local memory +//! (`memory::host_image_types`): where none of them has room, the image is made without the +//! usage, as on a device without `VK_EXT_host_image_copy`, in device-local memory where that +//! image has room there. An RTX 3090 without resizable BAR (NVIDIA 620.70.06) takes such an +//! image in its 246 MiB BAR heap alone, which every process's devices share; past it the image +//! lay in system memory while its 24 GiB device-local heap had room. Where the //! device reserved a staging queue (`device/staging.rs`: a copy engine, NVIDIA's; or, on a //! device where no memory the host caches holds a texture's image, a queue of compute work //! beside its own, an RX 7900 XTX's), a color texture copies on the host only from host-cached diff --git a/docs/FAST-PATHS.md b/docs/FAST-PATHS.md index d8d36bbc3..6c50c0e8c 100644 --- a/docs/FAST-PATHS.md +++ b/docs/FAST-PATHS.md @@ -98,6 +98,7 @@ known. The rest of the differences are docs/API.md section 9's precision notes. | A visibility result of a draw whose fragment function declares `[[early_fragment_tests]]` and writes its sample mask (the pipeline's private sample mask or coverage, or its own `[[sample_mask]]` return), on a device without `earlyFragmentMultisampleCoverageAfterSampleCounting` (ANV on the Iris Xe of RPL-P): the count may leave out the samples the mask drops, which Metal counts; a `Boolean` result may be 0 where Metal's passed. | Vulkan lets such a device count after the fragment shader's mask, every form that masks the colors alone (the `SampleMask` output, a discard) is a fragment operation it may count after, and only a second draw of each counted draw without the mask would count as Metal does. | `VisibilityPastEarlyMask` (`visibility-past-early-mask`) | | On MoltenVK a no-copy buffer or heap released with no keep-alive while batches are in flight runs its deallocator once the batches submitted before its release completed, and the program's own submissions through `CommandQueue::with_vk_queue` before it, where Metal runs it at the release. | MoltenVK 1.4.1 fails pending work that reads device addresses where memory a device-address buffer lay in is freed (`RuntimeDriverDefect::FreedAddressMemoryFailsPendingWork`), so freed memory waits for the batches in flight (`WorkCounts::freed_memory_parked`). | `HostDeallocatorDelayed` (`host-deallocator-delayed`) | | On MoltenVK a `Shared` or `Managed` texture whose format packs more than one texel into a block (every block-compressed family) keeps its image out of host-transfer memory, so its CPU copies take submissions where another driver's take none. The stored texels are Metal's either way; what changes is the work, in `WorkCounts::command_buffers_begun_batch_work` and the `command_buffers_begun` and `command_buffers_submitted` that carry it (`bc1-rgba`, four 16 x 16 `BC1_RGBA` levels: `command_buffers_begun` 8 on the bind-time path and 15 off it; `fresh-texture-bc1-rgba-managed`: 3 and 5). A `replaceRegion` of such a texture stages its bytes for the device's next submission and waits for none (`texture/first_move.rs`). Its CPU **reads** come out of a host shadow of the image's texels, made at the first read of the texture by the submission that read waits for either way and read from by every read after it: exact (it holds the image's own bytes, and a CPU write writes both), bounded (`host_shadow::SHADOW_BYTES`, past which a read takes the submission path), and lazy, so a texture nobody reads back holds nothing. It is dropped wherever anything but a CPU write may have written the texels: every commit of the program's, its own Vulkan submissions, another `VkImage`, a detach, or the program taking the image's handle (`texture/host_shadow.rs`; `WorkCounts::texel_shadows_made`, `texel_shadow_reads`, `texel_shadows_dropped`). Measured on an M3 Max: `compressed-moves-bc1-rgba` reads `internal_submissions` 5 where it read 56 and `command_buffers_begun` 30 where it read 81, for 1,168 bytes of shadow over its five textures and 56 reads out of them. | MoltenVK 1.4.2 binds such an image through a `flushToDevice` that `replaceRegion:`s every subresource at one block's bytes a row instead of the row of blocks, tripping AGX's `bytes_per_row >= used_bytes_per_row` assertion (`RuntimeDriverDefect::HostTransferImagesCopiedAtBind`). The copy is the driver's own and no call of the program's asks for it, so the only way not to provoke it is not to ask for the image; every other driver keeps the host-transfer path, as does a device without `VK_EXT_host_image_copy`. A write cannot leave the GPU's copy of the texels unwritten, so only reads come off the host shadow. | None (cost only, and exact) | +| On a GPU without unified memory whose types for host-transfer images lie in a heap with no room left, a `Shared` or `Managed` texture made then takes no host-transfer usage: its image lies in device-local memory where that image has room, and its CPU copies take submissions where those of a texture made while the heap had room take none (`memory::host_image_types`, `texture/host_copy.rs`). An RTX 3090 without resizable BAR (NVIDIA 620.70.06) places such images in its 246 MiB BAR heap alone, which every process's devices share, beside a device-local heap of 24 GiB; a color texture there copies on NVIDIA's staging queue where its image has both transfer usages (`texture/staging_copy.rs`), so this reaches its depth and stencil textures and the color textures it does not stage. The texels are Metal's either way. | The heap's size is the device's (resizable BAR is the platform's setting). The other memory with room is system memory, where the GPU would reach the image across the bus for as long as it lives (`device-memory-overflow`) to spare the CPU copies their submissions. | None (cost only, and exact) | | On a driver that does not take a set-0 buffer binding whose entry point uses it through several variables as a **dynamic** descriptor, a draw or dispatch of such a variant that binds it at another offset than its predecessor did allocates and writes a descriptor set of its own, where a dynamic binding would let it bind its predecessor's set again at its own offset. That saving needs the binding's range to stay as its offset moves (`bind::instantiate::descriptor_range`): a slot read to its buffer's end has a range that moves with its offset, so its commands write a set each in either form. Such a binding is a slot reached through its word view and a narrow or `uvec4` unit view (`memory::views`), as `record_stride_not_a_multiple_of_four`'s `recs` is. The stored values are the same either way; what changes is the set a command allocates and writes (`WorkCounts::set_zero_sets_reused` counts none of them). The device answers for itself, by creating one pipeline of exactly that shape and destroying it (`pipeline::objects::takes_multi_variable_dynamic`, `bind::DynamicViewsModule`, asked once and only where a layout has such a binding), so a driver without the defect pays nothing. A binding the device takes still turns dynamic only while the layout's dynamic-buffer budget lasts (`maxDescriptorSetUniformBuffersDynamic`, `maxDescriptorSetStorageBuffersDynamic`), spent in binding order: on a Radeon 780M (RADV, Mesa 26.2.4, eight dynamic storage buffers) a layout's storage bindings past the eighth get none, so commands that bind them at moving offsets keep a set each wherever set 0 is not pushed. A device whose set 0 is pushed (`VK_KHR_push_descriptor` with an eligible layout) never reaches the choice. | Nothing in Vulkan bounds the variables at a binding, dynamic or not, so there is no exact form to switch to: the driver either compiles the shape or does not. MoltenVK's SPIRV-Cross declares one variable's local alone -- read in 1.4.1's source and measured on 1.4.2 (`driverVersion` 10402) on an Apple M3 Max, where `vkCreateComputePipelines` answers `VK_ERROR_INITIALIZATION_FAILED` for a kernel of three and of four variables at one dynamic binding. The check proves the driver compiles the shape, not that it applies the dynamic offset to every variable at it; no device is measured to get that wrong, and RADV (Mesa 26.2.4, Radeon 780M, at offset 0) and lavapipe (Mesa, arm64, at moving offsets) are measured to get it right, `record_stride_not_a_multiple_of_four` answering Metal's `sizeof` and both its narrow stores with its three-variable binding dynamic. | None (cost only, and exact) | ## Accuracy switches whose default is Metal's