Skip to main content

VkImage

Struct VkImage 

Source
pub struct VkImage {
    pub acquire_release: Option<VkSlotRelease>,
    /* private fields */
}
Expand description

Vulkan VkImage on a specific VkDevice, with optional cross-vendor identity (deviceUUID).

Fields§

§acquire_release: Option<VkSlotRelease>

Consumer→producer slot-release back-pressure gate. Carries the PREVIOUS frame’s per-slot Arc<AtomicU64> + target value; the consumer’s import path arms an on_submitted_work_done callback that stores value into the gate after the user’s previous-frame render has retired on the wgpu queue.

Mirrors the acquire_release field on the platform opaque-export carriers (VkOpaqueWin32 on Windows, VkOpaqueFd on POSIX; the two are mutually cfg-exclusive, so neither can be linked from here) — required for any producer that recycles its destination VkImage across frames (e.g. a decoder’s shared-VkDevice intermediate ring pool). Without it, the producer’s next-cycle reuse of a slot CPU-spins indefinitely waiting for the never-armed gate, surfacing as a playback freeze as soon as the ring wraps.

Implementations§

Source§

impl VkImage

Source

pub unsafe fn try_from_raw( image: u64, device: *mut c_void, instance: *mut c_void, phys_dev: *mut c_void, uuid: Option<[u8; 16]>, row_pitch: u32, keep_alive: Option<KeepAlive>, ) -> Result<Self, InvalidHandleError>

Wrap a raw VkImage and its device parentage. Borrowing: stored non-owningly, no Drop, and every obligation below extends to each Clone.

§Safety
  • image must be a live VkImage handle. It is stored verbatim and later passed to vkGetImageMemoryRequirements / vkCmdPipelineBarrier / vkCmdCopyImage by the importer, so a handle from a destroyed image, or a handle from a different Vulkan object type, is undefined behaviour. Only image == 0 is checked, and it is reported as InvalidHandleError::NullHandle rather than being a caller obligation.
  • device, when non-null, must be the VkDevice that image was created on. device == null is permitted, and means “trusted import”: the consumer recovers the device implicitly, which is sound only when it genuinely shares the device the image was minted on. Passing null while the image lives on some other device makes the importer issue commands for a handle the device has never seen.
  • instance and phys_dev follow the same rule as device (non-null must match, null means trusted), against the VkInstance and VkPhysicalDevice the image’s device belongs to.
  • uuid, when Some, must equal phys_dev’s reported VkPhysicalDeviceIDProperties::deviceUUID. Importers use it to refuse cross-adapter imports; a wrong UUID defeats that check and lets a foreign-device handle through.
  • row_pitch must be the plane-0 row pitch in bytes for a VK_IMAGE_TILING_LINEAR image, or 0 for VK_IMAGE_TILING_OPTIMAL. Consumers use it to size host-side copies, so an over-large value reads past the mapping.
  • Lifetime: nothing here retains the image and there is no Drop, so the caller must not call vkDestroyImage (nor free its VkDeviceMemory, nor destroy device / instance) while this value or any Clone of it is still reachable. Pass a keep_alive anchor to discharge that obligation; with None the caller carries it directly.
  • Thread affinity: none for the handle itself — VkImage is a plain handle and Vulkan permits use from any thread — but the caller must still uphold Vulkan’s external-synchronisation rules for whatever queue and command buffers the importer is told to use.
Source

pub fn with_plane_format(self, plane_format: PlaneFormat) -> Self

Builder-style: stamp the per-plane storage primitive. Used by producers (e.g. a shared-VkDevice intermediate copy) that hand the consumer a single-channel intermediate which doesn’t fit any crate::PixelFormat variant.

Source

pub fn with_acquire_release(self, release: VkSlotRelease) -> Self

Builder-style: stamp the consumer→producer slot-release back-pressure gate. Required for ring-pool producers that recycle the underlying VkImage across frames — without it, the producer’s next-cycle reuse of a slot CPU-spins forever waiting for the never-armed gate (visible as a playback freeze as soon as the ring wraps).

Source

pub fn acquire_release(&self) -> Option<&VkSlotRelease>

Consumer-side accessor — mirrors acquire_release on the platform opaque-export carriers (VkOpaqueWin32 / VkOpaqueFd, mutually cfg-exclusive). Returns None when the producer didn’t stamp a release gate (single-shot non-ring-pool path).

Source

pub fn with_dimensions(self, width: u32, height: u32) -> Self

Builder-style: stamp the texel dimensions of the image. Required when the producer side wants the consumer’s trusted-import path to know the dims without the caller having to pass an explicit size at every import site. 0 dimensions stay “unknown” — the consumer falls back to the caller’s import size.

Source

pub fn with_format(self, format: PixelFormat) -> Self

Builder-style: stamp the pixel format. See Self::with_dimensions for the rationale on producer-side stamping.

Source

pub fn image(&self) -> u64

Source

pub fn device(&self) -> *mut c_void

Source

pub fn instance(&self) -> *mut c_void

Source

pub fn phys_dev(&self) -> *mut c_void

Source

pub fn uuid(&self) -> Option<[u8; 16]>

Source

pub fn row_pitch(&self) -> u32

Source

pub fn keep_alive(&self) -> Option<&KeepAlive>

Source

pub fn width(&self) -> u32

0 when unset (see Self::with_dimensions).

Source

pub fn height(&self) -> u32

0 when unset (see Self::with_dimensions).

Source

pub fn format(&self) -> Option<PixelFormat>

None when unset (see Self::with_format).

Source

pub fn plane_format(&self) -> Option<PlaneFormat>

None when unset (see Self::with_plane_format).

Source§

impl VkImage

Source

pub fn as_ash_image(&self) -> Image

Available on crate feature ash only.

Re-wrap the stored u64 handle as ash’s typed vk::Image.

Trait Implementations§

Source§

impl Clone for VkImage

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 Debug for VkImage

Source§

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

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

impl Send for VkImage

Source§

impl Sync for VkImage

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<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,