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
impl VkImage
Sourcepub 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>
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
imagemust be a liveVkImagehandle. It is stored verbatim and later passed tovkGetImageMemoryRequirements/vkCmdPipelineBarrier/vkCmdCopyImageby the importer, so a handle from a destroyed image, or a handle from a different Vulkan object type, is undefined behaviour. Onlyimage == 0is checked, and it is reported asInvalidHandleError::NullHandlerather than being a caller obligation.device, when non-null, must be theVkDevicethatimagewas created on.device == nullis 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.instanceandphys_devfollow the same rule asdevice(non-null must match, null means trusted), against theVkInstanceandVkPhysicalDevicethe image’s device belongs to.uuid, whenSome, must equalphys_dev’s reportedVkPhysicalDeviceIDProperties::deviceUUID. Importers use it to refuse cross-adapter imports; a wrong UUID defeats that check and lets a foreign-device handle through.row_pitchmust be the plane-0 row pitch in bytes for aVK_IMAGE_TILING_LINEARimage, or0forVK_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 callvkDestroyImage(nor free itsVkDeviceMemory, nor destroydevice/instance) while this value or anyCloneof it is still reachable. Pass akeep_aliveanchor to discharge that obligation; withNonethe caller carries it directly. - Thread affinity: none for the handle itself —
VkImageis 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.
Sourcepub fn with_plane_format(self, plane_format: PlaneFormat) -> Self
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.
Sourcepub fn with_acquire_release(self, release: VkSlotRelease) -> Self
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).
Sourcepub fn acquire_release(&self) -> Option<&VkSlotRelease>
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).
Sourcepub fn with_dimensions(self, width: u32, height: u32) -> Self
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.
Sourcepub fn with_format(self, format: PixelFormat) -> Self
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.
pub fn image(&self) -> u64
pub fn device(&self) -> *mut c_void
pub fn instance(&self) -> *mut c_void
pub fn phys_dev(&self) -> *mut c_void
pub fn uuid(&self) -> Option<[u8; 16]>
pub fn row_pitch(&self) -> u32
pub fn keep_alive(&self) -> Option<&KeepAlive>
Sourcepub fn width(&self) -> u32
pub fn width(&self) -> u32
0 when unset (see Self::with_dimensions).
Sourcepub fn height(&self) -> u32
pub fn height(&self) -> u32
0 when unset (see Self::with_dimensions).
Sourcepub fn format(&self) -> Option<PixelFormat>
pub fn format(&self) -> Option<PixelFormat>
None when unset (see Self::with_format).
Sourcepub fn plane_format(&self) -> Option<PlaneFormat>
pub fn plane_format(&self) -> Option<PlaneFormat>
None when unset (see Self::with_plane_format).