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