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
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
A structural error or the first pass failure: RenderError::UnknownEffect for an effect
without a CPU kernel, 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 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
impl CpuRenderer
Sourcepub fn new(threads: usize) -> Self
pub fn new(threads: usize) -> Self
A CPU renderer on threads threads (one means 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
Blends composites 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 use now.
Sourcepub fn unsupported_builtins() -> Vec<(String, u32)>
pub fn unsupported_builtins() -> Vec<(String, u32)>
Built-ins the GPU registers that this renderer cannot draw, as (id, version); currently
empty.
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 node results for reuse, like
crate::Renderer::set_result_cache_budget.
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 previous one, as recorded via
RenderControls::record_frame_outcome.
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 3D LUT id, like crate::Renderer::register_lut3d.
§Errors
RenderError::InvalidEffectResource for an empty id 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
Drops the cached results 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 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.
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 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.
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 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
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_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 set_texture_budget_bytes(&self, _budget_bytes: u64)
fn set_texture_budget_bytes(&self, _budget_bytes: u64)
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