Struct GpuRenderer

Source
pub struct GpuRenderer {
    gl: Arc<Context>,
    vao: VertexArray,
    vert: Shader,
    programs: Programs,
    pool: Pool,
    textures: HashMap<u64, LayerTex>,
    blank: Texture,
    loaned: Vec<Target>,
    pub text: Option<Arc<Mutex<TextRasterizer>>>,
}
Expand description

The renderer. One per app; lives on the UI thread.

Fields§

§gl: Arc<Context>§vao: VertexArray§vert: Shader§programs: Programs§pool: Pool§textures: HashMap<u64, LayerTex>

Uploaded layer textures by caller key.

§blank: Texture

1×1 white texture, bound where a sampler is unused.

§loaned: Vec<Target>

Targets handed to the caller; recycled at the start of the next frame.

§text: Option<Arc<Mutex<TextRasterizer>>>

What NodeKind::Text rasterises with — the app hands over the same one the player and export use, so fonts and the glyph cache are shared. None = Text nodes render nothing.

Implementations§

Source§

impl GpuRenderer

Source

pub fn new(gl: Arc<Context>) -> Result<Self, String>

Compile the shader set. Err (with the GLSL log) when the driver rejects something — the caller falls back to the CPU compositor and shows the message once.

Source

pub fn upload(&mut self, key: u64, frame: &Frame) -> Texture

Upload/refresh a decoded layer as a texture keyed by (clip id, source time bucket). Returns the texture to use; re-uploads only when the frame actually changed (Frame pointer/pts).

Source

pub fn render_to_texture( &mut self, project: &Project, t: f64, w: u32, h: u32, quality: f32, layers: &LayerSet, ) -> Option<Texture>

Render the whole timeline at time t into an off-screen target and return it, so the preview can paint it with eframe::Frame::register_native_glow_texture. quality (0.25..1.0) scales the internal resolution (see render_size); the texture is always presented at w×h.

Source

pub fn render_frame( &mut self, project: &Project, t: f64, w: u32, h: u32, layers: &LayerSet, out: &mut Frame, )

Same, but read back into out (export / export-frame / MCP render.frame).

Source

pub fn render_preview_texture( &mut self, project: &Project, t: f64, w: u32, h: u32, layers: &LayerSet, ) -> Option<(Texture, u32, u32)>

Apply one effect to a texture (used by the effect-thumbnail grid and the node editor previews). Render the timeline into an off-screen texture the caller can paint directly (zero-copy preview). The texture stays owned by the renderer and is valid until the next call; reclaim() recycles it on the following frame, so the caller must paint it in the same frame it asked for it.

Source

pub fn effect_preview( &mut self, src: &Frame, effect: &Effect, t: f64, out: &mut Frame, ) -> bool

Render effect over src and read the result back into out (catalogue thumbnails). t is the clip-local time to sample animated parameters at. False when the effect has no GPU body.

Source

pub fn apply_effect( &mut self, src: Texture, size: (u32, u32), effect: &Effect, t: f64, ) -> Option<Texture>

Source

pub fn mask_texture( &mut self, mask: &Mask, size: (u32, u32), t: f64, project_w: u32, ) -> Option<Texture>

Rasterise a mask into a single-channel texture (also used by the mask editor overlay).

Source

pub fn eval_graph( &mut self, graph: &NodeGraph, clip: &Clip, t: f64, fps: f64, layers: &LayerSet, ) -> Option<Texture>

Evaluate a node graph, returning the output texture.

Source

pub fn invalidate(&mut self, key: Option<u64>)

Drop cached textures for a clip/asset (source replaced, project closed).

Source

pub fn scaler_supported(&self, _s: Scaler) -> bool

Source

pub fn last_error(&self) -> Option<&str>

The GLSL log of the last program that failed to compile, if any.

Source

pub fn shader_error(&self, src: &str) -> Option<&str>

The GLSL log this user shader body was rejected with, if it ever was.

Source

pub fn check_shader(&mut self, src: &str) -> Result<(), String>

Compile + link a user shader body without rendering anything, so the editor can show the log before the effect is applied. The program lands in the cache the renderer reads.

Source

fn host_fbo(&self) -> Option<Framebuffer>

The framebuffer eframe/egui had bound when it called us.

Source

fn restore(&self, host: Option<Framebuffer>)

Put back the GL state egui assumes (its framebuffer, unit 0, no program bound).

Source

fn reclaim(&mut self)

Take back everything handed out during the previous frame.

Source

fn acquire(&mut self, w: u32, h: u32) -> Option<Target>

Source

fn clear(&self, t: &Target, c: [f32; 4])

Source

fn ensure(&mut self, key: u64) -> Result<(), String>

Ensure a program is compiled and cached. Err carries the GLSL log.

Source

fn effect_program(&mut self, effect: &Effect) -> Option<u64>

Compile (once) the program for an effect; None when the kind has no GPU body.

Source

fn draw( &self, key: u64, dst: &Target, tex: Texture, mask: Option<Texture>, set: impl Fn(&Prog), )

Bind prog, point the fixed sampler units at tex/mask, size uniforms, and draw the triangle.

Source

fn copy_to(&mut self, src: Texture, size: (u32, u32)) -> Option<Target>

Copy src (stretched to the target) into a fresh target.

Source

fn run_effect( &mut self, src: Texture, size: (u32, u32), effect: &Effect, t: f64, scale: f32, mask: Option<Texture>, motion: Option<(Texture, Texture, f32)>, blob: Option<(f64, f64, f64)>, ) -> Option<Target>

One effect pass: src -> a new target of the same size. None when the effect has no GPU body. motion is the (prev, next, count) sampler set a needs_motion kind wants; anything else passes None.

Source

fn track_blob( &self, effect: &Effect, clip: u64, t: f64, layers: &LayerSet, ) -> Option<(f64, f64, f64)>

BlobTrack: find the target colour’s centroid on the clip’s decoded frame. The tracking runs on the CPU copy the decoder already produced, so no readback is needed; the shader only draws it.

Source

fn motion_texs(&mut self, id: u64, layers: &LayerSet) -> (Texture, Texture, f32)

The neighbouring frames a needs_motion effect wants: (prev, next, how many are real). LayerSet::motion carries whatever the decoder managed to produce — 0, 1 or 2 samples.

Source

fn render_mask( &mut self, mask: &Mask, size: (u32, u32), t: f64, scale: f32, centre: (f32, f32), ) -> Option<Target>

Rasterise mask at size; scale is canvas px per project px and centre the shape origin.

Source

fn composite( &mut self, canvas: Target, layer: Texture, layer_size: (u32, u32), inv: [[f32; 3]; 3], mode: BlendMode, opacity: f32, scaler: Scaler, mask: Option<Texture>, ) -> Target

Composite layer onto canvas through inv (canvas px -> layer uv). Consumes and returns the canvas (ping-pong: you cannot sample the framebuffer you are drawing into).

Source

fn render_canvas( &mut self, project: &Project, t: f64, w: u32, h: u32, layers: &LayerSet, ) -> Option<Target>

The whole timeline at t into a fresh canvas target.

Source

fn draw_transition( &mut self, project: &Project, tr: &Transition, left: Option<&Clip>, right: Option<&Clip>, p: f32, t: f64, canvas: Target, layers: &LayerSet, ) -> Target

Both sides of a transition, per kind (mirrors compose::render_transition). Edge transitions have one side missing (In: no left, Out: no right): that side is nothing — the black canvas.

Source

fn fill_canvas(&mut self, canvas: Target, color: [u8; 4], f: f32) -> Target

Mix the whole canvas towards color by f (FadeToColor).

Source

fn draw_subtitles( &mut self, project: &Project, sub: &Arc<Frame>, canvas: Target, ) -> Target

The subtitle bitmap, bottom-centre (mirrors compose::render).

Source

fn draw_clip( &mut self, project: &Project, clip: &Clip, t: f64, canvas: Target, layers: &LayerSet, extra: Extra, ) -> Target

One clip: layer -> chain -> composite. Returns the (possibly new) canvas.

Source

fn run_chain( &mut self, clip: &Clip, t: f64, fps: f64, layers: &LayerSet, src: Texture, size: (u32, u32), scale: f32, ) -> Option<Target>

The clip’s effect chain (node graph when it has one, else the linear stack). None = unchanged.

Source

fn eval_graph_on( &mut self, graph: &NodeGraph, clip: &Clip, t: f64, fps: f64, layers: &LayerSet, input: Option<Texture>, size: (u32, u32), scale: f32, ) -> Option<Target>

Walk graph in evaluation order, one target per node. Missing inputs are transparent.

Source

fn finish_graph( &mut self, done: Vec<(u64, Target)>, out_id: u64, ) -> Option<Target>

Keep the output node’s target, recycle the rest.

Source

fn transparent(&mut self, size: (u32, u32)) -> Option<Target>

Source

fn text_node( &mut self, id: u64, style: &TextStyle, t: f64, lt: f64, fps: f64, scale: f32, size: (u32, u32), ) -> Option<Target>

A Text node: expand the format, rasterise it (shared TextRasterizer) and centre it on an otherwise transparent canvas. A counter re-rasterises every frame — that is what it is for.

Source

fn matte( &mut self, a: Texture, b: Texture, size: (u32, u32), invert: bool, use_alpha: bool, ) -> Option<Target>

Source

fn native_size( &self, project: &Project, clip: &Clip, frame: &Frame, ) -> (u32, u32)

The layer’s “native” size for placement: the asset/sequence size for footage, the bitmap size for anything the caller rendered for us.

Trait Implementations§

Source§

impl Drop for GpuRenderer

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<S> FromSample<S> for S

§

fn from_sample_(s: S) -> S

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

§

impl<T> MaybeSend for T

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,