Vulkan Schnee 0.0.1
High-performance rendering engine
Loading...
Searching...
No Matches
Engine::Core::AssetManager Class Reference

#include <AssetManager.h>

Collaboration diagram for Engine::Core::AssetManager:

Public Types

using AudioAssetRef = Assets::AudioAssetRef
using AnimationAssetRef = Assets::AnimationAssetRef
using MaterialAssetRef = Assets::MaterialAssetRef
using MeshAssetRef = Assets::MeshAssetRef
using SkinAssetRef = Assets::SkinAssetRef
using TextureAssetRef = Assets::TextureAssetRef

Public Member Functions

template<typename AssetClass, typename Key>
auto getAsset (const Key &asset)
 AssetManager ()
 AssetManager (ApplicationContext *context)
 ~AssetManager ()
void attachToRenderer (Rendering::Renderer *renderer)
 Sets what renderer the render process belongs to.
void setRenderingDataManager (RenderingDataManager *renderingDataManager)
 Sets the RenderingDataManager on asset pipelines for hook notifications.
Assets::CubemapTextureloadEcsCubemap (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 loaded texture by path.
uint32_t getImageCount () const
void cleanup ()
std::vector< VkDescriptorImageInfo > getTextureDescriptorInfos () const
Ecs::TextureAssetPipelinegetTextureAssetPipeline ()
Ecs::ModelAssetPipelinegetMeshAssetPipeline ()
Ecs::AudioAssetPipelinegetAudioAssetPipeline ()
void unloadAllData ()
void discardSceneLoadingData ()
 Drops any queued or in-flight scene asset loading work.
AudioAssetRef loadAudioAsset (const Asset::Path &path)
 Submit an audio file for async loading through the pipeline.
Assets::AudiogetAudioAsset (const Asset::Path &path)
 Get a loaded audio asset by path.
Assets::AudioAssetManagergetAudioAssetManager () const
 Gets the audio asset manager for direct access.
Assets::MaterialAssetManagergetMaterialAssetManager () const
 Gets the material asset manager for material lookups.
Assets::ModelAssetManager * getModelAssetManager () const
 Gets the model asset manager for model/GLTF file loading state lookups.
Assets::MeshAssetManagergetMeshAssetManager () const
 Gets the mesh asset manager for mesh asset lookups.
Assets::SkinAssetManagergetSkinAssetManager () const
Assets::AnimationAssetManagergetAnimationAssetManager () const
Assets::Textures::TextureHandleRegistrygetTextureHandleRegistry ()
 Gets the texture handle registry for O(1) descriptor index lookups.
uint32_t reserveRuntimeTextureDescriptorIndex ()
void releaseRuntimeTextureDescriptorIndex (uint32_t descriptorIndex)
NamedThreadPoolgetCalculationPool () const
NamedThreadPoolgetAssetLoaderPool () const

Private Member Functions

void loadEcsModel (const std::filesystem::path &path)
 Submits a gltf model for loading. You provide the path of the model to load. This can include 3D data, materials and textures.
void loadEcsTexture (const std::filesystem::path &path)
 Loads a texture (.png / .jpg / .exr)
Assets::MeshgetMeshAsset (const Asset::MeshPath &asset)
 Get a mesh asset by path. If not loaded, requests its model and returns nullptr.
bool doesTextureAlreadyExist (const std::filesystem::path &path)
 Checks if a texture has already been loaded.
Assets::RuntimeTextureregisterTexture (const std::filesystem::path &path, Assets::RuntimeTexture texture)
 Registers a texture with the texture manager which prevents the same texture from being loaded twice.
Assets::RuntimeTextureregisterTextureFromPrepared (const std::filesystem::path &path, Assets::RuntimeTexture texture)
 Register a texture whose Vulkan resources are already created. Skips createResources() — only allocates a descriptor index and queues for GPU upload. Used by the async texture preparation pipeline.
Assets::RuntimeTexturereplaceTextureFromPrepared (const std::filesystem::path &path, Assets::RuntimeTexture texture)
 Replace an already registered texture while preserving its descriptor index.
void unregisterTexture (Assets::RuntimeTexture *texture)
void unloadRuntimeTextures ()

Private Attributes

friend ApplicationContext
friend RenderingDataManager
NamedThreadPoolthreadPool_ = new NamedThreadPool( 2, "Asset Loader" )
NamedThreadPoolthreadedCalculation_ = new NamedThreadPool( 2, "Bounding Sphere" )
Assets::TextureAssetManagertextureAssetManager
Ecs::TextureAssetPipeline texturePipeline
Assets::MeshAssetManagermeshAssetManager
Assets::MaterialAssetManagermaterialAssetManager
Assets::ModelAssetManager * modelAssetManager
Assets::SkinAssetManagerskinAssetManager_
Assets::AnimationAssetManageranimationAssetManager_
Assets::Textures::TextureHandleRegistry textureHandleRegistry_
 Registry for type-safe texture handles.
Ecs::ModelAssetPipeline modelAssetPipeline
Assets::AudioAssetManageraudioAssetManager_
Ecs::AudioAssetPipeline audioAssetPipeline_
Assets::Loaders::GltfLoader gltfLoader = Assets::Loaders::GltfLoader( threadPool_ )
ApplicationContextcontext = nullptr
Rendering::Rendererrenderer = nullptr
std::unordered_map< std::filesystem::path, Assets::RuntimeTexture *, PathHashertextures = {}
std::unordered_map< std::filesystem::path, std::unique_ptr< Assets::CubemapTexture >, PathHashercubemapTextures = {}
BidirectionalMap< uint32_t, Assets::RuntimeTexture * > textureIndexMap
std::array< std::optional< Assets::RuntimeTexture >, MAX_TEXTURE_COUNTtextureData
DescriptorIndexAllocator textureAllocator
std::unordered_set< uint32_t > runtimeTextureDescriptorIndices_
std::mutex textureMutex
std::vector< TextureStoragetexturesToUpload {}
std::vector< Assets::RuntimeTexture * > texturesToCopyImageData

Detailed Description

Definition at line 153 of file AssetManager.h.

Member Typedef Documentation

◆ AnimationAssetRef

◆ AudioAssetRef

◆ MaterialAssetRef

◆ MeshAssetRef

◆ SkinAssetRef

◆ TextureAssetRef

Constructor & Destructor Documentation

◆ AssetManager() [1/2]

Engine::Core::AssetManager::AssetManager ( )

◆ AssetManager() [2/2]

Engine::Core::AssetManager::AssetManager ( ApplicationContext * context)

References ApplicationContext, and context.

◆ ~AssetManager()

Engine::Core::AssetManager::~AssetManager ( )

Member Function Documentation

◆ attachToRenderer()

void Engine::Core::AssetManager::attachToRenderer ( Rendering::Renderer * renderer)

Sets what renderer the render process belongs to.

Parameters
rendererWhere the render process belongs to

References renderer.

◆ cleanup()

void Engine::Core::AssetManager::cleanup ( )

◆ discardSceneLoadingData()

void Engine::Core::AssetManager::discardSceneLoadingData ( )

Drops any queued or in-flight scene asset loading work.

◆ doesTextureAlreadyExist()

bool Engine::Core::AssetManager::doesTextureAlreadyExist ( const std::filesystem::path & path)
private

Checks if a texture has already been loaded.

Parameters
paththe path of the texture on disk
Returns
if the texture has been found in the loaded data

◆ getAnimationAssetManager()

Assets::AnimationAssetManager * Engine::Core::AssetManager::getAnimationAssetManager ( ) const
inlinenodiscard

Definition at line 379 of file AssetManager.h.

References animationAssetManager_.

◆ getAsset()

template<typename AssetClass, typename Key>
auto Engine::Core::AssetManager::getAsset ( const Key & asset)
inlinenodiscard

Definition at line 168 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.

Here is the call graph for this function:

◆ getAssetLoaderPool()

NamedThreadPool * Engine::Core::AssetManager::getAssetLoaderPool ( ) const
inline

Definition at line 433 of file AssetManager.h.

References threadPool_.

◆ getAudioAsset()

Assets::Audio * Engine::Core::AssetManager::getAudioAsset ( const Asset::Path & path)
nodiscard

Get a loaded audio asset by path.

Parameters
pathThe path used when loading
Returns
Pointer to the audio asset, or nullptr if not loaded

◆ getAudioAssetManager()

Assets::AudioAssetManager * Engine::Core::AssetManager::getAudioAssetManager ( ) const
inlinenodiscard

Gets the audio asset manager for direct access.

Returns
Pointer to the AudioAssetManager

Definition at line 333 of file AssetManager.h.

References audioAssetManager_.

◆ getAudioAssetPipeline()

Ecs::AudioAssetPipeline & Engine::Core::AssetManager::getAudioAssetPipeline ( )

◆ getCalculationPool()

NamedThreadPool * Engine::Core::AssetManager::getCalculationPool ( ) const
inline

Definition at line 428 of file AssetManager.h.

References threadedCalculation_.

◆ getImageCount()

uint32_t Engine::Core::AssetManager::getImageCount ( ) const

◆ getMaterialAssetManager()

Assets::MaterialAssetManager * Engine::Core::AssetManager::getMaterialAssetManager ( ) const
inlinenodiscard

Gets the material asset manager for material lookups.

Returns
Pointer to the material asset manager

Definition at line 351 of file AssetManager.h.

References materialAssetManager.

◆ getMeshAsset()

Assets::Mesh * Engine::Core::AssetManager::getMeshAsset ( const Asset::MeshPath & asset)
nodiscardprivate

Get a mesh asset by path. If not loaded, requests its model and returns nullptr.

Parameters
assetPath to the mesh asset
Returns
Pointer to the mesh asset, or nullptr if not loaded

Referenced by getAsset().

Here is the caller graph for this function:

◆ getMeshAssetManager()

Assets::MeshAssetManager * Engine::Core::AssetManager::getMeshAssetManager ( ) const
inlinenodiscard

Gets the mesh asset manager for mesh asset lookups.

Returns
Pointer to the mesh asset manager

Definition at line 369 of file AssetManager.h.

References meshAssetManager.

◆ getMeshAssetPipeline()

Ecs::ModelAssetPipeline & Engine::Core::AssetManager::getMeshAssetPipeline ( )

◆ getModelAssetManager()

Assets::ModelAssetManager * Engine::Core::AssetManager::getModelAssetManager ( ) const
inlinenodiscard

Gets the model asset manager for model/GLTF file loading state lookups.

Returns
Pointer to the model asset manager

Definition at line 360 of file AssetManager.h.

References modelAssetManager.

◆ getSkinAssetManager()

Assets::SkinAssetManager * Engine::Core::AssetManager::getSkinAssetManager ( ) const
inlinenodiscard

Definition at line 374 of file AssetManager.h.

References skinAssetManager_.

◆ getTextureAssetPipeline()

Ecs::TextureAssetPipeline & Engine::Core::AssetManager::getTextureAssetPipeline ( )

◆ getTextureDescriptorIndex()

uint32_t Engine::Core::AssetManager::getTextureDescriptorIndex ( const std::filesystem::path & path)
nodiscard

Gets the descriptor index of a loaded texture by path.

Parameters
pathPath to the texture (relative or absolute)
Returns
Descriptor index if texture is loaded, 0xFFFFFFFF otherwise

◆ getTextureDescriptorInfos()

std::vector< VkDescriptorImageInfo > Engine::Core::AssetManager::getTextureDescriptorInfos ( ) const

◆ getTextureHandleRegistry()

Assets::Textures::TextureHandleRegistry * Engine::Core::AssetManager::getTextureHandleRegistry ( )
inlinenodiscard

Gets the texture handle registry for O(1) descriptor index lookups.

Returns
Pointer to the texture handle registry

Definition at line 388 of file AssetManager.h.

References textureHandleRegistry_.

◆ loadAudioAsset()

AudioAssetRef Engine::Core::AssetManager::loadAudioAsset ( const Asset::Path & path)

Submit an audio file for async loading through the pipeline.

Parameters
pathRelative path to the audio file (WAV, FLAC, MP3)

Referenced by getAsset().

Here is the caller graph for this function:

◆ loadEcsCubemap()

Assets::CubemapTexture * Engine::Core::AssetManager::loadEcsCubemap ( const std::filesystem::path & path)

Loads a six-face cubemap asset from a directory.

◆ loadEcsModel()

void Engine::Core::AssetManager::loadEcsModel ( const std::filesystem::path & path)
private

Submits a gltf model for loading. You provide the path of the model to load. This can include 3D data, materials and textures.

Parameters
pathWhere the gltf file is

Referenced by getAsset().

Here is the caller graph for this function:

◆ loadEcsTexture()

void Engine::Core::AssetManager::loadEcsTexture ( const std::filesystem::path & path)
private

Loads a texture (.png / .jpg / .exr)

Parameters
pathwhere the texture is

Referenced by getAsset().

Here is the caller graph for this function:

◆ registerTexture()

Assets::RuntimeTexture * Engine::Core::AssetManager::registerTexture ( const std::filesystem::path & path,
Assets::RuntimeTexture texture )
private

Registers a texture with the texture manager which prevents the same texture from being loaded twice.

Parameters
pathpath to the texture
texturethe texture to register
Returns
pointer to a usable texture object

◆ registerTextureFromPrepared()

Assets::RuntimeTexture * Engine::Core::AssetManager::registerTextureFromPrepared ( const std::filesystem::path & path,
Assets::RuntimeTexture texture )
private

Register a texture whose Vulkan resources are already created. Skips createResources() — only allocates a descriptor index and queues for GPU upload. Used by the async texture preparation pipeline.

Parameters
pathPath to the texture (used as key)
textureTexture with VkImage/VkImageView/VkSampler already created
Returns
Pointer to the registered texture, or existing texture if already registered

◆ releaseRuntimeTextureDescriptorIndex()

void Engine::Core::AssetManager::releaseRuntimeTextureDescriptorIndex ( uint32_t descriptorIndex)

Release a descriptor index previously reserved with reserveRuntimeTextureDescriptorIndex().

◆ replaceTextureFromPrepared()

Assets::RuntimeTexture * Engine::Core::AssetManager::replaceTextureFromPrepared ( const std::filesystem::path & path,
Assets::RuntimeTexture texture )
private

Replace an already registered texture while preserving its descriptor index.

◆ reserveRuntimeTextureDescriptorIndex()

uint32_t Engine::Core::AssetManager::reserveRuntimeTextureDescriptorIndex ( )
nodiscard

Reserve a stable texture-array descriptor index for a runtime-generated sampled image. The caller owns descriptor writes and must release the index when the runtime image is destroyed.

◆ setRenderingDataManager()

void Engine::Core::AssetManager::setRenderingDataManager ( RenderingDataManager * renderingDataManager)

Sets the RenderingDataManager on asset pipelines for hook notifications.

Parameters
renderingDataManagerPointer to the RenderingDataManager

References RenderingDataManager.

◆ unloadAllData()

void Engine::Core::AssetManager::unloadAllData ( )

◆ unloadRuntimeTextures()

void Engine::Core::AssetManager::unloadRuntimeTextures ( )
private

◆ unregisterTexture()

void Engine::Core::AssetManager::unregisterTexture ( Assets::RuntimeTexture * texture)
private

Member Data Documentation

◆ animationAssetManager_

Assets::AnimationAssetManager* Engine::Core::AssetManager::animationAssetManager_
private

Definition at line 414 of file AssetManager.h.

Referenced by getAnimationAssetManager(), and getAsset().

◆ ApplicationContext

friend Engine::Core::AssetManager::ApplicationContext
private

Definition at line 155 of file AssetManager.h.

Referenced by AssetManager().

◆ audioAssetManager_

Assets::AudioAssetManager* Engine::Core::AssetManager::audioAssetManager_
private

Definition at line 424 of file AssetManager.h.

Referenced by getAudioAssetManager().

◆ audioAssetPipeline_

Ecs::AudioAssetPipeline Engine::Core::AssetManager::audioAssetPipeline_
private

Definition at line 425 of file AssetManager.h.

◆ context

ApplicationContext* Engine::Core::AssetManager::context = nullptr
private

Definition at line 441 of file AssetManager.h.

Referenced by AssetManager().

◆ cubemapTextures

std::unordered_map<std::filesystem::path, std::unique_ptr<Assets::CubemapTexture>, PathHasher> Engine::Core::AssetManager::cubemapTextures = {}
private

Definition at line 446 of file AssetManager.h.

◆ gltfLoader

Assets::Loaders::GltfLoader Engine::Core::AssetManager::gltfLoader = Assets::Loaders::GltfLoader( threadPool_ )
private

Definition at line 439 of file AssetManager.h.

◆ materialAssetManager

Assets::MaterialAssetManager* Engine::Core::AssetManager::materialAssetManager
private

Definition at line 411 of file AssetManager.h.

Referenced by getAsset(), and getMaterialAssetManager().

◆ meshAssetManager

Assets::MeshAssetManager* Engine::Core::AssetManager::meshAssetManager
private

Definition at line 410 of file AssetManager.h.

Referenced by getAsset(), and getMeshAssetManager().

◆ modelAssetManager

Assets::ModelAssetManager* Engine::Core::AssetManager::modelAssetManager
private

Definition at line 412 of file AssetManager.h.

Referenced by getModelAssetManager().

◆ modelAssetPipeline

Ecs::ModelAssetPipeline Engine::Core::AssetManager::modelAssetPipeline
private

Definition at line 422 of file AssetManager.h.

◆ renderer

Rendering::Renderer* Engine::Core::AssetManager::renderer = nullptr
private

Definition at line 442 of file AssetManager.h.

Referenced by attachToRenderer().

◆ RenderingDataManager

friend Engine::Core::AssetManager::RenderingDataManager
private

Definition at line 156 of file AssetManager.h.

Referenced by setRenderingDataManager().

◆ runtimeTextureDescriptorIndices_

std::unordered_set<uint32_t> Engine::Core::AssetManager::runtimeTextureDescriptorIndices_
private

Definition at line 451 of file AssetManager.h.

◆ skinAssetManager_

Assets::SkinAssetManager* Engine::Core::AssetManager::skinAssetManager_
private

Definition at line 413 of file AssetManager.h.

Referenced by getAsset(), and getSkinAssetManager().

◆ textureAllocator

DescriptorIndexAllocator Engine::Core::AssetManager::textureAllocator
private

Definition at line 450 of file AssetManager.h.

◆ textureAssetManager

Assets::TextureAssetManager* Engine::Core::AssetManager::textureAssetManager
private

Definition at line 408 of file AssetManager.h.

Referenced by getAsset().

◆ textureData

std::array<std::optional<Assets::RuntimeTexture>, MAX_TEXTURE_COUNT> Engine::Core::AssetManager::textureData
private

Definition at line 449 of file AssetManager.h.

◆ textureHandleRegistry_

Assets::Textures::TextureHandleRegistry Engine::Core::AssetManager::textureHandleRegistry_
private

Registry for type-safe texture handles.

Definition at line 420 of file AssetManager.h.

Referenced by getTextureHandleRegistry().

◆ textureIndexMap

BidirectionalMap<uint32_t, Assets::RuntimeTexture *> Engine::Core::AssetManager::textureIndexMap
private

Definition at line 447 of file AssetManager.h.

◆ textureMutex

std::mutex Engine::Core::AssetManager::textureMutex
private

Definition at line 495 of file AssetManager.h.

◆ texturePipeline

Ecs::TextureAssetPipeline Engine::Core::AssetManager::texturePipeline
private

Definition at line 409 of file AssetManager.h.

◆ textures

std::unordered_map<std::filesystem::path, Assets::RuntimeTexture *, PathHasher> Engine::Core::AssetManager::textures = {}
private

Definition at line 444 of file AssetManager.h.

◆ texturesToCopyImageData

std::vector<Assets::RuntimeTexture *> Engine::Core::AssetManager::texturesToCopyImageData
private

Definition at line 498 of file AssetManager.h.

◆ texturesToUpload

std::vector<TextureStorage> Engine::Core::AssetManager::texturesToUpload {}
private

Definition at line 497 of file AssetManager.h.

◆ threadedCalculation_

NamedThreadPool* Engine::Core::AssetManager::threadedCalculation_ = new NamedThreadPool( 2, "Bounding Sphere" )
private

Definition at line 406 of file AssetManager.h.

Referenced by getCalculationPool().

◆ threadPool_

NamedThreadPool* Engine::Core::AssetManager::threadPool_ = new NamedThreadPool( 2, "Asset Loader" )
private

Definition at line 405 of file AssetManager.h.

Referenced by getAssetLoaderPool().


The documentation for this class was generated from the following file:
  • /home/magerbeton/Documents/gl3-vulkan/Engine/include/Engine/Mesh/AssetManager.h