Files
Seele/docs/subsystems/render-graph-and-passes.md
T
coding-agent 1324d903cb docs: add per-subsystem deep-dives + cross-repo orientation (for coding agents)
Adds docs/ — a navigation layer on top of AGENTS.md for future coding
agents working on the Seele engine and the MeshShadingDemo harness.

- docs/README.md: index + 30-second orientation + how-to-use workflow.
- docs/cross-repo.md: the engine<->demo contract (2-symbol ABI, the
  ComponentSystem<...> demo pattern with the FlyCamSystem example, the
  CMake in-tree vs install(EXPORT) split, a where-to-look task map).
- docs/subsystems/*.md: 16 per-subsystem deep-dives (scene/ECS, systems,
  game-interface, window, graphics backends, render graph, materials,
  physics, UI, assets, platform, core utils). Each maps public types to
  their defining headers and gives file:line pointers + gotchas.

All cross-links verified resolving. This is documentation only — no source
changes.
2026-11-07 22:08:50 +00:00

7.5 KiB

Render Graph & Render Passes

The linear RenderGraph, the per-frame begin/render/end protocol, shared string-named resources, and every render pass in the active pipeline.

This is a navigation doc: it tells you where things live, how data actually flows, and the sharp edges — so you can orient in minutes instead of hours. It complements the repository's AGENTS.md (map + rules) and the cross-repo guide (engine ↔ demo contract). Everything below is grounded in the checked-out source at commit d3ed573.

Key types & where they live

Type Defined in
RenderGraph src/Engine/Graphics/RenderPass/RenderGraph.h
RenderPass src/Engine/Graphics/Metal/RenderPass.h
RenderGraphResources src/Engine/Graphics/RenderPass/RenderGraphResources.h
CachedDepthPass src/Engine/Graphics/RenderPass/CachedDepthPass.h
DepthCullingPass src/Engine/Graphics/RenderPass/DepthCullingPass.h
VisibilityPass src/Engine/Graphics/RenderPass/VisibilityPass.h
LightCullingPass src/Engine/Graphics/RenderPass/LightCullingPass.h
ShadowPass src/Engine/Graphics/RenderPass/ShadowPass.h
BasePass src/Engine/Graphics/RenderPass/BasePass.h
ToneMappingPass src/Engine/Graphics/RenderPass/ToneMappingPass.h
RayTracingPass src/Engine/Graphics/RenderPass/RayTracingPass.h
SimulationComputePass src/Engine/Graphics/RenderPass/SimulationComputePass.h
SurfaceExtractPass src/Engine/Graphics/RenderPass/SurfaceExtractPass.h
FluidRenderPass src/Engine/Graphics/RenderPass/FluidRenderPass.h
TerrainRenderer src/Engine/Graphics/RenderPass/TerrainRenderer.h
WaterRenderer src/Engine/Graphics/RenderPass/WaterRenderer.h
UIPass src/Engine/Graphics/RenderPass/UIPass.h

Paths above are resolved against the actual source tree (namespace ≈ directory in this codebase). A (search) marker means the file contains the name but may also define others — open it and grep. git grep is always a fallback. The full per-file map is in Where to look below.

Data flow / lifecycle

RenderGraph (src/Engine/Graphics/RenderPass/RenderGraph.h) is a simple linear pipeline: addPass(ORenderPass) (calls pass->setResources(res) to inject shared RenderGraphResources), setViewport, createRenderPass() (two-phase: first pass->publishOutputs() on all passes to register outputs into the shared resource map, then pass->createRenderPass() to create GPU render pass objects), render(cam, transform) (three-phase: beginFrame on all, render() on all, endFrame() on all). RenderGraphResources (RenderGraphResources.h) is a name-keyed resource registry: requestRenderTarget/requestTexture/requestBuffer/requestUniform/requestQuery/requestTimestampQuery for consumers, registerRenderPassOutput/registerTextureOutput/registerBufferOutput/registerUniformOutput/registerQueryOutput/registerTimestampQueryOutput for producers. Passes discover each other's outputs by string name (e.g. 'depthTexture', 'visibilityTexture', 'cullingBuffer', 'lightIndexList', 'lightGrid', 'shadowMaps'). RenderPass base class (RenderPass.h) holds: PRenderGraphResources resources, Gfx::PViewport viewport, Gfx::ORenderPass renderPass (GPU-side), Gfx::ODescriptorLayout viewParamsLayout, ViewParameter viewParams struct (viewMatrix, inverseViewMatrix, projectionMatrix, viewProjectionMatrix, cameraPosition_WS, cameraForward_WS, screenDimensions, invScreenDimensions, frameIndex, time). It provides updateViewParameters(cam, transform), createViewParamsSet(), and frustum culling helpers (computePlane, extract_planes_from_view_projection_matrix). A RenderPassType concept (std::derived_from) is defined. GameView.cpp wires the active pipeline: CachedDepthPass -> DepthCullingPass -> VisibilityPass -> LightCullingPass -> ShadowPass -> BasePass -> ToneMappingPass. RayTracingPass is in a separate rayTracingGraph, gated by getGlobals().useRayTracing && graphics->supportRayTracing(). SimulationComputePass, SurfaceExtractPass, FluidRenderPass are commented out in both graphs (WIP).

Where to look

Path What's there
src/Engine/Graphics/RenderPass/RenderGraph.h 45 lines, full file
src/Engine/Graphics/RenderPass/RenderPass.h + RenderPass.cpp base class, 77 lines header / 6.8KB impl
src/Engine/Graphics/RenderPass/RenderGraphResources.h + .cpp shared resource registry
src/Engine/Window/GameView.cpp pipeline wiring, lines 24-108
src/Engine/Graphics/RenderPass/CachedDepthPass.h + .cpp depth prepass + visibility prepass
src/Engine/Graphics/RenderPass/DepthCullingPass.h + .cpp GPU culling: depth mip buffer, BLOCK_SIZE=32, cullingBuffer output
src/Engine/Graphics/RenderPass/VisibilityPass.h + .cpp visibilityTexture + cullingBuffer, compute shader
src/Engine/Graphics/RenderPass/LightCullingPass.h + .cpp oLightIndexList/tLightIndexList, oLightGrid/tLightGrid, frustumBuffer, double-buffered
src/Engine/Graphics/RenderPass/ShadowPass.h + .cpp 4 cascades, 8192x8192 shadow maps, light-space matrices
src/Engine/Graphics/RenderPass/BasePass.h + .cpp main 3D pass: HDR MSAA color/depth, opaque+transparent meshlets, skybox, debug rendering
src/Engine/Graphics/RenderPass/ToneMappingPass.h + .cpp post-processing, final output to viewport
src/Engine/Graphics/RenderPass/RayTracingPass.h + .cpp TLAS 'scene', rayGen/anyhit/miss shaders, radiance accumulator

Gotchas & sharp edges

  • RenderGraph is NOT a data-flow graph — it is a linear list with a two-phase setup (publishOutputs then createRenderPass) and a three-phase per-frame loop (beginFrame/render/endFrame on ALL passes before any pass runs its GPU work).
  • Passes communicate exclusively through string-named resources in RenderGraphResources. The names are hardcoded constants (e.g. DEPTHTEXTURE_NAME='depthTexture', VISIBILITY_NAME='visibilityTexture', CULLINGBUFFER_NAME='cullingBuffer', LIGHTINDEX_NAME='lightIndexList'). If you rename one, every consumer breaks silently.
  • CachedDepthPass is the FIRST pass in the graph — it does a depth prepass AND a visibility prepass (renders meshlets twice before anything else).
  • DepthCullingPass and VisibilityPass both write to 'cullingBuffer' — the culling buffer is a shared GPU buffer that DepthCullingPass creates and VisibilityPass consumes.
  • LightCullingPass uses double-buffered light grids (oLightGrid/tLightGrid, oLightIndexList/tLightIndexList) — the 'o' and 't' prefixes stand for odd/even frames.
  • BasePass.h has WaterRenderer and TerrainRenderer members commented out (lines 67-68) — water/terrain are not currently in the active render path.
  • SimulationComputePass, SurfaceExtractPass, FluidRenderPass are all commented out in GameView.cpp (lines 33-35, 41-43). The fluid simulation pipeline exists but is disabled.
  • ToneMappingPass takes only Gfx::PGraphics in its constructor (no scene) — it is the only pass that does not need scene access.
  • The 'RenderPass' name is overloaded: Gfx::RenderPass (GPU render pass object, created by Graphics::createRenderPass) vs Seele::RenderPass (the C++ base class for frame passes). They are different types in different namespaces.
  • RenderGraph::addPass takes ORenderPass (OwningPtr) — the graph owns the passes. You cannot remove a pass once added (no removePass method).

Generated from a full read of the checked-out source at commit d3ed573. If a path has moved, git grep for the type name — the engine is small enough to find anything in seconds.