|
Vulkan Schnee 0.0.1
High-performance rendering engine
|
The asset loading system owns asset records, submits asynchronous loading work, and hands renderer-ready data to RenderingDataManager.
Use AssetRegistry handles for stable authored references. Use Asset::Ref when code needs the loaded payload.
| Type | Meaning | Used For |
|---|---|---|
| Asset::Path | Wrapper around std::filesystem::path | Single-file assets: audio clips and direct texture requests |
| Asset::MeshPath | Source file path plus named object | glTF sub-assets: meshes, materials, skins, animations |
| Engine::Assets::AssetHandle<Tag> | Index plus generation handle | AssetRegistry stores for scene and component references |
| Engine::Assets::TextureHandle | Texture registry id plus semantic type | Descriptor lookup for material textures |
Use Asset::MeshPath when the asset is a named object inside a container file.
Use Asset::Path when the asset is the file itself.
Asset::Ref::isLoaded() returns true when the current record generation has a loaded payload. AssetHandle<Tag> values are stable references into registry stores, not loaded payload pointers.
Engine::Core::AssetRegistry stores stable handles for scene and component data. The engine creates it with the central AssetManager, and each Scene exposes it through Scene::getAssetRegistry().
GltfStore::load() reads glTF metadata and creates renderable, geometry mesh, and material handles. Geometry handle creation requests the backing mesh through AssetManager::getAsset<Engine::Assets::Mesh>().
Registry stores reject absolute paths for geometry meshes, materials, glTF files, textures, and audio clips. Use engine-relative authored paths for those handles.
Use Engine::Core::AssetManager::getAsset<T>() when code needs the loaded asset payload.
getAsset<Engine::Assets::Mesh>() returns a ref immediately and requests the backing glTF model when the mesh payload is absent.
getAsset<Engine::Assets::Skin>() and getAsset<Engine::Assets::Animation>() request the backing glTF model when the target record is UNLOADED.
getAsset<Engine::Assets::Material>() creates or returns the material ref. Material payloads are resolved when the model pipeline processes the source glTF.
getAsset<Engine::Assets::Texture>() and getAsset<Engine::Assets::Audio>() accept Asset::Path or std::filesystem::path. The facade converts the key to Asset::Path.
EngineKern::processResourceLoadingPipelines() advances asset work once per frame.
Texture preparation finishes on worker threads. RenderingDataManager::processCompletedTextures() registers finished RuntimeTexture objects and updates TextureHandleRegistry.
Meshlet generation also finishes asynchronously. ModelAssetPipeline::takePendingMeshletCompletions() returns completed meshlet data at render-safe points.
ModelAssetPipeline loads glTF files and resolves sub-assets from them.
| Stage | Work |
|---|---|
| submitLoadModel() | Submit tinygltf parse work to the asset loader pool |
| processModel() | Parse scene extensions, pre-register texture handles, register textures, resolve skins and animations, create material records, and submit primitive loading |
| processSkinData() | Reserved stage; skin loading currently runs inside processModel() |
| processMaterial() | Write MaterialData to material asset entities and notify the renderer |
| processMeshData() | Write mesh primitive metadata, optimize geometry, and schedule meshlet generation |
| processKtx2Textures() | Poll KTX/KTX2 texture load futures and notify the renderer |
Model keeps non-owning pointers to sub-assets created from one source file. The owning managers are MeshAssetManager, MaterialAssetManager, TextureAssetManager, SkinAssetManager, and AnimationAssetManager.
Lightmapped glTF nodes receive material keys named <material>__lightmap__<node>. The metadata import path and the runtime model pipeline use the same naming rule.
Textures have a CPU asset record and a renderer-owned runtime texture.
| Source | Flow |
|---|---|
| glTF PNG/JPG | tinygltf loads image bytes during model load; processTextures() creates GltfTextureAsset records |
| glTF KTX/KTX2 | Ktx2Loader runs on the asset loader pool; RenderingDataManager::onKtx2TextureLoaded() prepares the runtime texture |
| EXR lightmaps | TextureAssetPipeline loads headers, then image data, then calls RenderingDataManager::onTextureLoaded() |
| Direct KTX/KTX2 requests | TextureAssetPipeline runs Ktx2Loader and reports to RenderingDataManager |
RenderingDataManager::onTextureLoaded() moves Ecs::ImageData out of the asset entity and creates a RuntimeTexture on a worker thread. RenderingDataManager::processCompletedTextures() registers the texture in AssetManager and writes its descriptor index to TextureHandleRegistry.
Materials store typed texture handles for descriptor lookup.
TextureHandleRegistry::resolveDescriptorIndex() returns 0xFFFFFFFF until the runtime texture is registered.
Meshes and materials are glTF sub-assets keyed by Asset::MeshPath.
A mesh is loaded when its hidden asset entity has Engine::Ecs::MeshPrimitiveData.
A material is loaded when its hidden asset entity has Engine::Core::MaterialData.
Skins and animations are loaded from glTF by the model pipeline and owned by their managers.
Current skeletal runtime data stores raw pointers to manager-owned payloads.
| ECS Component | Pointer |
|---|---|
| Engine::Ecs::SkeletalMeshData | Engine::Assets::Skin* |
| Engine::Ecs::AnimationState | Engine::Assets::Animation* |
Audio uses generic asset records and refs. Playback remains path-based.
AudioAssetPipeline decodes files on the asset loader pool and resolves Engine::Assets::Audio records. AudioEngine::onAudioLoaded() registers loaded clips by filesystem path, and playback uses AudioEngine::play(path).
AudioClipStore::load() creates an AudioClipHandle and submits the decode request through AssetManager::loadAudioAsset().
Asset::Record owns the current payload, load state, generation, error string, and ready future. Asset::Ref is a non-owning handle to that record.
| State | Meaning |
|---|---|
| UNLOADED | No payload is available |
| REQUESTED_LOAD | A load was requested but no worker owns it yet |
| LOADING | A pipeline is processing the asset |
| LOADED | The payload is ready |
| FAILED | Loading reached a terminal failure |
Asset::Ref::readyFuture() resolves with Asset::LoadResult<Key, AssetClass> when the current generation succeeds or fails. A new generation starts when loading restarts, a payload is replaced, or a payload is unloaded.
AssetManager::discardSceneLoadingData() clears queued and in-flight scene loading work from texture, model, and audio pipelines. It also asks RenderingDataManager to discard pending texture preparations.
AssetManager::unloadAllData() discards pending work, clears renderer scene resource caches, unloads runtime textures, clears texture handles, and clears all asset managers.
| API | Purpose |
|---|---|
| Asset::Path, Asset::MeshPath | Asset keys |
| Asset::Record, Asset::Ref, Asset::AssetManager, Asset::LoadResult | Generic asset record and payload access API |
| Engine::Core::AssetManager | Central asset manager facade |
| Engine::Core::AssetRegistry | Stable handle stores and authored reference resolution |
| GltfStore, GeometryMeshStore, MaterialStore, Texture2DStore, AudioClipStore | Registry stores |
| Engine::Assets::AssetHandle | Stable index/generation handle template |
| TextureAssetPipeline, ModelAssetPipeline, AudioAssetPipeline | Async loading pipelines |
| Model, Mesh, Material, Texture, Audio, Skin, Animation | Asset payload classes |
| TextureHandleRegistry, TextureHandle | Runtime texture handle and descriptor lookup API |
| RenderingDataManager | Runtime texture preparation, GPU upload, and renderer cache invalidation |