From ed75c57d5d829232d27ea88cc57ccf23967a39d8 Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Thu, 3 Dec 2026 08:40:59 -0800 Subject: [PATCH] Runtime docs: a heap texture in an imported block is Gap::HeapTexture with unified memory, an image of its own without What: new_heap_texture's Err list, heap_source's, and Gap::HeapTexture's own doc name imported blocks (Device::import_host_memory, and on Unix the dma-buf imports) beside exported ones, by form. On a device with unified memory a texture in an imported block is Gap::HeapTexture. On one without it, an imported block is Shared, so its texture is an image of its own, as in any Shared heap. Why: heap_source makes a Shared block's texture an image of its own on a device without unified memory before it tests whether the block's memory is its own. An import is a Shared block with memory of its own (memory.rs: Own::Import is MemoryClass::Shared). So since 71b5a07856 an imported heap's texture is made on a discrete card and refused on an integrated one. The docs named only exported blocks for Gap::HeapTexture, which left the import case unsaid in both forms. The consumer makes heaps over the host's memory. Verified: docs only; job m3-max-84317, on the CPU with no device: fmt, workspace rustdoc, the runtime's private rustdoc, scripts/api-docs and refusal_surface.py --check, all EXIT=0. docs/REFUSALS.md and basis.rs regenerate unchanged. runtime-sources.sha256 is unchanged (44066e69...): texture.rs and error.rs are not its inputs. --- crates/metal2vulkan-runtime/src/error.rs | 12 +++++++----- crates/metal2vulkan-runtime/src/texture.rs | 20 +++++++++++++------- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/crates/metal2vulkan-runtime/src/error.rs b/crates/metal2vulkan-runtime/src/error.rs index ddfee1a9c..fc0ed5845 100644 --- a/crates/metal2vulkan-runtime/src/error.rs +++ b/crates/metal2vulkan-runtime/src/error.rs @@ -1518,11 +1518,13 @@ pub enum Gap { /// [`Device::new_heap_texture_for_views`](crate::Device::new_heap_texture_for_views) and /// [`Device::heap_texture_size_and_align`](crate::Device::heap_texture_size_and_align)): in an /// exported block, whose memory is dedicated to its buffer - /// (`VUID-vkBindImageMemory-memory-10926`), or one whose image the device requires an - /// allocation of its own for, or that does not take the memory type of its heap's class - /// (`VkMemoryRequirements::memoryTypeBits`): the block's where it is placed, the Private type - /// at the size query and at a Shared heap's placement on a device without unified memory, - /// whose texture is an image of its own + /// (`VUID-vkBindImageMemory-memory-10926`), or, on a device with unified memory, in an imported + /// one ([`Device::import_host_memory`](crate::Device::import_host_memory), and on Unix the + /// dma-buf imports), a Shared block whose texture on a device without it is an image of its + /// own; or one whose image the device requires an allocation of its own for, or that does not + /// take the memory type of its heap's class (`VkMemoryRequirements::memoryTypeBits`): the + /// block's where it is placed, the Private type at the size query and at a Shared heap's + /// placement on a device without unified memory, whose texture is an image of its own /// ([`Device::has_unified_memory`](crate::Device::has_unified_memory)). /// /// Basis: ours (heap textures are built for Private and Shared heaps of placeable images). diff --git a/crates/metal2vulkan-runtime/src/texture.rs b/crates/metal2vulkan-runtime/src/texture.rs index 2c7f1a947..98e74d330 100644 --- a/crates/metal2vulkan-runtime/src/texture.rs +++ b/crates/metal2vulkan-runtime/src/texture.rs @@ -1658,12 +1658,16 @@ impl Device { /// Err: as [`Device::new_texture`], but for [`Refusal::TextureBufferNotOverBuffer`], a texture /// buffer's errors being [`Buffer::new_texture`]'s; [`Error::NoSuchBlock`] for a block the /// consumer does not hold; [`Gap::HeapTexture`] for an image in an exported block - /// ([`Device::new_exported_block`](crate::Device::new_exported_block)), or an image the device - /// requires an allocation of its own for or that does not take the memory type of the block's - /// class (the Private or the Shared type; for a Shared heap's image of its own, as - /// [`Device::heap_texture_size_and_align`]); [`Refusal::HeapTexturePlace`] for a heap range that - /// leaves its block, or a texture that does not fit in the heap at `offset` or is not aligned - /// there as the device requires ([`Device::heap_texture_size_and_align`]). + /// ([`Device::new_exported_block`](crate::Device::new_exported_block)), or, on a device with + /// unified memory, in an imported one + /// ([`Device::import_host_memory`](crate::Device::import_host_memory), and on Unix + /// `Device::import_dma_buf` and `Device::import_dma_bufs`; on a device without it, a texture in + /// an imported block, a Shared one, is an image of its own as in any Shared heap), or an image + /// the device requires an allocation of its own for or that does not take the memory type of + /// the block's class (the Private or the Shared type; for a Shared heap's image of its own, as + /// [`Device::heap_texture_size_and_align`]); [`Refusal::HeapTexturePlace`] for a heap range + /// that leaves its block, or a texture that does not fit in the heap at `offset` or is not + /// aligned there as the device requires ([`Device::heap_texture_size_and_align`]). pub fn new_heap_texture( &self, descriptor: &TextureDescriptor, @@ -1714,7 +1718,9 @@ impl Device { /// /// Err: [`Error::NoSuchBlock`]; for an image of its own, [`Device::heap_texture_size_and_align`]'s /// errors and [`Refusal::HeapTexturePlace`]; else [`Gap::HeapTexture`] for an exported block, - /// whose memory is dedicated to its buffer (`VUID-vkBindImageMemory-memory-10926`). + /// whose memory is dedicated to its buffer (`VUID-vkBindImageMemory-memory-10926`), or an + /// imported one, a Shared block of memory the consumer brought, which reaches here only on a + /// device with unified memory. fn heap_source( &self, descriptor: &TextureDescriptor,