|
Vulkan Schnee 0.0.1 (22840dc8)
High-performance rendering engine
|
Coordinates engine asset loading pipelines and runtime texture descriptor ownership. More...
#include <AssetManager.h>
Public Types | |
| using | AudioAssetRef = Assets::AudioAssetRef |
| Legacy asset reference type for audio assets. | |
| using | AnimationAssetRef = Assets::AnimationAssetRef |
| Legacy asset reference type for animation assets. | |
| using | MaterialAssetRef = Assets::MaterialAssetRef |
| Legacy asset reference type for material assets. | |
| using | MeshAssetRef = Assets::MeshAssetRef |
| Legacy asset reference type for mesh assets. | |
| using | SkinAssetRef = Assets::SkinAssetRef |
| Legacy asset reference type for skin assets. | |
| using | TextureAssetRef = Assets::TextureAssetRef |
| Legacy asset reference type for texture assets. | |
Public Member Functions | |
| template<typename AssetClass, typename Key> | |
| auto | getAsset (const Key &asset) |
| Gets or creates an asset reference and requests loading when needed. | |
| AssetManager () | |
| Creates an asset manager without an application context. | |
| AssetManager (ApplicationContext *context) | |
| Creates an asset manager bound to an application context. | |
| ~AssetManager () | |
| Destroys owned asset managers and worker pools. | |
| void | attachToRenderer (Rendering::Renderer *renderer) |
| Attaches the renderer used for texture uploads and descriptor reservation notifications. | |
| void | setRenderingDataManager (RenderingDataManager *renderingDataManager) |
| Sets the rendering data manager used by asset pipelines. | |
| Assets::CubemapTexture * | loadEcsCubemap (const std::filesystem::path &path) |
| Loads a six-face cubemap asset from a directory. | |
| uint32_t | getTextureDescriptorIndex (const std::filesystem::path &path) |
| Gets the descriptor index of a resident texture by path. | |
| uint32_t | getTextureDescriptorIndex (const std::filesystem::path &path, Assets::TextureType type) |
| Gets the descriptor index of a resident texture by path and semantic type. | |
| Assets::TextureHandle | getOrCreateTextureHandleWithSlot (const std::filesystem::path &path, Assets::TextureType type) |
| Gets or creates a texture handle and reserves a stable descriptor slot for it. | |
| template<Assets::TextureType Type> | |
| Assets::TypedTextureHandle< Type > | getOrCreateTextureHandleWithSlot (const std::filesystem::path &path) |
| Gets or creates a typed texture handle and reserves a stable descriptor slot for it. | |
| uint32_t | getImageCount () const |
| Gets the number of registered runtime texture identities. | |
| void | cleanup () |
| Waits for asset jobs and releases loaded runtime texture resources. | |
| std::vector< VkDescriptorImageInfo > | getTextureDescriptorInfos () const |
| Builds descriptor image info records for resident textures. | |
| Ecs::AssetImportPipeline & | getAssetImportPipeline () |
| Gets the master asset import pipeline. | |
| Ecs::TextureAssetPipeline & | getTextureAssetPipeline () |
| Gets the texture loading pipeline. | |
| Ecs::ModelAssetPipeline & | getMeshAssetPipeline () |
| Gets the glTF model loading pipeline. | |
| Ecs::AudioAssetPipeline & | getAudioAssetPipeline () |
| Gets the audio loading pipeline. | |
| void | unloadAllData () |
| Discards pending work and clears loaded asset manager state. | |
| void | discardSceneLoadingData () |
| Drops queued or in-flight scene asset loading work. | |
| AudioAssetRef | loadAudioAsset (const Asset::Path &path) |
| Submits an audio file for async loading through the audio pipeline. | |
| Assets::Audio * | getAudioAsset (const Asset::Path &path) |
| Gets a loaded audio asset by path. | |
| Assets::AudioAssetManager * | getAudioAssetManager () const |
| Gets the audio asset manager for direct access. | |
| Assets::MaterialAssetManager * | getMaterialAssetManager () const |
| Gets the material asset manager for material lookups. | |
| Assets::ModelAssetManager * | getModelAssetManager () const |
| Gets the model asset manager for model and glTF loading state lookups. | |
| Assets::MeshAssetManager * | getMeshAssetManager () const |
| Gets the mesh asset manager for mesh asset lookups. | |
| Assets::SkinAssetManager * | getSkinAssetManager () const |
| Gets the skin asset manager for direct access. | |
| Assets::AnimationAssetManager * | getAnimationAssetManager () const |
| Gets the animation asset manager for direct access. | |
| Assets::Textures::TextureHandleRegistry * | getTextureHandleRegistry () |
| Gets the texture handle registry for O(1) descriptor index lookups. | |
| Assets::RuntimeTextureDescriptorLease | reserveRuntimeTextureDescriptor () |
| Reserves a stable descriptor index for a runtime-generated sampled image. | |
| NamedThreadPool * | getCalculationPool () const |
| Gets the worker pool used for asset-side CPU calculations. | |
| NamedThreadPool * | getAssetLoaderPool () const |
| Gets the worker pool used for asynchronous asset loading. | |
Private Member Functions | |
| void | loadEcsModel (const std::filesystem::path &path) |
| Submits a glTF model file for asynchronous loading. | |
| void | loadEcsTexture (const std::filesystem::path &path) |
| Submits a texture file for asynchronous loading. | |
| Assets::Mesh * | getMeshAsset (const Asset::MeshPath &asset) |
| Gets a mesh asset by path or requests its model if it is not loaded. | |
| void | releaseRuntimeTextureDescriptorIndex (uint32_t descriptorIndex) |
| bool | doesTextureAlreadyExist (const std::filesystem::path &path) |
| Checks whether a texture path has a loaded identity entry. | |
| Assets::RuntimeTexture * | registerTexture (const std::filesystem::path &path, Assets::RuntimeTexture texture) |
| Creates Vulkan resources for a texture and registers it as file-backed texture data. | |
| Assets::RuntimeTexture * | registerTexture (const std::filesystem::path &path, Assets::TextureType type, Assets::RuntimeTexture texture) |
| Creates Vulkan resources for a typed texture and registers it as file-backed texture data. | |
| Assets::RuntimeTexture * | registerTextureFromPrepared (const std::filesystem::path &path, Assets::RuntimeTexture texture) |
| Registers a texture whose Vulkan resources are already created. | |
| Assets::RuntimeTexture * | registerTextureFromPrepared (const std::filesystem::path &path, Assets::TextureType type, Assets::RuntimeTexture texture) |
| Registers a typed texture whose Vulkan resources are already created. | |
| Assets::RuntimeTexture * | replaceTextureFromPrepared (const std::filesystem::path &path, Assets::RuntimeTexture texture) |
| Replaces an already registered texture while preserving its descriptor index. | |
| Assets::RuntimeTexture * | replaceTextureFromPrepared (const std::filesystem::path &path, Assets::TextureType type, Assets::RuntimeTexture texture) |
| Replaces an already registered typed texture while preserving its descriptor index. | |
| void | unregisterTexture (Assets::RuntimeTexture *texture) |
| Unregisters a runtime texture and clears its descriptor slot. | |
| void | unloadRuntimeTextures () |
| Releases all runtime texture data and descriptor reservations owned by this manager. | |
| void | ensureFallbackTextureLocked () |
| Creates the built-in fallback texture when it does not already exist. | |
Coordinates engine asset loading pipelines and runtime texture descriptor ownership.
AssetManager owns the high-level mesh, material, texture, skin, animation, and audio managers used by the renderer and scene loading code. It submits asynchronous load work, exposes stable asset refs, and keeps descriptor indices for loaded or runtime-generated textures.
Definition at line 193 of file AssetManager.h.
Legacy asset reference type for animation assets.
Definition at line 204 of file AssetManager.h.
Legacy asset reference type for audio assets.
Definition at line 202 of file AssetManager.h.
Legacy asset reference type for material assets.
Definition at line 206 of file AssetManager.h.
Legacy asset reference type for mesh assets.
Definition at line 208 of file AssetManager.h.
Legacy asset reference type for skin assets.
Definition at line 210 of file AssetManager.h.
Legacy asset reference type for texture assets.
Definition at line 212 of file AssetManager.h.
| Engine::Core::AssetManager::AssetManager | ( | ) |
Creates an asset manager without an application context.
Texture resource creation APIs that need Vulkan context data require a context-backed manager.
| Engine::Core::AssetManager::AssetManager | ( | ApplicationContext * | context | ) |
Creates an asset manager bound to an application context.
| context | Application context used for Vulkan resource creation. |
References ApplicationContext, and context.
| Engine::Core::AssetManager::~AssetManager | ( | ) |
Destroys owned asset managers and worker pools.
Call AssetManager::cleanup() before destruction when Vulkan texture resources are still resident.
| void Engine::Core::AssetManager::attachToRenderer | ( | Rendering::Renderer * | renderer | ) |
Attaches the renderer used for texture uploads and descriptor reservation notifications.
Existing file-backed and runtime descriptor reservations are registered with the renderer's RenderingDataManager when available.
| renderer | Renderer used by asset upload paths. Passing nullptr detaches renderer access. |
References renderer.
| void Engine::Core::AssetManager::cleanup | ( | ) |
Waits for asset jobs and releases loaded runtime texture resources.
This clears texture, cubemap, and descriptor-index maps owned by the manager.
| void Engine::Core::AssetManager::discardSceneLoadingData | ( | ) |
Drops queued or in-flight scene asset loading work.
Pending texture preparations are discarded when a renderer and rendering data manager are attached.
|
private |
Checks whether a texture path has a loaded identity entry.
| path | Texture path to check. |
path.
|
private |
Creates the built-in fallback texture when it does not already exist.
The caller must hold AssetManager::textureMutex.
|
inlinenodiscard |
Gets the animation asset manager for direct access.
Definition at line 566 of file AssetManager.h.
References animationAssetManager_.
|
inlinenodiscard |
Gets or creates an asset reference and requests loading when needed.
Supported asset classes and keys:
Mesh, animation, and skin requests can submit the owning glTF model for async loading. Texture and audio requests submit the referenced file when it is not already requested, loading, or loaded. Material requests return a ref only; material payloads are populated by model loading.
| AssetClass | Asset class to request. |
| Key | Key type accepted by the selected asset class. |
| asset | Asset key. |
Definition at line 235 of file AssetManager.h.
References animationAssetManager_, Asset::Path::getFilePath(), getMeshAsset(), loadAudioAsset(), loadEcsModel(), loadEcsTexture(), Asset::LOADED, Asset::LOADING, materialAssetManager, meshAssetManager, Asset::REQUESTED_LOAD, skinAssetManager_, textureAssetManager, and Asset::UNLOADED.
| Ecs::AssetImportPipeline & Engine::Core::AssetManager::getAssetImportPipeline | ( | ) |
Gets the master asset import pipeline.
|
inline |
Gets the worker pool used for asynchronous asset loading.
Definition at line 628 of file AssetManager.h.
References threadPool_.
|
nodiscard |
Gets a loaded audio asset by path.
| path | Audio asset path. |
|
inlinenodiscard |
Gets the audio asset manager for direct access.
Definition at line 512 of file AssetManager.h.
References audioAssetManager_.
| Ecs::AudioAssetPipeline & Engine::Core::AssetManager::getAudioAssetPipeline | ( | ) |
Gets the audio loading pipeline.
|
inline |
Gets the worker pool used for asset-side CPU calculations.
Definition at line 619 of file AssetManager.h.
References threadedCalculation_.
| uint32_t Engine::Core::AssetManager::getImageCount | ( | ) | const |
Gets the number of registered runtime texture identities.
|
inlinenodiscard |
Gets the material asset manager for material lookups.
Definition at line 530 of file AssetManager.h.
References materialAssetManager.
|
nodiscardprivate |
Gets a mesh asset by path or requests its model if it is not loaded.
| asset | Mesh asset path. |
Referenced by getAsset().
|
inlinenodiscard |
Gets the mesh asset manager for mesh asset lookups.
Definition at line 548 of file AssetManager.h.
References meshAssetManager.
| Ecs::ModelAssetPipeline & Engine::Core::AssetManager::getMeshAssetPipeline | ( | ) |
Gets the glTF model loading pipeline.
|
inlinenodiscard |
Gets the model asset manager for model and glTF loading state lookups.
Definition at line 539 of file AssetManager.h.
References modelAssetManager.
|
inlinenodiscard |
Gets or creates a typed texture handle and reserves a stable descriptor slot for it.
| Type | Semantic texture type encoded in the returned handle. |
| path | Texture path. |
Definition at line 429 of file AssetManager.h.
References getOrCreateTextureHandleWithSlot().
|
nodiscard |
Gets or creates a texture handle and reserves a stable descriptor slot for it.
The returned handle can resolve to a descriptor slot before the image is resident. A fallback texture is created when needed so reserved file-backed descriptors have a valid sampled image.
| path | Texture path. |
| type | Semantic texture type. |
Referenced by getOrCreateTextureHandleWithSlot().
|
inlinenodiscard |
Gets the skin asset manager for direct access.
Definition at line 557 of file AssetManager.h.
References skinAssetManager_.
| Ecs::TextureAssetPipeline & Engine::Core::AssetManager::getTextureAssetPipeline | ( | ) |
Gets the texture loading pipeline.
|
nodiscard |
Gets the descriptor index of a resident texture by path.
This overload is ambiguous when the same path is loaded for multiple texture types. Use the typed overload for material textures that can map to multiple formats.
| path | Texture path. |
|
nodiscard |
Gets the descriptor index of a resident texture by path and semantic type.
| path | Texture path. |
| type | Semantic texture type used for identity lookup. |
| std::vector< VkDescriptorImageInfo > Engine::Core::AssetManager::getTextureDescriptorInfos | ( | ) | const |
Builds descriptor image info records for resident textures.
|
inlinenodiscard |
Gets the texture handle registry for O(1) descriptor index lookups.
Definition at line 575 of file AssetManager.h.
References textureHandleRegistry_.
| AudioAssetRef Engine::Core::AssetManager::loadAudioAsset | ( | const Asset::Path & | path | ) |
Submits an audio file for async loading through the audio pipeline.
| path | Audio asset path. |
Referenced by getAsset().
| Assets::CubemapTexture * Engine::Core::AssetManager::loadEcsCubemap | ( | const std::filesystem::path & | path | ) |
Loads a six-face cubemap asset from a directory.
Cubemaps are cached by normalized path. Loading requires the asset manager to be attached to a renderer.
| path | Directory containing the cubemap faces. |
|
private |
Submits a glTF model file for asynchronous loading.
| path | glTF file path. |
Referenced by getAsset().
|
private |
Submits a texture file for asynchronous loading.
| path | Texture file path. |
Referenced by getAsset().
|
private |
Creates Vulkan resources for a texture and registers it as file-backed texture data.
| path | Texture path. |
| texture | Runtime texture to register. |
|
private |
Creates Vulkan resources for a typed texture and registers it as file-backed texture data.
| path | Texture path. |
| type | Semantic texture type used for identity lookup. |
| texture | Runtime texture to register. |
|
private |
Registers a texture whose Vulkan resources are already created.
This skips RuntimeTexture resource creation, assigns a descriptor index, and queues the texture for upload. The async texture preparation pipeline uses this path.
| path | Texture path. |
| texture | Prepared texture with image, image view, and sampler resources. |
|
private |
Registers a typed texture whose Vulkan resources are already created.
| path | Texture path. |
| type | Semantic texture type used for identity lookup. |
| texture | Prepared texture with image, image view, and sampler resources. |
|
private |
|
private |
Replaces an already registered texture while preserving its descriptor index.
| path | Texture path. |
| texture | Prepared replacement texture. |
|
private |
Replaces an already registered typed texture while preserving its descriptor index.
| path | Texture path. |
| type | Semantic texture type used for identity lookup. |
| texture | Prepared replacement texture. |
|
nodiscard |
Reserves a stable descriptor index for a runtime-generated sampled image.
The descriptor is tracked as runtime-owned and registered with the RenderingDataManager when attached. The caller owns descriptor writes for the image and must release the index when the image is destroyed.
| void Engine::Core::AssetManager::setRenderingDataManager | ( | RenderingDataManager * | renderingDataManager | ) |
Sets the rendering data manager used by asset pipelines.
The texture and model pipelines use this pointer to notify render data about prepared textures and loaded model resources.
| renderingDataManager | Rendering data manager used by pipeline hooks. |
References RenderingDataManager.
| void Engine::Core::AssetManager::unloadAllData | ( | ) |
Discards pending work and clears loaded asset manager state.
Runtime textures, cubemaps, texture handles, material refs, mesh refs, model refs, skin refs, animation refs, texture refs, and audio refs are cleared.
|
private |
Releases all runtime texture data and descriptor reservations owned by this manager.
|
private |
Unregisters a runtime texture and clears its descriptor slot.
| texture | Texture pointer returned by a registration function. |
|
private |
Definition at line 603 of file AssetManager.h.
Referenced by getAnimationAssetManager(), and getAsset().
|
private |
Definition at line 195 of file AssetManager.h.
Referenced by AssetManager().
|
private |
Definition at line 612 of file AssetManager.h.
|
private |
Definition at line 611 of file AssetManager.h.
Referenced by getAudioAssetManager().
|
private |
Definition at line 636 of file AssetManager.h.
Referenced by AssetManager().
|
private |
Definition at line 646 of file AssetManager.h.
|
private |
Definition at line 653 of file AssetManager.h.
|
private |
Definition at line 652 of file AssetManager.h.
|
private |
Definition at line 634 of file AssetManager.h.
|
private |
Definition at line 600 of file AssetManager.h.
Referenced by getAsset(), and getMaterialAssetManager().
|
private |
Definition at line 599 of file AssetManager.h.
Referenced by getAsset(), and getMeshAssetManager().
|
private |
Definition at line 601 of file AssetManager.h.
Referenced by getModelAssetManager().
|
private |
Definition at line 637 of file AssetManager.h.
Referenced by attachToRenderer().
|
private |
Definition at line 196 of file AssetManager.h.
Referenced by setRenderingDataManager().
|
private |
Definition at line 651 of file AssetManager.h.
|
private |
Definition at line 602 of file AssetManager.h.
Referenced by getAsset(), and getSkinAssetManager().
|
private |
Definition at line 650 of file AssetManager.h.
|
private |
Definition at line 598 of file AssetManager.h.
Referenced by getAsset().
|
private |
Definition at line 649 of file AssetManager.h.
|
private |
Registry for type-safe texture handles.
Definition at line 609 of file AssetManager.h.
Referenced by getTextureHandleRegistry().
|
private |
Definition at line 644 of file AssetManager.h.
|
private |
Definition at line 647 of file AssetManager.h.
|
private |
Definition at line 755 of file AssetManager.h.
|
private |
Definition at line 643 of file AssetManager.h.
|
private |
Definition at line 758 of file AssetManager.h.
|
private |
Definition at line 757 of file AssetManager.h.
|
private |
Definition at line 596 of file AssetManager.h.
Referenced by getCalculationPool().
|
private |
Definition at line 595 of file AssetManager.h.
Referenced by getAssetLoaderPool().