Import no-copy memory a driver refuses from the caller's dma-bufs

RADV imports host pointers through amdgpu userptr with ANONONLY, so it
refuses MAP_SHARED memfd pages (QEMU's memory-backend-memfd guest RAM and
views of it): every no-copy buffer, heap and rebind over them was refused,
and a macOS guest could not boot on AMD. NVIDIA imports the same pages.

What:
- The five no-copy entry points (new_buffer_with_bytes_no_copy, both
  new_heap_with_bytes_no_copy calls, Buffer and Heap rebind_bytes_no_copy)
  take a HostMemory; HostMemory::with_dma_buf adds a retained DmaBufSource.
- Where the pointer import is refused, and only there, on any device that
  lists VK_KHR_external_memory_fd and VK_EXT_external_memory_dma_buf, the
  runtime asks the source for dma-bufs of the window's pages (chunks cut at
  the device's sparse granule, sized by the caller within udmabuf's default
  limits) and binds one buffer over them: plain for one chunk, sparse for
  several (vkQueueBindSparse signalling queue 0's timeline; later work waits
  on it, no host wait). Every path that imported before is unchanged.
- Textures over such pages get a dedicated DRM_FORMAT_MOD_LINEAR image import
  of their own pages where the driver takes the plane offset and row pitch
  (multiples of 256 on RADV), with 64-bit modifier features; elsewhere, or on
  a source error, the existing shadow path.
- The extensions are enabled outside the compile profile: no device's enable
  set, fingerprint or ARTIFACT_FORMAT_VERSION changes. The translator crate is
  unchanged.
- Imports free inside exit-guard sections; the source is never called with a
  runtime lock held. WorkCounts gains dma_buf_imports, dma_buf_sparse_buffers,
  dma_buf_images and dma_buf_image_fallbacks.

Verified:
- Product suites 4553/4553, validation suite 1289/1289, clippy in every
  configuration, rustdoc -D warnings, scripts/api-docs.
- runtime_lane::dma_buf_imports and rebinds on RADV Mesa 26.2.4 (validation
  layer clean), the RTX 3090 and lavapipe (pointer imported, source never
  called), and dma_buf_imports on RADV Mesa 26.0.8.
- reims-vgpu on the Radeon 780M (RADV 26.0.8, udmabuf at its defaults): a
  macOS 26 guest cold-boots to the desktop and runs Safari; 5,119 dma-buf
  requests, none refused.
- 64 MiB on RADV 26.2.4, release: pointer import 187 us; one chunk 665 us;
  16 chunks 16.9 ms, about half of it the refused pointer attempt. The old
  host-fence bind waited 1.26 s behind queue-0 work on RADV 26.0.8.
This commit is contained in:
Anees Iqbal committed 2026-10-12 11:33:41 +03:00
1 parent e51abf38e1
commit 11715e2a3f
50 files changed
+5078 -458

No files matched your search

+9 -4
View File
@@ -178,10 +178,13 @@ the runtime made.
`IdPlacement`, `Device::reserve_resource_ids`); a pin the space cannot honour is
`Error::PlacementConflict`.
- **Host memory without a copy.** `unsafe Device::new_buffer_with_bytes_no_copy` imports host
memory through `VK_EXT_external_memory_host`; memory the device cannot import exactly is refused.
`unsafe Device::new_heap_with_bytes_no_copy` is its heap twin. `Buffer::rebind_bytes_no_copy`
and `Heap::rebind_bytes_no_copy` move either to another range, keeping the objects, addresses and
IDs. `CommandBuffer::used_resources` lists what a command buffer uses until it completes, so a
memory, given as a `HostMemory`, through `VK_EXT_external_memory_host`; memory the device cannot
import exactly is refused. `unsafe Device::new_heap_with_bytes_no_copy` is its heap twin.
`Buffer::rebind_bytes_no_copy` and `Heap::rebind_bytes_no_copy` move either to another range,
keeping the objects, addresses and IDs. Where a driver refuses the pointer (RADV refuses shared
mappings, a `memfd`'s among them), memory made with `HostMemory::with_dma_buf` is imported from
dma-bufs of its pages instead ([HOWTO](../../docs/HOWTO.md#6-host-memory-a-driver-refuses)).
`CommandBuffer::used_resources` lists what a command buffer uses until it completes, so a
program knows when it may take memory away.
- **Hazards** are tracked as Metal tracks them. A heap's resources are untracked by default, so
encoders that share them order themselves with fences. Commands that reach a resource through an
@@ -212,6 +215,8 @@ Calls Metal does not have, for a consumer that emulates a Metal device:
its sampler's.
- Resource ID reservations, placements and counts (`Device::reserve_resource_ids`,
`IdPlacement`, `Device::sampler_ids_live`), and the private getters of indirect commands.
- `HostMemory::with_dma_buf` and its `DmaBufSource`: dma-bufs of a no-copy object's pages, for a
device that refuses their pointer.
[docs/API.md section 10](../../docs/API.md#10-accepted-differences) lists where the runtime
answers otherwise than Metal on purpose.
+42 -1
View File
@@ -266,6 +266,8 @@ pub(super) struct Detached {
/// The index of the memory type of the pages it was detached from: a texture made over the
/// bytes meanwhile takes the route it would over them (`texture/heap.rs`).
type_index: u32,
/// Whether the pages it was detached from were imported as dma-bufs, for the same.
over_dma_buf: bool,
}
impl Detached {
@@ -301,6 +303,7 @@ impl Detached {
_stand_in: stand_in,
pages,
type_index: from.type_index(),
over_dma_buf: from.over_dma_buf(),
})
}
}
@@ -506,6 +509,23 @@ impl HostPages {
self.import.pages.memory.placement.type_index()
}
/// Whether they were imported as dma-bufs (`dma_buf.rs`), not by their pointer.
pub(super) fn over_dma_buf(&self) -> bool {
self.import.pages.memory.placement.over_dma_buf()
}
/// Where they lie as dma-bufs (`dma_buf.rs`): the imports, with the caller's source; the host
/// address where their bytes start (from which an image over them reckons its texels'); and
/// the imports' memory type. `None` for pages imported by their pointer.
#[cfg(unix)]
pub(super) fn dma_buf(&self) -> Option<(&Arc<crate::dma_buf::DmaBufPages>, u64, u32)> {
let pages = &self.import.pages;
let placement = &pages.memory.placement;
let imports = placement.dma_buf_pages()?;
let start = (placement.mapped?.as_ptr() as u64).checked_add(pages.offset)?;
Some((imports, start, placement.type_index()))
}
/// Release the pages to `release` when they go.
pub(super) fn release_to(&self, release: Release) {
// A refused set leaves the deallocator unrun, as a refused call does: never reached,
@@ -600,10 +620,13 @@ impl Drop for HostImport {
return;
};
let shared = self.device.shared();
// A submission that used the pages waited for their sparse binding: waited for here
// where none did.
self.pages.memory.placement.settle();
// SAFETY: no pending command buffer uses the pages: one whose commands used them holds
// them until it completed (`rebind.rs`), one that may read a texture's image over them
// holds the image, which holds the import (`heap_sets.rs`), and every buffer over them
// let go of them.
// let go of them; their binding completed.
unsafe { release::object(shared.vk(), self.pages.raw) };
lock(&shared.memory).free(shared.vk(), &self.pages.memory.placement);
drop(busy);
@@ -1956,6 +1979,13 @@ impl Buffer {
}
}
/// The host pages the buffer's bytes lie in now ([`Buffer::pages_cell`]): a no-copy
/// buffer's, or a no-copy heap's for a buffer of the heap; `None` for any other buffer, and
/// while they are detached.
pub(super) fn host_pages(&self) -> Option<Arc<HostPages>> {
self.pages_cell()?.current()
}
/// Where the bytes of the host pages the buffer lies in ([`Buffer::pages_cell`]) start in
/// their memory, which an aliasing image's place in them is reckoned from. Refused (an
/// internal error) for a buffer over no host pages.
@@ -2021,6 +2051,17 @@ impl Buffer {
}
}
/// Whether the host pages the buffer's bytes lie in (a no-copy buffer's, or for a heap's
/// buffer its heap's), or lay in while they are detached, were imported as dma-bufs
/// (`dma_buf.rs`); false for a buffer over no host pages.
pub(super) fn over_dma_buf(&self) -> bool {
match self.pages_cell().map(|cell| cell.lying()) {
Some(Lying::In(pages)) => pages.over_dma_buf(),
Some(Lying::Detached(detached)) => detached.over_dma_buf,
None => false,
}
}
/// `device`.
pub fn device(&self) -> &Device {
&self.0.device
@@ -17,12 +17,13 @@ use super::error::{internal, invalid, nil, vulkan, Error, Problem, RuntimeGap};
use super::heap::{Heap, HeapProblem};
use super::host_memory::{
based_size, binds_in, buffer_base, import_refused, import_window, not_importable,
refuse_unwritable, Deallocator, HostMemory, HostRelease, ImportWindow, Importer, KeepAlive,
WindowRefusal,
refuse_unwritable, refused, Deallocator, HostMemory, HostRelease, ImportWindow, Importer,
KeepAlive, Source,
};
use super::memory::{ImportFailure, MemoryClass, Placement};
use super::rebind::RebindProblem;
use super::texture::stand_in::TextureImages;
use super::texture::Remade;
use super::values::{ResourceOptions, StorageMode};
use super::Device;
use crate::release;
@@ -217,7 +218,8 @@ impl Device {
}
self.buffer_with_bytes(CALL, bytes, resource_options, place)
}
// SAFETY: `HostMemory::new`'s caller vouched for `length` bytes at the pointer.
// SAFETY: the `HostMemory` constructor's caller vouched for `length` bytes at the
// pointer.
BufferContents::NoCopy {
memory,
deallocator,
@@ -258,33 +260,38 @@ impl Device {
Ok(self.visible(buffer))
}
/// `newBufferWithBytesNoCopy:length:options:deallocator:`: a buffer whose bytes are the
/// caller's `length` bytes at `bytes` (module docs of `host_memory.rs`). `deallocator`
/// runs once, with `bytes` and `length`, when the buffer's last reference goes: on a runtime
/// thread when that is a command buffer completing. A refused call never runs it.
/// `newBufferWithBytesNoCopy:length:options:deallocator:`, its pointer wrapped in `memory`
/// ([`HostMemory`]): a buffer whose bytes are the caller's `length` bytes at
/// `memory.pointer()` (module docs of `host_memory.rs`). `deallocator` runs once, with the
/// pointer and `length`, when the buffer's last reference goes: on a runtime thread when that
/// is a command buffer completing. A refused call never runs it.
///
/// The pages are imported here, as Metal wires them when it makes the buffer: the GPU uses
/// the pages mapped at `bytes` now, and memory the device cannot import is refused here, as
/// Metal answers nil. The import costs work per page here (on macOS about 11 to 20 ms per GiB
/// measured on an M4 and an M3 Max), where Metal makes the buffer at once and pays at the
/// first command using it (24 to 88 ms per GiB).
/// the pages mapped at the pointer now, and memory the device cannot import is refused here,
/// as Metal answers nil. The import costs work per page here (on macOS about 11 to 20 ms per
/// GiB measured on an M4 and an M3 Max), where Metal makes the buffer at once and pays at the
/// first command using it (24 to 88 ms per GiB). Where the device refuses the pointer and
/// `memory` carries a dma-buf source ([`HostMemory::with_dma_buf`]), the dma-bufs it makes of
/// the pages are imported instead.
///
/// Refused: a length of 0 or past `max_buffer_length` (`Nil`, as plain Metal answers nil, EV
/// TTG-nil10-m4); `Private` or `Memoryless` storage, as Metal stops them, and an undefined
/// option (`Invalid`); a device
/// without `VK_EXT_external_memory_host` (`Unsupported`, naming it); memory this device
/// cannot import exactly (`Unsupported`, `HostMemory`), among it on Linux a page this process
/// cannot write ([`HostMemory::new`]); pages past the device's allocation size
/// (`OutOfMemory`). Pages not mapped, or mapped without access, which Metal makes no buffer
/// over (nil), are refused here too, typed as the check or the import answers, though such
/// memory breaks [`HostMemory::new`]'s contract.
/// cannot import exactly, by its pointer or by its dma-bufs (`Unsupported`, `HostMemory`),
/// among it on Linux a page this process cannot write ([`HostMemory::new`]); dma-bufs that
/// break the source's contract (`Invalid`, `Problem::DmaBuf`); pages past the
/// device's allocation size (`OutOfMemory`). Pages not mapped, or mapped without access, which
/// Metal makes no buffer over (nil), are refused here too, typed as the check or the import
/// answers, though such memory breaks [`HostMemory::new`]'s contract.
///
/// # Safety
///
/// The `length` bytes at `bytes` meet [`HostMemory::new`]'s contract.
/// `memory` meets the contract of the [`HostMemory`] constructor that made it
/// ([`HostMemory::new`], [`HostMemory::with_dma_buf`]) for `length` bytes.
pub unsafe fn new_buffer_with_bytes_no_copy(
&self,
bytes: NonNull<u8>,
memory: HostMemory,
length: u64,
options: ResourceOptions,
deallocator: Option<Deallocator>,
@@ -295,7 +302,7 @@ impl Device {
let buffer = unsafe {
self.buffer_over_host_memory(
CALL,
HostMemory::new(bytes),
memory,
length,
options,
HostRelease {
@@ -425,18 +432,9 @@ impl Device {
.host_import
.as_ref()
.map_err(|unsupported| Error::Unsupported(unsupported.clone()))?;
let pointer = memory.pointer();
let window = import_window(
pointer.as_ptr() as u64,
length,
importer.page,
importer.alignment,
)
.map_err(|refusal| match refusal {
// Memory past the address space's end is not mapped: Metal makes no buffer over it.
WindowRefusal::Overflow => nil(call, Problem::BufferLength { length }),
WindowRefusal::BeyondPages | WindowRefusal::Binding => not_importable(),
})?;
let (pointer, source) = memory.into_parts();
let host = host_window(call, importer, pointer, length, source)?;
let window = host.window;
if of_heap && window.offset != 0 {
let alignment = importer.page.max(importer.alignment);
let problem = HeapProblem::HostMemoryAlignment { alignment };
@@ -444,7 +442,8 @@ impl Device {
}
refuse_unwritable(&window)?;
// A buffer over the bytes a live no-copy buffer was made over, of its memory class, lies
// in its import (`host_aliases.rs`); a heap's own buffer imports its own.
// in its import (`host_aliases.rs`), its dma-buf source dropped uncalled; a heap's own
// buffer imports its own.
let made_over = (pointer.as_ptr() as u64, length);
let release = release.of(pointer, length);
let shares = (!of_heap)
@@ -460,19 +459,21 @@ impl Device {
shared.aliases.place(buffer.identity().key, made_over);
return Ok(buffer);
}
let buffer = self.host_buffer(&window, length)?;
// The window starts `window.offset` bytes before the pointer, in the pages it touches.
let start = pointer.as_ptr().wrapping_sub(window.offset as usize);
// SAFETY: the window lies in the pages of the caller's bytes, which stay mapped
// (`HostMemory::new`), and the buffer is a new one of this device.
let placed = unsafe {
self.import_pages(importer, &buffer, start, &window, class, placement, length)
};
let (memory, (address, reserved)) = match placed {
Ok(placed) => placed,
// (`HostMemory::new`), and the source's pieces hold them (`HostMemory::with_dma_buf`). No
// lock of the runtime's is held.
let (buffer, memory) =
match unsafe { self.import_by_pointer(importer, pointer, length, host, class) }? {
Ok(made) => made,
// SAFETY: as above.
Err(source) => unsafe {
self.import_from_source(call, importer, pointer, length, &window, source, class)
}?,
};
let (address, reserved) = match self.place_window(placement, &window, length) {
Ok(held) => held,
Err(error) => {
// SAFETY: the buffer is unused.
unsafe { release::object(shared.vk(), buffer.raw) };
self.discard_import(buffer, memory);
return Err(error);
}
};
@@ -548,18 +549,9 @@ impl Device {
.host_import
.as_ref()
.map_err(|unsupported| Error::Unsupported(unsupported.clone()))?;
let pointer = memory.pointer();
let window = import_window(
pointer.as_ptr() as u64,
length,
importer.page,
importer.alignment,
)
.map_err(|refusal| match refusal {
// Memory past the address space's end is not mapped: Metal makes no buffer over it.
WindowRefusal::Overflow => nil(call, Problem::BufferLength { length }),
WindowRefusal::BeyondPages | WindowRefusal::Binding => not_importable(),
})?;
let (pointer, source) = memory.into_parts();
let host = host_window(call, importer, pointer, length, source)?;
let window = host.window;
if heap.is_some() && window.offset != 0 {
let alignment = importer.page.max(importer.alignment);
let problem = HeapProblem::HostMemoryAlignment { alignment };
@@ -577,25 +569,48 @@ impl Device {
refuse_unwritable(&window)?;
// Detached bytes are given pages with no texture being made over them, and none is
// made until the textures that presented stand-ins present their own images again.
let settled = match cell.detached() {
true => Some(
cell.settled()
.ok_or(Error::NotImplemented(RuntimeGap::DetachTextures))?,
),
let detached_textures = || Error::NotImplemented(RuntimeGap::DetachTextures);
let mut settled = match cell.detached() {
true => Some(cell.settled().ok_or_else(detached_textures)?),
false => None,
};
let host = self.host_buffer(&window, length)?;
// The window starts `window.offset` bytes before the pointer, in the pages it touches.
let start = pointer.as_ptr().wrapping_sub(window.offset as usize);
// SAFETY: the window lies in the pages of the caller's bytes, which stay mapped
// (`HostMemory::new`), and the buffer is a new one of this device.
let placed = unsafe { self.import_backing(importer, &host, start, &window, class) };
let placement = match placed {
Ok(placement) => placement,
Err(error) => {
// SAFETY: the buffer is unused.
unsafe { release::object(shared.vk(), host.raw) };
return Err(error);
// (`HostMemory::new`, `HostMemory::with_dma_buf`).
let (host, placement, remade) = match unsafe {
self.import_by_pointer(importer, pointer, length, host, class)
}? {
Ok((host, placement)) => (host, placement, Remade::default()),
// The source is called with no lock of the runtime's held (`dma_buf.rs`): the
// textures over detached bytes are let go of meanwhile, and must be settled again
// after it.
Err(source) => {
let was_settled = settled.take().is_some();
// SAFETY: as above, and the source's pieces hold the pages
// (`HostMemory::with_dma_buf`).
let (host, placement) = unsafe {
self.import_from_source(call, importer, pointer, length, &window, source, class)
}?;
// The aliasing images of the textures over the bytes, made over dma-bufs of their
// own pages, each of which the source makes: still with no lock held.
let again = self.dma_buf_images_again(&aliases, heap, &placement, pointer);
let remade = match again {
Ok(remade) => remade,
Err(error) => {
self.discard_import(host, placement);
return Err(error);
}
};
if was_settled {
match cell.settled() {
Some(again) => settled = Some(again),
None => {
drop(remade);
self.discard_import(host, placement);
return Err(detached_textures());
}
}
}
(host, placement, remade)
}
};
let pages = self.host_pages(
@@ -607,13 +622,14 @@ impl Device {
);
// The heap's images bound to its bytes, made again over the new pages. A refusal drops
// them and the new pages unreleased: the deallocator goes unrun.
let mut remade = remade;
let mut swaps = match heap {
Some(heap) => self.rebound_heap_images(heap, &pages)?,
Some(heap) => self.rebound_heap_images(heap, &pages, &mut remade)?,
None => Vec::new(),
};
// The aliasing images of the textures over the bytes, made again over the new pages.
if !aliases.is_empty() {
swaps.extend(self.rebound_alias_images(&aliases, &pages)?);
swaps.extend(self.rebound_alias_images(&aliases, &pages, remade)?);
}
let (old, again) = shared
.rebinds
@@ -747,39 +763,103 @@ impl Device {
Ok(buffer)
}
/// Import the window's pages at `start`, bind `buffer` in them, `buffer.base` bytes below
/// the window's offset, and hold bytes of the address space for the buffer's `length` bytes
/// at `address`: the placement, and the buffer's address and held bytes. A range the runtime
/// picks keeps the pointer's offset in its page, as Metal's address does. Everything is
/// released again on failure but the buffer.
/// The pointer's import of `host`'s window ([`Device::import_pointer`]), where the device's
/// import alignment covers it, exactly as ever; and where the device refuses it ([`refused`]:
/// no window, a buffer that does not fit it, no memory type, a driver refusal) and the caller
/// gave a dma-buf source the device can use, the source, uncalled (`Err`), for the caller to
/// call with no lock of the runtime's held (`Device::import_from_source`, `dma_buf.rs`). A
/// refusal without such a source is the pointer's.
///
/// # Safety
///
/// The window's `size` bytes at `start` are host memory of this process that stays mapped
/// until the buffer is dropped; `buffer` is an unbound buffer of this device made for host
/// allocations.
unsafe fn import_pages(
/// The window's pages are host memory of this process that stays mapped until the
/// placement is freed (`HostMemory::new`).
unsafe fn import_by_pointer(
&self,
importer: &Importer,
buffer: &HostBuffer,
start: *mut u8,
pointer: NonNull<u8>,
length: u64,
host: HostWindow,
class: MemoryClass,
) -> Result<Result<(HostBuffer, Placement), Source>, Error> {
let HostWindow {
window,
by_pointer,
source,
} = host;
let refusal = match by_pointer {
// SAFETY: the caller's.
true => match unsafe { self.import_pointer(importer, pointer, length, &window, class) }
{
Ok(imported) => return Ok(Ok(imported)),
Err(error) if refused(&error) => error,
Err(error) => return Err(error),
},
false => not_importable(),
};
source.map(Err).ok_or(refusal)
}
/// The `VkBuffer` of a no-copy buffer of `length` bytes at `pointer`, made for host
/// allocations and bound in the import of the window's pages at their pointer
/// (`VK_EXT_external_memory_host`), `buffer.base` bytes below the window's offset, as memory
/// of `class`: the buffer and the placement. Released again on failure.
///
/// # Safety
///
/// The window's `size` bytes are host memory of this process that stays mapped until the
/// placement is freed.
unsafe fn import_pointer(
&self,
importer: &Importer,
pointer: NonNull<u8>,
length: u64,
window: &ImportWindow,
class: MemoryClass,
address: Place,
length: u64,
) -> Result<(Placement, (GpuAddress, Held)), Error> {
let shared = self.shared();
// SAFETY: the caller's.
let placement = unsafe { self.import_backing(importer, buffer, start, window, class) }?;
match self.place_window(address, window, length) {
Ok(held) => Ok((placement, held)),
) -> Result<(HostBuffer, Placement), Error> {
let buffer = self.host_buffer(window, length)?;
// The window starts `window.offset` bytes before the pointer, in the pages it touches.
let start = pointer.as_ptr().wrapping_sub(window.offset as usize);
// SAFETY: the caller's, and the buffer is a new one of this device.
match unsafe { self.import_backing(importer, &buffer, start, window, class) } {
Ok(placement) => Ok((buffer, placement)),
Err(error) => {
lock(&shared.memory).free(shared.vk(), &placement);
// SAFETY: the buffer is unused.
unsafe { release::object(self.shared().vk(), buffer.raw) };
Err(error)
}
}
}
/// No dma-buf is imported on this system: there is no source to call.
///
/// # Safety
///
/// None: it does nothing.
#[cfg(not(unix))]
unsafe fn import_from_source(
&self,
_call: &'static str,
_importer: &Importer,
_pointer: NonNull<u8>,
_length: u64,
_window: &ImportWindow,
source: Source,
_class: MemoryClass,
) -> Result<(HostBuffer, Placement), Error> {
match source {}
}
/// Release `buffer` and its `placement`, an import made for a buffer or rebind that is not
/// made after all: the `VkBuffer` first, once its sparse binding completed.
fn discard_import(&self, buffer: HostBuffer, placement: Placement) {
let shared = self.shared();
placement.settle();
// SAFETY: the buffer is unused, and its binding completed.
unsafe { release::object(shared.vk(), buffer.raw) };
lock(&shared.memory).free(shared.vk(), &placement);
}
/// The Metal addresses of a no-copy buffer of `length` bytes `window.offset` bytes into
/// `window`, placed as `address` asks: the window's pages where the program names no address,
/// so that the buffer's address keeps its pointer's offset in its page.
@@ -836,7 +916,9 @@ impl Device {
///
/// # Safety
///
/// As [`Device::import_pages`]'s.
/// The window's `size` bytes at `start` are host memory of this process that stays mapped
/// until the placement is freed; `buffer` is an unbound buffer of this device made for host
/// allocations.
unsafe fn import_backing(
&self,
importer: &Importer,
@@ -911,11 +993,51 @@ impl Device {
}
}
/// The host pages a no-copy buffer (or a heap's own buffer) of some length imports
/// ([`host_window`]).
struct HostWindow {
/// The pages: the range rounded out to the host page.
window: ImportWindow,
/// Whether the device's import alignment covers them, so that their pointer is imported
/// first (`VK_EXT_external_memory_host`).
by_pointer: bool,
/// The caller's dma-buf source, where it gave one and the device imports dma-bufs.
source: Option<Source>,
}
/// The host pages a no-copy object of `length` bytes at `pointer` imports on the device of
/// `importer`, for `call`: the pages the range touches ([`import_window`]), imported by their
/// pointer where the device's import alignment covers them, else only as a dma-buf where the
/// caller gave a source the device can use. A source the device cannot use is dropped uncalled.
/// Refused: memory past the address space's end (`Nil`, as Metal makes no buffer over it); a
/// range the import alignment cannot cover, with no usable source (`Unsupported`, `HostMemory`).
fn host_window(
call: &'static str,
importer: &Importer,
pointer: NonNull<u8>,
length: u64,
source: Option<Source>,
) -> Result<HostWindow, Error> {
let source = source.filter(|_| importer.imports_dma_bufs());
let at = pointer.as_ptr() as u64;
let window = import_window(at, length, importer.page, 1)
.map_err(|_| nil(call, Problem::BufferLength { length }))?;
let by_pointer = import_window(at, length, importer.page, importer.alignment).is_ok();
if !by_pointer && source.is_none() {
return Err(not_importable());
}
Ok(HostWindow {
window,
by_pointer,
source,
})
}
/// A no-copy buffer's unbound `VkBuffer` (`Device::host_buffer`): `size` bytes, its bytes from
/// `base`, with its memory requirements.
struct HostBuffer {
raw: vk::Buffer,
base: u64,
size: u64,
requirements: vk::MemoryRequirements,
pub(super) struct HostBuffer {
pub(super) raw: vk::Buffer,
pub(super) base: u64,
pub(super) size: u64,
pub(super) requirements: vk::MemoryRequirements,
}
@@ -930,19 +930,22 @@ impl Texels {
}
/// The attachment twin of `pixel_format` kept with the texels (a texture buffer's, or a
/// rotated texture's), made by `make` at the first pass that needs it.
/// rotated texture's), made by `make` at the first pass that needs it, with the twins'
/// lock not held: a twin over dma-buf pages calls the program's source (`dma_buf.rs`). Where
/// another pass made one meanwhile, that one is kept and `make`'s goes, with no lock held.
pub(super) fn twin(
&self,
pixel_format: PixelFormat,
make: impl FnOnce() -> Result<Texture, Error>,
) -> Result<Texture, Error> {
let mut twins = lock(&self.twins);
if let Some(twin) = twins.get(&pixel_format) {
if let Some(twin) = lock(&self.twins).get(&pixel_format) {
return Ok(twin.clone());
}
let twin = make()?;
twins.insert(pixel_format, twin.clone());
Ok(twin)
let made = make()?;
let kept = (lock(&self.twins).entry(pixel_format))
.or_insert_with(|| made.clone())
.clone();
Ok(kept)
}
/// The copies of a rotated texture's image of its pass's frame (`image` of `identity`, of
@@ -402,6 +402,13 @@ impl CommandBufferShared {
wait_values.push(value);
wait_stages.push(vk::PipelineStageFlags::ALL_COMMANDS);
}
// And the last binding of a no-copy buffer's dma-bufs, on every `VkQueue`, the first
// too (a binding is ordered with no later submission), until it completed.
if let Some((timeline, value)) = device.binding_wait() {
wait_semaphores.push(timeline);
wait_values.push(value);
wait_stages.push(vk::PipelineStageFlags::ALL_COMMANDS);
}
// The first work waits for what the batch's commands wait for (a heap's fill another
// queue did comes before a move of an image placed in it; an event the program waits
// for before reusing a heap's memory), but a binary semaphore, which one wait consumes;
@@ -39,6 +39,27 @@ pub(crate) unsafe fn image(
unsafe { device.create_image(info, None) }.map_err(vulkan)
}
/// A `VkImage` of `info`, made by `device`, or the driver's refusal of it: an image whose making
/// the driver may refuse for its parameters alone (one of a DRM format modifier's explicit
/// layout, `dma_buf.rs`), whose caller takes another way then. A lost device is
/// `Error::DeviceLost`; refused in a host step.
///
/// # Safety
///
/// As `vkCreateImage`'s: `device` is live, and `info` and its chain are valid for it.
pub(crate) unsafe fn image_or_refusal(
device: &ash::Device,
info: &vk::ImageCreateInfo<'_>,
) -> Result<Result<vk::Image, vk::Result>, Error> {
outside_host_step(HostStepObject::Image)?;
// SAFETY: the caller's.
match unsafe { device.create_image(info, None) } {
Ok(raw) => Ok(Ok(raw)),
Err(vk::Result::ERROR_DEVICE_LOST) => Err(Error::DeviceLost),
Err(refusal) => Ok(Err(refusal)),
}
}
/// A `VkRenderPass` of `info`, made by `device`; refused in a host step.
///
/// # Safety
@@ -222,9 +222,10 @@ degradations! {
/// A 2D texture over a buffer is a shadow image: no linear image of the device lays its
/// texels out as Metal does in the buffer's memory (over a no-copy buffer's imported
/// host memory, no linear image made for host allocations does), or the buffer is over
/// the caller's `VkBuffer`, whose memory backs no image of the runtime's. Also a heap's
/// depth or stencil texture on a device whose driver lays
/// such images apart from their memory
/// the caller's `VkBuffer`, whose memory backs no image of the runtime's, or over host
/// pages imported as dma-bufs (`HostMemory::with_dma_buf`) where the device makes no image
/// over a dma-buf of the texture's own pages (the notice names why). Also a heap's depth
/// or stencil texture on a device whose driver lays such images apart from their memory
/// ([`metal2vulkan::device::DriverFact::DepthStencilImagesLieApart`]): its image is a
/// shadow of the heap's bytes in its range. Also a heap's 2D texture of one level of
/// `RGB10A8_2P_XR10` or its sRGB twin: its image is a shadow of its two planes in the
@@ -50,7 +50,10 @@ pub struct RawDevice {
/// buffer a Metal texture over the buffer's imported memory, without a copy;
/// `VK_NV_linear_color_attachment`, with its `linearColorAttachment` feature enabled beside
/// it (and, below Vulkan 1.3, `VK_KHR_format_feature_flags2`, which it requires there), makes
/// a texture over a buffer's memory render into its linear image in place.
/// a texture over a buffer's memory render into its linear image in place;
/// `VK_KHR_external_memory_fd` with `VK_EXT_external_memory_dma_buf` serve
/// `HostMemory::with_dma_buf`, and with them `VK_EXT_image_drm_format_modifier` with
/// `VK_EXT_queue_family_foreign` make textures over its pages images rather than shadows.
pub device_extensions: Vec<CString>,
/// Where the device keeps translated shaders: by default, the platform's per-user cache
/// directory.
@@ -219,6 +222,9 @@ impl Device {
// `VK_KHR_pipeline_library` with its feature, and the device's properties say whether it
// links fast, as a made device takes it.
let listed: BTreeSet<CString> = raw.device_extensions.iter().cloned().collect();
// Nor whether the dma-buf route's were (`dma_buf.rs`): the consumer lists them.
let dma_buf = super::create::dma_buf_names(&listed).is_some();
let dma_buf_images = super::create::dma_buf_image_names(&listed).is_some();
let graphics_pipeline_library = super::create::graphics_pipeline_library(&listed, || {
// SAFETY: the consumer's physical device of its instance, which lists the
// extension (the consumer enabled it), at Vulkan 1.2 or later.
@@ -254,6 +260,8 @@ impl Device {
.device_extensions
.iter()
.any(|name| name.as_c_str() == ash::ext::pipeline_creation_feedback::NAME),
dma_buf,
dma_buf_images,
calibration: gpu_time::Extension::among(&raw.device_extensions.into_iter().collect()),
gpu_times_from_host: raw.gpu_times_from_host,
// An adopted device keeps no execution record: validation makes its own devices.
@@ -742,6 +742,34 @@ pub(crate) fn enable_set(description: &DeviceDescription, options: &DeviceOption
set
}
/// The extensions of the dma-buf route (`dma_buf.rs`) of a device listing `listed`:
/// `VK_KHR_external_memory_fd` and the `VK_EXT_external_memory_dma_buf` that requires it, where the
/// device lists both. The runtime's own need, outside the vocabulary, so outside the enable set,
/// the compile profile and its fingerprint (the shader cache's key).
pub(crate) fn dma_buf_names(listed: &BTreeSet<CString>) -> Option<[&'static CStr; 2]> {
let names = [
ash::khr::external_memory_fd::NAME,
ash::ext::external_memory_dma_buf::NAME,
];
names
.iter()
.all(|name| listed.contains(*name))
.then_some(names)
}
/// The extensions of the images of textures over the dma-buf route's pages (`dma_buf.rs`) of a
/// device listing `listed`: `VK_EXT_image_drm_format_modifier` and `VK_EXT_queue_family_foreign`,
/// where the device lists both and the route's two ([`dma_buf_names`]). Outside the vocabulary as
/// the route's are; what they require is core at the runtime's Vulkan 1.2 floor.
pub(crate) fn dma_buf_image_names(listed: &BTreeSet<CString>) -> Option<[&'static CStr; 2]> {
let names = [
ash::ext::image_drm_format_modifier::NAME,
ash::ext::queue_family_foreign::NAME,
];
(dma_buf_names(listed).is_some() && names.iter().all(|name| listed.contains(*name)))
.then_some(names)
}
/// Whether a device of `description` the runtime creates under `options` enables
/// `VK_EXT_device_generated_commands`: where the description states it (the extension and its
/// `deviceGeneratedCommands`), `options` do not withhold it, and `set` enables
@@ -1076,6 +1104,9 @@ fn create_on(
.device_extensions
.iter()
.any(|name| name.as_c_str() == feedback_name);
// The runtime's own needs, outside the vocabulary, where listed (`dma_buf.rs`).
let dma_buf = dma_buf_names(&listed);
let dma_buf_images = dma_buf_image_names(&listed);
let extra: Vec<CString> = options
.device_extensions
.iter()
@@ -1083,6 +1114,8 @@ fn create_on(
.chain(calibration.map(|extension| extension.name().to_owned()))
.chain((metal_objects && !metal_asked).then(|| metal_name.to_owned()))
.chain((creation_feedback && !feedback_asked).then(|| feedback_name.to_owned()))
.chain(dma_buf.into_iter().flatten().map(CStr::to_owned))
.chain(dma_buf_images.into_iter().flatten().map(CStr::to_owned))
.collect();
let mut enables = Enables::of(&set, api, &listed, &extra)?;
// The features of the caller's extensions whose structures the runtime knows, as the device
@@ -1222,6 +1255,8 @@ fn create_on(
graphics_pipeline_library,
metal_objects: metal_objects || metal_asked,
creation_feedback: creation_feedback || feedback_asked,
dma_buf: dma_buf.is_some(),
dma_buf_images: dma_buf_images.is_some(),
sparse_features,
owned: true,
cache: cache.clone(),
@@ -222,6 +222,10 @@ pub(super) struct DeviceShared {
/// a dispatch of the state that made it (`function_table.rs`).
pub(super) function_tables: Mutex<BTreeMap<u64, Weak<TableShared>>>,
internal: Mutex<Option<Internal>>,
/// The last sparse binding of a no-copy buffer's dma-bufs (`dma_buf.rs`) the host has not
/// seen complete: the internal timeline and the value it signals, which every later
/// submission that may use the buffer waits for (`submit.rs`).
bound_at: Mutex<Option<(vk::Semaphore, u64)>>,
/// The queue reserved for staging copies, where the device has one (`staging.rs`).
staging: Option<staging::StagingQueue>,
pub(super) scheduler: Scheduler,
@@ -767,6 +771,11 @@ pub(super) struct Parts {
/// vocabulary, wherever listed: each making of a program's pipeline reads whether its cache
/// held the pipeline (`shader_cache/mod.rs`).
pub(super) creation_feedback: bool,
/// It enables the dma-buf route's extensions (`create.rs`'s `dma_buf_names`), outside
/// `enabled`'s vocabulary (`dma_buf.rs`).
pub(super) dma_buf: bool,
/// It enables the route's image extensions (`create.rs`'s `dma_buf_image_names`), likewise.
pub(super) dma_buf_images: bool,
/// The sparse members of the core features it enables, outside `enabled`'s vocabulary
/// (`sparse/device.rs`).
pub(super) sparse_features: vk::PhysicalDeviceFeatures,
@@ -810,6 +819,8 @@ impl Device {
graphics_pipeline_library,
metal_objects,
creation_feedback,
dma_buf,
dma_buf_images,
sparse_features,
owned,
cache,
@@ -1012,6 +1023,8 @@ impl Device {
&loader_word,
metal_objects,
instance.sink().is_some(),
dma_buf,
dma_buf_images,
)
};
// SAFETY: as above; the loader serves `vkGetDeviceProcAddr` once the word is put back.
@@ -1202,6 +1215,7 @@ impl Device {
heap_nan_residue: NanResidue::default(),
function_tables: Mutex::default(),
internal: Mutex::new(None),
bound_at: Mutex::new(None),
staging,
scheduler,
completion,
@@ -6,10 +6,16 @@
//! work that waits (`texture/first_move.rs`), after the batches on other `VkQueue`s that did such
//! work: no new resource waits for one, so making one waits for no GPU work. That work goes in a
//! submission of its own just before the work's.
//!
//! The one submission no one waits for is a no-copy buffer's sparse binding of its dma-bufs
//! (`dma_buf.rs`), on the same queue and timeline: it would wait behind the queue's work in
//! flight. Every submission after it, on every `VkQueue`, waits for it until the host saw it
//! complete, and the buffer's release waits for it.
use super::relay::By;
use super::{lock, Device};
use crate::error::{vulkan, Error};
use crate::exit_guard::{self, Call};
use crate::release;
use crate::resource::ResourceKey;
use ash::vk;
@@ -170,10 +176,13 @@ impl Device {
// SAFETY: the fence is unsignaled or signaled and not pending.
unsafe { raw.reset_fences(&[objects.fence]) }.map_err(vulkan)?;
let buffers = [objects.buffer];
let wait_semaphores: Vec<vk::Semaphore> = (waits.iter())
.map(|point| shared.queues[point.queue].timeline)
// And the last binding of a no-copy buffer's dma-bufs, until it completed.
let waits: Vec<(vk::Semaphore, u64)> = (waits.iter())
.map(|point| (shared.queues[point.queue].timeline, point.value))
.chain(self.binding_wait())
.collect();
let wait_values: Vec<u64> = waits.iter().map(|point| point.value).collect();
let wait_semaphores: Vec<vk::Semaphore> = waits.iter().map(|wait| wait.0).collect();
let wait_values: Vec<u64> = waits.iter().map(|wait| wait.1).collect();
let wait_stages = vec![vk::PipelineStageFlags::ALL_COMMANDS; waits.len()];
// It signals its own timeline, which a batch on another `VkQueue` waits for where it did
// first work.
@@ -261,6 +270,70 @@ impl Device {
}
}
/// Bind `binds` to `buffer`, a sparse buffer no command has used, with one
/// `vkQueueBindSparse` on the device's first `VkQueue` that signals the internal timeline,
/// and return without waiting for it: every submission made after it, on every `VkQueue`,
/// waits for it until the host saw it complete ([`Device::binding_wait`]). The timeline and
/// the value it signals, which the buffer's release waits for.
pub(crate) fn bind_sparse_buffer(
&self,
buffer: vk::Buffer,
binds: &[vk::SparseMemoryBind],
) -> Result<(vk::Semaphore, u64), Error> {
if self.is_lost() {
return Err(Error::DeviceLost);
}
let shared = self.shared();
let raw = shared.vk();
let mut internal = lock(&shared.internal);
if internal.is_none() {
*internal = Some(Internal::new(self)?);
}
let Some(objects) = internal.as_mut() else {
unreachable!("made above");
};
let buffer_binds = [vk::SparseBufferMemoryBindInfo::default()
.buffer(buffer)
.binds(binds)];
let value = objects.signalled + 1;
let signal_semaphores = [objects.timeline];
let signal_values = [value];
let mut timeline =
vk::TimelineSemaphoreSubmitInfo::default().signal_semaphore_values(&signal_values);
let info = vk::BindSparseInfo::default()
.buffer_binds(&buffer_binds)
.signal_semaphores(&signal_semaphores)
.push_next(&mut timeline);
// SAFETY: the buffer is live, made with `SPARSE_BINDING`, unused; every bind lies in it
// and in its memory at its alignment, of a type it takes (`dma_buf.rs`); the queue's
// family binds sparse memory, and the queue is used under its lock; the signal is above
// the timeline's value (the internal lock is held).
let bound = shared.use_queue(0, By::Runtime, |queue| unsafe {
raw.queue_bind_sparse(queue, &[info], vk::Fence::null())
});
exit_guard::called(Call::QueueBindSparse);
bound.map_err(|error| self.failed(error))?;
objects.signalled = value;
*lock(&shared.bound_at) = Some((objects.timeline, value));
Ok((objects.timeline, value))
}
/// The last binding of a no-copy buffer's dma-bufs ([`Device::bind_sparse_buffer`]) while
/// the host has not seen it complete: what a submission waits for, as the buffer may be
/// among what it uses.
pub(crate) fn binding_wait(&self) -> Option<(vk::Semaphore, u64)> {
let shared = self.shared();
let mut bound_at = lock(&shared.bound_at);
let (timeline, value) = (*bound_at)?;
// SAFETY: the timeline is the device's, live while the device is.
let reached = unsafe { shared.vk().get_semaphore_counter_value(timeline) };
if reached.is_ok_and(|reached| reached >= value) {
*bound_at = None;
return None;
}
Some((timeline, value))
}
/// The error of a failed submission or wait, recording a lost device.
pub(crate) fn failed(&self, error: vk::Result) -> Error {
if error == vk::Result::ERROR_DEVICE_LOST {
File diff suppressed because it is too large. Load diff
+14 -1
View File
@@ -499,6 +499,11 @@ pub enum Problem {
AlreadyCommitted,
/// An object made by another device.
ForeignObject,
/// Dma-bufs a `DmaBufSource` returned (a runtime extension: Metal has none,
/// `HostMemory::with_dma_buf`) that break its contract: chunks that do not cover the pages
/// asked for, split off the granule, or of lengths off the host page, and a descriptor that
/// is no dma-buf or holds fewer bytes than its chunk.
DmaBuf,
/// An image the caller made that cannot be wrapped as a texture of the descriptor
/// (`new_texture_with_vk_image`).
WrappedImage(WrappedImageProblem),
@@ -1294,7 +1299,15 @@ pub enum RuntimeGap {
OverlappingTextureCopies,
/// `Buffer::rebind_bytes_no_copy` of a no-copy buffer with a live texture over its bytes,
/// given memory at another offset in its page than the old: the texture's copies and texel
/// views are planned at the bytes' offset in their `VkBuffer` (`rebind.rs`).
/// views are planned at the bytes' offset in their `VkBuffer` (`rebind.rs`). Also a rebind
/// of a no-copy buffer or heap with a texture whose image is bound to its bytes, where the
/// device makes no such image over the new memory: over memory it imports by its pointer, one
/// that takes the import's type and lies where the texture's texels do, its rows (and slices)
/// as far apart as the old image's, and never for a heap's texture whose image lay over
/// dma-bufs, whose rows the driver's `DRM_FORMAT_MOD_LINEAR` layout spaces; over memory it
/// imports as dma-bufs (`HostMemory::with_dma_buf`), an image of `DRM_FORMAT_MOD_LINEAR` over
/// a dma-buf of the texture's own new pages, which needs `VK_EXT_image_drm_format_modifier`
/// and `VK_EXT_queue_family_foreign`, a layout the driver takes and the source's dma-buf.
RebindTextures,
/// A PVRTC texture's blocks in a Metal block order the runtime does not lay out:
/// `replaceRegion` and `getBytes` of a region other than a whole level, which Metal's API
+28 -25
View File
@@ -67,7 +67,6 @@ use super::values::{CpuCacheMode, HazardTrackingMode, ResourceOptions, StorageMo
use super::Device;
use metal2vulkan::device::AllocationLimits;
use std::collections::HashMap;
use std::ptr::NonNull;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, Mutex, Weak};
@@ -482,24 +481,27 @@ impl Device {
}
/// A heap over the caller's host memory (a runtime extension, the heap twin of
/// [`Device::new_buffer_with_bytes_no_copy`]): an automatic or placement heap of the
/// descriptor's size rounded up to 16 KiB whose bytes are the caller's, from `bytes`. Its
/// buffers and textures alias at their offsets as in any heap of its type, and the CPU's
/// writes through `bytes` are what its resources' commands read. `deallocator` runs once,
/// with `bytes` and the heap's size, when the heap's last reference goes (its resources hold
/// it): on a runtime thread when that is a command buffer completing. A refused call never
/// runs it. `keep_alive` ([`KeepAlive`]) is dropped once the device's import of the memory is
/// freed: with one, `deallocator` runs at the heap's release, though a command buffer submitted
/// before a texture placed in the heap was released may hold the import until it completes;
/// with none, `deallocator` waits for the import (`host-deallocator-delayed`).
/// [`Device::new_buffer_with_bytes_no_copy`]), its pointer wrapped in `memory`
/// ([`HostMemory`]): an automatic or placement heap of the descriptor's size rounded up to 16
/// KiB whose bytes are the caller's, from `memory.pointer()`. Its buffers and textures alias at
/// their offsets as in any heap of its type, and the CPU's writes through the pointer are what
/// its resources' commands read. `deallocator` runs once, with the pointer and the heap's size,
/// when the heap's last reference goes (its resources hold it): on a runtime thread when that
/// is a command buffer completing. A refused call never runs it. `keep_alive` ([`KeepAlive`])
/// is dropped once the device's import of the memory is freed: with one, `deallocator` runs at
/// the heap's release, though a command buffer submitted before a texture placed in the heap
/// was released may hold the import until it completes; with none, `deallocator` waits for the
/// import (`host-deallocator-delayed`).
///
/// The memory is imported here, as a no-copy buffer's is (`host_memory.rs`). A buffer
/// placed in the heap is its bytes; a texture is an image bound to them where the device
/// binds such an image to imported host memory (its optimal image, else a linear one), else
/// an image of its own whose texels the encoders copy from the heap's bytes and back, laid
/// out by level and layer from the texture's offset, which the device announces once
/// (`shadowed-texture`; `texture/heap.rs`). Its purgeable state answers as a no-copy
/// buffer's: non-volatile, and emptying it keeps the caller's bytes.
/// The memory is imported here, as a no-copy buffer's is (`host_memory.rs`): by its pointer, or
/// where the device refuses that and `memory` carries a dma-buf source
/// ([`HostMemory::with_dma_buf`]), by the dma-bufs it makes of the pages. A buffer placed in
/// the heap is its bytes; a texture is an image bound to them where the device binds such an
/// image to imported host memory (its optimal image, else a linear one; over dma-bufs, an
/// image over a dma-buf of its own pages), else an image of its own whose texels the encoders copy from
/// the heap's bytes and back, laid out by level and layer from the texture's offset, which the
/// device announces once (`shadowed-texture`; `texture/heap.rs`). Its purgeable state answers
/// as a no-copy buffer's: non-volatile, and emptying it keeps the caller's bytes.
///
/// Refused: a size of 0 (`Nil`, as [`Device::new_heap`] answers it); storage other than
/// `Shared`, a sparse heap, an undefined option (`Invalid`); memory whose first byte is not a multiple of the import's unit
@@ -512,10 +514,11 @@ impl Device {
///
/// # Safety
///
/// The heap's [`size`](Heap::size) bytes at `bytes` meet [`HostMemory::new`]'s contract.
/// `memory` meets the contract of the [`HostMemory`] constructor that made it
/// ([`HostMemory::new`], [`HostMemory::with_dma_buf`]) for the heap's [`size`](Heap::size).
pub unsafe fn new_heap_with_bytes_no_copy(
&self,
bytes: NonNull<u8>,
memory: HostMemory,
descriptor: &HeapDescriptor,
deallocator: Option<Deallocator>,
keep_alive: Option<KeepAlive>,
@@ -525,7 +528,7 @@ impl Device {
keep_alive,
};
// SAFETY: the caller's contract.
unsafe { self.no_copy_heap_with_token(bytes, descriptor, release, None) }
unsafe { self.no_copy_heap_with_token(memory, descriptor, release, None) }
}
/// [`Device::new_heap_with_bytes_no_copy`] with `token` (a runtime extension), dropped once
@@ -537,7 +540,7 @@ impl Device {
/// As [`Device::new_heap_with_bytes_no_copy`]'s.
pub unsafe fn new_heap_with_bytes_no_copy_and_range_token(
&self,
bytes: NonNull<u8>,
memory: HostMemory,
descriptor: &HeapDescriptor,
deallocator: Option<Deallocator>,
keep_alive: Option<KeepAlive>,
@@ -548,7 +551,7 @@ impl Device {
keep_alive,
};
// SAFETY: the caller's contract.
unsafe { self.no_copy_heap_with_token(bytes, descriptor, release, Some(token)) }
unsafe { self.no_copy_heap_with_token(memory, descriptor, release, Some(token)) }
}
/// [`Device::new_heap_with_bytes_no_copy`], given back to `release`, the heap's own bytes
@@ -559,7 +562,7 @@ impl Device {
/// As [`Device::new_heap_with_bytes_no_copy`]'s.
unsafe fn no_copy_heap_with_token(
&self,
bytes: NonNull<u8>,
memory: HostMemory,
descriptor: &HeapDescriptor,
release: HostRelease,
token: Option<RangeToken>,
@@ -578,7 +581,7 @@ impl Device {
let bytes = unsafe {
self.buffer_over_host_memory(
CALL,
HostMemory::new(bytes),
memory,
size,
options,
release,
+158 -16
View File
@@ -1,5 +1,6 @@
//! Buffers over the caller's host memory without a copy (`newBufferWithBytesNoCopy:`), through
//! `VK_EXT_external_memory_host`.
//! `VK_EXT_external_memory_host`, or, where the device refuses the pointer, dma-buf memory of the
//! pages the caller imports (`VK_EXT_external_memory_dma_buf`, [`DmaBufSource`], `dma_buf.rs`).
//!
//! - **What Metal takes** (measured on an Apple M3 Max and an M4, plain and under API validation):
//! any pointer and any length but 0; the buffer covers the whole host pages its range touches
@@ -29,9 +30,16 @@
//! there the rule refuses a little more than the driver would. On macOS, MoltenVK hands the
//! range to Metal, which reads read-only pages, so there is no check.
//! - **What drivers answered**. Private anonymous memory was imported on every venue measured. RADV
//! refused shared memory (anonymous shared, or a mapping of a shared memory object) typed: Mesa
//! 26.2.4 answers `VK_ERROR_INVALID_EXTERNAL_HANDLE`, 26.0.8 `VK_ERROR_UNKNOWN`, and both are
//! refusals ([`import_refused`]).
//! refused shared memory typed: anonymous shared memory, and any mapping of a file, a shared
//! memory object or a `memfd` among them (QEMU's `memory-backend-memfd,share=on` guest RAM). It
//! imports a host pointer through amdgpu's userptr, which the kernel takes only over anonymous
//! pages. Mesa 26.2.4 answers `VK_ERROR_INVALID_EXTERNAL_HANDLE`, 26.0.8 `VK_ERROR_UNKNOWN`, and
//! both are refusals ([`import_refused`]). NVIDIA and lavapipe imported the same shared memory.
//! - **Dma-bufs of the pages** ([`HostMemory::with_dma_buf`]), the last resort before that
//! refusal: where the device refuses the pointer ([`refused`]: the import window, the buffer's
//! binding in it, the memory types, or the driver) and imports dma-bufs, the buffer is bound in
//! imports of the source's dma-bufs of the pages instead (`dma_buf.rs`). Every import the device
//! takes by its pointer is made exactly as before, with no call more.
//! - **When**. The pages are imported when the buffer is made, on every platform, as Metal wires
//! them then: the GPU uses the pages mapped at the pointer when the buffer was made, whatever is
//! mapped there later, and memory the device cannot import is refused by the call that makes the
@@ -58,6 +66,8 @@
//! contract keeps mapped: its deallocator runs at its release either way.
use super::device::lock;
#[cfg(unix)]
use super::dma_buf::DmaBufSource;
use super::error::{vulkan, Error};
use super::exit_guard;
use super::loader_word::LoaderWord;
@@ -68,17 +78,41 @@ use std::ffi::c_void;
use std::ptr::NonNull;
use std::sync::Mutex;
/// Host memory a buffer wraps without a copy: a pointer whose bytes the caller vouches for (the
/// `pointer` of `newBufferWithBytesNoCopy:length:options:deallocator:`).
#[derive(Debug)]
pub struct HostMemory(NonNull<u8>);
/// Host memory a buffer or heap wraps without a copy: a pointer whose bytes the caller vouches for
/// (the `pointer` of `newBufferWithBytesNoCopy:length:options:deallocator:`), and, as a runtime
/// extension, a source of dma-bufs of its pages for a device that refuses the pointer itself
/// ([`HostMemory::with_dma_buf`]).
pub struct HostMemory {
pointer: NonNull<u8>,
source: Option<Source>,
}
// SAFETY: a `HostMemory` is an address and the caller's guarantee for it (`HostMemory::new`); the
// runtime touches the bytes only as a buffer of them, under that guarantee.
/// What a [`HostMemory`] may carry besides its pointer: a [`DmaBufSource`] where the system has
/// file descriptors, nothing elsewhere.
#[cfg(unix)]
pub(super) type Source = DmaBufSource;
/// What a [`HostMemory`] may carry besides its pointer: nothing on this system.
#[cfg(not(unix))]
pub(super) type Source = std::convert::Infallible;
// SAFETY: a `HostMemory` is an address and the caller's guarantee for it (`HostMemory::new`),
// and a source that is `Send`; the runtime touches the bytes only as a buffer of them, under that
// guarantee.
unsafe impl Send for HostMemory {}
// SAFETY: as above.
// SAFETY: as above; a shared `HostMemory` answers its pointer alone, and its source is reached
// only by value ([`HostMemory::into_parts`]).
unsafe impl Sync for HostMemory {}
impl std::fmt::Debug for HostMemory {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("HostMemory")
.field("pointer", &self.pointer)
.field("dma_buf", &self.source.is_some())
.finish()
}
}
impl HostMemory {
/// The host memory at `pointer`, for a buffer of some length `length` made from it.
///
@@ -101,14 +135,53 @@ impl HostMemory {
/// (`Unsupported`, `HostMemory`), though Metal reads such pages: Linux drivers pin imported
/// pages for writing, and one (ANV) imported a read-only page and then lost the device at the
/// GPU's first read. Some drivers also refuse shared memory (RADV refused anonymous shared
/// memory and mappings of shared memory objects); private memory imports everywhere measured.
/// memory and mappings of shared memory objects, `memfd` mappings among them); private memory
/// imports everywhere measured. [`HostMemory::with_dma_buf`] imports such memory where the
/// device imports dma-bufs.
pub unsafe fn new(pointer: NonNull<u8>) -> HostMemory {
HostMemory(pointer)
HostMemory {
pointer,
source: None,
}
}
/// As [`HostMemory::new`], plus a source of dma-bufs of the pages for a device that refuses
/// the pointer (a runtime extension, [`DmaBufSource`]). The runtime first imports the pointer
/// exactly as [`HostMemory::new`]'s; only where the device refuses it (a driver refusal, or a
/// range its import alignment cannot cover) and enables `VK_EXT_external_memory_dma_buf`, it
/// imports the source's chunks instead: one chunk binds a plain buffer, several a sparse one.
/// A texture over such pages (over the buffer, placed in the heap, or a view of one) is an
/// image over a dma-buf of its own pages where the device lists
/// `VK_EXT_image_drm_format_modifier` and `VK_EXT_queue_family_foreign`, else a shadow of the
/// bytes (announced `shadowed-texture`). Refused as [`HostMemory::new`]'s memory is
/// (`Unsupported`, `HostMemory`) where the device imports no chunk or the source fails; chunks
/// that break the source's contract are misuse (`Invalid`, `Problem::DmaBuf`). Measured: RADV
/// refuses the pointer of `memfd` and other shared mappings and imports `udmabuf`s of their
/// pages; NVIDIA and lavapipe import the pointer and never call the source.
///
/// # Safety
///
/// [`HostMemory::new`]'s contract for the bytes at `pointer`, holding while the chunks are
/// imported as while the pointer is; and the chunks `source` returns hold exactly the pages it
/// is asked for, in order (then padding, [`DmaBufRequest`](crate::DmaBufRequest)), the same
/// pieces of the same files for every request over the same pages, so that the GPU's bytes,
/// the buffer's and its textures', are the CPU's.
#[cfg(unix)]
pub unsafe fn with_dma_buf(pointer: NonNull<u8>, source: DmaBufSource) -> HostMemory {
HostMemory {
pointer,
source: Some(source),
}
}
/// The pointer.
pub fn pointer(&self) -> NonNull<u8> {
self.0
self.pointer
}
/// The pointer, and the dma-buf source where the caller gave one.
pub(super) fn into_parts(self) -> (NonNull<u8>, Option<Source>) {
(self.pointer, self.source)
}
}
@@ -172,7 +245,8 @@ pub(super) enum WindowRefusal {
/// The import of `length` bytes at `pointer` on a host of `page`-byte pages and a device that
/// imports at multiples of `alignment`: the range rounded out to the larger of the two. Refused
/// when the rounding would take pages the range does not touch.
/// when the rounding would take pages the range does not touch, so a window made is always the
/// pages the range touches, the one an `alignment` of 1 makes (a dma-buf's, which has none).
pub(super) fn import_window(
pointer: u64,
length: u64,
@@ -255,6 +329,13 @@ pub(super) fn not_importable() -> Error {
Error::Unsupported(Unsupported::not_representable(Feature::HostMemory))
}
/// Whether `error` is the refusal of host memory this device cannot import exactly
/// ([`not_importable`]): the window, the buffer's binding in it, the memory types or the driver
/// refused the pointer, which a dma-buf of its pages may serve ([`DmaBufSource`]).
pub(super) fn refused(error: &Error) -> bool {
*error == not_importable()
}
/// The error of a failed import call (`vkGetMemoryHostPointerPropertiesEXT` or the allocation): a
/// driver that refuses the memory is a device gap, anything else a Vulkan failure. Refusing
/// drivers answer `VK_ERROR_INVALID_EXTERNAL_HANDLE`, but RADV of Mesa 26.0.8 answers
@@ -427,6 +508,16 @@ pub(super) struct Importer {
/// instance reports through `VK_EXT_debug_utils`: an image made of a Metal texture is named
/// [`METAL_TEXTURE_IMAGE`] for the layers' messages.
names: Option<ash::ext::debug_utils::DeviceFn>,
/// `vkGetMemoryFdPropertiesKHR`, where the device enables the dma-buf route (`dma_buf.rs`).
dma_buf: Option<ash::khr::external_memory_fd::DeviceFn>,
/// Whether the device also enables the route's image extensions (`create.rs`'s
/// `dma_buf_image_names`), for images of textures over dma-buf pages (`dma_buf.rs`).
dma_buf_images: bool,
/// The granule a dma-buf source's chunks split at, where the device assembles a buffer of
/// several (`dma_buf.rs`): the alignment of a sparse buffer made for dma-bufs. Asked once,
/// the first time a pointer is refused and a source called; `None` where the device makes no
/// such buffer.
pub(super) sparse_granule: std::sync::OnceLock<Option<u64>>,
}
/// The debug name of an image the runtime made of a Metal texture over an import's `MTLBuffer`
@@ -445,7 +536,8 @@ impl Importer {
/// # Safety
///
/// `device` is a live device of `physical`, made from `instance` with `enabled` enabled, and
/// `loader_word` is its loader word.
/// `loader_word` is its loader word; made with the dma-buf route's extensions where `dma_buf`,
/// and its image extensions where `dma_buf_images` (`create.rs`).
pub(super) unsafe fn new(
instance: &ash::Instance,
physical: vk::PhysicalDevice,
@@ -455,6 +547,8 @@ impl Importer {
loader_word: &LoaderWord,
metal_objects: bool,
debug_names: bool,
dma_buf: bool,
dma_buf_images: bool,
) -> Result<Importer, Unsupported> {
if !enabled
.extensions
@@ -499,15 +593,63 @@ impl Importer {
let metal = metal_objects.then(|| ash::ext::metal_objects::DeviceFn::load(load));
let names =
(metal_objects && debug_names).then(|| ash::ext::debug_utils::DeviceFn::load(load));
let dma_buf = dma_buf.then(|| ash::khr::external_memory_fd::DeviceFn::load(load));
let dma_buf_images = dma_buf.is_some() && dma_buf_images;
Ok(Importer {
functions,
page,
alignment,
metal,
names,
dma_buf,
dma_buf_images,
sparse_granule: std::sync::OnceLock::new(),
})
}
/// Whether the device imports dma-bufs (`VK_EXT_external_memory_dma_buf`), which a no-copy
/// buffer's pages may come as where it refuses their pointer ([`DmaBufSource`]).
pub(super) fn imports_dma_bufs(&self) -> bool {
self.dma_buf.is_some()
}
/// Whether the device makes images over dma-bufs of host pages (`dma_buf.rs`): it imports
/// dma-bufs and enables `VK_EXT_image_drm_format_modifier` and `VK_EXT_queue_family_foreign`.
pub(super) fn makes_dma_buf_images(&self) -> bool {
self.dma_buf_images
}
/// The memory types the dma-buf `fd` can be imported into (`vkGetMemoryFdPropertiesKHR`);
/// `ERROR_FEATURE_NOT_PRESENT` where the device imports no dma-bufs.
///
/// # Safety
///
/// `device` is the importer's device.
#[cfg(unix)]
pub(super) unsafe fn dma_buf_types(
&self,
device: &ash::Device,
fd: std::os::fd::BorrowedFd<'_>,
) -> Result<u32, vk::Result> {
use std::os::fd::AsRawFd;
let functions = self
.dma_buf
.as_ref()
.ok_or(vk::Result::ERROR_FEATURE_NOT_PRESENT)?;
let mut properties = vk::MemoryFdPropertiesKHR::default();
// SAFETY: the caller's contract; the function was loaded for this device, and the
// descriptor is open for the call (the query does not take it).
let result = unsafe {
(functions.get_memory_fd_properties_khr)(
device.handle(),
vk::ExternalMemoryHandleTypeFlags::DMA_BUF_EXT,
fd.as_raw_fd(),
&mut properties,
)
};
result.result_with_success(properties.memory_type_bits)
}
/// Whether the device's imports are allocated for export of their `MTLBuffer`
/// (`VK_EXT_metal_objects`).
pub(super) fn exports_metal(&self) -> bool {
+4
View File
@@ -66,6 +66,8 @@ mod depth_stencil_scratch;
mod descriptor_arena;
mod detach;
mod device;
#[cfg(unix)]
mod dma_buf;
mod draw_source;
mod driver_defects;
mod driver_facts;
@@ -215,6 +217,8 @@ pub use device::{
DebugMessage, Device, DeviceHandles, DeviceKind, DeviceOptions, LayerSetting,
LayerSettingValue, MessageKind, MessageSeverity, MessageSink, RawDevice,
};
#[cfg(unix)]
pub use dma_buf::{DmaBufChunk, DmaBufRequest, DmaBufSource};
pub use dynamic_library::DynamicLibrary;
pub use error::DynamicLibraryError;
pub use error::ExtensionFeature;
+14 -2
View File
@@ -590,6 +590,18 @@ pub(super) struct LinearLack {
/// none of the features of a usage that format does not take, so only those it takes are asked of
/// its linear tiling. `None` where the linear image lacks nothing.
pub(super) fn linear_lack(plan: &ImagePlan, facts: &ImageFacts) -> Option<LinearLack> {
tiling_lack(plan, facts, |format| facts.linear(format))
}
/// What an image of `plan` in another tiling than optimal, whose features in a format are
/// `tiling`'s answer, lacks of all its optimal image can do, as [`linear_lack`] asks it of linear
/// tiling: a `DRM_FORMAT_MOD_LINEAR` image's features are its modifier's (`dma_buf.rs`). `None`
/// where it lacks nothing.
pub(super) fn tiling_lack(
plan: &ImagePlan,
facts: &ImageFacts,
tiling: impl Fn(Format) -> FormatFeatureFlags2,
) -> Option<LinearLack> {
let needed = USAGE_FEATURES
.iter()
.filter(|(usage, _)| plan.usage.contains(*usage))
@@ -604,7 +616,7 @@ pub(super) fn linear_lack(plan: &ImagePlan, facts: &ImageFacts) -> Option<Linear
std::iter::once(plan.format)
.chain(viewed_formats(plan, facts))
.find_map(|format| {
let (optimal, linear) = (facts.optimal(format), facts.linear(format));
let (optimal, linear) = (facts.optimal(format), tiling(format));
let features = optimal.intersection(needed).difference(linear);
(!features.is_empty()).then_some(LinearLack { format, features })
})
@@ -614,7 +626,7 @@ pub(super) fn linear_lack(plan: &ImagePlan, facts: &ImageFacts) -> Option<Linear
/// format (a texture of `pixelFormatView` usage: `MUTABLE_FORMAT` without a list), each format
/// the runtime views a texture of a pixel format as for the plan's usages (`view_formats`) that
/// is compatible with the image's, of every pixel format.
fn viewed_formats(plan: &ImagePlan, facts: &ImageFacts) -> Vec<Format> {
pub(super) fn viewed_formats(plan: &ImagePlan, facts: &ImageFacts) -> Vec<Format> {
if !plan.flags.contains(ImageCreateFlags::MUTABLE_FORMAT) || !plan.view_formats.is_empty() {
return plan.view_formats.clone();
}
+127 -1
View File
@@ -12,7 +12,9 @@
//! [`MemoryClass`]; [`Memory::free`] with the placement it gave. Buffers use it in step 1;
//! textures and heaps add their classes and callers in their own steps. Imported host memory
//! has its own entry, [`Memory::import_host`]: one dedicated block per import, never
//! pooled, freed through the same [`Memory::free`].
//! pooled, freed through the same [`Memory::free`]. A dma-buf's import
//! (`Memory::import_dma_buf`) is in no block: the placement in it keeps it, and frees it as it
//! goes (`dma_buf.rs`'s `DmaBufPages`).
//!
//! - **Addresses** ([`allocate_addressed`]). A buffer placed for a device address gets it from its
//! block: a block that holds such a buffer has one buffer over its whole memory with the
@@ -33,6 +35,8 @@
use super::buffer::usage;
use super::device::lock;
#[cfg(unix)]
use super::dma_buf::DmaBufPages;
use super::error::{internal, vulkan, Error, MemoryKind};
use super::range::RangeAllocator;
use super::sharing::Sharing;
@@ -40,6 +44,8 @@ use super::work_counts::Counters;
use crate::release;
use ash::vk;
use std::ptr::NonNull;
#[cfg(unix)]
use std::sync::Arc;
use std::sync::Mutex;
/// The size of a pooled block, at most the device's `maxMemoryAllocationSize`.
@@ -469,6 +475,11 @@ pub(super) struct Placement {
/// asked for one ([`allocate_addressed`]) on a device that enables
/// `bufferDeviceAddress`.
pub(super) address: Option<u64>,
/// The imports of the caller's dma-bufs the placement lies in, with the source that made them
/// (`dma_buf.rs`), which no block of the runtime's holds: kept until the placement goes, and
/// freed, the source dropped, when their last holder goes.
#[cfg(unix)]
dma_buf: Option<Arc<DmaBufPages>>,
}
impl Placement {
@@ -491,6 +502,35 @@ impl Placement {
offset,
mapped: mapped.map(Mapped),
address: None,
#[cfg(unix)]
dma_buf: None,
}
}
/// The placement of a no-copy buffer's `size` bytes of host pages in the imports of the
/// caller's dma-bufs of them, `pages`: at offset 0 of `memory`, of type `type_index`, where
/// they are one import, or no memory (`VK_NULL_HANDLE`) where they are several bound to a
/// sparse buffer; their host address is `mapped`, the pages' pointer (the runtime never maps
/// a dma-buf). No block of the runtime's, so freeing it returns nothing; it keeps the imports
/// until it goes.
#[cfg(unix)]
pub(super) fn dma_buf(
pages: Arc<DmaBufPages>,
memory: vk::DeviceMemory,
type_index: u32,
size: u64,
mapped: NonNull<u8>,
) -> Placement {
Placement {
type_index,
holds: Holds::Buffers,
block: None,
size,
memory,
offset: 0,
mapped: Some(Mapped(mapped)),
address: None,
dma_buf: Some(pages),
}
}
@@ -504,6 +544,36 @@ impl Placement {
self.size
}
/// Whether the placement lies in imports of the caller's dma-bufs (`dma_buf.rs`), to which no
/// image is bound (an image over them is bound to a dma-buf of its own pages).
pub(super) fn over_dma_buf(&self) -> bool {
#[cfg(unix)]
{
self.dma_buf.is_some()
}
#[cfg(not(unix))]
{
false
}
}
/// The imports of the caller's dma-bufs the placement lies in, with their source
/// (`dma_buf.rs`); `None` for any other placement.
#[cfg(unix)]
pub(super) fn dma_buf_pages(&self) -> Option<&Arc<DmaBufPages>> {
self.dma_buf.as_ref()
}
/// Wait until the sparse binding of the buffer over the placement's dma-bufs completed,
/// where it may not have (`dma_buf.rs`'s `DmaBufPages::settle`): before that buffer is
/// destroyed. Any other placement has nothing to wait for.
pub(super) fn settle(&self) {
#[cfg(unix)]
if let Some(pages) = &self.dma_buf {
pages.settle();
}
}
/// The same placement, for another owner to free from now on: an image's first memory, which
/// goes with its first `VkImage` once the image takes its storage form
/// (`texture/storage_form.rs`). The image frees its storage form's memory instead, never
@@ -518,6 +588,8 @@ impl Placement {
offset: self.offset,
mapped: self.mapped,
address: self.address,
#[cfg(unix)]
dma_buf: self.dma_buf.clone(),
}
}
}
@@ -767,6 +839,8 @@ impl Memory {
.as_ref()
.filter(|_| addressed)
.map(|addresses| addresses.address + offset),
#[cfg(unix)]
dma_buf: None,
}
}
@@ -881,6 +955,58 @@ impl Memory {
Err(failure)
}
/// Import the dma-buf `fd`, `size` bytes, as memory of the best type of `class` among
/// `allowed` (the types both the dma-buf and what is bound in it take): the memory and its
/// type, the caller's to free (`dma_buf.rs`'s `DmaBufPages`), in no block and never mapped.
/// For a buffer, allocated with the device-address flag where the device enables
/// `bufferDeviceAddress`; for `image`, its dedicated allocation (`size` its requirements').
/// Refused when no type of `class` is among `allowed`, else with the failure of the last type
/// tried; the descriptor is Vulkan's once imported, and closed on failure.
#[cfg(unix)]
pub(super) fn import_dma_buf(
&self,
device: &ash::Device,
fd: std::os::fd::OwnedFd,
size: u64,
(allowed, class): (u32, MemoryClass),
image: Option<vk::Image>,
) -> Result<(vk::DeviceMemory, u32), ImportFailure> {
use std::os::fd::{AsRawFd, IntoRawFd};
let mut failure = ImportFailure::NoMemoryType;
for type_index in candidates(&self.types, allowed, class, self.unified) {
let mut import = vk::ImportMemoryFdInfoKHR::default()
.handle_type(vk::ExternalMemoryHandleTypeFlags::DMA_BUF_EXT)
.fd(fd.as_raw_fd());
let mut flags = vk::MemoryAllocateFlagsInfo::default()
.flags(vk::MemoryAllocateFlags::DEVICE_ADDRESS);
let mut dedicated = vk::MemoryDedicatedAllocateInfo::default();
let mut info = vk::MemoryAllocateInfo::default()
.allocation_size(size)
.memory_type_index(type_index)
.push_next(&mut import);
match image {
Some(image) => {
dedicated = dedicated.image(image);
info = info.push_next(&mut dedicated);
}
None if self.device_address => info = info.push_next(&mut flags),
None => {}
}
// SAFETY: `info` and its chain live for the call; the type index is the device's and
// allows the dma-buf (and the image, unbound and made for dma-bufs, whose size this
// is). A failed import leaves the descriptor open, the caller's.
match unsafe { device.allocate_memory(&info, None) } {
Ok(memory) => {
// A successful import owns the descriptor: Vulkan closes it with the memory.
let _ = fd.into_raw_fd();
return Ok((memory, type_index));
}
Err(error) => failure = ImportFailure::Vulkan(error),
}
}
Err(failure)
}
/// The property flags of memory type `index`, where the device has it.
pub(super) fn type_flags(&self, index: u32) -> Option<vk::MemoryPropertyFlags> {
self.types
+40 -36
View File
@@ -47,7 +47,9 @@
//! a heap's rebind keeps (its first byte at the import's unit); a no-copy buffer with a texture
//! over it is rebound only to memory at the same offset in its page
//! (`NotImplemented(RebindTextures)` else), as is one whose aliasing image the device cannot make
//! again over the new pages (their memory type is not one it takes).
//! again over the new pages (their memory type is not one it takes). Over new pages imported as
//! dma-bufs, each such image is made again over a dma-buf of its own new pages before the rebind
//! settles (`Device::dma_buf_images_again`, `dma_buf.rs`), and refused likewise where it is not.
use super::buffer::{Buffer, Detached, HostCell, HostPages, Lying, WeakBuffer};
use super::command_buffer::CommandBufferShared;
@@ -60,7 +62,6 @@ use super::Device;
use metal2vulkan::bind::ResidentRange;
use std::any::Any;
use std::collections::{BTreeSet, HashMap};
use std::ptr::NonNull;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::{Arc, Condvar, Mutex, MutexGuard, Weak};
@@ -691,23 +692,23 @@ impl Drop for Holds {
impl Buffer {
/// Give the no-copy buffer other host memory of its length from now on (a runtime extension;
/// the module docs of `rebind.rs` state the rule): `bytes`, under [`HostMemory::new`]'s
/// contract for the buffer's [`length`](Buffer::length), imported as
/// the module docs of `rebind.rs` state the rule): `memory` ([`HostMemory`]), under its
/// constructor's contract for the buffer's [`length`](Buffer::length), imported as
/// [`Device::new_buffer_with_bytes_no_copy`] imports memory. The buffer, its `gpu_address` and
/// its options stay; `contents` answers `bytes` from now on. Command buffers first submitted
/// before the call keep the old memory until they complete; one committed before it and first
/// submitted after reaches the new memory through what it made resident and what its commands
/// reach unnamed, and through what its compute, blit and render encoders named, which this call
/// encodes again; it fails `CommandBufferError::EncodedUseRebound` where an encoder this call
/// cannot encode again named the buffer (one of a command buffer that used command predication,
/// among others); commands encoded after it use the new. The old memory's deallocator runs once
/// every command buffer submitted before the call that used it completed (in the call, where
/// none holds it); `deallocator` runs for `bytes` at the next rebind's turn, or when the buffer
/// goes. A refused call runs neither and changes nothing. `keep_alive` ([`KeepAlive`]) is
/// dropped once the device's import of `bytes` is freed: with one, `deallocator` runs at that
/// turn though something still holds the import (a command buffer submitted before a texture
/// over the bytes was released); with none, `deallocator` waits for the import
/// (`host-deallocator-delayed`).
/// its options stay; `contents` answers `memory.pointer()` from now on. Command buffers first
/// submitted before the call keep the old memory until they complete; one committed before it
/// and first submitted after reaches the new memory through what it made resident and what its
/// commands reach unnamed, and through what its compute, blit and render encoders named, which
/// this call encodes again; it fails `CommandBufferError::EncodedUseRebound` where an encoder
/// this call cannot encode again named the buffer (one of a command buffer that used command
/// predication, among others); commands encoded after it use the new. The old memory's
/// deallocator runs once every command buffer submitted before the call that used it completed
/// (in the call, where none holds it); `deallocator` runs for the new memory at the next
/// rebind's turn, or when the buffer goes. A refused call runs neither and changes nothing.
/// `keep_alive` ([`KeepAlive`]) is dropped once the device's import of the new memory is freed:
/// with one, `deallocator` runs at that turn though something still holds the import (a command
/// buffer submitted before a texture over the bytes was released); with none, `deallocator`
/// waits for the import (`host-deallocator-delayed`).
///
/// A texture over the buffer (a shadow of its bytes, or a texture buffer) reads the new
/// memory from its next use, and one whose linear image aliases its bytes has its image made
@@ -719,18 +720,20 @@ impl Buffer {
/// memory at another offset in its page than the old where a texture over the buffer lives
/// (`NotImplemented(RebindTextures)`: the texture's copies, views and aliasing image are
/// planned at that offset), or where the device cannot make a texture's aliasing image again
/// over the new memory (`NotImplemented(RebindTextures)`); memory the device cannot import
/// exactly, as `new_buffer_with_bytes_no_copy` refuses it; a lost device.
/// over the new memory (`NotImplemented(RebindTextures)`, which says when); memory the device
/// cannot import exactly, as `new_buffer_with_bytes_no_copy` refuses it; a lost device.
///
/// # Safety
///
/// `bytes` meets [`HostMemory::new`]'s contract for the buffer's length. The old memory stays
/// mapped until its keep-alive is dropped, else until its deallocator runs, or with neither
/// until every command buffer first submitted before the call completed. No command that uses the buffer is encoded, and no command
/// buffer that uses it committed, on another thread during the call.
/// `memory` meets the contract of the [`HostMemory`] constructor that made it
/// ([`HostMemory::new`], [`HostMemory::with_dma_buf`]) for the buffer's length. The old memory
/// stays mapped until its keep-alive is dropped, else until its deallocator runs, or with
/// neither until every command buffer first submitted before the call completed. No command
/// that uses the buffer is encoded, and no command buffer that uses it committed, on another
/// thread during the call.
pub unsafe fn rebind_bytes_no_copy(
&self,
bytes: NonNull<u8>,
memory: HostMemory,
deallocator: Option<Deallocator>,
keep_alive: Option<KeepAlive>,
) -> Result<(), Error> {
@@ -744,7 +747,7 @@ impl Buffer {
CALL,
self,
cell,
HostMemory::new(bytes),
memory,
HostRelease {
deallocator,
keep_alive,
@@ -758,14 +761,15 @@ impl Buffer {
impl Heap {
/// Give the heap over the caller's host memory (`Device::new_heap_with_bytes_no_copy`) other
/// host memory of its size from now on (a runtime extension), as
/// [`Buffer::rebind_bytes_no_copy`] gives a no-copy buffer: `bytes`, its first byte at a
/// multiple of the import's unit as the heap's was. Every buffer and texture placed in the
/// heap stays, at its offset, with its `gpu_address` and resource ID; a buffer's `contents`
/// answers its offset in `bytes` from now on. A texture bound to the heap's bytes has its
/// image made again over the new memory, at its offset, before the call returns, as has a
/// texture over one of the heap's buffers whose linear image aliases its bytes; a texture
/// held as a shadow of the heap's bytes, a texture buffer and a shadowed texture over one of
/// the heap's buffers read them from their next use. Nothing of the old contents is copied.
/// [`Buffer::rebind_bytes_no_copy`] gives a no-copy buffer: `memory` ([`HostMemory`]), its
/// first byte at a multiple of the import's unit as the heap's was. Every buffer and texture
/// placed in the heap stays, at its offset, with its `gpu_address` and resource ID; a buffer's
/// `contents` answers its offset from `memory.pointer()` from now on. A texture bound to the
/// heap's bytes has its image made again over the new memory, at its offset, before the call
/// returns, as has a texture over one of the heap's buffers whose linear image aliases its
/// bytes; a texture held as a shadow of the heap's bytes, a texture buffer and a shadowed
/// texture over one of the heap's buffers read them from their next use. Nothing of the old
/// contents is copied.
///
/// Refused: a heap not over the caller's host memory (`Invalid`,
/// [`RebindProblem::NotHostMemory`]); a command buffer not yet committed whose commands used
@@ -781,7 +785,7 @@ impl Heap {
/// of the heap and its resources.
pub unsafe fn rebind_bytes_no_copy(
&self,
bytes: NonNull<u8>,
memory: HostMemory,
deallocator: Option<Deallocator>,
keep_alive: Option<KeepAlive>,
) -> Result<(), Error> {
@@ -798,7 +802,7 @@ impl Heap {
CALL,
own,
cell,
HostMemory::new(bytes),
memory,
HostRelease {
deallocator,
keep_alive,
@@ -8,7 +8,9 @@
//! `m2v_cpu_icd`), on the kind of device the cfg selects.
use crate::error::Error;
use crate::{Device, DeviceKind, DeviceOptions, EventRef, ResourceOptions, ShaderCacheOptions};
use crate::{
Device, DeviceKind, DeviceOptions, EventRef, HostMemory, ResourceOptions, ShaderCacheOptions,
};
use std::alloc::Layout;
use std::path::{Path, PathBuf};
use std::ptr::NonNull;
@@ -91,7 +93,12 @@ fn a_detach_waiting_for_a_submitted_command_buffer_settles_on_a_lost_device() {
// SAFETY: the memory outlives the device (dropped after it, below), and nothing else uses
// it meanwhile.
let made = unsafe {
device.new_buffer_with_bytes_no_copy(host.0, BYTES as u64, ResourceOptions::default(), None)
device.new_buffer_with_bytes_no_copy(
HostMemory::new(host.0),
BYTES as u64,
ResourceOptions::default(),
None,
)
};
let buffer = match made {
Ok(buffer) => buffer,
@@ -16,14 +16,15 @@ fn the_registry_id_folds_the_uuid_and_is_never_zero() {
}
use crate::device::create::{
default_loaders, enable_set, host_image_copy, instance_version, layer_settings,
linear_color_attachment, open_loader, queue_plan, setting_values, timeline_difference,
QueuePlan,
default_loaders, dma_buf_image_names, dma_buf_names, enable_set, host_image_copy,
instance_version, layer_settings, linear_color_attachment, open_loader, queue_plan,
setting_values, timeline_difference, QueuePlan,
};
use crate::enables::host_image_copy_names;
use crate::{DeviceOptions, Error, InstanceApiVersion, LayerSetting, LayerSettingValue};
use ash::vk;
use metal2vulkan::device::{ApiVersion, DeviceDescription, VkExtension, VkFeature};
use std::collections::BTreeSet;
use std::ffi::{CStr, CString};
/// Every committed profile's description at the runtime's Vulkan 1.2 instance, as `(file,
@@ -48,6 +49,75 @@ fn descriptions() -> Vec<(std::path::PathBuf, DeviceDescription)> {
out
}
/// The dma-buf route's extensions: `VK_KHR_external_memory_fd` and
/// `VK_EXT_external_memory_dma_buf`.
const DMA_BUF: [&CStr; 2] = [
c"VK_KHR_external_memory_fd",
c"VK_EXT_external_memory_dma_buf",
];
/// The extensions of the images of textures over the route's pages:
/// `VK_EXT_image_drm_format_modifier` and `VK_EXT_queue_family_foreign`.
const DMA_BUF_IMAGES: [&CStr; 2] = [
c"VK_EXT_image_drm_format_modifier",
c"VK_EXT_queue_family_foreign",
];
/// The dma-buf route of a no-copy buffer (`dma_buf.rs`), the last resort where a device refuses
/// the pointer, takes its two extensions on every committed profile that lists both (RADV's,
/// NVIDIA's, lavapipe's and ANV's among them), on no profile that lacks either, and outside the
/// vocabulary; the images of textures over its pages take theirs
/// (`VK_EXT_image_drm_format_modifier`, `VK_EXT_queue_family_foreign`) on every profile that
/// lists those two and the route's, and on no other. Every profile's enable set is the
/// recommendation and `VK_EXT_external_memory_host` where listed, as before the route, so no
/// compile profile or fingerprint (the shader cache's key) moves with them.
#[test]
fn the_dma_buf_route_is_enabled_wherever_listed_outside_the_profile() {
let (mut lists_both, mut lists_all) = (0, 0);
for (path, description) in descriptions() {
let text = std::fs::read_to_string(&path).unwrap();
let listed: BTreeSet<CString> = DMA_BUF
.iter()
.chain(&DMA_BUF_IMAGES)
.filter(|name| text.contains(&format!("\"{}\"", name.to_str().unwrap())))
.map(|name| (*name).to_owned())
.collect();
let lists = DMA_BUF.iter().all(|name| listed.contains(*name));
let lists_images = DMA_BUF_IMAGES.iter().all(|name| listed.contains(*name));
assert_eq!(dma_buf_names(&listed).is_some(), lists, "{path:?}");
assert_eq!(
dma_buf_image_names(&listed).is_some(),
lists && lists_images,
"{path:?}"
);
for name in DMA_BUF.iter().chain(&DMA_BUF_IMAGES) {
let mut one_short = listed.clone();
one_short.remove(*name);
assert_eq!(dma_buf_image_names(&one_short), None, "{path:?}");
if DMA_BUF.contains(name) {
assert_eq!(dma_buf_names(&one_short), None, "{path:?}");
}
}
lists_both += usize::from(lists);
lists_all += usize::from(lists && lists_images);
let options = DeviceOptions::default();
let mut before = description.recommended_enables(&options.policy);
let host_memory = VkExtension::ExtExternalMemoryHost;
if description.extensions.contains(&host_memory) {
before.extensions.insert(host_memory);
}
assert_eq!(enable_set(&description, &options), before, "{path:?}");
}
assert!(
lists_both > 1,
"fewer than two committed profiles list both"
);
assert!(
lists_all > 1,
"fewer than two committed profiles list all four"
);
}
/// The robustness features.
const ROBUSTNESS: [VkFeature; 4] = [
VkFeature::RobustBufferAccess,
@@ -416,7 +486,6 @@ fn equivalent_queue_families_are_all_taken_in_turn() {
#[test]
fn host_image_copy_is_enabled_wherever_the_device_has_it() {
use std::cell::Cell;
use std::collections::BTreeSet;
let names = host_image_copy_names(ApiVersion::V1_2);
assert_eq!(names.len(), 3);
let listed: BTreeSet<CString> = names.iter().map(|&name| name.to_owned()).collect();
@@ -443,7 +512,6 @@ fn host_image_copy_is_enabled_wherever_the_device_has_it() {
#[test]
fn linear_color_attachment_is_enabled_where_the_device_has_it_at_vulkan_1_3() {
use std::cell::Cell;
use std::collections::BTreeSet;
let listed: BTreeSet<CString> = [c"VK_NV_linear_color_attachment".to_owned()].into();
let asked = Cell::new(false);
assert!(linear_color_attachment(ApiVersion::V1_3, &listed, || {
@@ -2,8 +2,8 @@
//! binds in them, the memory types an import may use, and the host's page.
use crate::host_memory::{
based_size, binds_in, buffer_base, host_page, import_refused, import_window, ImportWindow,
WindowRefusal,
based_size, binds_in, buffer_base, host_page, import_refused, import_window, refused,
ImportWindow, WindowRefusal,
};
use crate::memory::{candidates, MemoryClass};
use crate::{Error, MemoryKind, VkResultCode};
@@ -490,3 +490,111 @@ fn a_driver_s_refused_import_is_a_device_gap_and_other_failures_are_vulkan_s() {
))
);
}
/// The refusals a dma-buf of the pages may serve are exactly the device's refusal of the memory
/// (`not_importable`): a Vulkan failure, running out of memory, a refusal of another feature or
/// of another kind, and a nil answer are final.
#[test]
fn only_the_device_s_refusal_of_the_memory_falls_back_to_a_dma_buf() {
assert!(refused(&Error::Unsupported(
Unsupported::not_representable(Feature::HostMemory)
)));
assert!(refused(&import_refused(
vk::Result::ERROR_INVALID_EXTERNAL_HANDLE
)));
assert!(refused(&import_refused(vk::Result::ERROR_UNKNOWN)));
for error in [
import_refused(vk::Result::ERROR_OUT_OF_DEVICE_MEMORY),
import_refused(vk::Result::ERROR_INITIALIZATION_FAILED),
Error::Unsupported(Unsupported::not_implemented(Feature::HostMemory)),
Error::Unsupported(Unsupported::not_representable(Feature::GpuTimes)),
Error::DeviceLost,
] {
assert!(!refused(&error), "{error:?}");
}
}
/// A dma-buf's window is the range rounded out to the host page alone (`import_window` at an
/// alignment of 1): where the device's import alignment for host pointers refuses a range
/// (`BeyondPages`), it still covers exactly the pages the range touches, and where the alignment
/// takes one, the two windows agree (`host_window` keeps one).
#[test]
fn a_dma_buf_window_is_the_pages_the_range_touches() {
let (page, unit, at) = (4096, 64 << 10, 0x7f00_0000_0000);
assert_eq!(
import_window(at, unit, page, unit),
import_window(at, unit, page, 1)
);
assert_eq!(
import_window(at + page + 100, page, page, unit),
Err(WindowRefusal::BeyondPages)
);
assert_eq!(
import_window(at + page + 100, page, page, 1),
Ok(ImportWindow {
start: at + page,
size: 2 * page,
offset: 100,
})
);
}
/// A source's chunks must cover the request, each a whole number of host pages, every boundary at
/// a multiple of the granule; several chunks cover the request rounded up to the granule (the
/// last one padded past the pages, as a sparse buffer binds whole granules), one chunk the request
/// or that rounding; one chunk is the only answer where the granule is the length.
#[cfg(unix)]
#[test]
fn a_source_s_chunks_cover_the_request_at_its_granule() {
use crate::dma_buf::{chunks_cover, DmaBufRequest};
let page = 4096;
let start = std::ptr::NonNull::<u8>::dangling();
let request = |length, granule| DmaBufRequest {
start,
length,
granule,
};
let one = request(8 * page, 8 * page);
assert!(chunks_cover(&[8 * page], &one, page));
assert!(!chunks_cover(&[], &one, page));
assert!(!chunks_cover(&[4 * page, 4 * page], &one, page));
assert!(!chunks_cover(&[7 * page], &one, page));
assert!(!chunks_cover(&[9 * page], &one, page));
let paged = request(8 * page, page);
assert!(chunks_cover(&[3 * page, page, 4 * page], &paged, page));
assert!(!chunks_cover(&[3 * page, 0, 5 * page], &paged, page));
assert!(!chunks_cover(
&[3 * page + 512, 5 * page - 512],
&paged,
page
));
let coarse = request(8 * page, 2 * page);
assert!(chunks_cover(&[2 * page, 6 * page], &coarse, page));
assert!(!chunks_cover(&[3 * page, 5 * page], &coarse, page));
// Several chunks end at the request rounded up to the granule: the last one is padded.
let ragged = request(5 * page, 2 * page);
assert!(chunks_cover(&[4 * page, 2 * page], &ragged, page));
assert!(chunks_cover(&[2 * page, 2 * page, 2 * page], &ragged, page));
assert!(!chunks_cover(&[4 * page, page], &ragged, page));
assert!(!chunks_cover(&[4 * page, 4 * page], &ragged, page));
// One chunk is the pages, or the pages padded to the granule.
assert!(chunks_cover(&[5 * page], &ragged, page));
assert!(chunks_cover(&[6 * page], &ragged, page));
assert!(!chunks_cover(&[7 * page], &ragged, page));
assert!(!chunks_cover(
&[u64::MAX - page + 1, 2 * page],
&ragged,
page
));
// A 64 KiB granule on 4 KiB pages, as RADV of Mesa 26.2.4 binds sparse buffers.
let granule = 64 << 10;
let window = request(16_201 * page, granule);
let rounded = (16_201 * page).next_multiple_of(granule);
let mut lengths = vec![4 << 20; 15];
lengths.push(rounded - 15 * (4 << 20));
assert!(chunks_cover(&lengths, &window, page));
assert!(chunks_cover(&[16_201 * page], &window, page));
lengths.pop();
lengths.push(16_201 * page - 15 * (4 << 20));
assert!(!chunks_cover(&lengths, &window, page));
}
@@ -16,7 +16,7 @@
use crate::pipeline::pool::held;
use crate::{
BlitOption, Buffer, ClearColor, CommandBufferStatus, Device, DeviceKind, DeviceOptions,
LoadAction, Origin, PipelineOptions, RenderPassDescriptor, RenderPipelineState,
HostMemory, LoadAction, Origin, PipelineOptions, RenderPassDescriptor, RenderPipelineState,
ResourceOptions, ShaderCacheOptions, Size, StoreAction, Texture, TextureDescriptor,
};
use metal2vulkan::metal::{PixelFormat, PrimitiveType, TextureUsage};
@@ -122,7 +122,7 @@ fn no_copy_texture(device: &Device, freed: &Arc<AtomicBool>) -> (Buffer, Texture
// deallocator unrun, and the memory then leaks.
let buffer = unsafe {
device.new_buffer_with_bytes_no_copy(
memory,
HostMemory::new(memory),
NO_COPY as u64,
ResourceOptions::shared(),
Some(Box::new(move |pointer, _| {
+415 -45
View File
@@ -134,6 +134,7 @@ use stand_in::StandIn;
use std::any::Any;
use std::collections::{BTreeSet, HashMap};
use std::ops::Range;
use std::ptr::NonNull;
use std::sync::atomic::{AtomicBool, AtomicU64, Ordering};
use std::sync::{Arc, Mutex, Weak};
use wrapped::WrappedImage;
@@ -448,7 +449,8 @@ struct Image {
/// It was made with host-transfer usage, moved to `GENERAL` and zeroed on the host, so its
/// CPU copies may run there (`texture/host_copy.rs`).
host_copies: bool,
/// Its `VkImage` has linear tiling: a texture over a buffer's memory (`alias_image`), or a
/// Its `VkImage` has linear tiling, or `DRM_FORMAT_MOD_LINEAR`'s, whose rows lie as a linear
/// image's: a texture over a buffer's memory (`alias_image`, `dma_buf_alias_image`), or a
/// heap's linear image (`texture/heap.rs`). Not a Metal texture over a buffer
/// (`metal_alias_image`), which renders where Metal's textures do.
linear: bool,
@@ -484,17 +486,61 @@ enum RawGoes {
}
/// An image's `VkImage`: its own for good, but for a texture bound to the bytes of a heap over
/// host pages, whose image a rebind re-makes over the new pages ([`Image::swap_in`]).
struct Raw(AtomicU64);
/// host pages, whose image a rebind re-makes over the new pages ([`Image::swap_in`]). With it, the
/// dedicated import its `VkImage` is bound to, for an image over dma-buf pages (`dma_buf.rs`),
/// which goes with that `VkImage`, after it.
struct Raw {
image: AtomicU64,
import: Mutex<Option<ImageImport>>,
}
/// The dedicated import of the pages a texture's image over dma-buf pages is bound to
/// (`dma_buf.rs`), freed after the image is destroyed.
#[cfg(unix)]
pub(super) type ImageImport = Arc<crate::dma_buf::DmaBufPages>;
/// No image is made over dma-buf pages on this system.
#[cfg(not(unix))]
pub(super) type ImageImport = std::convert::Infallible;
impl Raw {
fn new(raw: vk::Image) -> Raw {
Raw(AtomicU64::new(raw.as_raw()))
Raw {
image: AtomicU64::new(raw.as_raw()),
import: Mutex::new(None),
}
}
/// `raw`, bound to `import`, its dedicated import.
#[cfg(unix)]
fn imported(raw: vk::Image, import: ImageImport) -> Raw {
Raw {
image: AtomicU64::new(raw.as_raw()),
import: Mutex::new(Some(import)),
}
}
/// Whether the `VkImage` now is bound to a dedicated import of its own pages.
fn dedicated(&self) -> bool {
lock(&self.import).is_some()
}
/// The `VkImage` now.
fn get(&self) -> vk::Image {
vk::Image::from_raw(self.0.load(Ordering::Acquire))
vk::Image::from_raw(self.image.load(Ordering::Acquire))
}
/// Hold `raw`, bound to `import` where it has a dedicated one, from now on: the `VkImage` it
/// held and that one's import.
fn swap(
&self,
raw: vk::Image,
import: Option<ImageImport>,
) -> (vk::Image, Option<ImageImport>) {
let mut held = lock(&self.import);
let old = self.image.swap(raw.as_raw(), Ordering::AcqRel);
let old_import = std::mem::replace(&mut *held, import);
(vk::Image::from_raw(old), old_import)
}
}
@@ -507,6 +553,9 @@ pub(super) struct ImageObjects {
views: Vec<vk::ImageView>,
/// What becomes of `raw` as this goes.
raw_goes: RawGoes,
/// The dedicated import `raw` is bound to, an image over dma-buf pages (`dma_buf.rs`): freed
/// as this goes, after `raw` is destroyed.
import: Option<ImageImport>,
}
impl Drop for ImageObjects {
@@ -640,19 +689,50 @@ fn first_color_subresource() -> vk::ImageSubresource {
/// (`shadowed-texture`) names.
type Aliased = Result<Arc<Image>, String>;
/// A linear image aliasing the host pages of a no-copy buffer (or of a no-copy heap, for a
/// texture over one of its buffers), noted in the pages' hold (`buffer.rs`'s `HostCell`) so that
/// a rebind makes it again over the new pages ([`Device::rebound_alias_images`]): the image, and
/// where it is bound, in bytes from where the pages' bytes start in their memory.
/// An image aliasing the host pages of a no-copy buffer (or of a no-copy heap, for a texture over
/// one of its buffers), noted in the pages' hold (`buffer.rs`'s `HostCell`) so that a rebind makes
/// it again over the new pages ([`Device::rebound_alias_images`]): the image, and where its texels
/// lie, in bytes from where the pages' bytes start (in their memory, and in the host addresses
/// they lie at).
#[derive(Clone)]
pub(super) struct AliasWatch {
image: Weak<Image>,
from_base: u64,
/// The texture's type: a 2D texture or array.
texture_type: TextureType,
/// The Metal texture over the import's `MTLBuffer` the image is made of, where it is one
/// (`metal_texture.rs`); else a linear image made for host allocations.
metal: Option<MetalOver>,
/// What the image is made as.
kind: AliasKind,
}
/// What an aliasing image over host pages is made as ([`AliasWatch`]).
#[derive(Clone)]
pub(super) enum AliasKind {
/// A linear image, its rows (and slices) the texels' pitches apart: over pages imported by
/// their pointer, one made for host allocations and bound in the pages' import
/// ([`Device::alias_image`]); over pages imported as dma-bufs, a `DRM_FORMAT_MOD_LINEAR` image
/// bound to a dedicated import of a dma-buf of its own pages
/// ([`Device::dma_buf_alias_image`]). A rebind makes the kind its new pages take.
Linear { row_pitch: u64, slice_pitch: u64 },
/// A Metal texture over the import's `MTLBuffer` (`metal_texture.rs`).
Metal(MetalOver),
}
/// The images a rebind made for the textures over the bytes it gives pages it imported as
/// dma-bufs ([`Device::dma_buf_images_again`]), before it settled: each texture's image with its
/// new `VkImage`, bound to a dedicated import of its own pages (`dma_buf.rs`). Dropped unused,
/// they go.
#[derive(Default)]
pub(super) struct Remade(Vec<(Arc<Image>, ImageObjects)>);
impl Remade {
/// The objects made for `image`, where some were.
fn take(&mut self, image: &Arc<Image>) -> Option<ImageObjects> {
let at = self
.0
.iter()
.position(|(made, _)| Arc::ptr_eq(made, image))?;
Some(self.0.swap_remove(at).1)
}
}
impl AliasWatch {
@@ -670,6 +750,20 @@ impl ImageObjects {
raw,
views: Vec::new(),
raw_goes: RawGoes::Destroyed,
import: None,
}
}
/// `raw`, a new image of `device`'s bound to `import`, its dedicated import of dma-buf pages
/// (`dma_buf.rs`), with no views yet.
#[cfg(unix)]
fn imported(device: &Device, raw: vk::Image, import: ImageImport) -> ImageObjects {
ImageObjects {
device: device.clone(),
raw,
views: Vec::new(),
raw_goes: RawGoes::Destroyed,
import: Some(import),
}
}
@@ -702,6 +796,22 @@ impl ImageSwap {
}
}
/// `objects`, a new image for `image` over `pages`, dma-buf pages, bound to a dedicated import
/// of them (`dma_buf.rs`) and made `UNDEFINED`, to swap in: its first move acquires it from
/// `VK_QUEUE_FAMILY_FOREIGN_EXT` for `family` (`Device::foreign_acquirer`).
fn acquired(
image: Arc<Image>,
objects: ImageObjects,
pages: &HostPages,
family: u32,
) -> ImageSwap {
let swap = ImageSwap::new(image, objects, vk::ImageLayout::UNDEFINED, pages);
ImageSwap {
first: swap.first.acquired(family),
..swap
}
}
/// Whether the swap is `image`'s.
fn is_of(&self, image: &Arc<Image>) -> bool {
Arc::ptr_eq(&self.image, image)
@@ -798,8 +908,9 @@ impl Image {
fn swap_in(&self, objects: &mut ImageObjects) {
let mut views = lock(&self.views);
self.views_go();
let old = self.raw.0.swap(objects.raw.as_raw(), Ordering::AcqRel);
objects.raw = vk::Image::from_raw(old);
let (old, import) = self.raw.swap(objects.raw, objects.import.take());
objects.raw = old;
objects.import = import;
objects.views.extend(views.drain().map(|(_, view)| view));
// A stand-in's read image swapped out goes as the stand-in's (an image in memory of its
// own swaps its own back instead, `present_own`).
@@ -894,7 +1005,9 @@ impl Image {
return None;
}
self.views_go();
let old = vk::Image::from_raw(self.raw.0.swap(stand_in.read().as_raw(), Ordering::AcqRel));
let (old, import) = self.raw.swap(stand_in.read(), None);
// An image in memory of its own keeps its `VkImage`, which no dedicated import is bound
// to (only an image over dma-buf pages has one).
let own = self.own_memory().then_some(old);
// An image bound to the detached pages lets go of their memory: its `VkImage` goes with
// the pages.
@@ -906,11 +1019,13 @@ impl Image {
None => RawGoes::Destroyed,
};
*detached = Some(DetachedImage { stand_in, own });
// A dedicated import of dma-buf pages goes with the `VkImage` bound to it.
Some(ImageObjects {
device: self.device.clone(),
raw: old,
views: views.drain().map(|(_, view)| view).collect(),
raw_goes,
import,
})
}
@@ -925,12 +1040,13 @@ impl Image {
let own = detached.as_ref()?.own?;
let stand_in = detached.take()?.stand_in;
self.views_go();
let old = vk::Image::from_raw(self.raw.0.swap(own.as_raw(), Ordering::AcqRel));
let (old, import) = self.raw.swap(own, None);
Some(ImageObjects {
device: self.device.clone(),
raw: old,
views: views.drain().map(|(_, view)| view).collect(),
raw_goes: RawGoes::WithStandIn(stand_in),
import,
})
}
@@ -1815,20 +1931,35 @@ impl Device {
// Over bytes detached from their pages (`detach.rs`) no image aliases them: the texture
// is their shadow, which presents a stand-in until they lie in pages again.
let detached = texels.buffer.detached();
if wider != plan && !detached {
if let Ok(image) = self.alias_image(wider, layout, descriptor, &texels, &facts)? {
return Ok(Storage::Alias { image, texels });
}
}
let dma_buf = texels.buffer.over_dma_buf();
// Where no image aliases the bytes, the reason the plan's attempt gives is the notice's.
let why = match detached {
true => "the buffer's bytes were detached from their pages (detach_backing) as the \
texture was made"
.to_owned(),
false => match self.alias_image(plan.clone(), layout, descriptor, &texels, &facts)? {
let why = if detached {
"the buffer's bytes were detached from their pages (detach_backing) as the texture \
was made"
.to_owned()
} else if dma_buf {
// Over dma-buf pages, one image of the two plans at most, its pages' source called
// once (`dma_buf.rs`).
let plans = [&wider, &plan];
let plans = if wider != plan {
&plans[..]
} else {
&plans[1..]
};
match self.dma_buf_alias_image(plans, layout, descriptor, &texels, &facts)? {
Ok(image) => return Ok(Storage::Alias { image, texels }),
Err(why) => why,
},
}
} else {
if wider != plan {
if let Ok(image) = self.alias_image(wider, layout, descriptor, &texels, &facts)? {
return Ok(Storage::Alias { image, texels });
}
}
match self.alias_image(plan.clone(), layout, descriptor, &texels, &facts)? {
Ok(image) => return Ok(Storage::Alias { image, texels }),
Err(why) => why,
}
};
let plan = self.with_undeclared_usage(plan, layout, usage, false, &facts)?;
if !plan
@@ -2028,7 +2159,8 @@ impl Device {
/// makes it again over ([`Device::rebound_alias_images`]); on a device whose imports give
/// their `MTLBuffer`s it is instead made of a Metal texture over the import's `MTLBuffer`
/// ([`Device::metal_alias_image`]), which renders where the driver's linear images do not.
/// The image's hazard tracking is the buffer's.
/// Pages the runtime imported as dma-buf memory take [`Device::dma_buf_alias_image`]'s image
/// instead. The image's hazard tracking is the buffer's.
fn alias_image(
&self,
plan: ImagePlan,
@@ -2158,7 +2290,10 @@ impl Device {
image: Arc::downgrade(&image),
from_base: memory_offset - base,
texture_type: layout.texture_type,
metal: None,
kind: AliasKind::Linear {
row_pitch: texels.layout.row_pitch,
slice_pitch: texels.layout.slice_pitch,
},
});
}
Ok(Ok(image))
@@ -2239,11 +2374,140 @@ impl Device {
image: Arc::downgrade(&image),
from_base: memory_offset - base,
texture_type: layout.texture_type,
metal: Some(over),
kind: AliasKind::Metal(over),
});
Ok(Ok(image))
}
/// The image of the first of `plans` the device makes over `texels`, whose bytes lie in host
/// pages the runtime imported as dma-buf memory (`dma_buf.rs`): a `DRM_FORMAT_MOD_LINEAR`
/// image bound to a dedicated import of a dma-buf of its own pages, which the pages' source
/// makes (called once), its rows the texels' rows; noted in the pages' hold, which a rebind
/// makes it again over ([`Device::rebound_alias_images`]). Its first move acquires it from
/// `VK_QUEUE_FAMILY_FOREIGN_EXT` into `GENERAL`, keeping the bytes. It aliases the buffer's
/// bytes through another import of the same pages, so its hazard tracking is the buffer's (its
/// key), as every image aliasing a buffer's bytes is: a write through the one orders before a
/// read through the other in a command buffer, by the tracker's memory barriers. Where the
/// device makes none, why, the fallback counted (`WorkCounts::dma_buf_image_fallbacks`): the
/// texture takes the way a texture over memory no image aliases takes.
#[cfg(unix)]
fn dma_buf_alias_image(
&self,
plans: &[&ImagePlan],
layout: &TextureLayout,
descriptor: &TextureDescriptor,
texels: &Texels,
facts: &ImageFacts<'_>,
) -> Result<Aliased, Error> {
let pages = texels.buffer.host_pages();
let over = pages.as_deref().and_then(HostPages::dma_buf);
let Some((imports, start, type_index)) = over else {
return Err(internal(
"a texture over dma-buf pages the buffer does not lie in",
));
};
let base = texels.buffer.pages_base()?;
let (_, buffer_offset, _) = texels.buffer.memory();
let from_base = buffer_offset + texels.layout.offset - base;
let (row_pitch, slice_pitch) = (texels.layout.row_pitch, texels.layout.slice_pitch);
let place = crate::dma_buf::DmaBufTexels {
pages: imports,
type_index,
at: start + from_base,
row_pitch,
slice_pitch,
};
let made = match self.dma_buf_image(plans, facts, &place)? {
Ok(made) => made,
Err(why) => {
self.shared().counts.dma_buf_image_fell_back();
return Ok(Err(format!(
"the buffer's host pages are imported as dma-buf memory, and {why}"
)));
}
};
let (index, made) = made;
let owner = Owner::Buffer {
memory: Mutex::new(texels.buffer.memory_hold()),
};
let image = self.dma_buf_texture_image(
made,
plans[index].clone(),
owner,
(texels.options(), descriptor.allow_gpu_optimized_contents),
// The buffer's bytes, tracked as the texture is.
Identity {
tracked: texels.tracked(),
..texels.buffer.identity()
},
);
let image = image.shared();
texels.buffer.watch_alias(AliasWatch {
image: Arc::downgrade(&image),
from_base,
texture_type: layout.texture_type,
kind: AliasKind::Linear {
row_pitch,
slice_pitch,
},
});
Ok(Ok(image))
}
/// The image of a texture over dma-buf pages (over a buffer, or placed in a heap), `made` of
/// `plan` (`dma_buf.rs`), with its `owner`, its options and whether it allows GPU-optimized
/// contents, and the `identity` of its bytes: a `DRM_FORMAT_MOD_LINEAR` image, whose rows are a
/// linear image's (a write of its bytes is a write of its texels), its first move acquiring
/// it from `VK_QUEUE_FAMILY_FOREIGN_EXT` into `GENERAL`, keeping the bytes.
#[cfg(unix)]
fn dma_buf_texture_image(
&self,
made: crate::dma_buf::DmaBufImage,
plan: ImagePlan,
owner: Owner,
(options, allow_gpu_optimized_contents): (ResourceOptions, bool),
identity: Identity,
) -> Image {
let crate::dma_buf::DmaBufImage { raw, import } = made;
let image = Image {
device: self.clone(),
raw: Raw::imported(raw, import),
owner,
plan,
options,
allow_gpu_optimized_contents,
identity,
views: Mutex::new(HashMap::new()),
twin: None,
decoded: None,
form: Default::default(),
kept_outside: AtomicBool::new(false),
detached: Mutex::new(None),
first_move: Mutex::new(None),
host_copies: false,
linear: true,
staging_copies: false,
objects: ObjectsToken::default(),
};
let first = FirstMove::new(raw, image.plan().format, vk::ImageLayout::UNDEFINED, true)
.acquired(self.foreign_acquirer());
*lock(&image.first_move) = Some(first);
image
}
/// No host pages are imported as dma-bufs on this system.
#[cfg(not(unix))]
fn dma_buf_alias_image(
&self,
_plans: &[&ImagePlan],
_layout: &TextureLayout,
_descriptor: &TextureDescriptor,
_texels: &Texels,
_facts: &ImageFacts<'_>,
) -> Result<Aliased, Error> {
Err(internal("a texture over dma-buf pages on a system of none"))
}
/// A `VkImage` of `plan` (of Metal's `texture_type`), made of the Metal texture `over`
/// describes over the `MTLBuffer` of `memory`, an import allocated for its export, from
/// `offset`: treated as bound (`VkImportMetalTextureInfoEXT`). Where none is made, why (for
@@ -2395,16 +2659,25 @@ impl Device {
/// The aliasing images of `watches`, over a no-copy buffer's (or a no-copy heap's) host
/// pages, made again over a rebind's new `pages` (`rebind.rs`): each of the same plan, made
/// for host allocations as [`alias_image`](Self::alias_image) made it, bound as far from the
/// new pages' first byte as it was from the old's; swapped in once the rebind is made, the
/// device's next submission that names it moving it to `GENERAL`. Refused
/// (`NotImplemented(RebindTextures)`) where the device makes no such image there: the new
/// import's memory type is not one the image takes, or the image's alignment misses its place.
/// as the new pages take it, its texels as far from the new pages' first byte as they were
/// from the old's; swapped in once the rebind is made, the device's next submission that
/// names it moving it to `GENERAL`. Over pages imported by their pointer, an image made for
/// host allocations as [`alias_image`](Self::alias_image) made it, bound in their import (or
/// a Metal texture over its `MTLBuffer`, as [`metal_alias_image`](Self::metal_alias_image)
/// made it); over pages imported as dma-bufs (`dma_buf.rs`), the `DRM_FORMAT_MOD_LINEAR`
/// image `remade` holds for it, made before the rebind settled
/// ([`dma_buf_images_again`](Self::dma_buf_images_again)), which its first move acquires
/// from `VK_QUEUE_FAMILY_FOREIGN_EXT`. Refused (`NotImplemented(RebindTextures)`) where the
/// device makes no such image there: the new import's memory type is not one the image
/// takes, the image's alignment misses its place, `remade` holds none for it, or a Metal
/// texture's pages are imported as dma-bufs.
pub(super) fn rebound_alias_images(
&self,
watches: &[AliasWatch],
pages: &HostPages,
mut remade: Remade,
) -> Result<Vec<ImageSwap>, Error> {
let dma_buf = pages.over_dma_buf();
let (memory, base) = pages.memory();
let type_index = pages.type_index();
let raw_device = self.shared().vk();
@@ -2414,32 +2687,59 @@ impl Device {
continue;
};
let at = base + watch.from_base;
if let Some(over) = &watch.metal {
let made = self.metal_image(image.plan(), over, watch.texture_type, memory, at)?;
let Ok(raw) = made else {
if dma_buf {
let objects = match &watch.kind {
AliasKind::Linear { .. } => remade.take(&image),
AliasKind::Metal(_) => None,
};
let Some(objects) = objects else {
return Err(Error::NotImplemented(RuntimeGap::RebindTextures));
};
let family = self.foreign_acquirer();
// Dropped on a later failure, the images made so far go.
swaps.push(ImageSwap::new(
Arc::clone(&image),
ImageObjects::new(self, raw),
vk::ImageLayout::UNDEFINED,
pages,
));
swaps.push(ImageSwap::acquired(image, objects, pages, family));
continue;
}
let (row_pitch, slice_pitch) = match &watch.kind {
AliasKind::Linear {
row_pitch,
slice_pitch,
} => (*row_pitch, *slice_pitch),
AliasKind::Metal(over) => {
let made =
self.metal_image(image.plan(), over, watch.texture_type, memory, at)?;
let Ok(raw) = made else {
return Err(Error::NotImplemented(RuntimeGap::RebindTextures));
};
// Dropped on a later failure, the images made so far go.
swaps.push(ImageSwap::new(
Arc::clone(&image),
ImageObjects::new(self, raw),
vk::ImageLayout::UNDEFINED,
pages,
));
continue;
}
};
let made = self.host_linear_image(image.plan())?;
let Ok(LinearMade {
raw,
requirements,
report,
initial,
..
}) = made
else {
return Err(Error::NotImplemented(RuntimeGap::RebindTextures));
};
// Its rows (and slices) must lie as the old image's did: a `DRM_FORMAT_MOD_LINEAR`
// image's are the texture's, which the driver's linear image may not take.
let plan = image.plan();
let slices = plan.layers.max(plan.extent[2]);
if requirements.memory_type_bits & (1 << type_index) == 0
|| !at.is_multiple_of(requirements.alignment.max(1))
|| report.offset != 0
|| report.row_pitch != row_pitch
|| (slices > 1 && report.array_pitch != slice_pitch)
{
// SAFETY: the image is live and unbound, and no command uses it.
unsafe { release::object(raw_device, raw) };
@@ -2464,6 +2764,76 @@ impl Device {
Ok(swaps)
}
/// The images of the textures over a no-copy buffer's (or a no-copy heap's) bytes, made for a
/// rebind's new pages, which it imported as dma-bufs (`placement`), the bytes at `pointer`:
/// for each linear one `watches` note, a `DRM_FORMAT_MOD_LINEAR` image of its plan over the
/// one dma-buf the pages' source makes of its own pages ([`Device::dma_buf_image`]), its
/// texels as far from the new bytes' first as they were from the old's, and its rows as far
/// apart; and for each of `heap`'s textures bound to its bytes, one in the driver's layout at
/// its offset (`texture/heap.rs`). Made before the rebind settles, with no lock of the
/// runtime's held: the source is called once for each. Nothing for pages imported by their
/// pointer. Refused (`NotImplemented(RebindTextures)`), what was made released, where the
/// device makes no such image of one (`dma_buf_image`'s reasons).
#[cfg(unix)]
pub(super) fn dma_buf_images_again(
&self,
watches: &[AliasWatch],
heap: Option<&Heap>,
placement: &Placement,
pointer: NonNull<u8>,
) -> Result<Remade, Error> {
let mut remade = Remade::default();
let Some(imports) = placement.dma_buf_pages() else {
return Ok(remade);
};
if let Some(heap) = heap {
let type_index = placement.type_index();
self.dma_buf_heap_images_again(heap, imports, type_index, pointer, &mut remade)?;
}
let facts = self
.shared()
.textures
.facts(self.compile_device().profile());
for watch in watches {
let Some(image) = watch.image.upgrade() else {
continue;
};
// A Metal texture's rebind to dma-buf pages is refused as the swaps are made.
let AliasKind::Linear {
row_pitch,
slice_pitch,
} = watch.kind
else {
continue;
};
let texels = crate::dma_buf::DmaBufTexels {
pages: imports,
type_index: placement.type_index(),
at: pointer.as_ptr() as u64 + watch.from_base,
row_pitch,
slice_pitch,
};
let Ok((_, made)) = self.dma_buf_image(&[image.plan()], &facts, &texels)? else {
return Err(Error::NotImplemented(RuntimeGap::RebindTextures));
};
let objects = ImageObjects::imported(self, made.raw, made.import);
remade.0.push((image, objects));
}
Ok(remade)
}
/// No pages are imported as dma-bufs on this system: nothing is made.
#[cfg(not(unix))]
pub(super) fn dma_buf_images_again(
&self,
_watches: &[AliasWatch],
_heap: Option<&Heap>,
_placement: &Placement,
_pointer: NonNull<u8>,
) -> Result<Remade, Error> {
Ok(Remade::default())
}
/// The image of `plan` for a texture of `layout` made with `descriptor` (and its hazard
/// tracking mode `hazard`), checked against the device's limits for it, placed, and in the
/// `GENERAL` layout.
@@ -17,7 +17,12 @@
//! too; its image of a format a clear writes is cleared ([`FirstMove::cleared`]) rather than
//! copied over, single- or multisampled. An image that takes a rebind's new `VkImage` notes that
//! one's (`rebind.rs`). The image (or stand-in) is registered weakly once it is shared
//! ([`FirstMoves::register`]). A new buffer whose bytes the host cannot write (`Private`, and a
//! ([`FirstMoves::register`]). An image over a dma-buf of its own pages (`dma_buf.rs`) starts
//! `UNDEFINED` too, and its move is an acquire from `VK_QUEUE_FAMILY_FOREIGN_EXT` for the
//! device's queue family (`VK_QUEUE_FAMILY_IGNORED` where its images are concurrent among
//! several), from `GENERAL` (which keeps its bytes, as Vulkan's foreign images keep theirs only
//! through such an acquire) to `GENERAL` ([`FirstMove::acquired`]); it rests there.
//! A new buffer whose bytes the host cannot write (`Private`, and a
//! `Managed` buffer's device copy) notes its fill with zeros ([`FirstFill`]) the same way
//! (`Buffer::clear_first`), and a new `Private` buffer made with bytes then the copy of a staging
//! buffer's (`Buffer::fill_first_from`). So do a sparse texture's image (its move; an emulated
@@ -97,6 +102,9 @@ pub(crate) struct FirstMove {
/// Metal's pattern over the image's first levels, which the zeros then leave
/// ([`FirstMove::patterned`]).
pattern: Option<Patterned>,
/// The queue family the move acquires the image for from `VK_QUEUE_FAMILY_FOREIGN_EXT`, an
/// image over dma-buf pages the CPU writes ([`FirstMove::acquired`]).
acquire: Option<u32>,
}
/// How a first move writes Metal's pattern into the first `levels` levels of its image, of
@@ -208,9 +216,23 @@ impl FirstMove {
zero: None,
rebindable,
pattern: None,
acquire: None,
}
}
/// The move, an acquire of the image from `VK_QUEUE_FAMILY_FOREIGN_EXT` for `family` (the
/// device's one queue family, or `VK_QUEUE_FAMILY_IGNORED` for an image concurrent among
/// several, `sharing.rs`): an image over dma-buf pages (`dma_buf.rs`), made `UNDEFINED` as
/// Vulkan makes an image of external memory, whose bytes the CPU wrote outside Vulkan. It
/// moves from `GENERAL`, the layout of the bytes as they lie, which an acquire keeps; a move
/// from `UNDEFINED` may discard them, and so may a queue family that takes an exclusive
/// image without one.
pub(crate) fn acquired(mut self, family: u32) -> FirstMove {
self.old = vk::ImageLayout::GENERAL;
self.acquire = Some(family);
self
}
/// The move, which also writes every texel `copies` reach (`zero_copies`) with zero bytes
/// from `zeros`.
pub(crate) fn zeroed(mut self, zeros: vk::Buffer, copies: &[ImageRegion]) -> FirstMove {
@@ -486,15 +508,19 @@ impl FirstMove {
exit_guard::called(Call::CmdPipelineBarrier);
}
/// The barrier of the move.
/// The barrier of the move: an acquire from `VK_QUEUE_FAMILY_FOREIGN_EXT` where it is one.
fn barrier(&self) -> vk::ImageMemoryBarrier<'static> {
let (source, target) = match self.acquire {
Some(family) => (vk::QUEUE_FAMILY_FOREIGN_EXT, family),
None => (vk::QUEUE_FAMILY_IGNORED, vk::QUEUE_FAMILY_IGNORED),
};
vk::ImageMemoryBarrier::default()
.src_access_mask(vk::AccessFlags::MEMORY_WRITE)
.dst_access_mask(vk::AccessFlags::MEMORY_READ | vk::AccessFlags::MEMORY_WRITE)
.old_layout(self.old)
.new_layout(vk::ImageLayout::GENERAL)
.src_queue_family_index(vk::QUEUE_FAMILY_IGNORED)
.dst_queue_family_index(vk::QUEUE_FAMILY_IGNORED)
.src_queue_family_index(source)
.dst_queue_family_index(target)
.image(self.image)
.subresource_range(self.whole())
}
@@ -20,8 +20,8 @@ use super::{Image, Owner, Storage, Texture};
use crate::buffer::MemoryHold;
use crate::device::lock;
use crate::{
Device, DeviceKind, DeviceOptions, HeapDescriptor, HeapType, Region, ResourceOptions,
ShaderCacheOptions, TextureDescriptor,
Device, DeviceKind, DeviceOptions, HeapDescriptor, HeapType, HostMemory, Region,
ResourceOptions, ShaderCacheOptions, TextureDescriptor,
};
use metal2vulkan::metal::PixelFormat;
use std::alloc::Layout;
@@ -139,7 +139,12 @@ fn a_waiting_move_of_an_image_a_detach_let_go_of_is_dropped() {
let device = device(&scratch.0);
// SAFETY: the memory outlives the device (dropped after it), and nothing else uses it.
let made = unsafe {
device.new_buffer_with_bytes_no_copy(host.0, BYTES as u64, ResourceOptions::shared(), None)
device.new_buffer_with_bytes_no_copy(
HostMemory::new(host.0),
BYTES as u64,
ResourceOptions::shared(),
None,
)
};
let Ok(buffer) = made else {
eprintln!(
@@ -184,7 +189,9 @@ fn a_host_copy_makes_the_waiting_move_of_an_image_over_host_pages() {
let heap_descriptor =
HeapDescriptor::new(HeapType::Automatic, BYTES as u64, ResourceOptions::shared());
// SAFETY: the memory outlives the device (dropped after it), and nothing else uses it.
let made = unsafe { device.new_heap_with_bytes_no_copy(host.0, &heap_descriptor, None, None) };
let made = unsafe {
device.new_heap_with_bytes_no_copy(HostMemory::new(host.0), &heap_descriptor, None, None)
};
let Ok(heap) = made else {
eprintln!(
"first move lifetimes: no heap over host memory on {}",
+295 -26
View File
@@ -143,7 +143,7 @@ use super::heap_two_planes::{HeapPlaneCopies, TwoPlaneHeapLayout};
use super::stand_in::StandIn;
use super::{
copy_units, image_aspects, image_error, DetachedImage, IdUse, Image, ImageObjects,
ImagePlacement, ImageSwap, Owner, Raw, Storage, Texture, TextureDescriptor, ViewRecord,
ImagePlacement, ImageSwap, Owner, Raw, Remade, Storage, Texture, TextureDescriptor, ViewRecord,
};
use crate::address::ObjectsToken;
use crate::buffer::{
@@ -750,6 +750,12 @@ fn initial_layout(tiling: vk::ImageTiling) -> vk::ImageLayout {
}
}
/// Whether a heap texture's image of `tiling` lays its rows out linearly (`Image::linear`): linear
/// tiling, or `DRM_FORMAT_MOD_LINEAR`'s, the one modifier a heap's image takes (`dma_buf.rs`).
fn linear_tiling(tiling: vk::ImageTiling) -> bool {
tiling == vk::ImageTiling::LINEAR || tiling == vk::ImageTiling::DRM_FORMAT_MODIFIER_EXT
}
/// Metal's answer for a texture buffer of `layout` in a heap (CRF heap probe 1, an M3 Max and an
/// M4 alike): its row of texels exactly, at a multiple of 16 bytes
/// (`minimumTextureBufferAlignmentForPixelFormat:`, `LINEAR_ALIGNMENT`) for every format and
@@ -1682,6 +1688,12 @@ impl Device {
/// buffer), or ask a dedicated allocation (RADV). Elsewhere, and for a texture with a depth
/// twin, `NotImplemented(HeapTextureMemory)`.
///
/// Over pages imported as dma-bufs (`dma_buf.rs`, where the device refused their pointer),
/// where the linear image would be: an image of the driver's `DRM_FORMAT_MOD_LINEAR` layout at
/// the texture's offset, bound to a dedicated import of a dma-buf of its own pages, where its
/// bytes and alignment fit the answer ([`dma_buf_heap_plan`](Self::dma_buf_heap_plan)); else,
/// and where it is not made after all as the texture is, the shadow, counted and announced.
///
/// A texture of a plain format Metal lays out tiled (`HeapLayout::Tiled`) is a shadow of its
/// elements tiled in the heap's bytes (`AliasRoute::Tiled`, `heap_tiled.rs`), where its optimal
/// image takes copies and the moves fit the device; elsewhere it takes the routes above,
@@ -1744,7 +1756,6 @@ impl Device {
.shared()
.textures
.facts(self.compile_device().profile());
let texture_type = p.layout.texture_type;
let (linear, _) = plan_texture_images(&p.layout, descriptor.image_usage(), false, &facts)
.map_err(|refusal| image_error(call, refusal))?;
let SizeAndAlign { size, align } = p.size_and_align;
@@ -1752,6 +1763,15 @@ impl Device {
// one over it (MoltenVK: Metal makes no depth texture over a buffer).
let driver = &self.properties().driver_facts;
let apart = !colour(&linear) && driver.contains(&DriverFact::DepthStencilImagesLieApart);
// Over pages imported as dma-buf memory (`dma_buf.rs`), an image of the driver's
// `DRM_FORMAT_MOD_LINEAR` layout, bound to a dedicated import of a dma-buf of its own
// pages as the texture is made (`heap_texture_at`), where it fits the answer; else the
// shadow below, counted and announced.
let dma_buf = bytes.over_dma_buf();
if !apart && dma_buf {
let image = self.dma_buf_heap_plan(linear, &p, &facts)?;
return Ok(HeapPlan { image, ..p });
}
if !apart && linear_lack(&linear, &facts).is_none() {
let tiling = vk::ImageTiling::LINEAR;
if let Some(requirements) = self.host_image_requirements(&linear)? {
@@ -1769,17 +1789,177 @@ impl Device {
}
}
}
let optimal = self.with_free_usage(linear, texture_type)?;
if !shadowable(&optimal, size) {
let image = self.memory_shadow(linear, &p)?;
Ok(HeapPlan { image, ..p })
}
/// The image of a texture of plan `p` in a heap over pages imported as dma-buf memory
/// (`dma_buf.rs`), `linear` its plan: an image of the driver's `DRM_FORMAT_MOD_LINEAR` layout
/// ([`Device::dma_buf_natural_layout`]) at the texture's offset, made and bound to a dedicated
/// import of a dma-buf of its own pages as the texture is made (`heap_texture_at`), where the
/// device makes one of the plan and its bytes and alignment fit the heap's answer; else a
/// shadow of the heap's bytes ([`dma_buf_heap_shadow`](Self::dma_buf_heap_shadow)).
#[cfg(unix)]
fn dma_buf_heap_plan(
&self,
linear: ImagePlan,
p: &HeapPlan,
facts: &crate::image_plan::ImageFacts<'_>,
) -> Result<HeapImage, Error> {
let SizeAndAlign { size, align } = p.size_and_align;
let why = match self.dma_buf_natural_layout(&linear, facts)? {
Ok(natural) if natural.size <= size && natural.alignment <= align => {
return Ok(HeapImage {
plan: linear,
tiling: vk::ImageTiling::DRM_FORMAT_MODIFIER_EXT,
// The optimal image's, which its shadow takes where none is made.
requirements: p.image.requirements,
route: AliasRoute::Direct,
});
}
Ok(natural) => format!(
"the driver's DRM_FORMAT_MOD_LINEAR image of it takes {} bytes at an alignment \
of {}, past the {size} at {align} the heap answers",
natural.size, natural.alignment
),
Err(why) => why,
};
self.dma_buf_heap_shadow(linear, p, why)
}
/// No pages are imported as dma-bufs on this system: the shadow, as before.
#[cfg(not(unix))]
fn dma_buf_heap_plan(
&self,
linear: ImagePlan,
p: &HeapPlan,
_facts: &crate::image_plan::ImageFacts<'_>,
) -> Result<HeapImage, Error> {
self.memory_shadow(linear, p)
}
/// The image of a texture of plan `p` whose route is a `DRM_FORMAT_MOD_LINEAR` image over
/// dma-buf pages ([`dma_buf_heap_plan`](Self::dma_buf_heap_plan)), at `offset` of the heap
/// whose buffer is `bytes`: made in the driver's layout and bound to a dedicated import of
/// the dma-buf the pages' source makes of its own pages ([`Device::dma_buf_image`]), with no
/// lock of the runtime's held. Where none is made, `p` takes the shadow of the heap's bytes
/// instead ([`dma_buf_heap_shadow`](Self::dma_buf_heap_shadow)), and nothing is answered.
#[cfg(unix)]
fn made_dma_buf_heap_image(
&self,
bytes: &Buffer,
p: &mut HeapPlan,
offset: u64,
) -> Result<Option<crate::dma_buf::DmaBufImage>, Error> {
let pages = bytes.host_pages();
let facts = self
.shared()
.textures
.facts(self.compile_device().profile());
let made = match pages.as_deref().and_then(HostPages::dma_buf) {
None => Err("the heap's bytes lie in no dma-buf pages".to_owned()),
Some((imports, start, type_index)) => {
let pages = (&**imports, type_index, start + offset);
let size = p.size_and_align.size;
self.dma_buf_heap_image(&p.image.plan, &facts, pages, size)?
}
};
let why = match made {
Ok(made) => return Ok(Some(made)),
Err(why) => why,
};
p.image = self.dma_buf_heap_shadow(p.image.plan.clone(), p, why)?;
Ok(None)
}
/// The image of a heap texture of `plan` (viewed as `facts` says) in the driver's
/// `DRM_FORMAT_MOD_LINEAR` layout ([`Device::dma_buf_natural_layout`]), where it takes no more
/// than the texture's `size` bytes, over the one dma-buf the pages' source makes of its own
/// pages ([`Device::dma_buf_image`]): `pages` are the heap's imports, their memory type and
/// the host address of the texture's first byte. Why not, where none is made.
#[cfg(unix)]
fn dma_buf_heap_image(
&self,
plan: &ImagePlan,
facts: &crate::image_plan::ImageFacts<'_>,
(pages, type_index, at): (&crate::dma_buf::DmaBufPages, u32, u64),
size: u64,
) -> Result<Result<crate::dma_buf::DmaBufImage, String>, Error> {
let natural = match self.dma_buf_natural_layout(plan, facts)? {
Ok(natural) if natural.size <= size => natural,
Ok(natural) => {
let taken = natural.size;
let why = format!("the driver's image of it takes {taken} bytes, past its {size}");
return Ok(Err(why));
}
Err(why) => return Ok(Err(why)),
};
let texels = crate::dma_buf::DmaBufTexels {
pages,
type_index,
at,
row_pitch: natural.row_pitch,
slice_pitch: natural.slice_pitch,
};
Ok((self.dma_buf_image(&[plan], facts, &texels)?).map(|(_, made)| made))
}
/// No pages are imported as dma-bufs on this system: never reached.
#[cfg(not(unix))]
fn made_dma_buf_heap_image(
&self,
_bytes: &Buffer,
_p: &mut HeapPlan,
_offset: u64,
) -> Result<Option<std::convert::Infallible>, Error> {
Err(internal(
"a heap texture over dma-buf pages on a system of none",
))
}
/// The image of a texture of plan `p` in a heap over host pages that is a shadow of the heap's
/// bytes in memory of its own (`AliasRoute::MemoryShadow`): `linear`'s plan as an optimal
/// image with the runtime's free usage, where Vulkan copies it to and from the bytes (one
/// sample) and its planes fit the answered size; else `NotImplemented(HeapTextureMemory)`.
fn memory_shadow(&self, linear: ImagePlan, p: &HeapPlan) -> Result<HeapImage, Error> {
let optimal = self.with_free_usage(linear, p.layout.texture_type)?;
if !shadowable(&optimal, p.size_and_align.size) {
return Err(Error::NotImplemented(RuntimeGap::HeapTextureMemory));
}
let image = HeapImage {
Ok(HeapImage {
plan: optimal,
tiling: vk::ImageTiling::OPTIMAL,
requirements: p.image.requirements,
route: AliasRoute::MemoryShadow,
};
Ok(HeapPlan { image, ..p })
})
}
/// [`memory_shadow`](Self::memory_shadow)'s image for a texture of plan `p` in a heap over
/// pages imported as dma-buf memory, of which no image over a dma-buf of its own pages is made
/// for `why` (`dma_buf.rs`): counted (`WorkCounts::dma_buf_image_fallbacks`) and announced
/// once per device (`shadowed-texture`).
fn dma_buf_heap_shadow(
&self,
linear: ImagePlan,
p: &HeapPlan,
why: String,
) -> Result<HeapImage, Error> {
let image = self.memory_shadow(linear, p)?;
self.shared().counts.dma_buf_image_fell_back();
let layout = &p.layout;
self.degrade(Degradation::ShadowedTexture, || {
let [width, height, depth] = layout.extent;
let object = format!(
"a {:?} {:?} texture of {width}x{height}x{depth} in a heap",
layout.pixel_format, layout.texture_type
);
let why = format!(
"the heap's host pages are imported as dma-buf memory, and {why}: its image is \
a shadow of the heap's bytes"
);
(object, why)
});
Ok(image)
}
/// The image of a texture of plan `p` laid out as `tiled` in a heap over host pages
@@ -1874,7 +2054,7 @@ impl Device {
size: u64,
owner: Owner,
) -> Result<Image, Error> {
let (raw, initial) = self.heap_raw_image(
let made = self.heap_raw_image(
&image.plan,
image.tiling,
binding.host,
@@ -1882,6 +2062,9 @@ impl Device {
at,
size,
)?;
let (raw, initial) = made.ok_or_else(|| {
internal("a heap texture's image does not lie where its plan placed it")
})?;
let made = Image {
device: self.clone(),
raw: Raw::new(raw),
@@ -1898,7 +2081,7 @@ impl Device {
detached: Mutex::new(None),
first_move: Mutex::new(None),
host_copies: false,
linear: image.tiling == vk::ImageTiling::LINEAR,
linear: linear_tiling(image.tiling),
staging_copies: false,
objects: ObjectsToken::default(),
};
@@ -1937,7 +2120,7 @@ impl Device {
})),
first_move: Mutex::new(None),
host_copies: false,
linear: image.tiling == vk::ImageTiling::LINEAR,
linear: linear_tiling(image.tiling),
staging_copies: false,
objects: ObjectsToken::default(),
}
@@ -1945,7 +2128,8 @@ impl Device {
/// A `VkImage` of `plan` and `tiling` (made for host allocations where `host`) bound at `at`
/// of `memory`, whose requirements hold at most `size` bytes there, with the layout it
/// starts in, for its caller to move to `GENERAL`.
/// starts in, for its caller to move to `GENERAL`; `None`, nothing made, where its
/// requirements do not (its alignment misses `at`, or it takes more bytes).
fn heap_raw_image(
&self,
plan: &ImagePlan,
@@ -1954,7 +2138,7 @@ impl Device {
memory: vk::DeviceMemory,
at: u64,
size: u64,
) -> Result<(vk::Image, vk::ImageLayout), Error> {
) -> Result<Option<(vk::Image, vk::ImageLayout)>, Error> {
let raw_device = self.shared().vk();
let view_formats = plan.ash_view_formats();
let mut list = vk::ImageFormatListCreateInfo::default();
@@ -1983,9 +2167,7 @@ impl Device {
if !at.is_multiple_of(requirements.alignment.max(1)) || requirements.size > size {
// SAFETY: the image is live and unbound, and no command uses it.
unsafe { release::object(raw_device, raw) };
return Err(internal(
"a heap texture's image does not lie where its plan placed it",
));
return Ok(None);
}
// SAFETY: the image is live and unbound; the memory is the heap's, which the texture
// holds, of a type the image takes (`new_heap_texture`, `host_heap_plan`), at an offset
@@ -1995,22 +2177,29 @@ impl Device {
unsafe { release::object(raw_device, raw) };
return Err(vulkan(error));
}
Ok((raw, initial))
Ok(Some((raw, initial)))
}
/// The images of `heap`'s live textures bound to its bytes, re-made over a rebind's new
/// pages, `pages` (`rebind.rs`): each
/// the same plan, linear and made for host allocations as `host_heap_plan` made it, bound at
/// the texture's offset; swapped in once the rebind is made, the device's next submission
/// that names it moving it to `GENERAL`. A texture held as a shadow of the heap's bytes, or a
/// texture buffer, takes none: the one's copies and the other's views read the heap's buffer as
/// they are recorded or made.
/// pages, `pages` (`rebind.rs`): each the same plan, bound at the texture's offset; swapped in
/// once the rebind is made, the device's next submission that names it moving it to
/// `GENERAL`. Over pages imported by their pointer, linear and made for host allocations as
/// `host_heap_plan` made it; over pages imported as dma-bufs (`dma_buf.rs`), the
/// `DRM_FORMAT_MOD_LINEAR` image `remade` holds for it, made before the rebind settled
/// ([`Device::dma_buf_images_again`]), which its first move acquires from
/// `VK_QUEUE_FAMILY_FOREIGN_EXT`. A texture held as a shadow of the heap's bytes, or a texture
/// buffer, takes none: the one's copies and the other's views read the heap's buffer as they
/// are recorded or made. Refused (`NotImplemented(RebindTextures)`) where no such image is made
/// for a texture bound to the bytes: `remade` holds none for it, or the image made for host
/// allocations does not lie in its place (one made over dma-buf pages before).
pub(crate) fn rebound_heap_images(
&self,
heap: &Heap,
pages: &HostPages,
remade: &mut Remade,
) -> Result<Vec<ImageSwap>, Error> {
let (memory, base) = pages.memory();
let dma_buf = pages.over_dma_buf();
let (textures, _) = heap.textures_from(0);
let mut swaps: Vec<ImageSwap> = Vec::new();
for texture in &textures {
@@ -2023,7 +2212,26 @@ impl Device {
if swaps.iter().any(|swap| swap.is_of(image)) {
continue;
}
let (raw, initial) = self.heap_raw_image(
if dma_buf {
let Some(objects) = remade.take(image) else {
return Err(Error::NotImplemented(RuntimeGap::RebindTextures));
};
let family = self.foreign_acquirer();
// Dropped on a later failure, the images made so far go.
swaps.push(ImageSwap::acquired(
Arc::clone(image),
objects,
pages,
family,
));
continue;
}
// An image over dma-buf pages lies in the layout the driver gives a
// `DRM_FORMAT_MOD_LINEAR` image, which its linear image need not keep.
if image.raw.dedicated() {
return Err(Error::NotImplemented(RuntimeGap::RebindTextures));
}
let made = self.heap_raw_image(
image.plan(),
vk::ImageTiling::LINEAR,
true,
@@ -2031,6 +2239,9 @@ impl Device {
base + place.offset,
place.size,
)?;
let Some((raw, initial)) = made else {
return Err(Error::NotImplemented(RuntimeGap::RebindTextures));
};
// Dropped on a later failure, the images made so far go.
swaps.push(ImageSwap::new(
Arc::clone(image),
@@ -2042,6 +2253,46 @@ impl Device {
Ok(swaps)
}
/// The images of `heap`'s live textures bound to its bytes, made for a rebind's new pages,
/// which it imported as dma-bufs (`imports`, of memory type `type_index`), the heap's bytes at
/// `pointer`, into `remade`: for each, a `DRM_FORMAT_MOD_LINEAR` image of its plan in the
/// driver's layout ([`Device::dma_buf_natural_layout`]) at its offset, over the one dma-buf the
/// pages' source makes of its own pages ([`Device::dma_buf_image`]). With no lock of the
/// runtime's held, as the source is called once for each. Refused
/// (`NotImplemented(RebindTextures)`) where the device makes no such image of one.
#[cfg(unix)]
pub(super) fn dma_buf_heap_images_again(
&self,
heap: &Heap,
imports: &crate::dma_buf::DmaBufPages,
type_index: u32,
pointer: NonNull<u8>,
remade: &mut Remade,
) -> Result<(), Error> {
let facts = self
.shared()
.textures
.facts(self.compile_device().profile());
let (textures, _) = heap.textures_from(0);
for texture in &textures {
let Storage::Image(image) = &texture.0.storage else {
continue;
};
let Owner::Heap(place) = &image.owner else {
continue;
};
if remade.0.iter().any(|(made, _)| Arc::ptr_eq(made, image)) {
continue;
}
let pages = (imports, type_index, pointer.as_ptr() as u64 + place.offset);
let made = self.dma_buf_heap_image(image.plan(), &facts, pages, place.size)?;
let made = made.map_err(|_| Error::NotImplemented(RuntimeGap::RebindTextures))?;
let objects = ImageObjects::imported(self, made.raw, made.import);
remade.0.push((Arc::clone(image), objects));
}
Ok(())
}
/// The texture of plan `p` bound at `place` of its heap, whose buffer is `bytes`, with
/// `options` (the heap's), in the `GENERAL` layout and holding what its bytes held; its depth
/// twin, where it has one, inside the same range.
@@ -2072,6 +2323,16 @@ impl Device {
identity: bytes.identity(),
host: bytes.caller_memory() == Some(CallerMemory::HostPages),
};
// Over dma-buf pages the image of the driver's `DRM_FORMAT_MOD_LINEAR` layout is made
// here, its pages' source called once; where none is, the texture is a shadow of the
// heap's bytes, as it was before such images.
let mut p = p;
let dma_buf_image = match p.image.tiling == vk::ImageTiling::DRM_FORMAT_MODIFIER_EXT {
true if stand_in.is_none() => {
self.made_dma_buf_heap_image(bytes, &mut p, place.offset)?
}
_ => None,
};
let twin = p.twin;
let route = p.image.route;
let twin_route = twin.as_ref().map(|(twin, _)| twin.route);
@@ -2118,11 +2379,19 @@ impl Device {
*lock(&place.memory) = bytes.memory_hold();
let owner = Owner::Heap(Box::new(place));
let image_size = twin.as_ref().map_or(size, |&(_, offset)| offset);
let mut image = match &stand_in {
Some(stand_in) => {
let mut image = match (&stand_in, dma_buf_image) {
(Some(stand_in), _) => {
self.detached_heap_image(&binding, p.image, owner, Arc::clone(stand_in))
}
None => self.bind_heap_image(&binding, p.image, at, image_size, owner)?,
#[cfg(unix)]
(None, Some(made)) => self.dma_buf_texture_image(
made,
p.image.plan,
owner,
(binding.options, binding.allow_gpu_optimized_contents),
binding.identity,
),
_ => self.bind_heap_image(&binding, p.image, at, image_size, owner)?,
};
if let Some((twin, offset)) = twin {
let twin_size = size - offset;
@@ -78,7 +78,6 @@ use crate::tracker::Access;
use crate::values::StorageMode;
use crate::Device;
use ash::vk;
use ash::vk::Handle;
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
use std::sync::{Arc, Condvar, Mutex, MutexGuard, OnceLock, Weak};
use std::time::{Duration, Instant};
@@ -446,11 +445,10 @@ impl Prepared {
return None;
}
image.views_go();
let first = image
.raw
.0
.swap(swapped.objects.raw.as_raw(), Ordering::AcqRel);
swapped.objects.raw = vk::Image::from_raw(first);
let objects = &mut swapped.objects;
let (first, import) = image.raw.swap(objects.raw, objects.import.take());
objects.raw = first;
objects.import = import;
swapped
.objects
.views
@@ -79,6 +79,10 @@ pub(crate) struct Counters {
linear_passes_through_copies: AtomicU64,
draw_states_recorded: AtomicU64,
host_deallocators_delayed: AtomicU64,
dma_buf_imports: AtomicU64,
dma_buf_sparse_buffers: AtomicU64,
dma_buf_images: AtomicU64,
dma_buf_image_fallbacks: AtomicU64,
replay_logs_kept: AtomicU64,
replay_log_bytes: AtomicU64,
encoders_reencoded: AtomicU64,
@@ -415,6 +419,31 @@ impl Counters {
.fetch_add(1, Ordering::Relaxed);
}
/// `chunks` chunks of host pages a caller's source made were imported as dma-buf memory, and
/// a buffer bound in them, where the device refused the pages' pointer (`dma_buf.rs`).
pub(crate) fn dma_buf_imported(&self, chunks: usize) {
self.dma_buf_imports
.fetch_add(chunks as u64, Ordering::Relaxed);
}
/// A no-copy buffer's (or heap's, or rebind's) `VkBuffer` was assembled from several chunks'
/// imports as a sparse buffer (`dma_buf.rs`).
pub(crate) fn dma_buf_sparse_buffer_made(&self) {
self.dma_buf_sparse_buffers.fetch_add(1, Ordering::Relaxed);
}
/// A texture's image over dma-buf pages was made and bound to a dedicated import of a dma-buf
/// of its own pages (`dma_buf.rs`).
pub(crate) fn dma_buf_image_made(&self) {
self.dma_buf_images.fetch_add(1, Ordering::Relaxed);
}
/// A texture over dma-buf pages that such an image would alias took the path of a texture
/// over memory no image aliases instead: the device made no such image of it (`dma_buf.rs`).
pub(crate) fn dma_buf_image_fell_back(&self) {
self.dma_buf_image_fallbacks.fetch_add(1, Ordering::Relaxed);
}
/// A command buffer kept an ended encoder's log of `bytes` bytes (`replay.rs`).
pub(crate) fn replay_log_kept(&self, bytes: usize) {
self.replay_logs_kept.fetch_add(1, Ordering::Relaxed);
@@ -737,6 +766,23 @@ pub struct WorkCounts {
/// it runs once the import is freed (`host-deallocator-delayed`). With a keep-alive the
/// deallocator runs at the release, and none is counted.
pub host_deallocators_delayed: u64,
/// Chunks of host pages imported as dma-buf memory from a caller's source
/// (`HostMemory::with_dma_buf`), where the device refused the pages' pointer: no-copy
/// buffers', heaps' and rebinds' alike, one per chunk. None where every pointer was imported.
pub dma_buf_imports: u64,
/// Of those buffers, heaps and rebinds, the ones whose `VkBuffer` is a sparse buffer
/// assembled from several chunks.
pub dma_buf_sparse_buffers: u64,
/// Images of textures over such dma-buf memory (over a no-copy buffer, placed in a no-copy
/// heap, a view of either), each a `DRM_FORMAT_MOD_LINEAR` image bound to a dedicated import
/// of a dma-buf of its own pages from the caller's source, aliasing the buffer's bytes: one per
/// image made, a rebind's too. Not counted in `dma_buf_imports`.
pub dma_buf_images: u64,
/// Textures over such dma-buf memory that such an image would alias but the device made none
/// (the source failed, the format, usage, extent or plane layout is not supported, or the
/// driver refused the import): each takes the path of a texture over memory no image aliases
/// (`shadowed-texture`).
pub dma_buf_image_fallbacks: u64,
/// Ended compute and blit encoders whose logs their command buffers kept, as a rebind before
/// the first submission may encode them again (`replay.rs`), and the bytes of those logs.
pub replay_logs_kept: u64,
@@ -865,6 +911,10 @@ impl Device {
.load(Ordering::Relaxed),
draw_states_recorded: counters.draw_states_recorded.load(Ordering::Relaxed),
host_deallocators_delayed: counters.host_deallocators_delayed.load(Ordering::Relaxed),
dma_buf_imports: counters.dma_buf_imports.load(Ordering::Relaxed),
dma_buf_sparse_buffers: counters.dma_buf_sparse_buffers.load(Ordering::Relaxed),
dma_buf_images: counters.dma_buf_images.load(Ordering::Relaxed),
dma_buf_image_fallbacks: counters.dma_buf_image_fallbacks.load(Ordering::Relaxed),
replay_logs_kept: counters.replay_logs_kept.load(Ordering::Relaxed),
replay_log_bytes: counters.replay_log_bytes.load(Ordering::Relaxed),
encoders_reencoded: counters.encoders_reencoded.load(Ordering::Relaxed),
@@ -1 +1 @@
6d54d007da67eae179542f08d224b2b404eb7835fd4d5414689bb9a93b15fbc9
291c83b9334b98ab0a1078a1b5048196afc2ce23fe0062ee8949a8d89b1179b3
@@ -24,9 +24,9 @@ use metal2vulkan_devtools::{engine_dir, llvm_assemble};
use metal2vulkan_runtime::{
BlitCommandEncoder, BlitOption, Buffer, ClearColor, CommandBuffer, CommandBufferStatus,
CommandQueue, ComputeCommandEncoder, ComputePipelineState, DebugMessage, Device, EventRef,
Fence, Heap, HeapDescriptor, HeapType, Library, LoadAction, Origin, PipelineOptions,
RenderCommandEncoder, RenderPassDescriptor, RenderPipelineState, ResourceOptions, SharedEvent,
Size, StoreAction, Texture, TextureDescriptor,
Fence, Heap, HeapDescriptor, HeapType, HostMemory, Library, LoadAction, Origin,
PipelineOptions, RenderCommandEncoder, RenderPassDescriptor, RenderPipelineState,
ResourceOptions, SharedEvent, Size, StoreAction, Texture, TextureDescriptor,
};
use std::cell::{Cell, RefCell};
use std::collections::BTreeSet;
@@ -202,7 +202,7 @@ impl SeqApi for RuntimeSeq {
// SAFETY: the caller's contract, `HostMemory::new`'s.
unsafe {
self.device
.new_buffer_with_bytes_no_copy(bytes, length, options, None)
.new_buffer_with_bytes_no_copy(HostMemory::new(bytes), length, options, None)
}
.map_err(refused)
}
@@ -231,6 +231,8 @@ mod device_lockstep;
mod discard_counts;
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
mod discard_hoist;
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd), target_os = "linux"))]
mod dma_buf_imports;
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
mod dont_care_stores;
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
@@ -205,7 +205,7 @@ use metal2vulkan::Budget;
use metal2vulkan_devtools::{engine_dir, llvm_assemble};
use metal2vulkan_runtime::{
BlitOption, CpuCacheMode, DebugMessage, Degradation, DegradationCategory, Device,
DeviceOptions, DriverSetting, Error, HazardTrackingMode, HeapDescriptor, HeapType,
DeviceOptions, DriverSetting, Error, HazardTrackingMode, HeapDescriptor, HeapType, HostMemory,
LayerSetting, LayerSettingValue, LoadAction, MessageSeverity, MetalLevel,
MultisampleStencilResolveFilter, Origin, PipelineOptions, RenderPassDescriptor,
ResourceOptions, RuntimeGap, Size, StorageMode, StoreAction, TextureDescriptor,
@@ -753,7 +753,12 @@ fn the_private_option_bit_is_ignored_once() {
let memory = Mapping::anonymous(GUEST_PAGE);
// SAFETY: the mapping outlives the buffer, which is dropped first.
let no_copy = unsafe {
device.new_buffer_with_bytes_no_copy(memory.pointer(), GUEST_PAGE as u64, shared, None)
device.new_buffer_with_bytes_no_copy(
HostMemory::new(memory.pointer()),
GUEST_PAGE as u64,
shared,
None,
)
};
match no_copy {
Err(error) if not_importable(&error) => {}
@@ -41,9 +41,9 @@ use metal2vulkan::pipeline::{ColorAttachmentDescriptor, RenderPipelineDescriptor
use metal2vulkan_devtools::{engine_dir, llvm_assemble};
use metal2vulkan_runtime::{
Buffer, ClearColor, CommandBuffer, CommandBufferError, CommandBufferStatus, CommandQueue,
Degradation, Device, Error, EventRef, Heap, HeapDescriptor, HeapType, Invalid, LoadAction,
PipelineOptions, Problem, RebindProblem, Region, RenderPassDescriptor, ResourceOptions,
SharedEvent, StoreAction, TextureDescriptor,
Degradation, Device, Error, EventRef, Heap, HeapDescriptor, HeapType, HostMemory, Invalid,
LoadAction, PipelineOptions, Problem, RebindProblem, Region, RenderPassDescriptor,
ResourceOptions, SharedEvent, StoreAction, TextureDescriptor,
};
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
@@ -535,7 +535,7 @@ fn large_heap(device: &Device) -> Option<(Heap, Buffer)> {
// SAFETY: the deallocator releases the mapping once the heap's pages go.
let made = unsafe {
device.new_heap_with_bytes_no_copy(
pointer,
HostMemory::new(pointer),
&descriptor,
Some(recording(&seen, mapping)),
None,
@@ -573,7 +573,7 @@ fn a_detach_of_a_large_heap_allocates_no_device_memory() {
// SAFETY: the deallocator releases the mapping once the buffer's pages go.
let large = unsafe {
device.new_buffer_with_bytes_no_copy(
pointer,
HostMemory::new(pointer),
LARGE as u64,
ResourceOptions::default(),
Some(recording(&seen, mapping)),
File diff suppressed because it is too large. Load diff
@@ -25,7 +25,7 @@ use super::{validated_device, Messages, ScratchCache};
use crate::gpu::{DeviceType, TEST_DEVICE};
use metal2vulkan_runtime::{
Buffer, CommandBuffer, CommandBufferStatus, CommandQueue, Deallocator, Device, DeviceKind,
EventRef, ResourceOptions, SharedEvent, SharedEventListener,
EventRef, HostMemory, ResourceOptions, SharedEvent, SharedEventListener,
};
use std::io::Read;
use std::path::PathBuf;
@@ -322,7 +322,7 @@ fn child() {
// SAFETY: the pages stay mapped for the life of the process.
let made = unsafe {
device.new_buffer_with_bytes_no_copy(
memory,
HostMemory::new(memory),
page as u64,
ResourceOptions::default(),
Some(deallocator),
@@ -178,10 +178,18 @@ impl Busy {
/// word after the spin's flag, ordered after the spin by the buffer both use. The command
/// buffer, and the buffer of the mark.
pub(super) fn commit(&self, device: &Device, queue: &CommandQueue) -> (CommandBuffer, Buffer) {
let command_buffer = queue.command_buffer().unwrap();
let words = self.encode(device, &command_buffer);
command_buffer.commit().unwrap();
(command_buffer, words)
}
/// Encode the busy work into `command_buffer`, as [`commit`](Busy::commit) commits it: the
/// spin and the end mark's blit. The buffer of the mark.
pub(super) fn encode(&self, device: &Device, command_buffer: &CommandBuffer) -> Buffer {
let ticket = buffer_with(device, &1u32.to_le_bytes()).unwrap();
let words = buffer_with(device, &[0; 8]).unwrap();
let cap = buffer_with(device, &self.cap.to_le_bytes()).unwrap();
let command_buffer = queue.command_buffer().unwrap();
let mut encoder = command_buffer.compute_command_encoder().unwrap();
encoder.set_compute_pipeline_state(&self.state).unwrap();
encoder.set_buffer(Some(&ticket), 0, 0).unwrap();
@@ -193,8 +201,7 @@ impl Busy {
let mut blit = command_buffer.blit_command_encoder().unwrap();
blit.fill_buffer(&words, 4..8, 1).unwrap();
blit.end_encoding().unwrap();
command_buffer.commit().unwrap();
(command_buffer, words)
words
}
}
@@ -57,8 +57,8 @@ use metal2vulkan::pipeline::{
use metal2vulkan::Budget;
use metal2vulkan_devtools::llvm_assemble_text;
use metal2vulkan_runtime::{
CommandBufferStatus, ComputePipelineState, Degradation, Device, Error, PipelineOptions, Region,
ResourceOptions, SamplerState, Size, Texture, TextureDescriptor,
CommandBufferStatus, ComputePipelineState, Degradation, Device, Error, HostMemory,
PipelineOptions, Region, ResourceOptions, SamplerState, Size, Texture, TextureDescriptor,
};
use std::collections::{BTreeMap, BTreeSet};
use std::time::Duration;
@@ -975,7 +975,7 @@ fn a_raw_texture_over_a_buffer_announces_its_shadow_only_where_not_named() {
// SAFETY: the mapping outlives the buffer and its view, dropped first.
"no-copy" => match unsafe {
device.new_buffer_with_bytes_no_copy(
memory.pointer(),
HostMemory::new(memory.pointer()),
GUEST_PAGE as u64,
ResourceOptions::shared(),
None,
@@ -43,9 +43,9 @@ use metal2vulkan::metal::{PixelFormat, TextureType, TextureUsage};
use metal2vulkan_devtools::llvm_assemble;
use metal2vulkan_runtime::{
BlitOption, ClearColor, CommandQueue, Degradation, Device, DeviceOptions, Error, Heap,
HeapDescriptor, HeapType, LoadAction, MetalLevel, ObjectId, Origin, PipelineOptions, Region,
RenderPassDescriptor, ResourceOptions, RuntimeGap, Size, StoreAction, Texture,
TextureDescriptor, WorkCounts,
HeapDescriptor, HeapType, HostMemory, LoadAction, MetalLevel, ObjectId, Origin,
PipelineOptions, Region, RenderPassDescriptor, ResourceOptions, RuntimeGap, Size, StoreAction,
Texture, TextureDescriptor, WorkCounts,
};
use std::path::Path;
@@ -189,8 +189,14 @@ fn heap_over(device: &Device, mapping: &Mapping) -> Option<Heap> {
let descriptor = HeapDescriptor::new(HeapType::Placement, HEAP as u64, shared());
// SAFETY: the mapping holds `HEAP` writable bytes and outlives the heap (each test drops the
// heap first).
match unsafe { device.new_heap_with_bytes_no_copy(mapping.pointer(), &descriptor, None, None) }
{
match unsafe {
device.new_heap_with_bytes_no_copy(
HostMemory::new(mapping.pointer()),
&descriptor,
None,
None,
)
} {
Ok(heap) => Some(heap),
Err(error) if not_importable(&error) => {
eprintln!("HEAPLAYOUT: the device imports no host memory: {error:?}");
@@ -25,8 +25,9 @@ use crate::executor_contract::out_of_bounds::{GUARD_FILL, PAD_FILL};
use crate::gpu::TEST_DEVICE;
use metal2vulkan_runtime::{
Buffer, CommandBufferStatus, CommandQueue, CpuCacheMode, Degradation, Device, Error,
HazardTrackingMode, Heap, HeapDescriptor, HeapProblem, HeapType, Invalid, MemoryKind, Nil,
Problem, PurgeableState, ResourceOptions, RuntimeGap, SizeAndAlign, StorageMode,
HazardTrackingMode, Heap, HeapDescriptor, HeapProblem, HeapType, HostMemory, Invalid,
MemoryKind, Nil, Problem, PurgeableState, ResourceOptions, RuntimeGap, SizeAndAlign,
StorageMode,
};
use std::collections::BTreeMap;
use std::time::{Duration, Instant};
@@ -1405,7 +1406,7 @@ fn a_loaded_pointer_reaches_a_rebound_no_copy_buffer_once_a_command_used_it_agai
let new = Mapping::anonymous(len);
new.write(0, &bytes);
// SAFETY: `new` outlives the buffer, which is dropped first, and no other thread uses it.
unsafe { pages.rebind_bytes_no_copy(new.pointer(), None, None) }.unwrap();
unsafe { pages.rebind_bytes_no_copy(HostMemory::new(new.pointer()), None, None) }.unwrap();
old.write(0, &bytes);
let produced = walk_unnamed(device, &queue, &walker, &pages, None);
assert!(
@@ -1443,7 +1444,7 @@ fn a_loaded_pointer_reaches_a_no_copy_buffer_rebound_before_its_use_once_a_comma
let new = Mapping::anonymous(len);
new.write(0, &bytes);
// SAFETY: `new` outlives the buffer, which is dropped first, and no other thread uses it.
unsafe { pages.rebind_bytes_no_copy(new.pointer(), None, None) }.unwrap();
unsafe { pages.rebind_bytes_no_copy(HostMemory::new(new.pointer()), None, None) }.unwrap();
let produced = walk_unnamed(device, &queue, &walker, &pages, None);
assert!(produced != walker.metal_output, "no command used it");
gpu_read(&queue, &pages, 0..4);
@@ -1493,7 +1494,7 @@ fn a_loaded_pointer_reaches_a_rebound_heap_s_buffer_once_a_command_used_the_heap
let new = Mapping::anonymous(HEAP);
new.write(AT, &bytes);
// SAFETY: `new` outlives the heap, which is dropped first, and no other thread uses it.
unsafe { heap.rebind_bytes_no_copy(new.pointer(), None, None) }.unwrap();
unsafe { heap.rebind_bytes_no_copy(HostMemory::new(new.pointer()), None, None) }.unwrap();
old.write(AT, &bytes);
let produced = walk_unnamed(device, &queue, &walker, &placed, None);
assert!(
@@ -1537,7 +1538,8 @@ fn a_rebind_of_one_of_two_buffers_over_a_memory_ends_only_its_use() {
let new = Mapping::anonymous(len);
new.write(0, &bytes);
// SAFETY: `new` outlives the buffer, which is dropped first, and no other thread uses it.
unsafe { rebound.rebind_bytes_no_copy(new.pointer(), None, None) }.unwrap();
unsafe { rebound.rebind_bytes_no_copy(HostMemory::new(new.pointer()), None, None) }
.unwrap();
memory.write(0, &bytes);
let produced = walk_unnamed(device, &queue, &walker, &rebound, None);
assert!(
@@ -355,7 +355,14 @@ pub(super) unsafe fn no_copy(
deallocator: Option<Deallocator>,
) -> Result<Buffer, Error> {
// SAFETY: the caller's contract.
unsafe { device.new_buffer_with_bytes_no_copy(pointer, len as u64, options, deallocator) }
unsafe {
device.new_buffer_with_bytes_no_copy(
HostMemory::new(pointer),
len as u64,
options,
deallocator,
)
}
}
/// Commit `command_buffer`, wait for it, and check it completed without error.
@@ -1878,7 +1885,7 @@ fn refused_no_copy_buffers_never_run_their_deallocator() {
// SAFETY: the mapping outlives the call, which makes nothing.
let refused = unsafe {
device.new_buffer_with_bytes_no_copy(
memory.pointer(),
HostMemory::new(memory.pointer()),
length,
made,
Some(recording(&seen, ())),
@@ -41,7 +41,7 @@ use metal2vulkan_devtools::{engine_dir, llvm_assemble};
use metal2vulkan_runtime::{
Buffer, CommandBuffer, CommandBufferStatus, ComputeCommandEncoder, ComputePipelineState,
DebugMessage, Degradation, Device, DeviceOptions, Error, ExecutedPipeline, Execution, Heap,
HeapDescriptor, HeapType, IndirectCommand, IndirectCommandBuffer,
HeapDescriptor, HeapType, HostMemory, IndirectCommand, IndirectCommandBuffer,
IndirectCommandBufferDescriptor, IndirectCommandBufferProblem, Invalid, PipelineOptions,
Problem, Region, RenderPassDescriptor, ResourceOptions, Size, VisibleFunctionTableDescriptor,
};
@@ -1386,7 +1386,8 @@ fn commands_reach_a_rebound_no_copy_buffer_once_a_command_used_it_again() {
);
// SAFETY: the mapping outlives the buffer, dropped first, and no other thread uses
// the buffer.
unsafe { buffer.rebind_bytes_no_copy(memory.pointer(), None, None) }.unwrap();
unsafe { buffer.rebind_bytes_no_copy(HostMemory::new(memory.pointer()), None, None) }
.unwrap();
new_pages.push(memory);
}
assert_eq!(output(&case.compute, &buffers), before);
@@ -17,9 +17,9 @@ use metal2vulkan::pipeline::{
};
use metal2vulkan_devtools::llvm_assemble;
use metal2vulkan_runtime::{
Buffer, ClearColor, CommandBuffer, CommandBufferStatus, ComputePipelineState, Device, Library,
LoadAction, PipelineOptions, RenderPassDescriptor, RenderPipelineState, ResourceOptions, Size,
StoreAction, Texture, TextureDescriptor, WorkCounts,
Buffer, ClearColor, CommandBuffer, CommandBufferStatus, ComputePipelineState, Device,
HostMemory, Library, LoadAction, PipelineOptions, RenderPassDescriptor, RenderPipelineState,
ResourceOptions, Size, StoreAction, Texture, TextureDescriptor, WorkCounts,
};
use std::alloc::Layout;
use std::cell::RefCell;
@@ -93,7 +93,7 @@ fn no_copy_buffer(device: &Device, freed: &Arc<AtomicBool>) -> Buffer {
// deallocator unrun, and the memory then leaks.
unsafe {
device.new_buffer_with_bytes_no_copy(
memory,
HostMemory::new(memory),
NO_COPY as u64,
ResourceOptions::shared(),
Some(Box::new(move |pointer, _| {
@@ -29,9 +29,10 @@ use crate::gpu::TEST_DEVICE;
use metal2vulkan::metal::format::is_depth_stencil;
use metal2vulkan::metal::{PixelFormat, TextureUsage};
use metal2vulkan_runtime::{
BlitOption, Buffer, CommandQueue, CpuCacheMode, Deallocator, Degradation, Device, Error,
HazardTrackingMode, Heap, HeapDescriptor, HeapProblem, HeapType, Invalid, Nil, Origin, Problem,
Region, ResourceOptions, RuntimeGap, Size, StorageMode, Texture, TextureDescriptor,
BlitOption, Buffer, CommandBuffer, CommandQueue, CpuCacheMode, Deallocator, Degradation,
Device, Error, HazardTrackingMode, Heap, HeapDescriptor, HeapProblem, HeapType, HostMemory,
Invalid, Nil, Origin, Problem, Region, ResourceOptions, RuntimeGap, Size, StorageMode, Texture,
TextureDescriptor,
};
use std::ptr::NonNull;
use std::sync::atomic::{AtomicUsize, Ordering};
@@ -97,7 +98,9 @@ pub(super) unsafe fn no_copy_heap(
) -> Option<Heap> {
let descriptor = HeapDescriptor::new(heap_type, HEAP as u64, shared());
// SAFETY: the caller's contract.
match unsafe { device.new_heap_with_bytes_no_copy(pointer, &descriptor, deallocator, None) } {
match unsafe {
device.new_heap_with_bytes_no_copy(HostMemory::new(pointer), &descriptor, deallocator, None)
} {
Ok(heap) => Some(heap),
Err(error) if not_importable(&error) => {
eprintln!("NOCOPYHEAP: the device imports no host memory: {error:?}");
@@ -122,7 +125,7 @@ pub(super) fn band(len: usize, base: u8) -> Vec<u8> {
}
/// A Shared buffer holding `bytes`.
fn staged(device: &Device, bytes: &[u8]) -> Buffer {
pub(super) fn staged(device: &Device, bytes: &[u8]) -> Buffer {
let buffer = device
.new_buffer(bytes.len() as u64, ResourceOptions::shared())
.unwrap();
@@ -237,54 +240,48 @@ fn a_no_copy_heap_s_buffers_are_the_caller_s_bytes() {
assert_eq!(seen.dropped.load(Ordering::SeqCst), 0);
}
/// The texels of `texture`'s first level (`side` square, `bytes` a texel), read back through a
/// blit.
pub(super) fn blit_texels(
queue: &CommandQueue,
/// Encode a blit of `texture`'s first level, `size` texels of `bytes` bytes, into `out`, rows
/// packed.
pub(super) fn encode_texels_out(
command_buffer: &CommandBuffer,
texture: &Texture,
side: u64,
(width, height): (u64, u64),
bytes: u64,
) -> Vec<u8> {
let device = queue.device();
let len = side * side * bytes;
let copy = device.new_buffer(len, ResourceOptions::shared()).unwrap();
let command_buffer = queue.command_buffer().unwrap();
out: &Buffer,
) {
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(side, side, 1),
&copy,
Size::new(width, height, 1),
out,
0,
side * bytes,
len,
width * bytes,
width * height * bytes,
BlitOption::None,
)
.unwrap();
blit.end_encoding().unwrap();
run(&command_buffer);
read_buffer(&copy, 0, len).unwrap()
}
/// Blit `texels` (`side` square, `bytes` a texel) into `texture`'s first level.
pub(super) fn blit_into(
queue: &CommandQueue,
texture: &Texture,
side: u64,
/// Encode a blit of `from`'s bytes, rows packed, into `texture`'s first level, `size` texels of
/// `bytes` bytes.
pub(super) fn encode_texels_in(
command_buffer: &CommandBuffer,
from: &Buffer,
(width, height): (u64, u64),
bytes: u64,
texels: &[u8],
texture: &Texture,
) {
let source = staged(queue.device(), texels);
let command_buffer = queue.command_buffer().unwrap();
let mut blit = command_buffer.blit_command_encoder().unwrap();
blit.copy_from_buffer_to_texture(
&source,
from,
0,
side * bytes,
side * side * bytes,
Size::new(side, side, 1),
width * bytes,
width * height * bytes,
Size::new(width, height, 1),
texture,
0,
0,
@@ -293,6 +290,37 @@ pub(super) fn blit_into(
)
.unwrap();
blit.end_encoding().unwrap();
}
/// The texels of `texture`'s first level (`size` texels, `bytes` a texel), read back through a
/// blit, rows packed.
pub(super) fn blit_texels(
queue: &CommandQueue,
texture: &Texture,
size: (u64, u64),
bytes: u64,
) -> Vec<u8> {
let len = size.0 * size.1 * bytes;
let copy = (queue.device())
.new_buffer(len, ResourceOptions::shared())
.unwrap();
let command_buffer = queue.command_buffer().unwrap();
encode_texels_out(&command_buffer, texture, size, bytes, &copy);
run(&command_buffer);
read_buffer(&copy, 0, len).unwrap()
}
/// Blit `texels` (`size` texels, `bytes` a texel, rows packed) into `texture`'s first level.
pub(super) fn blit_into(
queue: &CommandQueue,
texture: &Texture,
size: (u64, u64),
bytes: u64,
texels: &[u8],
) {
let source = staged(queue.device(), texels);
let command_buffer = queue.command_buffer().unwrap();
encode_texels_in(&command_buffer, &source, size, bytes, texture);
run(&command_buffer);
}
@@ -355,8 +383,12 @@ fn texture_round_trip(pf: PixelFormat, side: u64, bytes: u64, offset: u64) -> Op
// The GPU writes the texture: the caller's bytes and the buffer's change.
mapping.fill(0);
let first = band(len, 0x00);
blit_into(&queue, &texture, side, bytes, &first);
assert_eq!(blit_texels(&queue, &texture, side, bytes), first, "{what}");
blit_into(&queue, &texture, (side, side), bytes, &first);
assert_eq!(
blit_texels(&queue, &texture, (side, side), bytes),
first,
"{what}"
);
let host = mapping.read(range.clone());
let changed = host.iter().filter(|&&byte| byte != 0).count();
assert!(
@@ -375,7 +407,7 @@ fn texture_round_trip(pf: PixelFormat, side: u64, bytes: u64, offset: u64) -> Op
// The CPU writes the caller's bytes: every texel changes.
let second = band(size as usize, 0x80);
mapping.write(start, &second);
let read = blit_texels(&queue, &texture, side, bytes);
let read = blit_texels(&queue, &texture, (side, side), bytes);
assert_eq!(
same_texels(&read, &first, bytes),
0,
@@ -384,7 +416,7 @@ fn texture_round_trip(pf: PixelFormat, side: u64, bytes: u64, offset: u64) -> Op
// The GPU writes through the buffer: every texel changes again.
gpu_fill(&queue, &buffer, 0..size, 0x5A);
let after = blit_texels(&queue, &texture, side, bytes);
let after = blit_texels(&queue, &texture, (side, side), bytes);
assert_eq!(
same_texels(&after, &read, bytes),
0,
@@ -406,7 +438,11 @@ fn texture_round_trip(pf: PixelFormat, side: u64, bytes: u64, offset: u64) -> Op
.get_bytes(&mut texels, row, 0, region, 0, 0)
.unwrap();
assert_eq!(texels, third, "{what}: getBytes after replaceRegion");
assert_eq!(blit_texels(&queue, &texture, side, bytes), third, "{what}");
assert_eq!(
blit_texels(&queue, &texture, (side, side), bytes),
third,
"{what}"
);
laid = if tiled {
let n = bytes as usize;
(0..side).all(|y| {
@@ -474,7 +510,12 @@ fn a_no_copy_heap_is_refused_as_its_rules_say() {
let deallocator: Deallocator = Box::new(move |_, _| drop(count));
// SAFETY: the mapping holds every byte asked for and outlives any heap.
let made = unsafe {
device.new_heap_with_bytes_no_copy(at, &descriptor, Some(deallocator), None)
device.new_heap_with_bytes_no_copy(
HostMemory::new(at),
&descriptor,
Some(deallocator),
None,
)
};
assert_eq!(seen.runs.load(Ordering::SeqCst), 0);
assert_eq!(seen.dropped.load(Ordering::SeqCst), 1, "{descriptor:?}");
@@ -45,8 +45,8 @@ use metal2vulkan::metal::TextureType;
use metal2vulkan::metal::{PixelFormat, TextureUsage};
use metal2vulkan_runtime::{
Buffer, CommandBuffer, CommandBufferStatus, CommandQueue, Deallocator, Device, Error, EventRef,
Heap, HeapDescriptor, HeapProblem, HeapType, Invalid, Origin, Problem, RebindProblem,
ResourceOptions, RuntimeGap, SharedEvent, Size, Texture, TextureDescriptor,
Heap, HeapDescriptor, HeapProblem, HeapType, HostMemory, Invalid, Origin, Problem,
RebindProblem, ResourceOptions, RuntimeGap, SharedEvent, Size, Texture, TextureDescriptor,
};
use std::collections::BTreeMap;
use std::ptr::NonNull;
@@ -112,14 +112,26 @@ pub(super) fn rebind(buffer: &Buffer, mapping: Mapping, seen: &Arc<Seen>) -> Res
let pointer = mapping.pointer();
// SAFETY: the mapping holds the buffer's length until the deallocator releases it, and no
// other thread encodes or commits meanwhile.
unsafe { buffer.rebind_bytes_no_copy(pointer, Some(recording(seen, mapping)), None) }
unsafe {
buffer.rebind_bytes_no_copy(
HostMemory::new(pointer),
Some(recording(seen, mapping)),
None,
)
}
}
/// Rebind `heap` to `mapping`, whose deallocator records into `seen` and releases it.
pub(super) fn rebind_heap(heap: &Heap, mapping: Mapping, seen: &Arc<Seen>) -> Result<(), Error> {
let pointer = mapping.pointer();
// SAFETY: as `rebind`'s, for the heap's size.
unsafe { heap.rebind_bytes_no_copy(pointer, Some(recording(seen, mapping)), None) }
unsafe {
heap.rebind_bytes_no_copy(
HostMemory::new(pointer),
Some(recording(seen, mapping)),
None,
)
}
}
/// Where a deallocator ran.
@@ -547,7 +559,8 @@ fn only_the_caller_s_memory_is_rebound() {
count.runs.fetch_add(1, Ordering::SeqCst);
});
// SAFETY: the mapping holds the heap's size past `off` and outlives any rebind.
let made = unsafe { over.rebind_bytes_no_copy(off, Some(deallocator), None) };
let made =
unsafe { over.rebind_bytes_no_copy(HostMemory::new(off), Some(deallocator), None) };
let Err(Error::Invalid(invalid)) = &made else {
panic!("an unaligned rebind: {made:?}");
};
@@ -603,7 +616,9 @@ fn a_texture_over_a_rebound_buffer_reads_the_new_pages() {
"REBIND texture over a no-copy buffer: {}",
if aliased { "aliased" } else { "shadowed" }
);
let read = |texture: &Texture| blit_texels(&queue, texture, side as u64, bytes as u64);
let read = |texture: &Texture| {
blit_texels(&queue, texture, (side as u64, side as u64), bytes as u64)
};
assert_eq!(read(&texture), rows(&counting(LEN, 1), side, bytes, pitch));
// Memory 256 bytes into a page.
@@ -614,7 +629,8 @@ fn a_texture_over_a_rebound_buffer_reads_the_new_pages() {
let count = DropRecord(Arc::clone(&seen));
let deallocator: Deallocator = Box::new(move |_, _| drop(count));
// SAFETY: the mapping holds the length past `off` and outlives any rebind.
let made = unsafe { buffer.rebind_bytes_no_copy(off, Some(deallocator), None) };
let made =
unsafe { buffer.rebind_bytes_no_copy(HostMemory::new(off), Some(deallocator), None) };
assert_eq!(made, Err(Error::NotImplemented(RuntimeGap::RebindTextures)));
assert_eq!(seen.dropped.load(Ordering::SeqCst), 1);
drop(off_page);
@@ -624,7 +640,13 @@ fn a_texture_over_a_rebound_buffer_reads_the_new_pages() {
rebind(&buffer, next, &Arc::default()).unwrap();
assert_eq!(read(&texture), rows(&counting(LEN, 2), side, bytes, pitch));
let written: Vec<u8> = (0..side * side * bytes).map(|i| (i % 199) as u8).collect();
blit_into(&queue, &texture, side as u64, bytes as u64, &written);
blit_into(
&queue,
&texture,
(side as u64, side as u64),
bytes as u64,
&written,
);
// SAFETY: the new mapping lives until the buffer goes; no command writes it now.
let now = unsafe { at(pointer, 0..side * pitch) };
assert_eq!(rows(&now, side, bytes, pitch), written);
@@ -658,7 +680,9 @@ fn a_texture_over_a_no_copy_heap_s_buffer_follows_a_rebind() {
let texture = buffer.new_texture(&descriptor, 0, pitch as u64).unwrap();
// SAFETY: the handle is only compared, while the texture lives.
let aliased = unsafe { texture.vk_image() }.is_some();
let read = |texture: &Texture| blit_texels(&queue, texture, side as u64, bytes as u64);
let read = |texture: &Texture| {
blit_texels(&queue, texture, (side as u64, side as u64), bytes as u64)
};
assert_eq!(
read(&texture),
rows(&counting(HEAP, 1)[offset..], side, bytes, pitch)
@@ -673,7 +697,13 @@ fn a_texture_over_a_no_copy_heap_s_buffer_follows_a_rebind() {
"the texels of the new pages"
);
let written: Vec<u8> = (0..side * side * bytes).map(|i| (i % 199) as u8).collect();
blit_into(&queue, &texture, side as u64, bytes as u64, &written);
blit_into(
&queue,
&texture,
(side as u64, side as u64),
bytes as u64,
&written,
);
// SAFETY: the new mapping lives until the heap goes; no command writes it now.
let now = unsafe { at(next_pointer, offset..offset + side * pitch) };
assert_eq!(rows(&now, side, bytes, pitch), written);
@@ -838,7 +868,7 @@ fn a_rebound_heap_keeps_its_resources() {
let id = texture.gpu_resource_id();
let len = (side * side * bytes) as usize;
let first: Vec<u8> = (0..len).map(|i| (i % 251) as u8).collect();
blit_into(&queue, &texture, side, bytes, &first);
blit_into(&queue, &texture, (side, side), bytes, &first);
let size = device
.heap_texture_size_and_align(&heap_descriptor(format, side))
.unwrap()
@@ -853,7 +883,11 @@ fn a_rebound_heap_keeps_its_resources() {
let next_pointer = next.pointer();
// SAFETY: the test keeps the mapping until the heap is gone.
unsafe {
heap.rebind_bytes_no_copy(next_pointer, Some(recording(&next_seen, ())), None)
heap.rebind_bytes_no_copy(
HostMemory::new(next_pointer),
Some(recording(&next_seen, ())),
None,
)
}
.unwrap_or_else(|error| panic!("{format:?}: {error:?}"));
ran(
@@ -868,12 +902,12 @@ fn a_rebound_heap_keeps_its_resources() {
mappings[old].fill(0);
assert_eq!(texture.gpu_resource_id(), id);
assert_eq!(
blit_texels(&queue, &texture, side, bytes),
blit_texels(&queue, &texture, (side, side), bytes),
first,
"{format:?}: the texels of the new pages"
);
let second: Vec<u8> = (0..len).map(|i| (i % 241) as u8 ^ 0x5a).collect();
blit_into(&queue, &texture, side, bytes, &second);
blit_into(&queue, &texture, (side, side), bytes, &second);
let current = mappings.len() - 1;
assert_ne!(
mappings[current].read(range.clone()),
@@ -891,7 +925,11 @@ fn a_rebound_heap_keeps_its_resources() {
let next_seen = Arc::new(Seen::default());
// SAFETY: the test keeps the mapping until the heap is gone.
unsafe {
heap.rebind_bytes_no_copy(next.pointer(), Some(recording(&next_seen, ())), None)
heap.rebind_bytes_no_copy(
HostMemory::new(next.pointer()),
Some(recording(&next_seen, ())),
None,
)
}
.unwrap();
mappings.push(next);
@@ -1025,8 +1063,14 @@ fn a_texture_sampled_before_its_first_submission_reads_its_heap_s_new_pages() {
second.write(0, &laid);
let before = device.work_counts();
// SAFETY: the test keeps the mapping until the heap is gone.
unsafe { heap.rebind_bytes_no_copy(second.pointer(), Some(recording(&seen[1], ())), None) }
.unwrap();
unsafe {
heap.rebind_bytes_no_copy(
HostMemory::new(second.pointer()),
Some(recording(&seen[1], ())),
None,
)
}
.unwrap();
// Its last use, the copy in, completed before the rebind.
ran(&seen[0], first.pointer(), HEAP, &laid[..16], Thread::Any);
assert_eq!(held.status(), CommandBufferStatus::Committed);
@@ -1100,7 +1144,8 @@ fn a_heap_rebind_costs_an_image_per_bound_texture() {
let next = Mapping::anonymous(HEAP);
let start = Instant::now();
// SAFETY: the test keeps the mapping until the heap is gone.
unsafe { heap.rebind_bytes_no_copy(next.pointer(), None, None) }.unwrap();
unsafe { heap.rebind_bytes_no_copy(HostMemory::new(next.pointer()), None, None) }
.unwrap();
times.push(format!("{:.0}", start.elapsed().as_secs_f64() * 1e6));
mappings.push(next);
}
@@ -44,8 +44,8 @@ use metal2vulkan::pipeline::{ComputePipelineDescriptor, StageSource};
use metal2vulkan_devtools::llvm_assemble_text;
use metal2vulkan_runtime::{
BlitOption, Buffer, ClearColor, CommandBuffer, CommandQueue, ComputePipelineState, Device,
EventRef, IoSurfacePlane, LoadAction, Origin, PipelineOptions, RenderPassDescriptor,
ResourceOptions, Size, StoreAction, Texture, TextureDescriptor,
EventRef, HostMemory, IoSurfacePlane, LoadAction, Origin, PipelineOptions,
RenderPassDescriptor, ResourceOptions, Size, StoreAction, Texture, TextureDescriptor,
};
/// The consumer's display surface: 1920x1080 `RGBA16Float`, 8 bytes a texel, rows packed.
@@ -205,7 +205,10 @@ impl Surface {
let second = import(other.pointer()).unwrap();
// SAFETY: the surface's mapping outlives the buffer, and the pages it leaves stay
// mapped until the surface goes; no command uses the buffer yet.
unsafe { second.rebind_bytes_no_copy(memory.pointer(), None, None) }.unwrap();
unsafe {
second.rebind_bytes_no_copy(HostMemory::new(memory.pointer()), None, None)
}
.unwrap();
left = Some(other);
second
}
+10 -2
View File
@@ -140,6 +140,12 @@ bit-exact `fneg`, `fabs` and `half`-to-`float` widening of NaNs and denormals. U
switches it also keeps Metal's canonical NaNs and Metal's operand choice in `fmin`, `fmax`,
`min3`, `max3` and `clamp`.
What the runtime enables for itself outside the vocabulary enters no enable set, compile profile
or fingerprint: among it the extensions of its dma-buf fallback for no-copy memory whose pointer
the device refuses (`HostMemory::with_dma_buf`), `VK_EXT_external_memory_dma_buf` with
`VK_KHR_external_memory_fd`, and `VK_EXT_image_drm_format_modifier` with
`VK_EXT_queue_family_foreign` beside them, wherever a device lists them.
## 2. A library
`Library::parse` takes a metallib, a bitcode wrapper or a raw AIR module; `Library::from_air`
@@ -680,8 +686,10 @@ fast forms record, and each `PrecisionNote`'s rustdoc states its bound.
buffer is a shadow image: no linear image of the device lays its texels out as Metal does in the
buffer's memory (over a no-copy buffer's imported host memory, no linear image made for host
allocations does), or the buffer is over the caller's `VkBuffer`, whose memory backs no image of
the runtime's. Cost: its texels are copied into an image before each use and back after each
write.
the runtime's, or over host pages imported as dma-bufs (`HostMemory::with_dma_buf`) where the
device makes no image over a dma-buf of the texture's own pages (the notice names why;
`WorkCounts::dma_buf_image_fallbacks` counts it). Cost: its texels are copied into an image before
each use and back after each write.
- `metal2vulkan-degrade-staged-texture-buffer` (performance). `StagedTextureBuffer`: A texture
buffer is viewed through a staging buffer: its texels start where the device views none
(`minTexelBufferOffsetAlignment`). Cost: its texels are copied into a staging buffer before each
+45 -3
View File
@@ -1,8 +1,8 @@
# Integrating metal2vulkan
The checklist around the library: the tools each piece needs, caching, failures, isolating a
compile and checking an integration. The API itself is [API.md](API.md); the runtime's is
[its README](../crates/metal2vulkan-runtime/README.md).
compile, host memory a driver refuses, and checking an integration. The API itself is
[API.md](API.md); the runtime's is [its README](../crates/metal2vulkan-runtime/README.md).
## 1. Tools
@@ -133,7 +133,49 @@ down, or a hard memory ceiling must hold, compile in a child process:
The validation crate's worker (`crates/metal2vulkan-validation/src/worker/`) implements this,
under 20 seconds and 500 MiB per attempt.
## 6. Check the integration
## 6. Host memory a driver refuses
`Device::new_buffer_with_bytes_no_copy`, `new_heap_with_bytes_no_copy` and the
`rebind_bytes_no_copy` calls import the caller's pages by their pointer
(`VK_EXT_external_memory_host`). Some drivers refuse the pointer of shared memory: RADV (AMD on
Linux) imports a pointer through amdgpu's userptr, which takes anonymous pages only, so it refuses
`MAP_SHARED` mappings of a `memfd`, a shared memory object or any file (QEMU's
`memory-backend-memfd,share=on` guest RAM among them) with `Unsupported`, `HostMemory`. NVIDIA and
lavapipe import the same memory.
A consumer whose memory is such a mapping passes `HostMemory::with_dma_buf(pointer, source)` instead
of `HostMemory::new(pointer)`. The runtime still imports the pointer first, exactly as without a
source, and calls the source only where the device refuses it: for dma-bufs of the pages the range
touches, and again once for each texture's image over its own pages in them. The rustdoc of
`HostMemory::with_dma_buf`, `DmaBufSource` and `DmaBufRequest` is the contract: when the source is
called, the chunks it answers, and what is refused. In short, answer each `DmaBufRequest` with
dma-bufs of exactly the pages asked for, in order, split only at multiples of its `granule`. Where
the granule is less than the length (64 KiB on RADV of Mesa 26.2.4, 4 KiB on 26.0.8), several
chunks are bound to one sparse buffer and must total the length rounded up to the granule: pad the
last with a scratch page of your own, repeated. A texture's request takes one chunk, of the same
file pieces the buffer's chunks hold there.
On Linux, `udmabuf` makes such a dma-buf of the file pieces behind the pages: open `/dev/udmabuf`
(the process needs read and write access to it) and issue `UDMABUF_CREATE_LIST` with one item per
run of contiguous file pages; the `memfd` must be sealed against shrinking (`F_SEAL_SHRINK`, as QEMU
seals it) and not against writing. The consumer knows the pieces behind every byte; the runtime runs
no udmabuf code. Each udmabuf takes at most `list_limit` items and `size_limit_mb` MiB (the module's
parameters under `/sys/module/udmabuf/parameters`, 1024 and 64 by default). Keep each chunk within
the host's limits as they are: read them, never assume them raised. Scattered memory needs many
items: a macOS desktop guest of 14 GiB was measured importing up to 63.3 MiB in one object, in up to
16,201 separate 4 KiB runs, with 19 to 29 of its imports past 1024 runs; at a 64 KiB granule such an
object takes 16 chunks.
A texture over such memory is an image over a dma-buf of its own pages where the device also lists
`VK_EXT_image_drm_format_modifier` and `VK_EXT_queue_family_foreign` (RADV does). RADV (Mesa 26.2.4
and 26.0.8) lays such an image's plane only at an offset in its page that is a multiple of 256
bytes, with rows a multiple of 256 bytes apart: keep a texture's offset and `bytes_per_row` so (a
4 KiB-aligned surface with 256-byte-aligned rows always is). Elsewhere the texture takes a shadow of
the bytes, announced (`shadowed-texture`, naming why), and a rebind that cannot make the image again
is refused (`NotImplemented(RebindTextures)`). `WorkCounts::dma_buf_imports`,
`dma_buf_sparse_buffers`, `dma_buf_images` and `dma_buf_image_fallbacks` count what the route did.
## 7. Check the integration
`spirv-val` checks structural validity, not agreement with Metal:
+57 -57
View File
@@ -14,7 +14,7 @@ Columns:
- `none`: no public API path: malformed or non-Metal input, Apple-private calls, or a cap no valid program of ordinary size meets;
- `?`: not assessed yet.
Generated at `53fc528b6`.
Generated at `d612d286c`.
## Totals
@@ -36,9 +36,9 @@ Generated at `53fc528b6`.
| `Stage` | A function stage the model does not cover | - | via a helper: 2: `crates/metal2vulkan-air/src/abi/check.rs:579`, `crates/metal2vulkan/src/error/mod.rs:246` | `none`: a stage outside AIR's public stages |
| `AddressSpace` | An LLVM address space the typed model does not define (it defines AIR's `thread` 0 through `threadgroup_imageblock` 4, `object_data` 6 and the... | every device (not implemented) | 2: `crates/metal2vulkan-air/src/ir/types.rs:191`, `crates/metal2vulkan/src/memory/plan.rs:1854` | `none`: Apple's AGX library address spaces |
| `ModuleRecord` | A module-level record outside the accepted subset (alias, ifunc, comdat, …) | - | via a helper: 4: `crates/metal2vulkan-air/src/bitcode/module.rs:343`, `crates/metal2vulkan-air/src/bitcode/module.rs:435` (+2) | `none`: LLVM constructs AIR does not emit |
| `Instruction` | An instruction record outside the closed instruction set | - | via a helper: 11: `crates/metal2vulkan-air/src/bitcode/function.rs:1015`, `crates/metal2vulkan-air/src/bitcode/function.rs:1062` (+9) | `none`: LLVM instructions AIR does not emit |
| `Instruction` | An instruction record outside the closed instruction set | - | via a helper: 11: `crates/metal2vulkan-air/src/bitcode/function.rs:1010`, `crates/metal2vulkan-air/src/bitcode/function.rs:1057` (+9) | `none`: LLVM instructions AIR does not emit |
| `Type` | A type outside the typed model | - | via a helper: 4: `crates/metal2vulkan-air/src/bitcode/types.rs:184`, `crates/metal2vulkan-air/src/bitcode/types.rs:206` (+2) | `none`: LLVM types AIR does not emit |
| `CallingConvention` | A calling convention other than AIR's | - | via a helper: 3: `crates/metal2vulkan-air/src/bitcode/function.rs:1359`, `crates/metal2vulkan-air/src/bitcode/module.rs:499` (+1) | `none`: LLVM calling conventions AIR does not use |
| `CallingConvention` | A calling convention other than AIR's | - | via a helper: 3: `crates/metal2vulkan-air/src/bitcode/function.rs:1354`, `crates/metal2vulkan-air/src/bitcode/module.rs:499` (+1) | `none`: LLVM calling conventions AIR does not use |
| `UnknownIntrinsic` | An intrinsic outside the closed set | every device (not implemented) | 2: `crates/metal2vulkan-air/src/error.rs:621`, `crates/metal2vulkan/src/lower/select.rs:990` | `rare`: AIR from a newer compiler (macOS 27 AIR 2.9) |
| `AgxUnmodeled` | An AGX intrinsic whose semantics are not modeled | every device (not implemented) | 1: `crates/metal2vulkan/src/lower/simd/agx.rs:62` | `rare`: Apple's own libraries' AGX intrinsics |
| `StaticInitializer` | A static initializer that cannot be evaluated | every device (not implemented) | 1: `crates/metal2vulkan-air/src/error.rs:627` | `none`: LLVM initializers AIR does not emit |
@@ -74,7 +74,7 @@ Generated at `53fc528b6`.
| `MinLodClamp` | `min_lod_clamp` without `shaderResourceMinLod` | devices without VkFeature::ShaderResourceMinLod; every device (not implemented) | 2: `crates/metal2vulkan/src/lower/sampler/select.rs:1311`, `crates/metal2vulkan/src/lower/sampler/select.rs:891` | `rare`: min_lod_clamp on a device without shaderResourceMinLod |
| `TexelOffset` | A texel offset the device cannot apply | devices short of a device limit the site names; every device (no Vulkan mechanism) | 2: `crates/metal2vulkan/src/lower/sampler/select.rs:750`, `crates/metal2vulkan/src/lower/sampler/select.rs:824` | `app`: texel offsets a device cannot apply |
| `GatherExtended` | Gather with non-constant offsets or components | - | via a helper: 1: `crates/metal2vulkan/src/lower/sampler/select.rs:782` | `rare`: gathers with dynamic offsets or components |
| `StorageImageMultisample` | Multisampled storage images | - | via a helper: 1: `crates/metal2vulkan/src/lower/texture/slot.rs:1037` | `rare`: writable multisampled textures |
| `StorageImageMultisample` | Multisampled storage images | - | via a helper: 1: `crates/metal2vulkan/src/lower/texture/slot.rs:1046` | `rare`: writable multisampled textures |
| `StorageTextureInVertexStage` | Storage images in the vertex stage | - | via a helper: 1: `crates/metal2vulkan/src/lower/texture/slot.rs:666` | `rare`: writable textures in vertex functions |
| `CubeArray` | Cube arrays | devices without VkFeature::ImageCubeArray | 2: `crates/metal2vulkan/src/lower/sampler/select.rs:1214`, `crates/metal2vulkan/src/lower/texture/slot.rs:456` | `rare`: cube arrays on a device without imageCubeArray |
| `SamplerAnisotropy` | Constexpr sampler anisotropy | devices without VkFeature::SamplerAnisotropy; every device (not implemented) | 3: `crates/metal2vulkan/src/lower/sampler/select.rs:1409`, `crates/metal2vulkan/src/metal/sampler.rs:255` (+1) | `app`: anisotropic constexpr samplers on a device without samplerAnisotropy |
@@ -90,10 +90,10 @@ Generated at `53fc528b6`.
| `LayeredRendering` | Layered rendering (`render_target_array_index`, `viewport_array_index`) | devices without VkFeature::ImageView2DOn3DImage; devices without VkFeature::ShaderOutputLayer; devices without VkFeature::ShaderOutputViewportIndex | 3: `crates/metal2vulkan-runtime/src/render_pass.rs:1538`, `crates/metal2vulkan/src/lower/mesh/mod.rs:736` (+1) | `rare`: layered rendering on a device without its features |
| `ClipDistance` | Clip or cull distances | devices without VkFeature::ShaderClipDistance; devices without VkLimit::MaxClipDistances | 2: `crates/metal2vulkan/src/lower/mesh/mod.rs:892`, `crates/metal2vulkan/src/lower/mesh/mod.rs:900` | `rare`: clip distances on a device without them |
| `DualSourceBlending` | Dual-source blending | devices without VkFeature::DualSrcBlend; devices without VkLimit::MaxFragmentDualSrcAttachments | 5: `crates/metal2vulkan-runtime/src/families/formats.rs:398`, `crates/metal2vulkan/src/metal/state.rs:37` (+3) | `rare`: dual-source blending on a device without it |
| `Barycentrics` | Barycentric coordinates | drivers with a defect | 1: `crates/metal2vulkan/src/lower/stage_io/plan.rs:1460` | `rare`: barycentric coordinates |
| `Barycentrics` | Barycentric coordinates | drivers with a defect | 1: `crates/metal2vulkan/src/lower/stage_io/plan.rs:1462` | `rare`: barycentric coordinates |
| `StencilExport` | Stencil export | devices without VkExtension::ExtShaderStencilExport; every device (not implemented) | 6: `crates/metal2vulkan-runtime/src/families/features.rs:1091`, `crates/metal2vulkan/src/bind/graphics.rs:2058` (+4) | `rare`: stencil from the shader |
| `SampleRateShading` | Per-sample shading | devices without VkFeature::SampleRateShading; devices without a capability the site computes (`needs`); every device (not implemented) | 3: `crates/metal2vulkan/src/pipeline/link/graphics.rs:700`, `crates/metal2vulkan/src/pipeline/link/graphics.rs:702` (+1) | `rare`: per-sample shading |
| `PixelCoverageAtSampleRate` | The pixel's coverage (`[[sample_mask]]` read) in a fragment function that runs once per sample | drivers with a defect; every device (no Vulkan mechanism); every device (not implemented) | 3: `crates/metal2vulkan/src/lower/fragment/coverage.rs:291`, `crates/metal2vulkan/src/lower/simd/mod.rs:735` (+1) | `rare`: coverage read at sample rate |
| `PixelCoverageAtSampleRate` | The pixel's coverage (`[[sample_mask]]` read) in a fragment function that runs once per sample | drivers with a defect; every device (no Vulkan mechanism); every device (not implemented) | 3: `crates/metal2vulkan/src/lower/fragment/coverage.rs:291`, `crates/metal2vulkan/src/lower/simd/mod.rs:739` (+1) | `rare`: coverage read at sample rate |
| `InterfaceComponents` | Too many interface components or locations | devices short of a device limit the site names; devices without VkLimit::MaxColorAttachments; devices without VkLimit::MaxVertexInputAttributes | 3: `crates/metal2vulkan/src/pipeline/link/graphics.rs:256`, `crates/metal2vulkan/src/pipeline/link/varyings.rs:343` (+1) | `rare`: too many varyings or attachments for a device |
| `UnmatchedVarying` | A fragment input without a vertex producer (a Metal link error) | every device (no Vulkan mechanism) | 3: `crates/metal2vulkan/src/pipeline/link/varyings.rs:253`, `crates/metal2vulkan/src/pipeline/link/varyings.rs:439` (+1) | `none`: a Metal link error |
| `KernelStageIn` | Kernel `[[stage_in]]` | every device (not implemented) | 3: `crates/metal2vulkan-runtime/src/indirect_execute.rs:337`, `crates/metal2vulkan/src/bind/dispatch.rs:881` (+1) | `rare`: kernel stage-in combinations Metal leaves unestablished |
@@ -104,12 +104,12 @@ Generated at `53fc528b6`.
| `RayTracing` | | devices without a capability the site computes (`missing`); every device (no Vulkan mechanism); every device (not implemented) | 12: `crates/metal2vulkan/src/bind/acceleration.rs:202`, `crates/metal2vulkan/src/bind/acceleration.rs:216` (+10) | `rare`: ray tracing (out of scope by ruling) |
| `Tensors` | | every device (not implemented) | 2: `crates/metal2vulkan-air/src/canon/matmul2d/synth.rs:32`, `crates/metal2vulkan/src/lower/select.rs:887` | `rare`: shader tensors |
| `RasterizationRateMap` | | every device (not implemented) | 1: `crates/metal2vulkan/src/lower/fragment/mod.rs:875` | `rare`: rasterization rate maps |
| `GpuEncodedIndirectCommands` | | devices short of a Vulkan feature the site names; devices without buffer device addresses (`addressed_needs`); every device (no Vulkan mechanism); every device (not implemented) | 11: `crates/metal2vulkan/src/bind/replay.rs:530`, `crates/metal2vulkan/src/bind/replay.rs:770` (+9) | `rare`: indirect command buffers encoded by a kernel |
| `GpuEncodedIndirectCommands` | | devices short of a Vulkan feature the site names; devices without buffer device addresses (`addressed_needs`); every device (no Vulkan mechanism); every device (not implemented) | 11: `crates/metal2vulkan/src/bind/replay.rs:530`, `crates/metal2vulkan/src/bind/replay.rs:772` (+9) | `rare`: indirect command buffers encoded by a kernel |
| `VulkanVersion` | The device's Vulkan version is below the 1.2 floor | devices without ApiVersion::V1_2 | 2: `crates/metal2vulkan/src/ash_interop/query.rs:898`, `crates/metal2vulkan/src/device/derive.rs:101` | `none`: a device below Vulkan 1.2 |
| `Constant` | A bitcode constant record outside the typed model (block address, inline asm, `select` and other constant expressions the IR has no form for) | - | via a helper: 3: `crates/metal2vulkan-air/src/bitcode/constants.rs:210`, `crates/metal2vulkan-air/src/bitcode/constants.rs:268` (+1) | `none`: LLVM constant forms AIR does not emit |
| `Attribute` | An LLVM attribute kind that changes the calling ABI and that AIR does not use (`inalloca`, `preallocated`, `byref`, `nest`, the `swift*` kinds) | - | via a helper: 2: `crates/metal2vulkan-air/src/bitcode/attrs.rs:493`, `crates/metal2vulkan/src/error/mod.rs:258` | `none`: LLVM ABI attributes AIR does not use |
| `BitcodeRecord` | A bitcode record LLVM defines in `block` that the typed model does not cover and that has no more specific variant (legacy spellings predating... | - | via a helper: 7: `crates/metal2vulkan-air/src/bitcode/attrs.rs:337`, `crates/metal2vulkan-air/src/bitcode/function.rs:577` (+5) | `none`: bitcode records AIR does not emit |
| `SyncScope` | An atomic access or fence in a synchronization scope other than LLVM's built-in `singlethread` and system scopes | - | via a helper: 2: `crates/metal2vulkan-air/src/bitcode/function.rs:1260`, `crates/metal2vulkan/src/error/mod.rs:260` | `none`: synchronization scopes AIR does not use |
| `BitcodeRecord` | A bitcode record LLVM defines in `block` that the typed model does not cover and that has no more specific variant (legacy spellings predating... | - | via a helper: 7: `crates/metal2vulkan-air/src/bitcode/attrs.rs:337`, `crates/metal2vulkan-air/src/bitcode/function.rs:572` (+5) | `none`: bitcode records AIR does not emit |
| `SyncScope` | An atomic access or fence in a synchronization scope other than LLVM's built-in `singlethread` and system scopes | - | via a helper: 2: `crates/metal2vulkan-air/src/bitcode/function.rs:1255`, `crates/metal2vulkan/src/error/mod.rs:260` | `none`: synchronization scopes AIR does not use |
| `SubgroupOperations` | Simdgroup operations of a class the stage's subgroups do not support (the stage is not in `subgroupSupportedStages`, or an operation class is... | devices without VkFeature::ShaderQuadControl; devices without VkFeature::ShaderSubgroupExtendedTypes; devices without VkProperty::SubgroupStage | 4: `crates/metal2vulkan-runtime/src/families/features.rs:1643`, `crates/metal2vulkan/src/lower/simd/mod.rs:402` (+2) | `app`: simdgroup functions in a stage a device's subgroups do not support |
| `DirectCall` | A call to a defined function the inliner cannot take | every device (not implemented) | 1: `crates/metal2vulkan-air/src/canon/mod.rs:1283` | `rare`: variadic or byval calls the inliner cannot take |
| `WideSwitchLiteral` | A switch case literal wider than 32 bits | every device (not implemented) | 1: `crates/metal2vulkan/src/structurize/emit.rs:207` | `rare`: 64-bit switch literals |
@@ -131,9 +131,9 @@ Generated at `53fc528b6`.
| `TextureSize` | A texture whose extent, array layers, or level count is past what the device takes for its format, type, and usage (`Capability::Limit` names the... | devices short of a device limit the site names | 1: `crates/metal2vulkan-runtime/src/image_plan.rs:1062` | `app`: a texture past a device's image limits |
| `TextureSampleCount` | A texture sample count the device does not take for its format, type, and usage | devices short of a Vulkan property the site names; devices without VkFeature::MultisampleArrayImage; every device (no Vulkan mechanism) | 3: `crates/metal2vulkan-runtime/src/image_plan.rs:1110`, `crates/metal2vulkan-runtime/src/image_plan.rs:570` (+1) | `app`: a sample count a device lacks for the texture |
| `TextureView` | A texture view Vulkan cannot make exactly on this image | every device (no Vulkan mechanism); every device (not implemented) | 5: `crates/metal2vulkan-runtime/src/binding_view.rs:156`, `crates/metal2vulkan-runtime/src/texture/view_shadow.rs:184` (+3) | `app`: a texture view Vulkan cannot make exactly |
| `TextureSwizzle` | A texture swizzle whose Metal behavior is not measured | devices short of a Vulkan feature the site names; every device (not implemented) | 7: `crates/metal2vulkan-runtime/src/binding_view.rs:167`, `crates/metal2vulkan-runtime/src/texture.rs:775` (+5) | `app`: texture swizzles whose Metal behaviour is unmeasured |
| `TextureSwizzle` | A texture swizzle whose Metal behavior is not measured | devices short of a Vulkan feature the site names; every device (not implemented) | 7: `crates/metal2vulkan-runtime/src/binding_view.rs:167`, `crates/metal2vulkan-runtime/src/texture.rs:885` (+5) | `app`: texture swizzles whose Metal behaviour is unmeasured |
| `MipmapGeneration` | `generateMipmapsForTexture:` where the device's filter is not shown to give Metal's answer | devices without VkFeature::ShaderInt64; devices without a format's usage; every device (not implemented) | 7: `crates/metal2vulkan-runtime/src/blit_texture.rs:1689`, `crates/metal2vulkan-runtime/src/mipmap_pick.rs:37` (+5) | `app`: generateMipmapsForTexture: where the device's filter is not Metal's |
| `HostMemory` | A buffer over the caller's host memory without a copy (`newBufferWithBytesNoCopy:`) | devices without VkExtension::ExtExternalMemoryHost; every device (no Vulkan mechanism); every device (not implemented) | 5: `crates/metal2vulkan-runtime/src/host_memory.rs:255`, `crates/metal2vulkan-runtime/src/host_memory.rs:280` (+3) | `system`: newBufferWithBytesNoCopy: where the device cannot import the memory |
| `HostMemory` | A buffer over the caller's host memory without a copy (`newBufferWithBytesNoCopy:`) | devices without VkExtension::ExtExternalMemoryHost; every device (no Vulkan mechanism); every device (not implemented) | 5: `crates/metal2vulkan-runtime/src/host_memory.rs:329`, `crates/metal2vulkan-runtime/src/host_memory.rs:361` (+3) | `system`: newBufferWithBytesNoCopy: where the device cannot import the memory |
| `GpuTimes` | A command buffer's GPU times (`GPUStartTime`, `GPUEndTime`) on a device whose queue family writes no timestamps (`timestampValidBits` 0) | every device (no Vulkan mechanism) | 1: `crates/metal2vulkan-runtime/src/command_buffer/mod.rs:1830` | `rare`: GPU times on a queue without timestamps |
| `CountingVisibility` | A `Counting` visibility result (`MTLVisibilityResultModeCounting`) on a device without `occlusionQueryPrecise` | devices without VkFeature::OcclusionQueryPrecise | 1: `crates/metal2vulkan-runtime/src/visibility.rs:447` | `rare`: counting occlusion queries on a device without precise queries |
| `ViewFormatReinterpretation` | A texture view whose format has other components, or components of other widths, than its texture's (`RGBA8Unorm` as `R32Uint`), on a device whose... | every device (no Vulkan mechanism) | 1: `crates/metal2vulkan-runtime/src/view_plan.rs:547` | `app`: a view of another component layout on a portability subset (MoltenVK) |
@@ -143,7 +143,7 @@ Generated at `53fc528b6`.
| `PrivateMemory` | A stage whose private memory (its `thread` variables and arrays, and the constants it holds per thread) takes more Function storage a thread than... | - | via a helper: 1: `crates/metal2vulkan/src/lower/select.rs:1153` | `rare`: very large per-thread arrays |
| `SparseTextures` | A sparse heap (`MTLHeapTypeSparse`), or a texture made from one, on a device without what a sparse resident image of it needs, which `missing` names | every device (no Vulkan mechanism) | 1: `crates/metal2vulkan-runtime/src/sparse/texture.rs:32` | `rare`: sparse heaps on a device without sparse images |
| `SparseMapping` | A sparse texture's mapping update (`updateTextureMapping:` and its array form, or a move of mappings) that covers part of one of the device's... | every device (no Vulkan mechanism) | 1: `crates/metal2vulkan-runtime/src/sparse/encoder.rs:466` | `rare`: sparse mappings off the device's blocks |
| `TimelineSemaphores` | Command buffers and events, which the runtime completes and signals through timeline semaphores (core in Vulkan 1.2), on a device whose... | every device (no Vulkan mechanism) | 1: `crates/metal2vulkan-runtime/src/device/create.rs:986` | `none`: a device below the runtime's floor |
| `TimelineSemaphores` | Command buffers and events, which the runtime completes and signals through timeline semaphores (core in Vulkan 1.2), on a device whose... | every device (no Vulkan mechanism) | 1: `crates/metal2vulkan-runtime/src/device/create.rs:1014` | `none`: a device below the runtime's floor |
| `Reflection` | Reflection of an argument whose answer Metal's has not been measured for (`reflection`) | every device (not implemented) | 9: `crates/metal2vulkan/src/bind/argument_buffer.rs:628`, `crates/metal2vulkan/src/reflection/derive.rs:179` (+7) | `rare`: reflection of argument kinds Metal's answer is unmeasured for |
| `HeapTextureTiling` | A texture of a heap whose memory the device's optimal images do not take (a `Shared` heap on a device whose optimal images take no host-visible... | every device (no Vulkan mechanism) | 1: `crates/metal2vulkan-runtime/src/texture/heap.rs:540` | `app`: textures in Shared heaps on a device whose optimal images take no host memory |
| `ViewportDepthRange` | A viewport depth range past `[0, 1]` (`setViewport:`), which Metal takes and the runtime draws natively (`VK_EXT_depth_range_unrestricted`) or... | drivers with a defect | 1: `crates/metal2vulkan-runtime/src/render_state.rs:1035` | `rare`: viewport depth outside [0, 1] |
@@ -152,8 +152,8 @@ Generated at `53fc528b6`.
| `IndirectRenderState` | A render state a function sets on an indirect render command (`render_command::set_cull_mode`, `set_front_facing_winding`,... | every device (not implemented) | 1: `crates/metal2vulkan/src/lower/access/encode.rs:559` | `rare`: render state set by a kernel on an indirect command |
| `GlobalBuiltinInFragment` | A fragment function's read of a Metal 3.1 program-scope built-in variable that Metal does not lower there | every device (not implemented) | 1: `crates/metal2vulkan/src/lower/select.rs:896` | `rare`: Metal 3.1 global built-ins in fragment functions |
| `PrivateRenderState` | A private fixed-function property of Metal's pipeline descriptor (Apple SPI, OpenGL on Metal's) set to a value whose effect the translation has... | every device (not implemented) | 4: `crates/metal2vulkan/src/bind/heap.rs:1278`, `crates/metal2vulkan/src/bind/plan/resources.rs:880` (+2) | `none`: Apple-private pipeline fields of OpenGL on Metal (no public header) |
| `ExtendedRangeBlend` | Metal's blend into an extended-range attachment (`BGRA10_XR`, `BGR10_XR`, `RGB10A8_2P_XR10` and their `_sRGB` twins), which the function computes... | every device (not implemented) | 4: `crates/metal2vulkan/src/lower/arith/extended_range/blend.rs:276`, `crates/metal2vulkan/src/lower/fragment/fetch.rs:1006` (+2) | `system`: the parts of a blend into an extended-range (XR10) attachment the measured model does not hold (second-source factors, the color blend color difference, a one-color-channel mask, float4 and sRGB outside the measured forms); the consumer's guests blend RGB10A8_2P_XR10 attachments |
| `TileReach` | The tiles a render pass's primitives reach, binned on the device ([`tile_reach_module`](crate::bind::tile_reach_module)), on a device without what... | devices short of a Vulkan feature the site names; devices without a capability the site computes (`vec![int64]`); devices without buffer device addresses (`addressed_needs`); every device (not implemented) | 5: `crates/metal2vulkan/src/bind/tile_reach.rs:272`, `crates/metal2vulkan/src/lower/stage_io/plan.rs:1944` (+3) | `app`: the tiles a pass's draws reach, binned on a device without shaderInt64 |
| `ExtendedRangeBlend` | Metal's blend into an extended-range attachment (`BGRA10_XR`, `BGR10_XR`, `RGB10A8_2P_XR10` and their `_sRGB` twins), which the function computes... | every device (not implemented) | 4: `crates/metal2vulkan/src/lower/arith/extended_range/blend.rs:276`, `crates/metal2vulkan/src/lower/fragment/fetch.rs:1008` (+2) | `system`: the parts of a blend into an extended-range (XR10) attachment the measured model does not hold (second-source factors, the color blend color difference, a one-color-channel mask, float4 and sRGB outside the measured forms); the consumer's guests blend RGB10A8_2P_XR10 attachments |
| `TileReach` | The tiles a render pass's primitives reach, binned on the device ([`tile_reach_module`](crate::bind::tile_reach_module)), on a device without what... | devices short of a Vulkan feature the site names; devices without a capability the site computes (`vec![int64]`); devices without buffer device addresses (`addressed_needs`); every device (not implemented) | 5: `crates/metal2vulkan/src/bind/tile_reach.rs:272`, `crates/metal2vulkan/src/lower/stage_io/plan.rs:1946` (+3) | `app`: the tiles a pass's draws reach, binned on a device without shaderInt64 |
| `CommandPredication` | Metal's private command predication (`encodeStartIf:offset:comparison:referenceValue:` and the rest), whose step module... | devices without buffer device addresses (`addressed_needs`) | 1: `crates/metal2vulkan/src/bind/replay/predication.rs:415` | `none`: Apple-private command predication on a device without buffer device addresses |
| `ProgramScopeBinding` | A program-scope buffer binding of MSL 3.2 (macOS 15 and later), `constant T* constant p [[buffer(n)]];` in Apple's `!air.global_bindings` list,... | - | via a helper: 2: `crates/metal2vulkan-air/src/abi/module.rs:77`, `crates/metal2vulkan/src/error/mod.rs:268` | `app`: MSL 3.2 program-scope buffer bindings (macOS 15 and later) |
| `SeqCstFence` | A sequentially consistent fence (`seq_cst` `atomic_thread_fence`, an LLVM `fence seq_cst`, or a `seq_cst` barrier ordering device memory), whose... | devices short of a Vulkan feature the site names; devices without buffer device addresses (`addressed_needs`) | 2: `crates/metal2vulkan/src/lower/sync/barrier.rs:443`, `crates/metal2vulkan/src/lower/sync/barrier.rs:449` | `rare`: a seq_cst fence on a device without buffer device addresses or the stage's stores |
@@ -162,13 +162,13 @@ Generated at `53fc528b6`.
| Variant | What it blocks | Where | Sites | Reach |
|---|---|---|---|---|
| `Textures` | Textures and texture buffers | every device (runtime piece not built) | 9: `crates/metal2vulkan-runtime/src/blit_texture.rs:159`, `crates/metal2vulkan-runtime/src/buffer_texture.rs:1522` (+7) | `rare`: texture forms the runtime has not built (texture buffers of some forms, X24Stencil8 views) |
| `Textures` | Textures and texture buffers | every device (runtime piece not built) | 9: `crates/metal2vulkan-runtime/src/blit_texture.rs:159`, `crates/metal2vulkan-runtime/src/buffer_texture.rs:1525` (+7) | `rare`: texture forms the runtime has not built (texture buffers of some forms, X24Stencil8 views) |
| `ResourceHeap` | The resource-ID heap, descriptor set 1 | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/binding.rs:1358` | `rare`: the resource-ID heap's remaining forms |
| `SparseHeaps` | Sparse heaps and their textures | every device (runtime piece not built) | 3: `crates/metal2vulkan-runtime/src/sparse/encoder.rs:458`, `crates/metal2vulkan-runtime/src/texture.rs:1360` (+1) | `rare`: sparse heaps |
| `SparseHeaps` | Sparse heaps and their textures | every device (runtime piece not built) | 3: `crates/metal2vulkan-runtime/src/sparse/encoder.rs:458`, `crates/metal2vulkan-runtime/src/texture.rs:1476` (+1) | `rare`: sparse heaps |
| `SparseTileMaps` | What the runtime's emulation of sparse textures does not build yet | every device (runtime piece not built) | 3: `crates/metal2vulkan-runtime/src/binding.rs:428`, `crates/metal2vulkan-runtime/src/sparse/texture.rs:30` (+1) | `rare`: sparse texture emulation's unbuilt pieces |
| `HeapPastMaxBufferSize` | A heap larger than the device's `maxBufferSize`, which the device can allocate | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/heap.rs:686` | `rare`: a heap past maxBufferSize |
| `HeapTextureAlignment` | A heap texture whose image needs an alignment past the heap memory's base alignment (64 KiB) | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/texture/heap.rs:1269` | `rare`: a heap texture needing more than 64 KiB alignment |
| `HeapTextureMemory` | A heap texture whose image the heap's memory type does not take | every device (runtime piece not built) | 5: `crates/metal2vulkan-runtime/src/texture/heap.rs:1254`, `crates/metal2vulkan-runtime/src/texture/heap.rs:1261` (+3) | `app`: a heap texture the heap's memory type does not take |
| `HeapPastMaxBufferSize` | A heap larger than the device's `maxBufferSize`, which the device can allocate | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/heap.rs:689` | `rare`: a heap past maxBufferSize |
| `HeapTextureAlignment` | A heap texture whose image needs an alignment past the heap memory's base alignment (64 KiB) | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/texture/heap.rs:1275` | `rare`: a heap texture needing more than 64 KiB alignment |
| `HeapTextureMemory` | A heap texture whose image the heap's memory type does not take | every device (runtime piece not built) | 5: `crates/metal2vulkan-runtime/src/texture/heap.rs:1260`, `crates/metal2vulkan-runtime/src/texture/heap.rs:1267` (+3) | `app`: a heap texture the heap's memory type does not take |
| `FunctionTablePastMaxBufferLength` | A visible-function table of more entries than one buffer of the device's `max_buffer_length` holds words for, or than its size word holds | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/function_table.rs:628` | `none`: a function table past one buffer |
| `IndirectCommandBufferPastMaxBufferLength` | An indirect command buffer of more commands than one buffer of the device's `max_buffer_length` holds the records of | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs:522` | `none`: an ICB past one buffer |
| `IndirectRenderCommands` | What indirect command buffers lack of their render commands | every device (runtime piece not built) | 16: `crates/metal2vulkan-runtime/src/compute.rs:1026`, `crates/metal2vulkan-runtime/src/compute.rs:1076` (+14) | `rare`: indirect render commands' remaining pieces |
@@ -207,20 +207,20 @@ Generated at `53fc528b6`.
| `LayeredPass` | A layered render pass (`renderTargetArrayLength` 2 or more) that needs a step of one layer | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/color_resolve.rs:517` | `rare`: layered passes needing a per-layer color resolve |
| `FunctionOptions` | A function descriptor's options beyond `CompileToBinary` and `StoreFunctionInMetalPipelinesScript` (`Library::new_function_with_descriptor`) | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/library.rs:215` | `rare`: function descriptor options beyond CompileToBinary |
| `OverlappingTextureCopies` | A blit copy between overlapping regions of one texture's texels (`copyFromTexture:...` with the source's region meeting the destination's, through... (not scheduled) | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/blit_texture.rs:1201` | `rare`: overlapping texture copies (Metal races) |
| `RebindTextures` | `Buffer::rebind_bytes_no_copy` of a no-copy buffer with a live texture over its bytes, given memory at another offset in its page than the old | every device (runtime piece not built) | 4: `crates/metal2vulkan-runtime/src/buffer_descriptor.rs:575`, `crates/metal2vulkan-runtime/src/texture.rs:2420` (+2) | `none`: a runtime extension's rebind with a live texture |
| `PvrtcBlockOrder` | A PVRTC texture's blocks in a Metal block order the runtime does not lay out | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/texture.rs:5095` | `rare`: PVRTC regions off whole levels |
| `RebindTextures` | `Buffer::rebind_bytes_no_copy` of a no-copy buffer with a live texture over its bytes, given memory at another offset in its page than the old | every device (runtime piece not built) | 10: `crates/metal2vulkan-runtime/src/buffer_descriptor.rs:567`, `crates/metal2vulkan-runtime/src/texture.rs:2696` (+8) | `none`: a runtime extension's rebind with a live texture |
| `PvrtcBlockOrder` | A PVRTC texture's blocks in a Metal block order the runtime does not lay out | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/texture.rs:5465` | `rare`: PVRTC regions off whole levels |
| `VertexFetchPast4GiB` | A draw (`drawPrimitives:` and its forms, or an indirect command buffer's command) that may read a vertex attribute the pipeline fetches in its... | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/render/vertex_reach.rs:72` | `rare`: vertex fetch past 4 GiB of a bind offset |
| `StageInFetchPast4GiB` | A dispatch (`dispatchThreads:threadsPerThreadgroup:` and its forms, or an indirect command buffer's command) whose kernel may read a... | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/fetch_reach.rs:126` | `rare`: stage-in fetch past 4 GiB of a bind offset |
| `MappedTextureSampling` | A command that would sample a texture of an address-mode map (`TextureDescriptor::address_mode_map`) where the runtime cannot map it at bind... | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/address_map.rs:158` | `none`: a runtime extension's texture (address_mode_map) sampled where the runtime cannot map it; no Metal API path |
| `LibrarySource` | A library compiled from Metal Shading Language source | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/library.rs:107` | `app`: a library compiled from Metal source (newLibraryWithSource:); the runtime takes metallibs and AIR |
| `RestartedStrip` | An indexed strip after `set_primitive_restart_enabled` with an index Vulkan does not restart at, which the runtime draws as a list an index... | every device (runtime piece not built) | 2: `crates/metal2vulkan-runtime/src/index_rewrite.rs:109`, `crates/metal2vulkan-runtime/src/render.rs:5912` | `none`: a strip after the Apple-private setPrimitiveRestartEnabled:index: whose rewrite pass cannot run as Metal draws |
| `RotatedTexture` | A rotated texture (`TextureDescriptor::rotation`) where the runtime does not build what Metal does | every device (runtime piece not built) | 9: `crates/metal2vulkan-runtime/src/blit_texture.rs:1508`, `crates/metal2vulkan-runtime/src/buffer_texture.rs:706` (+7) | `rare`: a rotated drawable's views, blits with images over overlapping rows, rows past its buffer |
| `DetachTextures` | A texture over a no-copy buffer's or heap's bytes (a heap's texture, or a texture over the buffer or over one of the heap's buffers) that no... | every device (runtime piece not built) | 9: `crates/metal2vulkan-runtime/src/buffer.rs:1969`, `crates/metal2vulkan-runtime/src/buffer_descriptor.rs:583` (+7) | `none`: a runtime extension's detach with a texture no stand-in presents exactly |
| `DetachTextures` | A texture over a no-copy buffer's or heap's bytes (a heap's texture, or a texture over the buffer or over one of the heap's buffers) that no... | every device (runtime piece not built) | 9: `crates/metal2vulkan-runtime/src/buffer.rs:1999`, `crates/metal2vulkan-runtime/src/buffer_descriptor.rs:572` (+7) | `none`: a runtime extension's detach with a texture no stand-in presents exactly |
| `TextureBufferLevels` | A texture buffer of more than one level (`TextureDescriptor::mipmap_level_count`, up to its width's full chain) from the device's, a heap's or the... | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/texture_descriptor.rs:531` | `rare`: a texture buffer of more than one level (public, unusual) |
| `WriteSwizzle` | A texture of `TextureDescriptor::write_swizzle_enabled` whose swizzle is not the default, with `ShaderWrite` or `RenderTarget` usage, from the... | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/texture_descriptor.rs:538` | `none`: Apple-private writeSwizzleEnabled with a swizzle that writes |
| `DetachedTexelAccess` | `Texture::replace_region` or `get_bytes` of a texture whose bytes (a no-copy buffer's or heap's) are detached (`detach_backing`) | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/texture.rs:4392` | `none`: CPU texel access while a runtime extension detached the bytes |
| `DetachedTexelAccess` | `Texture::replace_region` or `get_bytes` of a texture whose bytes (a no-copy buffer's or heap's) are detached (`detach_backing`) | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/texture.rs:4762` | `none`: CPU texel access while a runtime extension detached the bytes |
| `SurfaceDepthStencil` | A use of a texture of a depth or stencil format (`Depth16Unorm`, `Depth32Float`, `Depth32Float_Stencil8`, `Stencil8`, `X32_Stencil8`) over a plane... | every device (runtime piece not built) | 2: `crates/metal2vulkan-runtime/src/blit_texture.rs:232`, `crates/metal2vulkan-runtime/src/texture/surface_depth.rs:56` | `rare`: a blit of the stencil of a Depth32Float_Stencil8 texture over a plane of an IOSurface with planes, or a pass on an X32_Stencil8 one's view as Depth32Float_Stencil8 |
| `HostHeapUncompressedMultisample` | A multisample texture in a heap over host pages (`Device::new_heap_with_bytes_no_copy`) that Metal keeps uncompressed | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/texture/heap.rs:1707` | `none`: a multisample texture Metal keeps uncompressed in a runtime extension's heap over host pages |
| `HostHeapUncompressedMultisample` | A multisample texture in a heap over host pages (`Device::new_heap_with_bytes_no_copy`) that Metal keeps uncompressed | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/texture/heap.rs:1719` | `none`: a multisample texture Metal keeps uncompressed in a runtime extension's heap over host pages |
| `PredicationUnbalanced` | An unbalanced command-predication record (`ComputeCommandEncoder::encode_end_if` and the other ends, or `encode_start_else`, with no block open;... | every device (runtime piece not built) | 4: `crates/metal2vulkan-runtime/src/predication.rs:354`, `crates/metal2vulkan-runtime/src/predication.rs:386` (+2) | `none`: an unbalanced Apple-private command-predication record, whose dropped work Metal decides by no rule measured |
| `PredicationOpenAtUnitEnd` | A command buffer one of whose units of predication ended with an If still open that no misused record killed, refused at `CommandBuffer::commit` | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/predication.rs:279` | `none`: an Apple-private predication If left open, live, where its unit ends |
| `PredicationWordPastBuffer` | A predication condition word (`encode_start_if`'s offset, rounded down to a multiple of 4) past its buffer's end | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/predication.rs:139` | `none`: an Apple-private predication condition word past its buffer |
@@ -269,7 +269,7 @@ Generated at `53fc528b6`.
| `TypeCount` | Types in the bitcode type table | every device (a deterministic cap) | 2: `crates/metal2vulkan-air/src/bitcode/types.rs:159`, `crates/metal2vulkan-air/src/ir/types.rs:239` | `none`: a type table past the cap |
| `MetadataNodes` | Metadata nodes | every device (a deterministic cap) | 3: `crates/metal2vulkan-air/src/bitcode/function.rs:334`, `crates/metal2vulkan-air/src/bitcode/metadata.rs:192` (+1) | `none`: metadata past the cap |
| `BitstreamNesting` | Bitstream block nesting | every device (a deterministic cap) | 1: `crates/metal2vulkan-air/src/bitstream/mod.rs:267` | `none`: malformed nesting |
| `InstructionCount` | Instructions of the decoded module | every device (a deterministic cap) | 8: `crates/metal2vulkan-air/src/bitcode/function.rs:1467`, `crates/metal2vulkan-air/src/bitcode/function.rs:180` (+6) | `rare`: very large modules |
| `InstructionCount` | Instructions of the decoded module | every device (a deterministic cap) | 8: `crates/metal2vulkan-air/src/bitcode/function.rs:1462`, `crates/metal2vulkan-air/src/bitcode/function.rs:180` (+6) | `rare`: very large modules |
| `LayoutNesting` | Nesting depth of `air.struct_type_info` layouts and the argument-buffer members inside them | every device (a deterministic cap) | 3: `crates/metal2vulkan-air/src/abi/structs.rs:147`, `crates/metal2vulkan-air/src/abi/structs.rs:160` (+1) | `none`: argument-buffer layouts nested past the cap |
| `ConstructNesting` | Nesting depth of structured constructs the structurizer emits (P8 recurses once per level) | every device (a deterministic cap) | 2: `crates/metal2vulkan/src/structurize/emit.rs:216`, `crates/metal2vulkan/src/structurize/emit/predicate.rs:151` | `none`: control flow nested past the cap |
| `PrivateArenaBytes` | Bytes of a function's private arena, whose pointers are `u32` byte offsets | every device (a deterministic cap) | 3: `crates/metal2vulkan/src/lower/access/local.rs:595`, `crates/metal2vulkan/src/memory/plan.rs:1684` (+1) | `none`: a private arena past 4 GiB |
@@ -299,9 +299,9 @@ Each refusal's sites, with the function that builds it.
- `feature::Stage`: `crates/metal2vulkan-air/src/abi/check.rs:579 (unsupported_stage)`; `crates/metal2vulkan/src/error/mod.rs:246 (from)`
- `feature::AddressSpace`: `crates/metal2vulkan-air/src/ir/types.rs:191 (from_raw)`; `crates/metal2vulkan/src/memory/plan.rs:1854 (reprs)`
- `feature::ModuleRecord`: `crates/metal2vulkan-air/src/bitcode/module.rs:343 (record)`; `crates/metal2vulkan-air/src/bitcode/module.rs:435 (global)`; `crates/metal2vulkan-air/src/bitcode/module.rs:514 (function)`; `crates/metal2vulkan/src/error/mod.rs:248 (from)`
- `feature::Instruction`: `crates/metal2vulkan-air/src/bitcode/function.rs:1015 (record)`; `crates/metal2vulkan-air/src/bitcode/function.rs:1062 (record)`; `crates/metal2vulkan-air/src/bitcode/function.rs:1083 (record)`; `crates/metal2vulkan-air/src/bitcode/function.rs:1140 (record)`; `crates/metal2vulkan-air/src/bitcode/function.rs:1214 (record)`; `crates/metal2vulkan-air/src/bitcode/function.rs:1222 (record)`; `crates/metal2vulkan-air/src/bitcode/function.rs:1238 (record)`; `crates/metal2vulkan-air/src/bitcode/function.rs:1343 (call)`; `crates/metal2vulkan-air/src/bitcode/function.rs:1385 (call)`; `crates/metal2vulkan-air/src/bitcode/function.rs:828 (record)`; `crates/metal2vulkan/src/error/mod.rs:249 (from)`
- `feature::Instruction`: `crates/metal2vulkan-air/src/bitcode/function.rs:1010 (record)`; `crates/metal2vulkan-air/src/bitcode/function.rs:1057 (record)`; `crates/metal2vulkan-air/src/bitcode/function.rs:1078 (record)`; `crates/metal2vulkan-air/src/bitcode/function.rs:1135 (record)`; `crates/metal2vulkan-air/src/bitcode/function.rs:1209 (record)`; `crates/metal2vulkan-air/src/bitcode/function.rs:1217 (record)`; `crates/metal2vulkan-air/src/bitcode/function.rs:1233 (record)`; `crates/metal2vulkan-air/src/bitcode/function.rs:1338 (call)`; `crates/metal2vulkan-air/src/bitcode/function.rs:1380 (call)`; `crates/metal2vulkan-air/src/bitcode/function.rs:823 (record)`; `crates/metal2vulkan/src/error/mod.rs:249 (from)`
- `feature::Type`: `crates/metal2vulkan-air/src/bitcode/types.rs:184 (decode)`; `crates/metal2vulkan-air/src/bitcode/types.rs:206 (decode)`; `crates/metal2vulkan-air/src/bitcode/types.rs:232 (decode)`; `crates/metal2vulkan/src/error/mod.rs:250 (from)`
- `feature::CallingConvention`: `crates/metal2vulkan-air/src/bitcode/function.rs:1359 (call)`; `crates/metal2vulkan-air/src/bitcode/module.rs:499 (function)`; `crates/metal2vulkan/src/error/mod.rs:251 (from)`
- `feature::CallingConvention`: `crates/metal2vulkan-air/src/bitcode/function.rs:1354 (call)`; `crates/metal2vulkan-air/src/bitcode/module.rs:499 (function)`; `crates/metal2vulkan/src/error/mod.rs:251 (from)`
- `feature::UnknownIntrinsic`: `crates/metal2vulkan-air/src/error.rs:621 (from)`; `crates/metal2vulkan/src/lower/select.rs:990 (route)`
- `feature::AgxUnmodeled`: `crates/metal2vulkan/src/lower/simd/agx.rs:62 (unmodeled)`
- `feature::StaticInitializer`: `crates/metal2vulkan-air/src/error.rs:627 (from)`
@@ -326,18 +326,18 @@ Each refusal's sites, with the function that builds it.
- `feature::ThreadgroupMemorySize`: `crates/metal2vulkan/src/bind/plan/compute.rs:710 (plan)`; `crates/metal2vulkan/src/memory/arena.rs:169 (check)`; `crates/metal2vulkan/src/memory/plan.rs:457 (too_large)`
- `feature::CoherentMemory`: `crates/metal2vulkan/src/lower/sync/memory_model.rs:152 (check)`
- `feature::Int64Atomics`: `crates/metal2vulkan/src/lower/access/atomic.rs:624 (select)`; `crates/metal2vulkan/src/lower/access/atomic.rs:633 (select)`
- `feature::ImageAtomics`: `crates/metal2vulkan-runtime/src/families/formats.rs:476 (atomic_gap)`; `crates/metal2vulkan-runtime/src/families/formats.rs:480 (atomic_gap)`; `crates/metal2vulkan/src/lower/texture/slot.rs:871 (atomic_format)`
- `feature::ImageAtomics`: `crates/metal2vulkan-runtime/src/families/formats.rs:476 (atomic_gap)`; `crates/metal2vulkan-runtime/src/families/formats.rs:480 (atomic_gap)`; `crates/metal2vulkan/src/lower/texture/slot.rs:880 (atomic_format)`
- `feature::DescriptorCount`: `crates/metal2vulkan/src/lower/access/mod.rs:1640 (accept_placement)`; `crates/metal2vulkan/src/lower/select.rs:1615 (finish)`; `crates/metal2vulkan/src/pipeline/link.rs:989 (limit_error)`
- `feature::BufferRange`: `crates/metal2vulkan-runtime/src/function_table.rs:575 (past_storage_buffer_range)`; `crates/metal2vulkan/src/bind/graphics.rs:2890 (patch_draw)`; `crates/metal2vulkan/src/bind/graphics.rs:2936 (patch_draw)`; `crates/metal2vulkan/src/bind/graphics.rs:2965 (patch_draw)`; `crates/metal2vulkan/src/bind/instantiate.rs:578 (bind_buffers)`; `crates/metal2vulkan/src/lower/access/function_table.rs:226 (select)`; `crates/metal2vulkan/src/lower/access/mod.rs:1155 (place_slots)`
- `feature::Int64Arithmetic`: `crates/metal2vulkan/src/lower/arith/legal.rs:582 (check_scalar)`; `crates/metal2vulkan/src/lower/select.rs:1117 (selector_form)`
- `feature::Float64Arithmetic`: `crates/metal2vulkan/src/device/metal.rs:230 (unsupported_features)`; `crates/metal2vulkan/src/lower/arith/legal.rs:587 (check_scalar)`
- `feature::Format`: `crates/metal2vulkan-runtime/src/binding_view.rs:146 (binding_view)`; `crates/metal2vulkan-runtime/src/blit_plan.rs:450 (check_formats)`; `crates/metal2vulkan-runtime/src/blit_plan.rs:464 (check_formats)`; `crates/metal2vulkan-runtime/src/blit_plan.rs:521 (pair_unit)`; `crates/metal2vulkan-runtime/src/blit_texture.rs:1980 (through_buffer)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:512 (make_texture_over)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:576 (make_texture_over)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:608 (make_texture_over)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:841 (texture_buffer_texel)`; `crates/metal2vulkan-runtime/src/copy_plan.rs:270 (colour_unit)`; `crates/metal2vulkan-runtime/src/copy_plan.rs:298 (copy_unit)`; `crates/metal2vulkan-runtime/src/copy_plan.rs:344 (copy_unit)`; `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:345 (scratch)`; `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:525 (usable_twin)`; `crates/metal2vulkan-runtime/src/families/features.rs:1555 (read_write_tier)`; `crates/metal2vulkan-runtime/src/families/formats.rs:1640 (sparse_missing)`; `crates/metal2vulkan-runtime/src/families/formats.rs:228 (none)`; `crates/metal2vulkan-runtime/src/families/formats.rs:272 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:292 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:307 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:365 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:404 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:486 (atomic_gap)`; `crates/metal2vulkan-runtime/src/families/formats.rs:520 (lacking)`; `crates/metal2vulkan-runtime/src/families/formats.rs:534 (unsupported)`; `crates/metal2vulkan-runtime/src/image_plan.rs:516 (check_own_memory)`; `crates/metal2vulkan-runtime/src/image_plan.rs:628 (plan_held)`; `crates/metal2vulkan-runtime/src/image_plan.rs:713 (plan_held)`; `crates/metal2vulkan-runtime/src/image_plan.rs:826 (plan_held)`; `crates/metal2vulkan-runtime/src/render.rs:5267 (viewing)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1259 (layout)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1578 (target)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1657 (attachment_format)`; `crates/metal2vulkan-runtime/src/render_pass.rs:926 (check_target)`; `crates/metal2vulkan-runtime/src/resolve.rs:387 (unmodelled_resolve)`; `crates/metal2vulkan-runtime/src/sample_copy.rs:176 (checked_twin)`; `crates/metal2vulkan-runtime/src/sample_copy.rs:204 (plan)`; `crates/metal2vulkan-runtime/src/sample_interleave.rs:295 (interleave_merge)`; `crates/metal2vulkan-runtime/src/shadow.rs:352 (unmerged)`; `crates/metal2vulkan-runtime/src/shadow.rs:359 (unmerged)`; `crates/metal2vulkan-runtime/src/texture.rs:1717 (texture_as)`; `crates/metal2vulkan-runtime/src/texture.rs:3269 (two_planes_refused)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:1604 (new_heap_texture)`; `crates/metal2vulkan-runtime/src/texture/surface_two_planes.rs:79 (refused)`; `crates/metal2vulkan-runtime/src/texture/ycbcr_image.rs:115 (converted_storage)`; `crates/metal2vulkan-runtime/src/texture/ycbcr_image.rs:275 (ycbcr_write_shadow)`; `crates/metal2vulkan-runtime/src/texture/ycbcr_image.rs:378 (new_render_shadow)`; `crates/metal2vulkan-runtime/src/two_planes.rs:115 (unmeasured)`; `crates/metal2vulkan-runtime/src/view_plan.rs:359 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:372 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:379 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:389 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:399 (check_format)`; `crates/metal2vulkan-runtime/src/ycbcr.rs:271 (refused)`; `crates/metal2vulkan/src/bind/extended_shadow.rs:184 (extended_shadow_module)`; `crates/metal2vulkan/src/bind/plan/resources.rs:1705 (extended_sampler)`; `crates/metal2vulkan/src/bind/plan/resources.rs:192 (require_filter_features)`; `crates/metal2vulkan/src/bind/plan/resources.rs:953 (plain_texture)`; `crates/metal2vulkan/src/bind/sample_interleave.rs:304 (finish)`; `crates/metal2vulkan/src/bind/unused_bits.rs:545 (unused_bits_module)`; `crates/metal2vulkan/src/lower/access/tile.rs:1029 (storage_format)`; `crates/metal2vulkan/src/lower/fragment/color.rs:154 (select_param)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1297 (select_output)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1323 (select_output)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:678 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:699 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:705 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:711 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:736 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:855 (plan)`; `crates/metal2vulkan/src/Line truncated
- `feature::Format`: `crates/metal2vulkan-runtime/src/binding_view.rs:146 (binding_view)`; `crates/metal2vulkan-runtime/src/blit_plan.rs:450 (check_formats)`; `crates/metal2vulkan-runtime/src/blit_plan.rs:464 (check_formats)`; `crates/metal2vulkan-runtime/src/blit_plan.rs:521 (pair_unit)`; `crates/metal2vulkan-runtime/src/blit_texture.rs:1980 (through_buffer)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:512 (make_texture_over)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:576 (make_texture_over)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:608 (make_texture_over)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:841 (texture_buffer_texel)`; `crates/metal2vulkan-runtime/src/copy_plan.rs:270 (colour_unit)`; `crates/metal2vulkan-runtime/src/copy_plan.rs:298 (copy_unit)`; `crates/metal2vulkan-runtime/src/copy_plan.rs:344 (copy_unit)`; `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:345 (scratch)`; `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:525 (usable_twin)`; `crates/metal2vulkan-runtime/src/families/features.rs:1555 (read_write_tier)`; `crates/metal2vulkan-runtime/src/families/formats.rs:1640 (sparse_missing)`; `crates/metal2vulkan-runtime/src/families/formats.rs:228 (none)`; `crates/metal2vulkan-runtime/src/families/formats.rs:272 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:292 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:307 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:365 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:404 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:486 (atomic_gap)`; `crates/metal2vulkan-runtime/src/families/formats.rs:520 (lacking)`; `crates/metal2vulkan-runtime/src/families/formats.rs:534 (unsupported)`; `crates/metal2vulkan-runtime/src/image_plan.rs:516 (check_own_memory)`; `crates/metal2vulkan-runtime/src/image_plan.rs:628 (plan_held)`; `crates/metal2vulkan-runtime/src/image_plan.rs:713 (plan_held)`; `crates/metal2vulkan-runtime/src/image_plan.rs:826 (plan_held)`; `crates/metal2vulkan-runtime/src/render.rs:5267 (viewing)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1259 (layout)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1578 (target)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1657 (attachment_format)`; `crates/metal2vulkan-runtime/src/render_pass.rs:926 (check_target)`; `crates/metal2vulkan-runtime/src/resolve.rs:387 (unmodelled_resolve)`; `crates/metal2vulkan-runtime/src/sample_copy.rs:176 (checked_twin)`; `crates/metal2vulkan-runtime/src/sample_copy.rs:204 (plan)`; `crates/metal2vulkan-runtime/src/sample_interleave.rs:295 (interleave_merge)`; `crates/metal2vulkan-runtime/src/shadow.rs:352 (unmerged)`; `crates/metal2vulkan-runtime/src/shadow.rs:359 (unmerged)`; `crates/metal2vulkan-runtime/src/texture.rs:1833 (texture_as)`; `crates/metal2vulkan-runtime/src/texture.rs:3639 (two_planes_refused)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:1610 (new_heap_texture)`; `crates/metal2vulkan-runtime/src/texture/surface_two_planes.rs:79 (refused)`; `crates/metal2vulkan-runtime/src/texture/ycbcr_image.rs:115 (converted_storage)`; `crates/metal2vulkan-runtime/src/texture/ycbcr_image.rs:275 (ycbcr_write_shadow)`; `crates/metal2vulkan-runtime/src/texture/ycbcr_image.rs:378 (new_render_shadow)`; `crates/metal2vulkan-runtime/src/two_planes.rs:115 (unmeasured)`; `crates/metal2vulkan-runtime/src/view_plan.rs:359 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:372 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:379 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:389 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:399 (check_format)`; `crates/metal2vulkan-runtime/src/ycbcr.rs:271 (refused)`; `crates/metal2vulkan/src/bind/extended_shadow.rs:184 (extended_shadow_module)`; `crates/metal2vulkan/src/bind/plan/resources.rs:1705 (extended_sampler)`; `crates/metal2vulkan/src/bind/plan/resources.rs:192 (require_filter_features)`; `crates/metal2vulkan/src/bind/plan/resources.rs:953 (plain_texture)`; `crates/metal2vulkan/src/bind/sample_interleave.rs:304 (finish)`; `crates/metal2vulkan/src/bind/unused_bits.rs:545 (unused_bits_module)`; `crates/metal2vulkan/src/lower/access/tile.rs:1029 (storage_format)`; `crates/metal2vulkan/src/lower/fragment/color.rs:154 (select_param)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1299 (select_output)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1325 (select_output)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:680 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:701 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:707 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:713 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:738 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:857 (plan)`; `crates/metal2vulkan/src/Line truncated
- `feature::DivergentImplicitLod`: `crates/metal2vulkan/src/lower/sampler/select.rs:377 (select_sampling)`
- `feature::ImplicitLodOutsideFragment`: `crates/metal2vulkan/src/lower/sampler/constexpr.rs:136 (query_min_level)`; `crates/metal2vulkan/src/lower/sampler/select.rs:254 (query_level_measured)`; `crates/metal2vulkan/src/lower/sampler/select.rs:280 (query_min_level)`
- `feature::MinLodClamp`: `crates/metal2vulkan/src/lower/sampler/select.rs:1311 (select_one)`; `crates/metal2vulkan/src/lower/sampler/select.rs:891 (min_lod)`
- `feature::TexelOffset`: `crates/metal2vulkan/src/lower/sampler/select.rs:750 (offset)`; `crates/metal2vulkan/src/lower/sampler/select.rs:824 (in_device_range)`
- `feature::GatherExtended`: `crates/metal2vulkan/src/lower/sampler/select.rs:782 (dynamic_offset)`
- `feature::StorageImageMultisample`: `crates/metal2vulkan/src/lower/texture/slot.rs:1037 (declare_slot)`
- `feature::StorageImageMultisample`: `crates/metal2vulkan/src/lower/texture/slot.rs:1046 (declare_slot)`
- `feature::StorageTextureInVertexStage`: `crates/metal2vulkan/src/lower/texture/slot.rs:666 (stage_stores)`
- `feature::CubeArray`: `crates/metal2vulkan/src/lower/sampler/select.rs:1214 (select_one)`; `crates/metal2vulkan/src/lower/texture/slot.rs:456 (declare_heap)`
- `feature::SamplerAnisotropy`: `crates/metal2vulkan/src/lower/sampler/select.rs:1409 (select_one)`; `crates/metal2vulkan/src/metal/sampler.rs:255 (check_sampler)`; `crates/metal2vulkan/src/metal/sampler.rs:258 (check_sampler)`
@@ -347,36 +347,36 @@ Each refusal's sites, with the function that builds it.
- `feature::PixelSamplerCompare`: `crates/metal2vulkan/src/lower/sampler/constexpr.rs:115 (lowered)`
- `feature::TexelBuffer`: `crates/metal2vulkan/src/bind/instantiate.rs:731 (texel_ranges)`; `crates/metal2vulkan/src/bind/instantiate.rs:737 (texel_ranges)`; `crates/metal2vulkan/src/bind/plan/resources.rs:1113 (plain_texture)`
- `feature::RasterOrderGroups`: `crates/metal2vulkan/src/device/metal.rs:242 (unsupported_features)`; `crates/metal2vulkan/src/lower/fragment/rog.rs:151 (mode)`; `crates/metal2vulkan/src/lower/fragment/rog.rs:172 (mode)`
- `feature::FramebufferFetch`: `crates/metal2vulkan-runtime/src/families/features.rs:1007 (state)`; `crates/metal2vulkan-runtime/src/framebuffer_fetch.rs:354 (ordered)`; `crates/metal2vulkan-runtime/src/render.rs:4359 (next_instance)`; `crates/metal2vulkan-runtime/src/sample_planes.rs:110 (lacks)`; `crates/metal2vulkan-runtime/src/sample_planes.rs:137 (new)`; `crates/metal2vulkan-runtime/src/sample_planes.rs:496 (planes_merge)`; `crates/metal2vulkan/src/bind/extended_shadow.rs:190 (extended_shadow_module)`; `crates/metal2vulkan/src/bind/graphics.rs:1013 (plan)`; `crates/metal2vulkan/src/bind/graphics.rs:1050 (plan)`; `crates/metal2vulkan/src/bind/graphics.rs:1069 (plan)`; `crates/metal2vulkan/src/bind/sample_planes.rs:431 (finish)`; `crates/metal2vulkan/src/device/metal.rs:255 (unsupported_features)`; `crates/metal2vulkan/src/lower/fragment/color.rs:208 (select_param)`; `crates/metal2vulkan/src/lower/fragment/color.rs:257 (unordered)`; `crates/metal2vulkan/src/lower/fragment/depth_test.rs:196 (not_implemented)`; `crates/metal2vulkan/src/lower/fragment/depth_test.rs:271 (depth_test_form)`; `crates/metal2vulkan/src/lower/fragment/depth_test.rs:317 (stencil_test_form)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1148 (plan_sample)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:383 (not_implemented)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:591 (storage_form)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:655 (storage_form)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:691 (extended_range_blend)`; `crates/metal2vulkan/src/pipeline/link/fetch.rs:159 (storage_attachments)`
- `feature::FramebufferFetch`: `crates/metal2vulkan-runtime/src/families/features.rs:1007 (state)`; `crates/metal2vulkan-runtime/src/framebuffer_fetch.rs:354 (ordered)`; `crates/metal2vulkan-runtime/src/render.rs:4359 (next_instance)`; `crates/metal2vulkan-runtime/src/sample_planes.rs:110 (lacks)`; `crates/metal2vulkan-runtime/src/sample_planes.rs:137 (new)`; `crates/metal2vulkan-runtime/src/sample_planes.rs:496 (planes_merge)`; `crates/metal2vulkan/src/bind/extended_shadow.rs:190 (extended_shadow_module)`; `crates/metal2vulkan/src/bind/graphics.rs:1013 (plan)`; `crates/metal2vulkan/src/bind/graphics.rs:1050 (plan)`; `crates/metal2vulkan/src/bind/graphics.rs:1069 (plan)`; `crates/metal2vulkan/src/bind/sample_planes.rs:431 (finish)`; `crates/metal2vulkan/src/device/metal.rs:255 (unsupported_features)`; `crates/metal2vulkan/src/lower/fragment/color.rs:208 (select_param)`; `crates/metal2vulkan/src/lower/fragment/color.rs:257 (unordered)`; `crates/metal2vulkan/src/lower/fragment/depth_test.rs:196 (not_implemented)`; `crates/metal2vulkan/src/lower/fragment/depth_test.rs:271 (depth_test_form)`; `crates/metal2vulkan/src/lower/fragment/depth_test.rs:317 (stencil_test_form)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1150 (plan_sample)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:383 (not_implemented)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:591 (storage_form)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:657 (storage_form)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:693 (extended_range_blend)`; `crates/metal2vulkan/src/pipeline/link/fetch.rs:159 (storage_attachments)`
- `feature::PrimitiveId`: `crates/metal2vulkan/src/device/metal.rs:264 (unsupported_features)`
- `feature::VertexAmplification`: `crates/metal2vulkan/src/bind/graphics.rs:3109 (multiview_instances)`; `crates/metal2vulkan/src/lower/tessellation/mod.rs:646 (select_param)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:219 (vertex_amplification)`; `crates/metal2vulkan/src/pipeline/link/tessellation/mod.rs:238 (control_plan)`
- `feature::LayeredRendering`: `crates/metal2vulkan-runtime/src/render_pass.rs:1538 (target)`; `crates/metal2vulkan/src/lower/mesh/mod.rs:736 (target_index)`; `crates/metal2vulkan/src/lower/mesh/mod.rs:755 (target_index)`
- `feature::ClipDistance`: `crates/metal2vulkan/src/lower/mesh/mod.rs:892 (select)`; `crates/metal2vulkan/src/lower/mesh/mod.rs:900 (select)`
- `feature::DualSourceBlending`: `crates/metal2vulkan-runtime/src/families/formats.rs:398 (answers)`; `crates/metal2vulkan/src/metal/state.rs:37 (blend_factor)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:1013 (check_outputs)`; `crates/metal2vulkan/src/pipeline/rotated_blend.rs:464 (rotated_blend)`; `crates/metal2vulkan/src/pipeline/rotated_blend.rs:539 (rotated_blend)`
- `feature::Barycentrics`: `crates/metal2vulkan/src/lower/stage_io/plan.rs:1460 (input_builtin)`
- `feature::Barycentrics`: `crates/metal2vulkan/src/lower/stage_io/plan.rs:1462 (input_builtin)`
- `feature::StencilExport`: `crates/metal2vulkan-runtime/src/families/features.rs:1091 (state)`; `crates/metal2vulkan/src/bind/graphics.rs:2058 (shadow_stencil_words)`; `crates/metal2vulkan/src/lower/fragment/stencil.rs:157 (device_form)`; `crates/metal2vulkan/src/lower/fragment/stencil.rs:168 (not_implemented)`; `crates/metal2vulkan/src/pipeline/link/stencil.rs:55 (shadow_stencil)`; `crates/metal2vulkan/src/pipeline/link/stencil.rs:73 (shadow_stencil)`
- `feature::SampleRateShading`: `crates/metal2vulkan/src/pipeline/link/graphics.rs:700 (sample_invocations)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:702 (sample_invocations)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:789 (sample_invocations)`
- `feature::PixelCoverageAtSampleRate`: `crates/metal2vulkan/src/lower/fragment/coverage.rs:291 (finish)`; `crates/metal2vulkan/src/lower/simd/mod.rs:735 (select_param)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:735 (sample_invocations)`
- `feature::PixelCoverageAtSampleRate`: `crates/metal2vulkan/src/lower/fragment/coverage.rs:291 (finish)`; `crates/metal2vulkan/src/lower/simd/mod.rs:739 (select_param)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:735 (sample_invocations)`
- `feature::InterfaceComponents`: `crates/metal2vulkan/src/pipeline/link/graphics.rs:256 (graphics_state)`; `crates/metal2vulkan/src/pipeline/link/varyings.rs:343 (assign)`; `crates/metal2vulkan/src/pipeline/link/varyings.rs:77 (limit_error)`
- `feature::UnmatchedVarying`: `crates/metal2vulkan/src/pipeline/link/varyings.rs:253 (mesh_fragment)`; `crates/metal2vulkan/src/pipeline/link/varyings.rs:439 (varyings)`; `crates/metal2vulkan/src/pipeline/link/varyings.rs:450 (varyings)`
- `feature::KernelStageIn`: `crates/metal2vulkan-runtime/src/indirect_execute.rs:337 (record)`; `crates/metal2vulkan/src/bind/dispatch.rs:881 (instantiate)`; `crates/metal2vulkan/src/lower/stage_io/stage_in.rs:133 (select)`
- `feature::Tessellation`: `crates/metal2vulkan-air/src/canon/mod.rs:1220 (post_check)`; `crates/metal2vulkan-air/src/canon/mod.rs:1311 (post_check)`; `crates/metal2vulkan/src/lower/stage_io/fetch.rs:519 (select)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:1328 (input_builtin)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:710 (param)`; `crates/metal2vulkan/src/lower/tessellation/mod.rs:100 (not_implemented)`; `crates/metal2vulkan/src/lower/tessellation/mod.rs:432 (plan_entry)`; `crates/metal2vulkan/src/lower/tessellation/mod.rs:435 (plan_entry)`; `crates/metal2vulkan/src/metal/vertex.rs:219 (fetch_as)`; `crates/metal2vulkan/src/pipeline/link/tessellation/mod.rs:222 (control_plan)`; `crates/metal2vulkan/src/pipeline/link/tessellation/mod.rs:251 (check_fragment)`; `crates/metal2vulkan/src/pipeline/link/tessellation/mod.rs:275 (push_offset)`
- `feature::Tessellation`: `crates/metal2vulkan-air/src/canon/mod.rs:1220 (post_check)`; `crates/metal2vulkan-air/src/canon/mod.rs:1311 (post_check)`; `crates/metal2vulkan/src/lower/stage_io/fetch.rs:519 (select)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:1330 (input_builtin)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:710 (param)`; `crates/metal2vulkan/src/lower/tessellation/mod.rs:100 (not_implemented)`; `crates/metal2vulkan/src/lower/tessellation/mod.rs:432 (plan_entry)`; `crates/metal2vulkan/src/lower/tessellation/mod.rs:435 (plan_entry)`; `crates/metal2vulkan/src/metal/vertex.rs:219 (fetch_as)`; `crates/metal2vulkan/src/pipeline/link/tessellation/mod.rs:222 (control_plan)`; `crates/metal2vulkan/src/pipeline/link/tessellation/mod.rs:251 (check_fragment)`; `crates/metal2vulkan/src/pipeline/link/tessellation/mod.rs:275 (push_offset)`
- `feature::MeshShading`: `crates/metal2vulkan/src/bind/graphics.rs:1096 (plan)`; `crates/metal2vulkan/src/bind/graphics.rs:2398 (mesh_limit)`; `crates/metal2vulkan/src/lower/mesh/mod.rs:459 (check_payload)`; `crates/metal2vulkan/src/lower/mesh/mod.rs:496 (plan_entry)`; `crates/metal2vulkan/src/lower/mesh/mod.rs:530 (plan_entry)`; `crates/metal2vulkan/src/memory/plan.rs:1849 (reprs)`; `crates/metal2vulkan/src/pipeline/link/mesh.rs:72 (records)`
- `feature::TileShading`: `crates/metal2vulkan-runtime/src/render/tile_dispatch.rs:497 (scratch)`; `crates/metal2vulkan/src/bind/plan/compute.rs:236 (tile_memory)`; `crates/metal2vulkan/src/lower/access/tile.rs:151 (not_implemented)`; `crates/metal2vulkan/src/lower/sync/barrier.rs:275 (tile_shading)`; `crates/metal2vulkan/src/pipeline/compile/api.rs:607 (tile_pipeline)`
- `feature::Imageblocks`: `crates/metal2vulkan/src/lower/access/imageblock.rs:98 (imageblocks)`; `crates/metal2vulkan/src/lower/access/mod.rs:879 (select_param)`; `crates/metal2vulkan/src/lower/fragment/imageblock.rs:103 (require)`; `crates/metal2vulkan/src/lower/fragment/imageblock.rs:85 (not_implemented)`; `crates/metal2vulkan/src/lower/texture/mod.rs:2289 (select)`; `crates/metal2vulkan/src/lower/texture/slice.rs:127 (imageblocks)`; `crates/metal2vulkan/src/pipeline/link/imageblock.rs:46 (fragment_imageblock)`
- `feature::RayTracing`: `crates/metal2vulkan/src/bind/acceleration.rs:202 (instance_record)`; `crates/metal2vulkan/src/bind/acceleration.rs:216 (instance_record)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs:1087 (primitive_data_read)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs:1202 (instance_count)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs:1245 (intersect)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs:1257 (intersect)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs:1282 (intersect)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs:1297 (intersect)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs:1312 (intersect)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs:344 (slot_of)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs:385 (select_param)`; `crates/metal2vulkan/src/lower/select.rs:883 (route_air)`
- `feature::Tensors`: `crates/metal2vulkan-air/src/canon/matmul2d/synth.rs:32 (refuse)`; `crates/metal2vulkan/src/lower/select.rs:887 (route_air)`
- `feature::RasterizationRateMap`: `crates/metal2vulkan/src/lower/fragment/mod.rs:875 (select)`
- `feature::GpuEncodedIndirectCommands`: `crates/metal2vulkan/src/bind/replay.rs:530 (preprocess)`; `crates/metal2vulkan/src/bind/replay.rs:770 (replay_preprocess_module)`; `crates/metal2vulkan/src/bind/replay/flat.rs:247 (flat_dispatch_module)`; `crates/metal2vulkan/src/lower/access/encode.rs:390 (needs)`; `crates/metal2vulkan/src/lower/access/encode.rs:406 (needs)`; `crates/metal2vulkan/src/lower/access/encode.rs:518 (select_command)`; `crates/metal2vulkan/src/lower/access/mod.rs:1509 (plan_replay)`; `crates/metal2vulkan/src/lower/access/mod.rs:1522 (plan_replay)`; `crates/metal2vulkan/src/lower/access/mod.rs:1525 (plan_replay)`; `crates/metal2vulkan/src/pipeline/compile.rs:1888 (plan_one)`; `crates/metal2vulkan/src/pipeline/compile.rs:1893 (plan_one)`
- `feature::GpuEncodedIndirectCommands`: `crates/metal2vulkan/src/bind/replay.rs:530 (preprocess)`; `crates/metal2vulkan/src/bind/replay.rs:772 (replay_preprocess_module)`; `crates/metal2vulkan/src/bind/replay/flat.rs:247 (flat_dispatch_module)`; `crates/metal2vulkan/src/lower/access/encode.rs:390 (needs)`; `crates/metal2vulkan/src/lower/access/encode.rs:406 (needs)`; `crates/metal2vulkan/src/lower/access/encode.rs:518 (select_command)`; `crates/metal2vulkan/src/lower/access/mod.rs:1509 (plan_replay)`; `crates/metal2vulkan/src/lower/access/mod.rs:1522 (plan_replay)`; `crates/metal2vulkan/src/lower/access/mod.rs:1525 (plan_replay)`; `crates/metal2vulkan/src/pipeline/compile.rs:1888 (plan_one)`; `crates/metal2vulkan/src/pipeline/compile.rs:1893 (plan_one)`
- `feature::VulkanVersion`: `crates/metal2vulkan/src/ash_interop/query.rs:898 (query)`; `crates/metal2vulkan/src/device/derive.rs:101 (with_deviations)`
- `feature::Constant`: `crates/metal2vulkan-air/src/bitcode/constants.rs:210 (record)`; `crates/metal2vulkan-air/src/bitcode/constants.rs:268 (record)`; `crates/metal2vulkan/src/error/mod.rs:257 (from)`
- `feature::Attribute`: `crates/metal2vulkan-air/src/bitcode/attrs.rs:493 (known)`; `crates/metal2vulkan/src/error/mod.rs:258 (from)`
- `feature::BitcodeRecord`: `crates/metal2vulkan-air/src/bitcode/attrs.rs:337 (decode_lists)`; `crates/metal2vulkan-air/src/bitcode/function.rs:577 (symtab)`; `crates/metal2vulkan-air/src/bitcode/metadata.rs:130 (decode)`; `crates/metal2vulkan-air/src/bitcode/metadata.rs:157 (decode)`; `crates/metal2vulkan-air/src/bitcode/module.rs:727 (check_bodies)`; `crates/metal2vulkan-air/src/bitcode/module.rs:872 (symtab)`; `crates/metal2vulkan/src/error/mod.rs:259 (from)`
- `feature::SyncScope`: `crates/metal2vulkan-air/src/bitcode/function.rs:1260 (atomic)`; `crates/metal2vulkan/src/error/mod.rs:260 (from)`
- `feature::SubgroupOperations`: `crates/metal2vulkan-runtime/src/families/features.rs:1643 (simd)`; `crates/metal2vulkan/src/lower/simd/mod.rs:402 (finish)`; `crates/metal2vulkan/src/lower/simd/mod.rs:448 (full_quads)`; `crates/metal2vulkan/src/lower/simd/mod.rs:971 (select_group)`
- `feature::BitcodeRecord`: `crates/metal2vulkan-air/src/bitcode/attrs.rs:337 (decode_lists)`; `crates/metal2vulkan-air/src/bitcode/function.rs:572 (symtab)`; `crates/metal2vulkan-air/src/bitcode/metadata.rs:130 (decode)`; `crates/metal2vulkan-air/src/bitcode/metadata.rs:157 (decode)`; `crates/metal2vulkan-air/src/bitcode/module.rs:727 (check_bodies)`; `crates/metal2vulkan-air/src/bitcode/module.rs:872 (symtab)`; `crates/metal2vulkan/src/error/mod.rs:259 (from)`
- `feature::SyncScope`: `crates/metal2vulkan-air/src/bitcode/function.rs:1255 (atomic)`; `crates/metal2vulkan/src/error/mod.rs:260 (from)`
- `feature::SubgroupOperations`: `crates/metal2vulkan-runtime/src/families/features.rs:1643 (simd)`; `crates/metal2vulkan/src/lower/simd/mod.rs:402 (finish)`; `crates/metal2vulkan/src/lower/simd/mod.rs:448 (full_quads)`; `crates/metal2vulkan/src/lower/simd/mod.rs:975 (select_group)`
- `feature::DirectCall`: `crates/metal2vulkan-air/src/canon/mod.rs:1283 (post_check)`
- `feature::WideSwitchLiteral`: `crates/metal2vulkan/src/structurize/emit.rs:207 (check_tree)`
- `feature::Lowering`: `crates/metal2vulkan/src/bind/plan/resources.rs:755 (level_views)`; `crates/metal2vulkan/src/lower/access/handle.rs:1062 (texture_target)`; `crates/metal2vulkan/src/lower/access/handle.rs:1073 (sampler_target)`; `crates/metal2vulkan/src/lower/access/handle.rs:318 (domain_kind)`; `crates/metal2vulkan/src/lower/access/imageblock.rs:175 (operand)`; `crates/metal2vulkan/src/lower/access/mod.rs:571 (not_lowered)`; `crates/metal2vulkan/src/lower/access/pulled.rs:76 (share)`; `crates/metal2vulkan/src/lower/arith/legal.rs:53 (not_lowered)`; `crates/metal2vulkan/src/lower/dispatch.rs:113 (not_lowered)`; `crates/metal2vulkan/src/lower/fragment/discard.rs:144 (not_lowered)`; `crates/metal2vulkan/src/lower/fragment/discard.rs:653 (plan)`; `crates/metal2vulkan/src/lower/fragment/mod.rs:111 (not_lowered)`; `crates/metal2vulkan/src/lower/mesh/mod.rs:144 (not_lowered)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs:126 (not_lowered)`; `crates/metal2vulkan/src/lower/sampler/mod.rs:207 (refuse)`; `crates/metal2vulkan/src/lower/sampler/select.rs:30 (refuse)`; `crates/metal2vulkan/src/lower/select.rs:813 (not_lowered)`; `crates/metal2vulkan/src/lower/select.rs:902 (route_air)`; `crates/metal2vulkan/src/lower/simd/mod.rs:136 (not_lowered)`; `crates/metal2vulkan/src/lower/simd/mod.rs:728 (select_param)`; `crates/metal2vulkan/src/lower/simd/workgroup.rs:353 (check)`; `crates/metal2vulkan/src/lower/stage_io/fetch.rs:96 (not_lowered)`; `crates/metal2vulkan/src/lower/stage_io/mod.rs:134 (not_lowered)`; `crates/metal2vulkan/src/lower/sync/barrier.rs:72 (not_lowered)`; `crates/metal2vulkan/src/lower/sync/memory_model.rs:212 (not_implemented)`; `crates/metal2vulkan/src/lower/sync/memory_model.rs:249 (select)`; `crates/metal2vulkan/src/lower/tessellation/mod.rs:96 (not_lowered)`; `crates/metal2vulkan/src/lower/texture/mod.rs:178 (refuse)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3565 (select_write)`; `crates/metal2vulkan/src/memory/alloca.rs:46 (not_lowered)`; `crates/metal2vulkan/src/memory/leaf.rs:183 (not_lowered)`; `crates/metal2vulkan/src/memory/plan.rs:453 (not_lowered)`; `crates/metal2vulkan/src/memory/provenance.rs:662 (not_lowered)`; `crates/metal2vulkan/src/pipeline/link/tessellation/mod.rs:92 (patch_fetch_projection)`
- `feature::Lowering`: `crates/metal2vulkan/src/bind/plan/resources.rs:755 (level_views)`; `crates/metal2vulkan/src/lower/access/handle.rs:1062 (texture_target)`; `crates/metal2vulkan/src/lower/access/handle.rs:1073 (sampler_target)`; `crates/metal2vulkan/src/lower/access/handle.rs:318 (domain_kind)`; `crates/metal2vulkan/src/lower/access/imageblock.rs:175 (operand)`; `crates/metal2vulkan/src/lower/access/mod.rs:571 (not_lowered)`; `crates/metal2vulkan/src/lower/access/pulled.rs:76 (share)`; `crates/metal2vulkan/src/lower/arith/legal.rs:53 (not_lowered)`; `crates/metal2vulkan/src/lower/dispatch.rs:113 (not_lowered)`; `crates/metal2vulkan/src/lower/fragment/discard.rs:144 (not_lowered)`; `crates/metal2vulkan/src/lower/fragment/discard.rs:653 (plan)`; `crates/metal2vulkan/src/lower/fragment/mod.rs:111 (not_lowered)`; `crates/metal2vulkan/src/lower/mesh/mod.rs:144 (not_lowered)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs:126 (not_lowered)`; `crates/metal2vulkan/src/lower/sampler/mod.rs:207 (refuse)`; `crates/metal2vulkan/src/lower/sampler/select.rs:30 (refuse)`; `crates/metal2vulkan/src/lower/select.rs:813 (not_lowered)`; `crates/metal2vulkan/src/lower/select.rs:902 (route_air)`; `crates/metal2vulkan/src/lower/simd/mod.rs:136 (not_lowered)`; `crates/metal2vulkan/src/lower/simd/mod.rs:732 (select_param)`; `crates/metal2vulkan/src/lower/simd/workgroup.rs:353 (check)`; `crates/metal2vulkan/src/lower/stage_io/fetch.rs:96 (not_lowered)`; `crates/metal2vulkan/src/lower/stage_io/mod.rs:134 (not_lowered)`; `crates/metal2vulkan/src/lower/sync/barrier.rs:72 (not_lowered)`; `crates/metal2vulkan/src/lower/sync/memory_model.rs:212 (not_implemented)`; `crates/metal2vulkan/src/lower/sync/memory_model.rs:249 (select)`; `crates/metal2vulkan/src/lower/tessellation/mod.rs:96 (not_lowered)`; `crates/metal2vulkan/src/lower/texture/mod.rs:178 (refuse)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3565 (select_write)`; `crates/metal2vulkan/src/memory/alloca.rs:46 (not_lowered)`; `crates/metal2vulkan/src/memory/leaf.rs:183 (not_lowered)`; `crates/metal2vulkan/src/memory/plan.rs:453 (not_lowered)`; `crates/metal2vulkan/src/memory/provenance.rs:662 (not_lowered)`; `crates/metal2vulkan/src/pipeline/link/tessellation/mod.rs:92 (patch_fetch_projection)`
- `feature::SamplerAddressMode`: `crates/metal2vulkan/src/lower/sampler/constexpr.rs:176`; `crates/metal2vulkan/src/metal/sampler.rs:248 (check_sampler)`
- `feature::AlphaToOne`: `crates/metal2vulkan/src/pipeline/link/graphics.rs:243 (graphics_state)`
- `feature::StageStoresAndAtomics`: `crates/metal2vulkan/src/lower/access/tile_memory.rs:73 (written)`
@@ -394,9 +394,9 @@ Each refusal's sites, with the function that builds it.
- `feature::TextureSize`: `crates/metal2vulkan-runtime/src/image_plan.rs:1062 (check_image_limits)`
- `feature::TextureSampleCount`: `crates/metal2vulkan-runtime/src/image_plan.rs:1110 (check_image_limits)`; `crates/metal2vulkan-runtime/src/image_plan.rs:570 (plan_held)`; `crates/metal2vulkan-runtime/src/image_plan.rs:580 (plan_held)`
- `feature::TextureView`: `crates/metal2vulkan-runtime/src/binding_view.rs:156 (binding_view)`; `crates/metal2vulkan-runtime/src/texture/view_shadow.rs:184 (apart_refusal)`; `crates/metal2vulkan-runtime/src/view_plan.rs:411 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:461 (check_view)`; `crates/metal2vulkan-runtime/src/view_plan.rs:483 (check_view)`
- `feature::TextureSwizzle`: `crates/metal2vulkan-runtime/src/binding_view.rs:167 (binding_view)`; `crates/metal2vulkan-runtime/src/texture.rs:775 (view)`; `crates/metal2vulkan/src/bind/plan/resources.rs:1088 (plain_texture)`; `crates/metal2vulkan/src/lower/sampler/select.rs:2275 (select_one)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3300 (select_read_as)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3637 (select_write)`; `crates/metal2vulkan/src/lower/texture/slice.rs:294 (select)`
- `feature::TextureSwizzle`: `crates/metal2vulkan-runtime/src/binding_view.rs:167 (binding_view)`; `crates/metal2vulkan-runtime/src/texture.rs:885 (view)`; `crates/metal2vulkan/src/bind/plan/resources.rs:1088 (plain_texture)`; `crates/metal2vulkan/src/lower/sampler/select.rs:2275 (select_one)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3300 (select_read_as)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3637 (select_write)`; `crates/metal2vulkan/src/lower/texture/slice.rs:294 (select)`
- `feature::MipmapGeneration`: `crates/metal2vulkan-runtime/src/blit_texture.rs:1689 (generate_mipmaps)`; `crates/metal2vulkan-runtime/src/mipmap_pick.rs:37 (pick_mipmaps)`; `crates/metal2vulkan-runtime/src/mipmap_plan.rs:264 (plan_mipmaps)`; `crates/metal2vulkan-runtime/src/mipmap_plan.rs:272 (plan_mipmaps)`; `crates/metal2vulkan-runtime/src/mipmap_plan.rs:277 (plan_mipmaps)`; `crates/metal2vulkan-runtime/src/mipmap_plan.rs:306 (plan_mipmaps)`; `crates/metal2vulkan/src/bind/mipmap_filter.rs:915 (mipmap_filter_module)`
- `feature::HostMemory`: `crates/metal2vulkan-runtime/src/host_memory.rs:255 (not_importable)`; `crates/metal2vulkan-runtime/src/host_memory.rs:280 (refuse_unwritable)`; `crates/metal2vulkan-runtime/src/host_memory.rs:463 (new)`; `crates/metal2vulkan-runtime/src/host_memory.rs:468 (new)`; `crates/metal2vulkan-runtime/src/host_memory.rs:486 (new)`
- `feature::HostMemory`: `crates/metal2vulkan-runtime/src/host_memory.rs:329 (not_importable)`; `crates/metal2vulkan-runtime/src/host_memory.rs:361 (refuse_unwritable)`; `crates/metal2vulkan-runtime/src/host_memory.rs:557 (new)`; `crates/metal2vulkan-runtime/src/host_memory.rs:562 (new)`; `crates/metal2vulkan-runtime/src/host_memory.rs:580 (new)`
- `feature::GpuTimes`: `crates/metal2vulkan-runtime/src/command_buffer/mod.rs:1830 (gpu_times)`
- `feature::CountingVisibility`: `crates/metal2vulkan-runtime/src/visibility.rs:447 (check_mode)`
- `feature::ViewFormatReinterpretation`: `crates/metal2vulkan-runtime/src/view_plan.rs:547 (reinterpretation_refused)`
@@ -406,7 +406,7 @@ Each refusal's sites, with the function that builds it.
- `feature::PrivateMemory`: `crates/metal2vulkan/src/lower/select.rs:1153 (function_storage)`
- `feature::SparseTextures`: `crates/metal2vulkan-runtime/src/sparse/texture.rs:32 (sparse_refusal)`
- `feature::SparseMapping`: `crates/metal2vulkan-runtime/src/sparse/encoder.rs:466 (splits_a_unit)`
- `feature::TimelineSemaphores`: `crates/metal2vulkan-runtime/src/device/create.rs:986 (timeline_difference)`
- `feature::TimelineSemaphores`: `crates/metal2vulkan-runtime/src/device/create.rs:1014 (timeline_difference)`
- `feature::Reflection`: `crates/metal2vulkan/src/bind/argument_buffer.rs:628 (unmeasured)`; `crates/metal2vulkan/src/reflection/derive.rs:179 (specialized_reads)`; `crates/metal2vulkan/src/reflection/derive.rs:213 (read_attributes)`; `crates/metal2vulkan/src/reflection/derive.rs:240 (gap_at)`; `crates/metal2vulkan/src/reflection/function.rs:172 (unmeasured)`; `crates/metal2vulkan/src/reflection/function.rs:366 (attribute)`; `crates/metal2vulkan/src/reflection/function.rs:437 (module_constants)`; `crates/metal2vulkan/src/reflection/linked.rs:127 (function)`; `crates/metal2vulkan/src/reflection/mod.rs:249 (stage)`
- `feature::HeapTextureTiling`: `crates/metal2vulkan-runtime/src/texture/heap.rs:540 (tiling_refusal)`
- `feature::ViewportDepthRange`: `crates/metal2vulkan-runtime/src/render_state.rs:1035 (depth_ranges_refused)`
@@ -415,18 +415,18 @@ Each refusal's sites, with the function that builds it.
- `feature::IndirectRenderState`: `crates/metal2vulkan/src/lower/access/encode.rs:559 (select_command)`
- `feature::GlobalBuiltinInFragment`: `crates/metal2vulkan/src/lower/select.rs:896 (route_air)`
- `feature::PrivateRenderState`: `crates/metal2vulkan/src/bind/heap.rs:1278 (array)`; `crates/metal2vulkan/src/bind/plan/resources.rs:880 (write_rounding)`; `crates/metal2vulkan/src/lower/texture/mod.rs:2811 (mode_rounded_write)`; `crates/metal2vulkan/src/pipeline/private_state.rs:47 (refused)`
- `feature::ExtendedRangeBlend`: `crates/metal2vulkan/src/lower/arith/extended_range/blend.rs:276 (refused)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1006 (plan)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1009 (plan)`; `crates/metal2vulkan/src/lower/fragment/input_blend.rs:154 (plan)`
- `feature::TileReach`: `crates/metal2vulkan/src/bind/tile_reach.rs:272 (tile_reach_module)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:1944 (capture)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:1970 (capture)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:2012 (refuse_unaddressed)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:447 (param)`
- `feature::ExtendedRangeBlend`: `crates/metal2vulkan/src/lower/arith/extended_range/blend.rs:276 (refused)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1008 (plan)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1011 (plan)`; `crates/metal2vulkan/src/lower/fragment/input_blend.rs:154 (plan)`
- `feature::TileReach`: `crates/metal2vulkan/src/bind/tile_reach.rs:272 (tile_reach_module)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:1946 (capture)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:1972 (capture)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:2014 (refuse_unaddressed)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:447 (param)`
- `feature::CommandPredication`: `crates/metal2vulkan/src/bind/replay/predication.rs:415 (predication_step_module)`
- `feature::ProgramScopeBinding`: `crates/metal2vulkan-air/src/abi/module.rs:77 (decode)`; `crates/metal2vulkan/src/error/mod.rs:268 (from)`
- `feature::SeqCstFence`: `crates/metal2vulkan/src/lower/sync/barrier.rs:443 (require_seq_cst)`; `crates/metal2vulkan/src/lower/sync/barrier.rs:449 (require_seq_cst)`
- `gap::Textures`: `crates/metal2vulkan-runtime/src/blit_texture.rs:159 (check_depth_view)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:1522 (view_usage)`; `crates/metal2vulkan-runtime/src/pipeline/mod.rs:1406 (compile_error)`; `crates/metal2vulkan-runtime/src/texture.rs:1176 (image_error)`; `crates/metal2vulkan-runtime/src/texture.rs:1838 (storage_over_buffer)`; `crates/metal2vulkan-runtime/src/texture.rs:2741 (new_image_starting)`; `crates/metal2vulkan-runtime/src/texture.rs:3750 (image)`; `crates/metal2vulkan-runtime/src/texture.rs:5025 (host_copy)`; `crates/metal2vulkan-runtime/src/texture/surface_two_planes.rs:206 (new_surface_planes_texture)`
- `gap::Textures`: `crates/metal2vulkan-runtime/src/blit_texture.rs:159 (check_depth_view)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:1525 (view_usage)`; `crates/metal2vulkan-runtime/src/pipeline/mod.rs:1406 (compile_error)`; `crates/metal2vulkan-runtime/src/texture.rs:1292 (image_error)`; `crates/metal2vulkan-runtime/src/texture.rs:1969 (storage_over_buffer)`; `crates/metal2vulkan-runtime/src/texture.rs:3111 (new_image_starting)`; `crates/metal2vulkan-runtime/src/texture.rs:4120 (image)`; `crates/metal2vulkan-runtime/src/texture.rs:5395 (host_copy)`; `crates/metal2vulkan-runtime/src/texture/surface_two_planes.rs:206 (new_surface_planes_texture)`
- `gap::ResourceHeap`: `crates/metal2vulkan-runtime/src/binding.rs:1358 (descriptor)`
- `gap::SparseHeaps`: `crates/metal2vulkan-runtime/src/sparse/encoder.rs:458 (first_slice)`; `crates/metal2vulkan-runtime/src/texture.rs:1360 (plan_sparse_texture)`; `crates/metal2vulkan-runtime/src/texture.rs:4322 (make_aliasable)`
- `gap::SparseTileMaps`: `crates/metal2vulkan-runtime/src/binding.rs:428 (slot_tile_map)`; `crates/metal2vulkan-runtime/src/sparse/texture.rs:30 (sparse_refusal)`; `crates/metal2vulkan-runtime/src/texture.rs:1385 (plan_sparse_texture)`
- `gap::HeapPastMaxBufferSize`: `crates/metal2vulkan-runtime/src/heap.rs:686 (heap_size)`
- `gap::HeapTextureAlignment`: `crates/metal2vulkan-runtime/src/texture/heap.rs:1269 (heap_plan)`
- `gap::HeapTextureMemory`: `crates/metal2vulkan-runtime/src/texture/heap.rs:1254 (heap_plan)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:1261 (heap_plan)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:1702 (host_heap_plan)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:1774 (host_heap_plan)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:467 (memory_refusal)`
- `gap::SparseHeaps`: `crates/metal2vulkan-runtime/src/sparse/encoder.rs:458 (first_slice)`; `crates/metal2vulkan-runtime/src/texture.rs:1476 (plan_sparse_texture)`; `crates/metal2vulkan-runtime/src/texture.rs:4692 (make_aliasable)`
- `gap::SparseTileMaps`: `crates/metal2vulkan-runtime/src/binding.rs:428 (slot_tile_map)`; `crates/metal2vulkan-runtime/src/sparse/texture.rs:30 (sparse_refusal)`; `crates/metal2vulkan-runtime/src/texture.rs:1501 (plan_sparse_texture)`
- `gap::HeapPastMaxBufferSize`: `crates/metal2vulkan-runtime/src/heap.rs:689 (heap_size)`
- `gap::HeapTextureAlignment`: `crates/metal2vulkan-runtime/src/texture/heap.rs:1275 (heap_plan)`
- `gap::HeapTextureMemory`: `crates/metal2vulkan-runtime/src/texture/heap.rs:1260 (heap_plan)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:1267 (heap_plan)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:1714 (host_heap_plan)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:1927 (memory_shadow)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:467 (memory_refusal)`
- `gap::FunctionTablePastMaxBufferLength`: `crates/metal2vulkan-runtime/src/function_table.rs:628 (past_limit)`
- `gap::IndirectCommandBufferPastMaxBufferLength`: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs:522 (new_indirect_command_buffer)`
- `gap::IndirectRenderCommands`: `crates/metal2vulkan-runtime/src/compute.rs:1026 (execute_commands_in_buffer)`; `crates/metal2vulkan-runtime/src/compute.rs:1076 (execute_commands_in_buffer_indirect)`; `crates/metal2vulkan-runtime/src/depth_stencil.rs:85 (gpu_resource_id)`; `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs:3495 (render_state)`; `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs:517 (new_indirect_command_buffer)`; `crates/metal2vulkan-runtime/src/pipeline/mod.rs:1413 (compile_error)`; `crates/metal2vulkan-runtime/src/render.rs:5737 (draw_resident)`; `crates/metal2vulkan-runtime/src/render.rs:6027 (draw_resident)`; `crates/metal2vulkan-runtime/src/render.rs:6306 (draw_resident)`; `crates/metal2vulkan-runtime/src/render.rs:6668 (draw_resident)`; `crates/metal2vulkan-runtime/src/render/executions.rs:1773 (record)`; `crates/metal2vulkan-runtime/src/render/executions.rs:2438 (record)`; `crates/metal2vulkan-runtime/src/render/executions.rs:361 (execute_commands_in_buffer)`; `crates/metal2vulkan-runtime/src/render/executions.rs:419 (execute_commands_in_buffer_indirect)`; `crates/metal2vulkan-runtime/src/render/executions.rs:432 (execute_commands_in_buffer_indirect)`; `crates/metal2vulkan-runtime/src/render/executions.rs:876 (back_memoryless)`
@@ -465,20 +465,20 @@ Each refusal's sites, with the function that builds it.
- `gap::LayeredPass`: `crates/metal2vulkan-runtime/src/color_resolve.rs:517 (plan)`
- `gap::FunctionOptions`: `crates/metal2vulkan-runtime/src/library.rs:215 (new_function_with_descriptor)`
- `gap::OverlappingTextureCopies`: `crates/metal2vulkan-runtime/src/blit_texture.rs:1201 (texture_copies_of_bytes)`
- `gap::RebindTextures`: `crates/metal2vulkan-runtime/src/buffer_descriptor.rs:575 (rebind_host_pages)`; `crates/metal2vulkan-runtime/src/texture.rs:2420 (rebound_alias_images)`; `crates/metal2vulkan-runtime/src/texture.rs:2439 (rebound_alias_images)`; `crates/metal2vulkan-runtime/src/texture.rs:2446 (rebound_alias_images)`
- `gap::PvrtcBlockOrder`: `crates/metal2vulkan-runtime/src/texture.rs:5095 (host_copy)`
- `gap::RebindTextures`: `crates/metal2vulkan-runtime/src/buffer_descriptor.rs:567 (rebind_host_pages)`; `crates/metal2vulkan-runtime/src/texture.rs:2696 (rebound_alias_images)`; `crates/metal2vulkan-runtime/src/texture.rs:2712 (rebound_alias_images)`; `crates/metal2vulkan-runtime/src/texture.rs:2732 (rebound_alias_images)`; `crates/metal2vulkan-runtime/src/texture.rs:2746 (rebound_alias_images)`; `crates/metal2vulkan-runtime/src/texture.rs:2817 (dma_buf_images_again)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2217 (rebound_heap_images)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2232 (rebound_heap_images)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2243 (rebound_heap_images)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2289 (dma_buf_heap_images_again)`
- `gap::PvrtcBlockOrder`: `crates/metal2vulkan-runtime/src/texture.rs:5465 (host_copy)`
- `gap::VertexFetchPast4GiB`: `crates/metal2vulkan-runtime/src/render/vertex_reach.rs:72 (check_vertex_reach)`
- `gap::StageInFetchPast4GiB`: `crates/metal2vulkan-runtime/src/fetch_reach.rs:126 (check_stage_in_reach)`
- `gap::MappedTextureSampling`: `crates/metal2vulkan-runtime/src/address_map.rs:158 (resolve)`
- `gap::LibrarySource`: `crates/metal2vulkan-runtime/src/library.rs:107 (new_library_with_source)`
- `gap::RestartedStrip`: `crates/metal2vulkan-runtime/src/index_rewrite.rs:109 (new)`; `crates/metal2vulkan-runtime/src/render.rs:5912 (draw_resident)`
- `gap::RotatedTexture`: `crates/metal2vulkan-runtime/src/blit_texture.rs:1508 (texel_copies)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:706 (turned_plane)`; `crates/metal2vulkan-runtime/src/rotated.rs:184 (new)`; `crates/metal2vulkan-runtime/src/rotated.rs:200 (new)`; `crates/metal2vulkan-runtime/src/shadow.rs:346 (unmerged)`; `crates/metal2vulkan-runtime/src/texture.rs:4562 (view)`; `crates/metal2vulkan-runtime/src/texture/rotation.rs:102 (check_rotated_reach)`; `crates/metal2vulkan-runtime/src/texture/rotation.rs:317 (copied_image)`; `crates/metal2vulkan-runtime/src/texture/usage_shadow.rs:188 (new_usage_shadow)`
- `gap::DetachTextures`: `crates/metal2vulkan-runtime/src/buffer.rs:1969 (pages_base)`; `crates/metal2vulkan-runtime/src/buffer_descriptor.rs:583 (rebind_host_pages)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:616 (make_texture_over)`; `crates/metal2vulkan-runtime/src/detach.rs:144 (detach_host_pages)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2152 (heap_texture_at)`; `crates/metal2vulkan-runtime/src/texture/stand_in.rs:143 (new_stand_in)`; `crates/metal2vulkan-runtime/src/texture/stand_in.rs:248 (stand_in_while_detached)`; `crates/metal2vulkan-runtime/src/texture/stand_in.rs:297 (stand_ins)`; `crates/metal2vulkan-runtime/src/texture/stand_in.rs:303 (stand_ins)`
- `gap::RotatedTexture`: `crates/metal2vulkan-runtime/src/blit_texture.rs:1508 (texel_copies)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:706 (turned_plane)`; `crates/metal2vulkan-runtime/src/rotated.rs:184 (new)`; `crates/metal2vulkan-runtime/src/rotated.rs:200 (new)`; `crates/metal2vulkan-runtime/src/shadow.rs:346 (unmerged)`; `crates/metal2vulkan-runtime/src/texture.rs:4932 (view)`; `crates/metal2vulkan-runtime/src/texture/rotation.rs:102 (check_rotated_reach)`; `crates/metal2vulkan-runtime/src/texture/rotation.rs:317 (copied_image)`; `crates/metal2vulkan-runtime/src/texture/usage_shadow.rs:188 (new_usage_shadow)`
- `gap::DetachTextures`: `crates/metal2vulkan-runtime/src/buffer.rs:1999 (pages_base)`; `crates/metal2vulkan-runtime/src/buffer_descriptor.rs:572 (rebind_host_pages)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:616 (make_texture_over)`; `crates/metal2vulkan-runtime/src/detach.rs:144 (detach_host_pages)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2421 (heap_texture_at)`; `crates/metal2vulkan-runtime/src/texture/stand_in.rs:143 (new_stand_in)`; `crates/metal2vulkan-runtime/src/texture/stand_in.rs:248 (stand_in_while_detached)`; `crates/metal2vulkan-runtime/src/texture/stand_in.rs:297 (stand_ins)`; `crates/metal2vulkan-runtime/src/texture/stand_in.rs:303 (stand_ins)`
- `gap::TextureBufferLevels`: `crates/metal2vulkan-runtime/src/texture_descriptor.rs:531 (check_made)`
- `gap::WriteSwizzle`: `crates/metal2vulkan-runtime/src/texture_descriptor.rs:538 (check_made)`
- `gap::DetachedTexelAccess`: `crates/metal2vulkan-runtime/src/texture.rs:4392 (refuse_detached_texels)`
- `gap::DetachedTexelAccess`: `crates/metal2vulkan-runtime/src/texture.rs:4762 (refuse_detached_texels)`
- `gap::SurfaceDepthStencil`: `crates/metal2vulkan-runtime/src/blit_texture.rs:232 (unit)`; `crates/metal2vulkan-runtime/src/texture/surface_depth.rs:56 (surface_depth_twin)`
- `gap::HostHeapUncompressedMultisample`: `crates/metal2vulkan-runtime/src/texture/heap.rs:1707 (host_heap_plan)`
- `gap::HostHeapUncompressedMultisample`: `crates/metal2vulkan-runtime/src/texture/heap.rs:1719 (host_heap_plan)`
- `gap::PredicationUnbalanced`: `crates/metal2vulkan-runtime/src/predication.rs:354 (nil)`; `crates/metal2vulkan-runtime/src/predication.rs:386 (start_else)`; `crates/metal2vulkan-runtime/src/predication.rs:438 (end_if)`; `crates/metal2vulkan-runtime/src/predication.rs:558 (end_loop)`
- `gap::PredicationOpenAtUnitEnd`: `crates/metal2vulkan-runtime/src/predication.rs:279 (commit)`
- `gap::PredicationWordPastBuffer`: `crates/metal2vulkan-runtime/src/predication.rs:139 (new)`
@@ -512,7 +512,7 @@ Each refusal's sites, with the function that builds it.
- `limit::TypeCount`: `crates/metal2vulkan-air/src/bitcode/types.rs:159 (decode)`; `crates/metal2vulkan-air/src/ir/types.rs:239 (intern)`
- `limit::MetadataNodes`: `crates/metal2vulkan-air/src/bitcode/function.rs:334 (metadata)`; `crates/metal2vulkan-air/src/bitcode/metadata.rs:192 (push)`; `crates/metal2vulkan-air/src/bitcode/metadata.rs:221 (strings)`
- `limit::BitstreamNesting`: `crates/metal2vulkan-air/src/bitstream/mod.rs:267 (enter_block)`
- `limit::InstructionCount`: `crates/metal2vulkan-air/src/bitcode/function.rs:1467 (call)`; `crates/metal2vulkan-air/src/bitcode/function.rs:180 (decode)`; `crates/metal2vulkan-air/src/bitcode/function.rs:320 (constants)`; `crates/metal2vulkan-air/src/bitcode/function.rs:595 (forward)`; `crates/metal2vulkan-air/src/bitcode/function.rs:686 (push)`; `crates/metal2vulkan-air/src/bitcode/function.rs:697 (push)`; `crates/metal2vulkan-air/src/bitcode/function.rs:727 (count_record)`; `crates/metal2vulkan-air/src/bitcode/function.rs:731 (count_record)`
- `limit::InstructionCount`: `crates/metal2vulkan-air/src/bitcode/function.rs:1462 (call)`; `crates/metal2vulkan-air/src/bitcode/function.rs:180 (decode)`; `crates/metal2vulkan-air/src/bitcode/function.rs:320 (constants)`; `crates/metal2vulkan-air/src/bitcode/function.rs:590 (forward)`; `crates/metal2vulkan-air/src/bitcode/function.rs:681 (push)`; `crates/metal2vulkan-air/src/bitcode/function.rs:692 (push)`; `crates/metal2vulkan-air/src/bitcode/function.rs:722 (count_record)`; `crates/metal2vulkan-air/src/bitcode/function.rs:726 (count_record)`
- `limit::LayoutNesting`: `crates/metal2vulkan-air/src/abi/structs.rs:147 (open)`; `crates/metal2vulkan-air/src/abi/structs.rs:160 (finish)`; `crates/metal2vulkan/src/bind/argument_buffer.rs:715 (layout)`
- `limit::ConstructNesting`: `crates/metal2vulkan/src/structurize/emit.rs:216 (check_tree)`; `crates/metal2vulkan/src/structurize/emit/predicate.rs:151 (facts)`
- `limit::PrivateArenaBytes`: `crates/metal2vulkan/src/lower/access/local.rs:595 (use_arena)`; `crates/metal2vulkan/src/memory/plan.rs:1684 (place_allocas)`; `crates/metal2vulkan/src/memory/plan.rs:1691 (place_allocas)`
+3 -3
View File
@@ -244,7 +244,7 @@ narrow refusal that the call's rustdoc describes.
| Item | Metal | Runtime |
|---|---|---|
| `heap_texture_size_and_align` | `heapTextureSizeAndAlignWithDescriptor:` | `Device::heap_texture_size_and_align`: the device's own requirement |
| `new_buffer_over_host_memory` | `newBufferWithBytesNoCopy:length:options:deallocator:` | `unsafe Device::new_buffer_with_bytes_no_copy` (`VK_EXT_external_memory_host`) *(partial)* |
| `new_buffer_over_host_memory` | `newBufferWithBytesNoCopy:length:options:deallocator:` | `unsafe Device::new_buffer_with_bytes_no_copy` over a `HostMemory` (`VK_EXT_external_memory_host`; where the device refuses the pointer, the dma-bufs of `HostMemory::with_dma_buf`'s source, `VK_EXT_external_memory_dma_buf`) *(partial)* |
| `new_buffer_of_length` | `newBufferWithLength:options:` | `Device::new_buffer` |
| `new_command_queue` | `newCommandQueue` | `Device::new_command_queue` |
| `new_compute_pipeline_state` | `newComputePipelineStateWithDescriptor:options:reflection:error:` | `Device::new_compute_pipeline_state` |
@@ -266,8 +266,8 @@ narrow refusal that the call's rustdoc describes.
| `new_buffer` | `newBufferWithDescriptor:` (SPI) | `Device::new_buffer_with_descriptor` (`BufferDescriptor` by value, with host contents and an `AddressPlacement`) |
| `new_heap` | `newHeapWithDescriptor:` | `Device::new_heap` (`HeapDescriptor::placement` pins its address range) |
| `reserve_address_pool` | (none: a runtime extension; Metal's own pools of buffers shorter than a page) | `Device::reserve_address_pool` -> `AddressPool`, holding a pin's span; `BufferDescriptor::with_pool_slot(&pool, offset)` places a buffer at the pool's address plus a 256-byte-aligned offset, holding its length rounded up to 256 bytes |
| `new_heap_over_host_memory` | (none: a runtime extension) | `unsafe Device::new_heap_with_bytes_no_copy`: a heap over the caller's page-aligned memory (`VK_EXT_external_memory_host`), the heap twin of `new_buffer_with_bytes_no_copy` |
| `rebind_host_memory` | (none: a runtime extension) | `unsafe Buffer::rebind_bytes_no_copy`, `unsafe Heap::rebind_bytes_no_copy`: another range of the same length under the same objects and GPU addresses, in commit order (`RebindProblem::EncodedUses` while uncommitted work used them) |
| `new_heap_over_host_memory` | (none: a runtime extension) | `unsafe Device::new_heap_with_bytes_no_copy`: a heap over the caller's page-aligned memory, a `HostMemory` (`VK_EXT_external_memory_host`, or dma-bufs as for a buffer), the heap twin of `new_buffer_with_bytes_no_copy` |
| `rebind_host_memory` | (none: a runtime extension) | `unsafe Buffer::rebind_bytes_no_copy`, `unsafe Heap::rebind_bytes_no_copy`: another range of the same length, a `HostMemory`, under the same objects and GPU addresses, in commit order (`RebindProblem::EncodedUses` while uncommitted work used them) |
| `new_sampler_state` | `newSamplerStateWithDescriptor:` | `Device::new_sampler_state`, or `Device::new_sampler_state_with_options` (argument-buffer support, placement) |
| `new_depth_stencil_state` | `newDepthStencilStateWithDescriptor:` | `Device::new_depth_stencil_state` |
| `new_indirect_command_buffer` | `newIndirectCommandBufferWithDescriptor:maxCommandCount:options:` | `Device::new_indirect_command_buffer` (placement as an option) |