Skip to main content

Renderer

Struct Renderer 

Source
pub struct Renderer<'runtime> { /* private fields */ }
Expand description

Runtime-borrowing headless render-to-texture session.

Admits multiple frame sources through the same slot-ring lifecycle. submit_frame returns a RenderFrame carrying the color Texture and exact producer Event.

Implementations§

Source§

impl<'runtime> Renderer<'runtime>

Source

pub fn new(runtime: &'runtime Runtime, config: RendererConfig) -> Result<Self>

Create a bounded headless target ring borrowing runtime.

When max_vertex_count / max_index_count are non-zero and the Runtime has a graphics queue, all graphics pipelines are created and per-slot render targets and mesh buffers are allocated.

§Errors

Returns an error for zero extent, zero or >4 target slots, invalid light/color config, a missing graphics queue when mesh capacity is requested, or device allocation failure.

Source

pub fn config(&self) -> &RendererConfig

Return this session’s fixed configuration.

Source

pub fn has_mesh_path(&self) -> bool

Return whether the graphics draw paths are available.

Source

pub fn register_texture( &self, handle: TextureHandle, texture: &Texture, ) -> Result<()>

Associate a semantic material texture handle with one native Texture.

Replacing an existing handle affects future frames only. Submitted frames retain the exact native image they referenced until their producer event completes.

Source

pub fn begin_frame(&self, source: &Texture) -> Result<()>

Begin one frame from a completed packed source Texture (blit path).

Source

pub fn begin_frame_mesh(&self, mesh: &MeshData, camera: &Camera) -> Result<()>

Begin one frame using the vertex-color-lit pipeline.

Requires has_mesh_path().

Source

pub fn begin_frame_flat_color( &self, mesh: &MeshData, camera: &Camera, material: &FlatColorMaterial, ) -> Result<()>

Begin one frame using the flat-color material pipeline.

Requires has_mesh_path(). material parameters are baked into the push constant block at record time — no GPU buffer is retained.

Source

pub fn begin_frame_canvas_grid(&self, frame: &CanvasGridFrame) -> Result<()>

Begin one frame drawing the procedural canvas grid.

Requires has_mesh_path(). The draw is a vertexless fullscreen triangle; frame is baked into the 100-byte fragment push block and the scissor limits coverage to frame’s destination rect.

Source

pub fn begin_frame_unlit( &self, mesh: &MeshData, camera: &Camera, material: &UnlitMaterial, ) -> Result<()>

Begin one frame using the unlit textured material pipeline.

Requires has_mesh_path(). Material tint and UV transform are baked into the push block. base_color_texture resolves through Renderer::register_texture; None uses the renderer’s retained white texture so tint-only unlit materials remain a valid draw path.

Source

pub fn begin_frame_scene(&self, scene: &Scene, camera: &Camera) -> Result<()>

Begin one frame by compiling and drawing a semantic Scene.

Requires has_mesh_path(). The scene is validated and compiled into a merged world-space mesh. Each visible mesh node with geometry produces one draw call; nodes with different materials bind different material UBOs and descriptor sets within the same render pass.

Material dispatch:

  • Material::Surface → Surface PBR pipeline.
  • None (no assignment) → SurfaceMaterial::default().
  • Non-Surface materials and scenes exceeding max_materials_per_scene are rejected.
§Errors

Returns an error when the graphics path is unavailable, the scene fails validation or produces an empty mesh, the compiled vertex/index count exceeds configured capacity, more than max_materials_per_scene distinct materials are referenced, any assigned material is not Material::Surface, or buffer write fails.

Source

pub fn submit_frame(&self) -> Result<RenderFrame>

Submit the in-progress frame and return its target lease and producer.

Source

pub fn cancel_frame(&self) -> Result<()>

Cancel the in-progress frame without submitting or waiting.

Source

pub fn collect(&self) -> Result<usize>

Recycle submitted slots whose exact producer event has completed.

Source

pub fn close(&self) -> Result<()>

Wait for outstanding submitted frames and permanently close the session.

Auto Trait Implementations§

§

impl<'runtime> !RefUnwindSafe for Renderer<'runtime>

§

impl<'runtime> !Send for Renderer<'runtime>

§

impl<'runtime> !Sync for Renderer<'runtime>

§

impl<'runtime> !UnwindSafe for Renderer<'runtime>

§

impl<'runtime> Forget for Renderer<'runtime>

§

impl<'runtime> Freeze for Renderer<'runtime>

§

impl<'runtime> Move for Renderer<'runtime>

§

impl<'runtime> Unpin for Renderer<'runtime>

§

impl<'runtime> UnsafeUnpin for Renderer<'runtime>

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<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

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<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

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

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

fn to_sample_(self) -> U

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.