forked from Dynamitos/Seele
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.
70 lines
8.3 KiB
Markdown
70 lines
8.3 KiB
Markdown
# Asset Pipeline (AssetManager / Loaders / Storage)
|
|
|
|
> Asset loading, saving, the registry, the storage backends, the editor-side importers, and the asset viewer.
|
|
|
|
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](../../AGENTS.md) (map + rules) and the [cross-repo guide](../cross-repo.md) (engine ↔ demo contract). Everything below is grounded in the checked-out source at commit `d3ed573`.
|
|
|
|
## Key types & where they live
|
|
|
|
| Type | Defined in |
|
|
|------|------------|
|
|
| `AssetManager` | `git grep` in `src/` |
|
|
| `Asset` | `src/Engine/Asset/Asset.h` |
|
|
| `AssetLoader<T>` | `git grep` in `src/` |
|
|
| `AssetLoaderBase` | `git grep` in `src/` |
|
|
| `AssetLoaderManager` | `git grep` in `src/` |
|
|
| `AssetSaveData` | `git grep` in `src/` |
|
|
| `AssetSaveContext` | `git grep` in `src/` |
|
|
| `AssetView` | `git grep` in `src/` |
|
|
| `Asset` | `src/Engine/Asset/Asset.h` |
|
|
| `MeshAsset` | `src/Engine/Asset/MeshAsset.h` |
|
|
| `MaterialAsset` | `src/Engine/Asset/MaterialAsset.h` |
|
|
| `MaterialInstanceAsset` | `src/Engine/Asset/MaterialInstanceAsset.h` |
|
|
| `SkyboxAsset` | `git grep` in `src/` |
|
|
| `FluidGridAsset` | `git grep` in `src/` |
|
|
| `TerrainTileAsset` | `git grep` in `src/` |
|
|
| `WaterTileAsset` | `git grep` in `src/` |
|
|
|
|
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
|
|
|
|
AssetManager (src/Engine/Asset/AssetManager.h + .cpp, 1.7KB header + 10.3KB impl) is the central asset registry. It maps asset names/paths to Asset objects. API: load(name) (checks cache, if missing calls the appropriate AssetLoader<T> to load from disk), get(name) (cached lookup), unload(name) (removes from cache, calls Asset::unload()), reload(name) (forces re-load from disk). AssetLoaderManager (AssetLoaderManager.h + .cpp, 589B + 472B) is a name->loader map: each AssetLoader<T> registers itself by file extension. AssetLoader<T> (AssetLoader.h, 1.1KB) is a template base with load(context, name) -> T and virtual load implementation. AssetLoaderBase (AssetLoaderBase.h + .cpp, 869B + 3.1KB) is the non-template base that handles the common load/unload lifecycle. Asset (Asset.h, 1.2KB) is the abstract base for all loadable assets: has a name, a path, a reference count, and virtual load/unload. Concrete asset types: MeshAsset (Asset/MeshAsset.h + .cpp, 580B + 5.4KB — loads mesh data from disk into a Gfx::Mesh + VertexData), MaterialAsset (791B + 1.2KB), MaterialInstanceAsset (791B + 1KB), SkyboxAsset (SkyboxAsset.h + .cpp, 813B + 2.3KB — loads cubemap textures), FluidGridAsset (1KB + 1.6KB — loads fluid simulation grid data), TerrainTileAsset (819B + 1.5KB), WaterTileAsset (815B + 1.5KB). AssetSaveData (AssetSaveData.h + .cpp, 798B + 3.1KB) and AssetSaveContext (AssetSaveContext.h + .cpp, 825B + 3.1KB) are the SAVE side: AssetSaveData holds the data to be written, AssetSaveContext tracks the save state. AssetView (AssetView.h + .cpp, 1.2KB + 6.5KB) is a read-only view over an asset (for the editor's asset browser). The AssetLoader<T> template pattern: each concrete loader (e.g. MeshAssetLoader) is registered with the AssetLoaderManager at startup (static initializer or explicit registration call). The loader's load() method reads the file from disk (using std::filesystem or a custom file abstraction) and deserializes it into the asset object. The editor (src/Editor/) has its own set of asset loaders (MaterialLoader, etc.) that are registered in the editor context. The AssetViewer (src/AssetViewer/main.cpp, 7KB) is a standalone CLI tool that uses the AssetManager to browse and inspect assets without running the full engine.
|
|
|
|
## Where to look
|
|
|
|
| Path | What's there |
|
|
|------|--------------|
|
|
| `src/Engine/Asset/AssetManager.h + .cpp` | central registry, 10.3KB impl |
|
|
| `src/Engine/Asset/Asset.h` | abstract asset base |
|
|
| `src/Engine/Asset/AssetLoader.h` | template base |
|
|
| `src/Engine/Asset/AssetLoaderBase.h + .cpp` | non-template lifecycle base |
|
|
| `src/Engine/Asset/AssetLoaderManager.h + .cpp` | loader registry |
|
|
| `src/Engine/Asset/AssetSaveData.h + .cpp` | save data |
|
|
| `src/Engine/Asset/AssetSaveContext.h + .cpp` | save context |
|
|
| `src/Engine/Asset/AssetView.h + .cpp` | read-only asset view, 6.5KB impl |
|
|
| `src/Engine/Asset/MeshAsset.h + .cpp` | mesh asset, 5.4KB impl |
|
|
| `src/Engine/Asset/MaterialAsset.h + .cpp` | material asset |
|
|
| `src/Engine/Asset/SkyboxAsset.h + .cpp` | skybox/cubemap asset, 2.3KB impl |
|
|
| `src/Engine/Asset/FluidGridAsset.h + .cpp` | fluid grid asset |
|
|
| `src/Engine/Asset/TerrainTileAsset.h + .cpp` | terrain tile asset |
|
|
| `src/Engine/Asset/WaterTileAsset.h + .cpp` | water tile asset |
|
|
| `src/Editor/Asset/MaterialLoader.h + .cpp` | editor material loader, 9.5KB impl |
|
|
| `src/AssetViewer/main.cpp` | standalone asset browser |
|
|
|
|
## Gotchas & sharp edges
|
|
|
|
- AssetLoader<T> uses a template + registration pattern. Each concrete loader MUST be explicitly registered with the AssetLoaderManager (or via a static initializer). If you add a new asset type but forget to register its loader, AssetManager::load() will fail with 'no loader for extension' at runtime.
|
|
- The asset file format is NOT documented in a schema file. Each asset type has its own serialization code in its .cpp file (e.g. MeshAsset.cpp uses Seele::Serialization to read/write). If you need to author assets by hand, you must reverse-engineer the format from the load code.
|
|
- AssetManager::load() is NOT thread-safe — it uses a single cache map with no locking. All asset loading must happen on the main thread (or be guarded by external synchronization). The editor loads assets on the main thread; the game DLL should do the same.
|
|
- AssetView (6.5KB impl) is the editor's read-only interface over assets. It is used by the AssetViewer tool and the editor's asset browser. It does NOT mutate the asset — all modifications go through the asset's own API (or the editor's specific loader).
|
|
- The AssetSaveData/AssetSaveContext pair is the save path. AssetSaveContext tracks the save state (which assets are dirty, which are being saved). The actual file writing is done by each asset's save() method (called through the save context). If an asset's save() throws, the context marks the save as failed and rolls back (check AssetSaveContext.cpp for the rollback logic).
|
|
- MeshAsset loading (5.4KB impl) reads mesh data from disk and constructs a Gfx::Mesh + VertexData. The VertexData then self-registers into the global VertexData::getList(). If you load a MeshAsset multiple times, you get MULTIPLE VertexData registrations (each load creates a new VertexData). The AssetManager cache prevents re-loading the same asset, but if you unload and reload, the old VertexData remains in the global list (check VertexData.cpp for whether it unregisters on destruction).
|
|
- The AssetViewer (main.cpp, 7KB) is a standalone executable that links against the engine's AssetManager. It does NOT require a window or GPU — it can run headless. It is useful for validating asset files without running the full engine.
|
|
- The editor's MaterialLoader (9.5KB impl) is a CUSTOM loader that does NOT go through the standard AssetLoader<T> template — it has its own loading logic. This is because material assets have a complex node graph (ShaderExpression) that requires special deserialization. If you modify the material asset format, you must update BOTH the engine's MaterialAsset.cpp AND the editor's MaterialLoader.cpp.
|
|
- Asset files are stored on disk in a project-specific directory (configured by the game's GameInterface or the editor's project settings). The AssetManager does NOT hardcode a path — the base path is provided at initialization. If the path is wrong, all loads will fail silently (return nullptr or throw).
|
|
- There is no asset hot-reload in the engine. To reload an asset, you must call AssetManager::unload() + AssetManager::load(). The editor may have a file-watcher that triggers this automatically (check the editor's source), but the engine itself has no file-watching capability.
|
|
|
|
---
|
|
|
|
*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.* |