RenderAgent

Struct RenderAgent 

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

The agent responsible for managing the state and logic of the rendering pipeline.

It orchestrates the various systems and lanes involved in preparing and translating scene data from the ECS into a format consumable by the low-level RenderSystem.

Implementations§

Source§

impl RenderAgent

Source

pub fn new() -> Self

Creates a new RenderAgent with default lanes and automatic strategy selection.

Source

pub fn with_strategy(strategy: RenderingStrategy) -> Self

Creates a new RenderAgent with the specified rendering strategy.

Source

pub fn add_lane(&mut self, lane: Box<dyn RenderLane>)

Adds a custom render lane to the available lanes.

Source

pub fn set_strategy(&mut self, strategy: RenderingStrategy)

Sets the rendering strategy.

Source

pub fn strategy(&self) -> RenderingStrategy

Returns the current rendering strategy.

Source

pub fn lanes(&self) -> &[Box<dyn RenderLane>]

Returns a reference to the available lanes.

Source

pub fn select_lane(&self) -> &dyn RenderLane

Selects the appropriate render lane based on the current strategy.

Source

pub fn prepare_frame( &mut self, world: &mut World, cpu_meshes: &Assets<Mesh>, graphics_device: &dyn GraphicsDevice, )

Prepares all rendering data for the current frame.

This method runs the entire Control Plane logic for rendering:

  1. Prepares GPU resources for any newly loaded meshes.
  2. Extracts all visible objects from the ECS into the internal RenderWorld.
Source

pub fn render( &mut self, world: &mut World, cpu_meshes: &Assets<Mesh>, graphics_device: &dyn GraphicsDevice, materials: &RwLock<Assets<Box<dyn Material>>>, encoder: &mut dyn CommandEncoder, render_ctx: &RenderContext<'_>, )

Renders a frame by preparing the scene data and encoding GPU commands.

This is the main rendering method that orchestrates the entire rendering pipeline:

  1. Calls prepare_frame() to extract and prepare all renderable data
  2. Calls produce_render_objects() to build the RenderObject list with proper pipelines
  3. Delegates to the selected render lane to encode GPU commands
§Arguments
  • world: The ECS world containing scene data
  • cpu_meshes: The cache of CPU-side mesh assets
  • graphics_device: The graphics device for GPU resource creation
  • materials: The cache of material assets
  • encoder: The command encoder to record GPU commands into
  • color_target: The texture view to render into (typically the swapchain)
  • clear_color: The color to clear the framebuffer with
Source

pub fn produce_render_objects( &self, materials: &RwLock<Assets<Box<dyn Material>>>, ) -> Vec<RenderObject>

Translates the prepared data from the RenderWorld into a list of RenderObjects.

This method should be called after prepare_frame. It reads the intermediate RenderWorld and produces the final, low-level data structure required by the RenderSystem.

This logic uses the render lane to determine the appropriate pipeline for each material, then builds the RenderObjects list.

§Arguments
  • materials: The cache of material assets for pipeline selection
Source

pub fn extract_camera_view(&self, world: &World) -> ViewInfo

Extracts the active camera from the ECS world and generates a ViewInfo.

This method queries the ECS for entities with both a Camera and GlobalTransform component, finds the first active camera, and constructs a ViewInfo containing the camera’s view and projection matrices.

§Arguments
  • world: The ECS world containing camera entities
§Returns

A ViewInfo containing the camera’s matrices and position. If no active camera is found, returns a default ViewInfo with identity matrices.

Trait Implementations§

Source§

impl Default for RenderAgent

Source§

fn default() -> Self

Returns the “default value” for a type. 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<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
§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

§

fn into_sample(self) -> T

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.