Runtime.Graphics (Visera.Runtime.Graphics)¶
Runtime.Graphics builds high-level graphics on top of RHI: framework init and lifecycle, material system, pipeline cache, render graph and scene (camera, light, renderable). Uses an immediate-mode draw API: the game submits per-frame via SetCamera, SubmitLight and Draw; the engine calls Render(FWindow*) after OnPreRender to send accumulated data to the Graphics thread. Converts draw commands and materials to RHI commands and resource bindings; manages multi-pass and resource dependencies via render graph.
Responsibilities¶
- Framework: Graphics subsystem init;
FRenderTask/FRenderContext; draw list fromFRenderData::DrawCommands(BatchAndSort→FRenderListby material/mesh); instance buffer upload (UploadInstanceBuffers→ per-batch SSBO + descriptor set); pass registration with read/write lock for concurrency. - Material: Material type, render state (cull mode, depth test/write/compare), descriptor set 0 (textures/samplers); JSON
.vmaterialdriven. - PipelineCache: Get-or-create PSO by material shaders, formats and render state; hash-based O(1) lookup (GoldenRatio); key includes depth/stencil and cull configuration.
- RenderGraph: Declarative passes; Execute(FRenderContext) (creates command list, runs passes with
RenderList, submits); pass names asFName; CullDeadPasses O(N+E) reverse BFS. - Scene: Camera (
FCamera), lights (FLight), renderables (IRenderable/FRenderableMeta→FInstanceData+ Material + optionalFMesh). All submitted per-frame viaFGraphics; no persistent scene container (FSceneremoved).
GPU instancing pipeline¶
- Game calls
GFX->Draw(renderable)orGFX->Draw(FRenderableMeta); data is captured at submit time. - After
OnPreRender, engine callsGFX->Render(Window)to buildFRenderTaskfrom accumulated draws, camera and lights. - Graphics thread runs
BatchAndSortonFRenderData::DrawCommands→FRenderList(batches by Material + Mesh). UploadInstanceBufferscreates per-batch SSBO and descriptor set.- Draw passes bind set 0 (material) + set 1 (instances) and issue
Draw(6, N)orDrawIndexed(IndexCount, N).
Submodules¶
| Module | Description |
|---|---|
| Framework | Graphics framework init, FRenderBatch, FRenderList, instance upload. |
| Material | Material type, render state and descriptor set 0. |
| PipelineCache | Pipeline cache with extended key. |
| RenderGraph | Render graph. |
| Scene | Camera, Light, Renderable. |