Files
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

5.6 KiB

Window & view layer (Window, View, GameView, WindowManager)

Scope: src/Engine/Window/ (4 files), src/Engine/View/ — the OS window + the per-frame render/update protocol that the whole engine hangs off. This is the "front door" of the frame loop.

This is the thinnest layer of the engine, and the single most important thing to understand for getting a frame to render. Everything else (render graph, systems, UI, physics) is driven from the protocol defined here.

Key types & where they live

Type Defined in
Window src/Engine/Window/Window.h (impl Window.cpp)
WindowManager src/Engine/Window/WindowManager.h
View src/Engine/Window/View.h (impl View.cpp)
GameView src/Engine/Window/GameView.h (impl GameView.cpp) — the concrete View that drives the render graph
WindowCreateInfo src/Engine/Window/Window.h (the Window ctor parameter)
Area / URect src/Engine/Containers/ + src/Engine/Math/ (geometry types)
InputAction, KeyCode, MouseButton, KeyModifier src/Engine/Platform/ (input enums, see Platform doc)
Game src/Engine/Game.h — the thing GameView wraps

The render/update protocol — the frame contract

View (src/Engine/Window/View.h:9) defines the per-frame protocol that Window calls in a fixed order. This is the spine of the whole engine; every system's update/prepare/render slot lands on one of these callbacks:

# Callback When What lands here
1 beginUpdate() before update pre-frame setup (e.g. reset accumulators)
2 update() the update tick all System::update calls (in SystemGraph topological order)
3 commitUpdate() after update commit the updated world state (meshlets, transforms) to GPU
4 prepareRender() before render all System::prepare calls (record command buffers, build render graph)
5 render() the render tick all System::render calls (submit passes to the graphics backend)
6 applyArea(URect) on resize resize swapchain / viewport

Input callbacks on the same protocol (fired by the OS window, routed to View and on to GameView → Game/UI):

  • keyCallback(KeyCode, InputAction, uint32_t modifier)
  • mouseMoveCallback(double x, double y), mouseButtonCallback(MouseButton, InputAction, uint32_t, ...)
  • scrollCallback(double, double), fileCallback(int, const char** paths) (drop/open files)

The golden rule (from AGENTS.md, and it holds): a system's update writes CPU-side state; a system's prepare/render (and commitUpdate) is what touches the GPU. The split between phases is what makes the SystemGraph ordering meaningful — do not move GPU work into update.

How a frame actually flows (concrete)

Window::render()                       (Window.cpp)
  └─ for each window:
       view->beginUpdate();  view->update();  view->commitUpdate();
       view->prepareRender(); view->render();
GameView (the View impl)
  └─ update()      → runs SystemGraph (topo order): each System::update(registry, scene)
  └─ commitUpdate()→ MeshUpdater / FluidUpdater commit meshlet & state changes
  └─ prepareRender()→ each System::prepare → RenderGraph records passes
  └─ render()      → RenderGraph::execute → Gfx::Graphics submit (Vulkan/Metal)
  • WindowManager (WindowManager.h) owns Array<PWindow> and a Gfx::PGraphics; addWindow creates a Window (per-OS native surface), render() drives the loop, notifyWindowClosed handles teardown, isActive() is the "should the process keep running" check.
  • GameView is the View that a Game (the demo's MeshShadingDemoGame) produces. It owns the PSystemGraph and the Scene, and is the live consumer of the Game protocol (see the Game interface doc and cross-repo.md).

Gotchas

  • applyArea on resize is the only legal place to resize the swapchain. Do not create new swapchains inside render/prepareRender; route through applyArea so the render graph's ResourceHandles (which encode the old surface) are invalidated consistently. The render graph auto-invalidation (see render-graph-and-passes.md) depends on this.
  • View is a friend of Window (friend class Window; in View.h) — the window reaches into the view's internals directly. Do not assume the View API is the only way state changes.
  • Input callbacks are delivered on the window thread. If you add UI or a system that consumes input, it must be safe to be called from the frame callback path (i.e. during update), not from another thread.
  • Window is per-OS but View/GameView are cross-OS. The OS-specific bits (surface creation, event pump) are isolated in Window/the platform layer; the render protocol above is portable. When you touch a platform bug, you almost always want Window.cpp + the Platform layer, not GameView.

Where to look

What you're doing Start here
Add a new per-frame phase / change frame order src/Engine/Window/View.h (protocol) + Window.cpp (caller)
Wire a Game into the render graph src/Engine/Window/GameView.cpp (the live consumer) + src/Engine/Game.h
Resize / multi-window src/Engine/Window/Window.h applyArea + WindowManager.h
Input (mouse/keys/scroll/files) src/Engine/Window/View.h callbacks → GameView.cpp → Game/UI
"Why does nothing render after my change" confirm you didn't move GPU work into update; check GameView.cpp prepareRender/render