Skip to main content

VulkanEncodeCopier

Struct VulkanEncodeCopier 

Source
pub struct VulkanEncodeCopier { /* private fields */ }
Expand description

Reusable NV12 handoff from the renderer’s plane textures to encoder frames, one per export.

Owns the command pool and command-buffer ring, so a frame costs one queue submission and no CPU wait. The copy is ordered after the render by queue order, not by a semaphore: a submission wgpu rejects signals nothing, and a copy waiting on it would block the shared queue.

Implementations§

Source§

impl VulkanEncodeCopier

Source

pub fn finish(self) -> Result<(), BridgeError>

Waits for outstanding copies and releases their resources.

§Errors

On timeout or device loss, retains the pending GPU resources and device instead of destroying images raw Vulkan work may still use.

Source§

impl VulkanEncodeCopier

Source

pub fn new(context: &SharedVulkanContext) -> Result<Self, BridgeError>

Creates the handoff for one export on context’s device.

§Errors

Returns an error when the command pool, buffers or fences cannot be created, or the device has no queue lock for its graphics family.

Source

pub fn slots() -> usize

Plane-texture pairs a caller must cycle through to feed this copier.

A single pair is only safe if the caller never runs ahead of the copy. A caller that encodes on another thread does, so the pairs must be a ring as deep as the copier’s command-buffer ring.

Source

pub fn await_slot(&mut self) -> Result<usize, BridgeError>

Waits until the slot the next copy will use is free, and returns it.

Call before recording the render that writes the plane textures, and render into this pair. The wait is on the copy four submissions ago, so a pipeline keeping up never blocks.

§Errors

Returns an error when the fence wait fails.

Source

pub fn submit( &mut self, frame: &mut VulkanEncodeFrameAccess<'_>, luma: &Texture, chroma: &Texture, size: (u32, u32), ) -> Result<(), BridgeError>

Copies a renderer-packed NV12 pair into an encoder frame’s image.

The submission that wrote the textures must already be on the renderer’s queue; queue order alone orders the copy after it. If that submission was rejected, the copy still runs over whatever the planes held, and the caller fails the frame.

§Errors

Returns an error when the frame is not one multi-planar image on this device, the textures are not Vulkan, or the submission fails.

Trait Implementations§

Source§

impl Debug for VulkanEncodeCopier

Source§

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

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

impl Drop for VulkanEncodeCopier

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Send for VulkanEncodeCopier

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> Downcast<T> for T

Source§

fn downcast(&self) -> &T

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

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