Skip to main content

VkOpaqueExportDesc

Struct VkOpaqueExportDesc 

Source
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],
}
Available on Hermit or Unix or WASI or Windows only.
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:

§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: u64

VkMemoryAllocateInfo::allocationSize of the exported VkDeviceMemory. Rejected when zero.

§memory_type_index: u32

VkMemoryAllocateInfo::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) and
  • VUID-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: u64

Byte offset of the image inside the exported allocation — the memoryOffset the producer passed to vkBindImageMemory. 0 for the common single-image dedicated bind.

§dedicated: bool

Mirrors VkMemoryDedicatedAllocateInfo — the importer MUST chain the matching VkMemoryDedicatedAllocateInfo if this is true.

§width: u32

VkImageCreateInfo::extent.width. Rejected when zero.

§height: u32

VkImageCreateInfo::extent.height. Rejected when zero.

§format: PixelFormat

Logical 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

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for VkOpaqueExportDesc

Source§

impl Debug for VkOpaqueExportDesc

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for VkOpaqueExportDesc

Source§

impl PartialEq for VkOpaqueExportDesc

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for VkOpaqueExportDesc

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> MaybeSend for T
where T: Send + ?Sized,

Source§

impl<T> MaybeSendSync for T
where T: Send + Sync + ?Sized,

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,