pub struct GpuFrameSink { /* private fields */ }Expand description
A FrameSink that processes each frame through a RenderGraph before
forwarding to a downstream sink.
When the wgpu feature is enabled and the graph was created with a GPU
context, the GPU pipeline runs. On GPU error the unprocessed frame is
forwarded as a fallback.
When the wgpu feature is not enabled (or the graph is CPU-only), the
CPU fallback pipeline runs transparently.
§Example
ⓘ
let ctx = Arc::new(RenderContext::init().await?);
let graph = RenderGraph::new(ctx)
.push(ColorGradeNode { brightness: 0.2, ..Default::default() });
let sink = GpuFrameSink::new(graph, Box::new(RgbaSink::new()));
runner.set_sink(Box::new(sink));Implementations§
Source§impl GpuFrameSink
impl GpuFrameSink
Sourcepub fn new(graph: RenderGraph, downstream: Box<dyn FrameSink>) -> Self
pub fn new(graph: RenderGraph, downstream: Box<dyn FrameSink>) -> Self
Construct a sink that applies graph to every incoming frame and
forwards the result to downstream.
Trait Implementations§
Source§impl FrameSink for GpuFrameSink
impl FrameSink for GpuFrameSink
Source§fn push_frame(&mut self, rgba: &[u8], width: u32, height: u32, pts: Duration)
fn push_frame(&mut self, rgba: &[u8], width: u32, height: u32, pts: Duration)
Receive a video frame at its presentation time. Read more
Source§fn flush(&mut self)
fn flush(&mut self)
Called when playback ends (EOF or
PlayerHandle::stop). Default: no-op. Read moreSource§fn accepts_gpu_frame(&self) -> bool
fn accepts_gpu_frame(&self) -> bool
Whether this sink can receive a GPU-resident frame via
push_frame_gpu. Default: false (CPU only). Read moreSource§fn push_frame_gpu(
&mut self,
texture: &Texture,
view: &TextureView,
width: u32,
height: u32,
pts: Duration,
)
fn push_frame_gpu( &mut self, texture: &Texture, view: &TextureView, width: u32, height: u32, pts: Duration, )
Receive a composited frame as a GPU texture, avoiding a GPU-to-CPU
readback. Only called when
accepts_gpu_frame
returns true; the default ignores the frame. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for GpuFrameSink
impl !Sync for GpuFrameSink
impl !UnwindSafe for GpuFrameSink
impl Freeze for GpuFrameSink
impl Send for GpuFrameSink
impl Unpin for GpuFrameSink
impl UnsafeUnpin for GpuFrameSink
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more