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 and no graphics driver.

It draws every built-in effect, transition and pass of the GPU crate::Renderer, to the same contract: the same graph, the same stages, and pictures stored as the GPU’s half-float intermediate stores them. Effects registered at run time as WGSL have no CPU implementation; a graph that draws one fails with RenderError::UnknownEffect.

Its output is the same for any thread count and on every 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

Returns a structural error or the first pass’s failure: RenderError::UnknownEffect for an effect with no CPU kernel and 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 its output into targets as YUV420 with encoding: the CPU counterpart of crate::Renderer::render_graph_yuv420p, writing the caller’s plane memory directly.

§Errors

Returns 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 drawing on threads threads (one draws on the calling thread), with every built-in registered.

Source

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

The renderer with composites blending 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 take now.

Source

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

Every built-in effect and transition the GPU registers that this renderer cannot draw, as (id, version). Empty: every built-in has a CPU kernel.

Source

pub fn set_result_cache_budget(&self, budget_bytes: u64)

Keeps up to budget_bytes of drawn node results for reuse across graphs, as crate::Renderer::set_result_cache_budget does.

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 one before, as RenderControls::record_frame_outcome counted them.

Source

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

Registers or replaces the 3D lookup table id, as crate::Renderer::register_lut3d does.

§Errors

Returns RenderError::InvalidEffectResource for an empty identity 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

Lets go of the cached results, which are kept only for reuse, 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 as presentation places them, converted the first time a graph draws it: the CPU counterpart of crate::Renderer::prepare_yuv_presented.

§Errors

Returns RenderError::InvalidImageData for an unsupported format or planes that do not hold the frame, 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 of size, rows stride bytes apart, as presentation places them: the CPU counterpart of crate::Renderer::prepare_rgba_presented. A stride of zero means rows packed.

§Errors

Returns RenderError::InvalidImageData for pixels that do not hold size 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-light RGBA as half-float bits, in BT.709 primaries with 1.0 at SDR white: the CPU counterpart of crate::Renderer::prepare_linear_presented. A stride of zero means rows packed.

§Errors

Returns RenderError::InvalidImageData for pixels that do not hold size 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 what id draws can change with the frame time alone. An effect that is not registered answers true.
Source§

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

The identity a project’s effect id at version is drawn under; None when this renderer cannot draw it, or it is an internal pass.
Source§

impl RenderControls for CpuRenderer

Source§

fn set_texture_budget_bytes(&self, _budget_bytes: u64)

The CPU renderer keeps no pool of pictures to budget: a picture’s memory goes back to the allocator when its last reader is done.

Source§

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

Sets the filter sample budget and the motion blur subframe count passes take; the renderer may cap the budget lower.
Source§

fn content_epoch(&self) -> u64

A count that changes whenever results drawn earlier may no longer be 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 one before.
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,