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
impl CpuRenderer
Sourcepub fn execute_graph(
&self,
graph: &RenderGraph<'_>,
) -> Result<Arc<CpuImage>, GraphError>
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.
Sourcepub fn render_graph_into_yuv420p(
&self,
graph: &RenderGraph<'_>,
encoding: YuvEncoding,
targets: &mut Yuv420pTargets<'_>,
) -> Result<(), RenderError>
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
impl CpuRenderer
Sourcepub fn new(threads: usize) -> Self
pub fn new(threads: usize) -> Self
A CPU renderer drawing on threads threads (one draws on the
calling thread), with every built-in registered.
Sourcepub const fn with_blend_space(self, blend_space: BlendSpace) -> Self
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.
Sourcepub fn quality_controls(&self) -> RenderQualityControls
pub fn quality_controls(&self) -> RenderQualityControls
The quality controls passes take now.
Sourcepub fn unsupported_builtins() -> Vec<(String, u32)>
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.
Sourcepub fn set_result_cache_budget(&self, budget_bytes: u64)
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.
Sourcepub fn result_cache_stats(&self) -> ResultCacheStats
pub fn result_cache_stats(&self) -> ResultCacheStats
The result cache’s counters.
Sourcepub fn clear_result_cache(&self)
pub fn clear_result_cache(&self)
Drops every cached result.
Sourcepub fn stats(&self) -> CpuRenderStats
pub fn stats(&self) -> CpuRenderStats
What the renderer has drawn so far.
Sourcepub fn frame_outcomes(&self) -> (u64, u64)
pub fn frame_outcomes(&self) -> (u64, u64)
Frames presented and frames that repeated the one before, as
RenderControls::record_frame_outcome counted them.
Sourcepub fn register_lut3d(
&mut self,
id: impl Into<String>,
data: &Lut3dData,
) -> Result<(), RenderError>
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.
Sourcepub fn clear_effect_resources(&mut self)
pub fn clear_effect_resources(&mut self)
Removes every resource and clears the cached results.
Sourcepub fn release_idle_memory(&self) -> u64
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.
Sourcepub fn unregister_effect_resource(&mut self, id: &str) -> bool
pub fn unregister_effect_resource(&mut self, id: &str) -> bool
Removes the resource id and returns whether it existed.
Source§impl CpuRenderer
impl CpuRenderer
Sourcepub fn present_yuv(
&self,
planes: Arc<dyn YuvPlanes>,
presentation: SourcePresentation,
policy: ColorPolicy,
) -> Result<(CpuSource, Vec<ColorDiagnostic>), RenderError>
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.
Sourcepub fn present_rgba8(
&self,
pixels: Arc<dyn RgbaPixels>,
size: RenderSize,
stride: u32,
presentation: SourcePresentation,
alpha: SourceAlpha,
) -> Result<CpuSource, RenderError>
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.
Sourcepub fn present_linear_rgba16f(
&self,
pixels: Arc<dyn RgbaPixels>,
size: RenderSize,
stride: u32,
presentation: SourcePresentation,
) -> Result<CpuSource, RenderError>
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
impl Debug for CpuRenderer
Source§impl EffectCatalog for CpuRenderer
impl EffectCatalog for CpuRenderer
Source§impl RenderControls for CpuRenderer
impl RenderControls for CpuRenderer
Source§fn set_texture_budget_bytes(&self, _budget_bytes: u64)
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,
)
fn set_quality_controls( &self, max_filter_samples: u32, motion_blur_subframes: u32, )
Source§fn content_epoch(&self) -> u64
fn content_epoch(&self) -> u64
Source§fn record_frame_outcome(&self, presented: bool, repeated: bool)
fn record_frame_outcome(&self, presented: bool, repeated: bool)
Source§fn graph_cache_key(
&self,
graph: &RenderGraph<'_>,
) -> Result<RenderCacheKey, GraphError>
fn graph_cache_key( &self, graph: &RenderGraph<'_>, ) -> Result<RenderCacheKey, GraphError>
graph draws on this renderer. Read moreAuto Trait Implementations§
impl !Freeze for CpuRenderer
impl !RefUnwindSafe for CpuRenderer
impl !UnwindSafe for CpuRenderer
impl Send for CpuRenderer
impl Sync for CpuRenderer
impl Unpin for CpuRenderer
impl UnsafeUnpin for CpuRenderer
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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