Trait RenderSystem
pub trait RenderSystem:
Debug
+ Send
+ Sync {
Show 16 methods
// Required methods
fn init(
&mut self,
window: &dyn KhoraWindow,
) -> Result<Vec<Arc<dyn ResourceMonitor>>, RenderError>;
fn resize(&mut self, new_width: u32, new_height: u32);
fn prepare_frame(&mut self, view_info: &ViewInfo);
fn render(
&mut self,
renderables: &[RenderObject],
view_info: &ViewInfo,
settings: &RenderSettings,
) -> Result<RenderStats, RenderError>;
fn get_last_frame_stats(&self) -> &RenderStats;
fn supports_feature(&self, feature_name: &str) -> bool;
fn get_adapter_info(&self) -> Option<GraphicsAdapterInfo>;
fn graphics_device(&self) -> Arc<dyn GraphicsDevice> ⓘ;
fn begin_frame(&mut self) -> Result<FrameTargets, RenderError>;
fn end_frame(&mut self) -> Result<RenderStats, RenderError>;
fn shutdown(&mut self);
fn as_any(&self) -> &(dyn Any + 'static);
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static);
// Provided methods
fn render_overlay(
&mut self,
_overlay: &mut dyn EditorOverlay,
_screen: OverlayScreenDescriptor,
) -> Result<(), RenderError> { ... }
fn render_to_viewport(&self) -> bool { ... }
fn set_render_to_viewport(&mut self, _enabled: bool) { ... }
}Expand description
A high-level trait representing the entire rendering subsystem.
This trait defines the primary interface for the engine to interact with the renderer.
A concrete implementation of RenderSystem (likely in khora-infra) encapsulates
all the state and logic needed to render a frame, including device management,
swapchain handling, and the execution of render pipelines.
Required Methods§
fn init(
&mut self,
window: &dyn KhoraWindow,
) -> Result<Vec<Arc<dyn ResourceMonitor>>, RenderError>
fn init( &mut self, window: &dyn KhoraWindow, ) -> Result<Vec<Arc<dyn ResourceMonitor>>, RenderError>
Initializes the rendering system with a given window.
This method sets up the graphics device, swapchain, and any other necessary backend resources. It should be called once at application startup.
§Returns
On success, it returns a Vec of ResourceMonitor trait objects that the
telemetry system can use to track GPU-specific resources like VRAM.
fn resize(&mut self, new_width: u32, new_height: u32)
fn resize(&mut self, new_width: u32, new_height: u32)
Notifies the rendering system that the output window has been resized.
fn prepare_frame(&mut self, view_info: &ViewInfo)
fn prepare_frame(&mut self, view_info: &ViewInfo)
Prepares for a new frame.
Updates per-frame uniforms (camera view-projection, etc.) before any pass is recorded.
fn render(
&mut self,
renderables: &[RenderObject],
view_info: &ViewInfo,
settings: &RenderSettings,
) -> Result<RenderStats, RenderError>
fn render( &mut self, renderables: &[RenderObject], view_info: &ViewInfo, settings: &RenderSettings, ) -> Result<RenderStats, RenderError>
Renders a single frame from a flat list of render objects.
Legacy entry point retained for non-agent code paths (tests, demos). Production rendering goes through the frame graph.
fn get_last_frame_stats(&self) -> &RenderStats
fn get_last_frame_stats(&self) -> &RenderStats
Returns a reference to the statistics of the last successfully rendered frame.
fn supports_feature(&self, feature_name: &str) -> bool
fn supports_feature(&self, feature_name: &str) -> bool
Checks if a specific, optional rendering feature is supported by the backend.
fn get_adapter_info(&self) -> Option<GraphicsAdapterInfo>
fn get_adapter_info(&self) -> Option<GraphicsAdapterInfo>
Returns information about the active graphics adapter (GPU).
fn graphics_device(&self) -> Arc<dyn GraphicsDevice> ⓘ
fn graphics_device(&self) -> Arc<dyn GraphicsDevice> ⓘ
Returns a shared, thread-safe reference to the underlying GraphicsDevice.
fn begin_frame(&mut self) -> Result<FrameTargets, RenderError>
fn begin_frame(&mut self) -> Result<FrameTargets, RenderError>
Begins a new visual frame by acquiring the swapchain (or viewport) texture.
Called exactly once per frame by the engine, before any agent runs.
The returned [FrameTargets] are inserted into the per-frame
FrameContext so agents can address the same color/depth attachments.
The matching end_frame presents the result.
fn end_frame(&mut self) -> Result<RenderStats, RenderError>
fn end_frame(&mut self) -> Result<RenderStats, RenderError>
Ends the current visual frame by presenting the swapchain texture.
Called exactly once per frame by the engine, after the frame graph has been compiled and submitted.
fn shutdown(&mut self)
fn shutdown(&mut self)
Cleans up and releases all graphics resources.
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Allows mutable downcasting to a concrete RenderSystem type.
Provided Methods§
fn render_overlay(
&mut self,
_overlay: &mut dyn EditorOverlay,
_screen: OverlayScreenDescriptor,
) -> Result<(), RenderError>
fn render_overlay( &mut self, _overlay: &mut dyn EditorOverlay, _screen: OverlayScreenDescriptor, ) -> Result<(), RenderError>
Renders an editor overlay on top of the current frame.
Called between the frame graph submission and end_frame.
The default implementation is a no-op (no overlay).
fn render_to_viewport(&self) -> bool
fn render_to_viewport(&self) -> bool
Whether begin_frame targets an offscreen viewport
instead of the swapchain.
When true, the engine skips its own end_frame call
— the caller managing the viewport is responsible for presenting.
fn set_render_to_viewport(&mut self, _enabled: bool)
fn set_render_to_viewport(&mut self, _enabled: bool)
Toggles whether begin_frame targets the offscreen
viewport texture instead of the swapchain.