pub struct ForwardPlusLane {
pub tile_config: ForwardPlusTileConfig,
pub shader_complexity: ShaderComplexity,
pub gpu_resources: Mutex<ForwardPlusGpuResources>,
/* private fields */
}Expand description
A rendering lane that implements Forward+ (Tiled Forward) rendering.
Forward+ divides the screen into tiles and uses a compute shader to determine which lights affect each tile before the main render pass. This significantly reduces per-fragment lighting cost for scenes with many lights.
§Configuration
The lane is configured via ForwardPlusTileConfig, which controls:
- Tile size: 16x16 or 32x32 pixels (trade-off between culling granularity and overhead)
- Max lights per tile: Memory budget for per-tile light lists
- Depth pre-pass: Optional optimization for depth-bounded light culling
Fields§
§tile_config: ForwardPlusTileConfigTile configuration for light culling.
shader_complexity: ShaderComplexityShader complexity for cost estimation.
gpu_resources: Mutex<ForwardPlusGpuResources>GPU resources for compute and render passes.
Implementations§
Source§impl ForwardPlusLane
impl ForwardPlusLane
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new ForwardPlusLane with default settings.
Default configuration:
- Tile size: 16x16 pixels
- Max lights per tile: 128
- No depth pre-pass
Sourcepub fn with_config(config: ForwardPlusTileConfig) -> Self
pub fn with_config(config: ForwardPlusTileConfig) -> Self
Creates a new ForwardPlusLane with the specified configuration.
§Arguments
config- The tile configuration for light culling
Sourcepub fn with_complexity(complexity: ShaderComplexity) -> Self
pub fn with_complexity(complexity: ShaderComplexity) -> Self
Creates a new ForwardPlusLane with the specified shader complexity.
Sourcepub fn set_screen_size(&mut self, width: u32, height: u32)
pub fn set_screen_size(&mut self, width: u32, height: u32)
Updates the screen size used for tile calculations.
This should be called when the window is resized to recalculate tile counts and buffer sizes.
Sourcepub fn tile_count(&self) -> (u32, u32)
pub fn tile_count(&self) -> (u32, u32)
Calculates the number of tiles in each dimension.
Sourcepub fn total_tiles(&self) -> u32
pub fn total_tiles(&self) -> u32
Calculates the total number of tiles on screen.
Sourcepub fn effective_light_count(&self, render_world: &RenderWorld) -> usize
pub fn effective_light_count(&self, render_world: &RenderWorld) -> usize
Returns the effective number of lights in the scene.
This counts all light types (directional, point, spot) that will be processed by the light culling pass.
Source§impl ForwardPlusLane
impl ForwardPlusLane
Sourcepub fn get_pipeline_for_material(
&self,
_material: Option<&AssetHandle<Box<dyn Material>>>,
) -> RenderPipelineId
pub fn get_pipeline_for_material( &self, _material: Option<&AssetHandle<Box<dyn Material>>>, ) -> RenderPipelineId
Returns the render pipeline for the given material (or default).