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
impl VulkanEncodeCopier
Sourcepub fn new(context: &SharedVulkanContext) -> Result<Self, BridgeError>
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.
Sourcepub fn slots() -> usize
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.
Sourcepub fn await_slot(&mut self) -> Result<usize, BridgeError>
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.
Sourcepub fn submit(
&mut self,
frame: &mut VulkanEncodeFrameAccess<'_>,
luma: &Texture,
chroma: &Texture,
size: (u32, u32),
) -> Result<(), BridgeError>
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.