Skip to main content

CpuRenderer

Struct CpuRenderer 

Source
pub struct CpuRenderer { /* private fields */ }
Expand description

A renderer that draws RenderGraphs on the CPU with no GPU or driver.

It draws every built-in of the GPU crate::Renderer to the same contract: same graph, same stages, same half-float storage. Runtime WGSL effects have no CPU implementation and fail with RenderError::UnknownEffect. Output is identical for any thread count and target.

Implementations§

Source§

impl CpuRenderer

Source

pub fn execute_graph( &self, graph: &RenderGraph<'_>, ) -> Result<Arc<CpuImage>, GraphError>

Draws the reachable part of graph and returns its output.

§Errors

A structural error or the first pass failure: RenderError::UnknownEffect for an effect without a CPU kernel, RenderError::InvalidSource for a GPU source.

Source

pub fn render_graph_into_yuv420p( &self, graph: &RenderGraph<'_>, encoding: YuvEncoding, targets: &mut Yuv420pTargets<'_>, ) -> Result<(), RenderError>

Draws graph and packs it as YUV420 with encoding directly into the caller’s planes; the CPU counterpart of crate::Renderer::render_graph_yuv420p.

§Errors

Self::execute_graph’s errors, and RenderError::TextureReadback for an odd size or a target too small.

Source§

impl CpuRenderer

Source

pub fn new(threads: usize) -> Self

A CPU renderer on threads threads (one means the calling thread), with every built-in registered.

Source

pub const fn with_blend_space(self, blend_space: BlendSpace) -> Self

Blends composites in blend_space unless a graph sets its own.

Source

pub const fn threads(&self) -> usize

Threads the renderer draws on.

Source

pub fn quality_controls(&self) -> RenderQualityControls

The quality controls passes use now.

Source

pub fn unsupported_builtins() -> Vec<(String, u32)>

Built-ins the GPU registers that this renderer cannot draw, as (id, version); currently empty.

Source

pub fn set_result_cache_budget(&self, budget_bytes: u64)

Keeps up to budget_bytes of node results for reuse, like crate::Renderer::set_result_cache_budget.

Source

pub fn result_cache_stats(&self) -> ResultCacheStats

The result cache’s counters.

Source

pub fn clear_result_cache(&self)

Drops every cached result.

Source

pub fn stats(&self) -> CpuRenderStats

What the renderer has drawn so far.

Source

pub fn frame_outcomes(&self) -> (u64, u64)

Frames presented and frames that repeated the previous one, as recorded via RenderControls::record_frame_outcome.

Source

pub fn register_lut3d( &mut self, id: impl Into<String>, data: &Lut3dData, ) -> Result<(), RenderError>

Registers or replaces 3D LUT id, like crate::Renderer::register_lut3d.

§Errors

RenderError::InvalidEffectResource for an empty id or an invalid cube.

Source

pub fn clear_effect_resources(&mut self)

Removes every resource and clears the cached results.

Source

pub fn release_idle_memory(&self) -> u64

Drops the cached results and returns the bytes they held.

Source

pub fn unregister_effect_resource(&mut self, id: &str) -> bool

Removes the resource id and returns whether it existed.

Source§

impl CpuRenderer

Source

pub fn present_yuv( &self, planes: Arc<dyn YuvPlanes>, presentation: SourcePresentation, policy: ColorPolicy, ) -> Result<(CpuSource, Vec<ColorDiagnostic>), RenderError>

A source showing decoded YCbCr planes placed by presentation, converted on first draw; the CPU counterpart of crate::Renderer::prepare_yuv_presented.

§Errors

RenderError::InvalidImageData for an unsupported format or short planes, and RenderError::UnsupportedHdr when ColorPolicy::RejectHdr meets an HDR source.

Source

pub fn present_rgba8( &self, pixels: Arc<dyn RgbaPixels>, size: RenderSize, stride: u32, presentation: SourcePresentation, alpha: SourceAlpha, ) -> Result<CpuSource, RenderError>

A source showing RGBA8 pixels placed by presentation; the CPU counterpart of crate::Renderer::prepare_rgba_presented. A zero stride means packed rows.

§Errors

RenderError::InvalidImageData for short pixels or an invalid presentation.

Source

pub fn present_linear_rgba16f( &self, pixels: Arc<dyn RgbaPixels>, size: RenderSize, stride: u32, presentation: SourcePresentation, ) -> Result<CpuSource, RenderError>

A source showing premultiplied linear BT.709 RGBA half-float bits (1.0 = SDR white); the CPU counterpart of crate::Renderer::prepare_linear_presented. A zero stride means packed rows.

§Errors

RenderError::InvalidImageData for short pixels or an invalid presentation.

Trait Implementations§

Source§

impl Debug for CpuRenderer

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl EffectCatalog for CpuRenderer

Source§

fn effect_definition(&self, id: &EffectId) -> Option<&EffectDef>

The definition registered as id.
Source§

fn effect_reads_time(&self, id: &EffectId) -> bool

Whether id’s output can change with frame time alone; true for unknown effects.
Source§

fn project_effect_id(&self, id: &str, version: u32) -> Option<&EffectId>

The identity a project’s effect id@version draws under; None if this renderer cannot draw it or it is internal.
Source§

impl RenderControls for CpuRenderer

Source§

fn set_quality_controls( &self, max_filter_samples: u32, motion_blur_subframes: u32, )

Sets the filter sample budget (possibly capped lower) and motion blur subframe count.
Source§

fn set_texture_budget_bytes(&self, _budget_bytes: u64)

Sets the byte budget of pooled pictures kept for reuse.
Source§

fn content_epoch(&self) -> u64

Changes whenever earlier results may differ from what the same graph draws now.
Source§

fn record_frame_outcome(&self, presented: bool, repeated: bool)

Records whether a frame was presented and whether it repeated the previous one.
Source§

fn graph_cache_key( &self, graph: &RenderGraph<'_>, ) -> Result<RenderCacheKey, GraphError>

A deterministic key for what graph draws on this renderer. 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<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> 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,