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.

Owns the command pool and the command-buffer ring, so a frame costs one queue submission and no CPU wait. One per export.

The copy is ordered after the render that packed the planes by being submitted after it on the same queue, not by waiting for a signal that render’s submission raises: a submission wgpu rejects raises nothing, and a copy waiting for 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 rather than destroying images that 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, command 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.

One pair is only safe while the copy and the next render are ordered on one queue by a caller that never runs ahead. A caller that hands the encode to another thread does run ahead, and then the pairs have to be a ring as deep as the command-buffer ring this copier already keeps.

Source

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

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

Call before recording the render that writes the plane textures, and render into the pair this returns. The wait is on the fence of the copy four submissions ago, so in a pipeline that is keeping up it is free.

§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 these textures must already be on the renderer’s queue: the copy is ordered after it by queue order alone. When that submission was rejected the copy still runs, over whatever the planes held, and the frame is the caller’s to fail.

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