pub trait RenderLane: Send + Sync {
// Required methods
fn strategy_name(&self) -> &'static str;
fn get_pipeline_for_material(
&self,
material_uuid: Option<AssetUUID>,
materials: &Assets<Box<dyn Material>>,
) -> RenderPipelineId;
fn render(
&self,
render_world: &RenderWorld,
encoder: &mut dyn CommandEncoder,
render_ctx: &RenderContext<'_>,
gpu_meshes: &RwLock<Assets<GpuMesh>>,
materials: &RwLock<Assets<Box<dyn Material>>>,
);
fn estimate_cost(
&self,
render_world: &RenderWorld,
gpu_meshes: &RwLock<Assets<GpuMesh>>,
) -> f32;
}Expand description
A trait defining the behavior of a rendering lane.
Rendering lanes are responsible for encoding GPU commands to render the scene
represented in the RenderWorld. Different implementations provide different
rendering strategies (e.g., forward rendering, deferred rendering, unlit rendering).
This trait enables the RenderAgent to work with multiple rendering strategies
without being coupled to any specific implementation, following the CLAD
architecture’s separation of concerns.
The lane uses abstractions from khora-core (CommandEncoder, TextureViewId, etc.)
and does not depend on infrastructure-specific types.
Required Methods§
Sourcefn strategy_name(&self) -> &'static str
fn strategy_name(&self) -> &'static str
Returns a human-readable identifier for this rendering strategy.
This can be used by the RenderAgent for logging, debugging, and
strategy selection purposes.
§Returns
A static string identifying the rendering strategy (e.g., “SimpleUnlit”, “ForwardPlus”).
Sourcefn get_pipeline_for_material(
&self,
material_uuid: Option<AssetUUID>,
materials: &Assets<Box<dyn Material>>,
) -> RenderPipelineId
fn get_pipeline_for_material( &self, material_uuid: Option<AssetUUID>, materials: &Assets<Box<dyn Material>>, ) -> RenderPipelineId
Gets the appropriate render pipeline for a given material.
This method determines which pipeline to use based on the material’s properties. Different rendering strategies may select different pipelines based on material characteristics (e.g., alpha blending, two-sided rendering, texturing).
§Arguments
material_uuid: The UUID of the material, if anymaterials: The cache of Material assets
§Returns
The RenderPipelineId to use for rendering with this material.
Sourcefn render(
&self,
render_world: &RenderWorld,
encoder: &mut dyn CommandEncoder,
render_ctx: &RenderContext<'_>,
gpu_meshes: &RwLock<Assets<GpuMesh>>,
materials: &RwLock<Assets<Box<dyn Material>>>,
)
fn render( &self, render_world: &RenderWorld, encoder: &mut dyn CommandEncoder, render_ctx: &RenderContext<'_>, gpu_meshes: &RwLock<Assets<GpuMesh>>, materials: &RwLock<Assets<Box<dyn Material>>>, )
Encodes GPU commands to render the scene into the provided command encoder.
This is the main rendering method that translates the RenderWorld into
actual GPU drawing commands using the abstractions from khora-core.
§Arguments
render_world: The intermediate world containing extracted mesh data.encoder: The command encoder to record GPU commands into (from core traits).render_ctx: The rendering context containing the color target and clear color.gpu_meshes: The cache of GPU-resident meshes.materials: The cache of materials for pipeline selection.
Sourcefn estimate_cost(
&self,
render_world: &RenderWorld,
gpu_meshes: &RwLock<Assets<GpuMesh>>,
) -> f32
fn estimate_cost( &self, render_world: &RenderWorld, gpu_meshes: &RwLock<Assets<GpuMesh>>, ) -> f32
Estimates the GPU cost of rendering the given RenderWorld with this strategy.
This method is used by the RenderAgent to negotiate with GORNA (Goal-Oriented
Resource Negotiation & Allocation) and determine which rendering strategy to use
based on available budget and scene complexity.
The cost is measured in abstract units representing GPU workload (e.g., number of triangles, draw calls, shader complexity).
§Arguments
render_world: The world to estimate the cost for.gpu_meshes: The GPU mesh cache to look up mesh complexity.
§Returns
An estimated cost value. Higher values indicate more expensive rendering.