pub struct VkOpaqueExportDesc {
pub size: u64,
pub memory_type_index: u32,
pub offset: u64,
pub dedicated: bool,
pub width: u32,
pub height: u32,
pub format: PixelFormat,
pub uuid: [u8; 16],
}Expand description
The producer-side export descriptor both native opaque-handle
carriers carry — VkOpaqueFd on POSIX, VkOpaqueWin32 on Windows.
(Those two are mutually-exclusive #[cfg]s, so they are named as
plain code spans here rather than intra-doc links: no single rustdoc
target can resolve both.)
One field per Vulkan source of truth, so a construction site reads
as the vkGetMemory{Fd,Win32Handle}KHR ceremony it mirrors:
Self::size—VkMemoryAllocateInfo::allocationSize.Self::memory_type_index—VkMemoryAllocateInfo::memoryTypeIndex.Self::offset— thevkBindImageMemorybind offset.Self::dedicated— whether the allocation chainedVkMemoryDedicatedAllocateInfo.Self::width/Self::height—VkImageCreateInfo::extent.Self::format— the logical format behindVkImageCreateInfo::format.Self::uuid—VkPhysicalDeviceIDProperties::deviceUUID.
§Why plain pub fields
The descriptor is inert metadata: the importer reads every field
back verbatim to reconstruct a matching VkImageCreateInfo +
VkMemoryDedicatedAllocateInfo chain. The invariants that can be
checked without a live VkDevice (non-zero size, non-degenerate
extent) are checked by the carrier constructors — which are the only
way to build a carrier — and each carrier then stores its descriptor
privately, exposing it only through by-value accessors. A
validated carrier therefore cannot be edited back into an invalid
one; the mutability stops at the constructor boundary.
Fields§
§size: u64VkMemoryAllocateInfo::allocationSize of the exported
VkDeviceMemory. Rejected when zero.
memory_type_index: u32VkMemoryAllocateInfo::memoryTypeIndex of the exported
VkDeviceMemory — on the exporting physical device, which
for an opaque payload is by construction the importer’s own (the
handle is only meaningful on the device whose Self::uuid this
is).
§Why this is not optional, and why the importer must not
re-derive it
For a payload created by the Vulkan API and carried over an opaque handle type, the import-side allocation must repeat the producer’s numbers exactly:
VUID-VkMemoryAllocateInfo-allocationSize-01742(VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT) andVUID-VkMemoryAllocateInfo-allocationSize-01743(..._OPAQUE_WIN32_BIT/..._OPAQUE_WIN32_KMT_BIT)
both read: “the values of allocationSize and
memoryTypeIndex must match those specified when the payload
being imported was created”. Sharing a physical device and
intersecting memoryTypeBits do not relax that — an importer
that re-runs its own “first device-local type” search can legally
land on a different index than a producer that preferred, say,
non-host-visible device-local memory, and the two disagree
silently.
The importer also cannot recover the value from the driver:
vkGetMemoryWin32HandlePropertiesKHR /
vkGetMemoryFdPropertiesKHR are forbidden for opaque handle
types (VUID-vkGetMemoryWin32HandlePropertiesKHR-handleType-00666,
VUID-vkGetMemoryFdPropertiesKHR-handleType-00674). Carrying it
on the descriptor is therefore the only correct channel.
A consumer should still validate what it receives — the index
must be < VkPhysicalDeviceMemoryProperties::memoryTypeCount and
must be set in its own image’s memoryTypeBits — and fall back
rather than allocate when it is not.
offset: u64Byte offset of the image inside the exported allocation — the
memoryOffset the producer passed to vkBindImageMemory. 0
for the common single-image dedicated bind.
dedicated: boolMirrors VkMemoryDedicatedAllocateInfo — the importer MUST chain
the matching VkMemoryDedicatedAllocateInfo if this is true.
width: u32VkImageCreateInfo::extent.width. Rejected when zero.
height: u32VkImageCreateInfo::extent.height. Rejected when zero.
format: PixelFormatLogical format of the exported image. Single-plane exports of a
multi-plane surface additionally stamp
with_plane_format(..) on the carrier.
uuid: [u8; 16]Source physical-device deviceUUID
(VkPhysicalDeviceIDProperties::deviceUUID). The receiver’s
VkPhysicalDevice MUST report the same UUID — opaque
fd / NT-handle export is same-physical-device-only.
Trait Implementations§
Source§impl Clone for VkOpaqueExportDesc
impl Clone for VkOpaqueExportDesc
impl Copy for VkOpaqueExportDesc
Source§impl Debug for VkOpaqueExportDesc
impl Debug for VkOpaqueExportDesc
impl Eq for VkOpaqueExportDesc
Source§impl PartialEq for VkOpaqueExportDesc
impl PartialEq for VkOpaqueExportDesc
impl StructuralPartialEq for VkOpaqueExportDesc
Auto Trait Implementations§
impl Freeze for VkOpaqueExportDesc
impl RefUnwindSafe for VkOpaqueExportDesc
impl Send for VkOpaqueExportDesc
impl Sync for VkOpaqueExportDesc
impl Unpin for VkOpaqueExportDesc
impl UnsafeUnpin for VkOpaqueExportDesc
impl UnwindSafe for VkOpaqueExportDesc
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.