|
Vulkan Schnee 0.0.1
High-performance rendering engine
|
#include <AssetManager.h>
Classes | |
| class | MaterialData |
| Storage for material data on the cpu side. More... | |
Public Member Functions | |
| AssetManager () | |
| AssetManager (ApplicationContext *context) | |
| ~AssetManager () | |
| void | attachToRenderer (Renderer *renderer) |
| Sets what renderer the render process belongs to. | |
| void | setRenderingDataManager (RenderingDataManager *renderingDataManager) |
| Sets the RenderingDataManager on asset pipelines for hook notifications. | |
| 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. | |
| MeshAsset * | getMeshAsset (const Asset::Path &asset) |
| Get a mesh from the asset manager. If it does not exist it requests the asset from the asset loader. | |
| void | loadEcsTexture (const std::filesystem::path &path) |
| Loads a texture (.png / .jpg / .exr) | |
| uint32_t | getTextureDescriptorIndex (const std::filesystem::path &path) |
| Gets the descriptor index of a loaded texture by path. | |
| std::vector< const Mesh * > | getAllMeshes () const |
| Gets a copy of all meshes which are currently loaded in the asset manager. | |
| uint32_t | getTotalPrimitiveCount () const |
| bool | doesMeshAlreadyExist (const std::filesystem::path &meshPath) const |
| Checks if a mesh is already present in the loaded meshes in RAM. | |
| uint32_t | getImageCount () const |
| void | logAllLoadedAssets () const |
| void | reloadMeshOffsets () |
| void | cleanup () |
| std::vector< VkDescriptorImageInfo > | getTextureDescriptorInfos () const |
| uint32_t | getShaderCount () const |
| std::vector< MaterialShader * > | getShaders () const |
| PipelineNames | materialNameFromString (const std::string &string) |
| MaterialShader * | getShaderByName (const std::string &shaderName) |
| MaterialShader * | getShaderByName (const PipelineNames &shaderName) |
| std::unordered_map< Mesh *, uint32_t > | getMeshOffsets () const |
| std::vector< Texture * > | getTexturesToUpload () |
| uint32_t | getMeshOffset (Mesh *mesh) const |
| MaterialShader * | registerShader (MaterialShader shader, const PipelineNames &materialName) |
| void | unregisterShader (MaterialShader *shader) |
| VulkanBuffer & | getMaterialStorageBufferByName (PipelineNames name) |
| Ecs::TextureAssetPipeline & | getTextureAssetPipeline () |
| Ecs::ModelAssetPipeline & | getMeshAssetPipeline () |
| void | unloadAllData () const |
| MeshAsset * | getMeshAsset (const Asset::Path &asset) const |
| MaterialAssetManager * | getMaterialAssetManager () const |
| Gets the material asset manager for material lookups. | |
| ModelAssetManager * | getModelAssetManager () const |
| Gets the model asset manager for model/GLTF file loading state lookups. | |
| MeshAssetManager * | getMeshAssetManager () const |
| Gets the mesh asset manager for mesh asset lookups. | |
| TextureHandleRegistry * | getTextureHandleRegistry () |
| Gets the texture handle registry for O(1) descriptor index lookups. | |
| NamedThreadPool * | getCalculationPool () const |
| NamedThreadPool * | getAssetLoaderPool () const |
Private Member Functions | |
| std::vector< const MeshPrimitive * > | getMeshPrimitivesFromMeshes (const std::vector< const Mesh * > &meshes) const |
| std::vector< MeshPrimitive * > | getMeshPrimitivesFromMeshes (const std::vector< Mesh * > &meshes) |
| uint32_t | getMeshletCount (const std::vector< const Mesh * > &meshes) const |
| template<typename T> | |
| void | initMaterialStorageBuffer (PipelineNames name, uint32_t materialCount) |
| template<typename T> | |
| uint32_t | addMaterialData (T data) |
| bool | doesTextureAlreadyExist (const std::filesystem::path &path) |
| Checks if a texture has already been loaded. | |
| Texture * | registerTexture (const std::filesystem::path &path, Texture texture) |
| Registers a texture with the texture manager which prevents the same texture from being loaded twice. | |
| void | unregisterTexture (Texture *texture) |
| Mesh * | registerMesh (const std::filesystem::path &path, GltfLoader::GltfMeshData &gltfMeshData) |
| void | unregisterMesh (Mesh *mesh) |
Definition at line 122 of file AssetManager.h.
| EngineCore::AssetManager::AssetManager | ( | ) |
Definition at line 24 of file AssetManager.cpp.
References materialAssetManager, MAX_MESH_COUNT, MAX_TEXTURE_COUNT, meshAllocator, meshAssetManager, meshIndexMap, modelAssetManager, modelAssetPipeline, textureAllocator, textureAssetManager, textureIndexMap, texturePipeline, and threadPool.
| EngineCore::AssetManager::AssetManager | ( | ApplicationContext * | context | ) |
Definition at line 33 of file AssetManager.cpp.
References ApplicationContext, context, materialAssetManager, MAX_MESH_COUNT, MAX_TEXTURE_COUNT, meshAllocator, meshAssetManager, modelAssetManager, modelAssetPipeline, textureAllocator, textureAssetManager, texturePipeline, and threadPool.
| EngineCore::AssetManager::~AssetManager | ( | ) |
Definition at line 43 of file AssetManager.cpp.
References materialAssetManager, meshAssetManager, modelAssetManager, textureAssetManager, threadedCalculation, and threadPool.
|
private |
| void EngineCore::AssetManager::attachToRenderer | ( | Renderer * | renderer | ) |
Sets what renderer the render process belongs to.
| renderer | Where the render process belongs to |
Definition at line 52 of file AssetManager.cpp.
References renderer.
| void EngineCore::AssetManager::cleanup | ( | ) |
Definition at line 127 of file AssetManager.cpp.
References materialStorageBuffers, meshAllocator, meshData, meshes, textureData, and textures.
| bool EngineCore::AssetManager::doesMeshAlreadyExist | ( | const std::filesystem::path & | meshPath | ) | const |
Checks if a mesh is already present in the loaded meshes in RAM.
| meshPath | Path to the mesh. This will be used as the key to the map which check whether it already exists. So try to use relative paths |
Definition at line 107 of file AssetManager.cpp.
References meshes.
|
private |
Checks if a texture has already been loaded.
| path | the path of the texture on disk |
Definition at line 290 of file AssetManager.cpp.
References textureMutex, textures, and TRACY_LOCK_GUARD.
|
nodiscard |
Gets a copy of all meshes which are currently loaded in the asset manager.
Definition at line 88 of file AssetManager.cpp.
References meshAllocator, and meshData.
Referenced by getTotalPrimitiveCount().
|
inline |
Definition at line 333 of file AssetManager.h.
References threadPool.
|
inline |
Definition at line 328 of file AssetManager.h.
References threadedCalculation.
| uint32_t EngineCore::AssetManager::getImageCount | ( | ) | const |
Definition at line 391 of file AssetManager.cpp.
References textures.
|
inlinenodiscard |
Gets the material asset manager for material lookups.
Definition at line 257 of file AssetManager.h.
References materialAssetManager.
Referenced by EngineCore::RenderingDataManager::collectMaterialsFromScene(), EngineCore::RenderingDataManager::updatePrimitiveData(), EngineCore::RenderingDataManager::updatePrimitiveDataInstanced(), and EngineCore::RenderingDataManager::uploadMaterialBuffers().
| VulkanBuffer & EngineCore::AssetManager::getMaterialStorageBufferByName | ( | PipelineNames | name | ) |
Definition at line 220 of file AssetManager.cpp.
References materialStorageBuffers.
| MeshAsset * EngineCore::AssetManager::getMeshAsset | ( | const Asset::Path & | asset | ) |
Get a mesh from the asset manager. If it does not exist it requests the asset from the asset loader.
| asset | Which asset to look for |
Definition at line 71 of file AssetManager.cpp.
References Asset::Path::getFilePath(), loadEcsModel(), and meshAssetManager.
Referenced by EngineCore::MeshComponent::MeshComponent().
|
nodiscard |
Definition at line 285 of file AssetManager.cpp.
References meshAssetManager, and EngineCore::UnpackOptional().
|
inlinenodiscard |
Gets the mesh asset manager for mesh asset lookups.
Definition at line 281 of file AssetManager.h.
References meshAssetManager.
Referenced by EngineCore::RenderingDataManager::processCompletedMeshletGenerations().
| Ecs::ModelAssetPipeline & EngineCore::AssetManager::getMeshAssetPipeline | ( | ) |
Definition at line 272 of file AssetManager.cpp.
References modelAssetPipeline.
|
private |
Definition at line 251 of file AssetManager.cpp.
References meshes.
| uint32_t EngineCore::AssetManager::getMeshOffset | ( | Mesh * | mesh | ) | const |
Definition at line 193 of file AssetManager.cpp.
References meshOffsets.
|
inline |
Definition at line 231 of file AssetManager.h.
References meshOffsets.
|
private |
Definition at line 224 of file AssetManager.cpp.
References meshes.
|
private |
Definition at line 238 of file AssetManager.cpp.
References meshes.
|
inlinenodiscard |
Gets the model asset manager for model/GLTF file loading state lookups.
Definition at line 269 of file AssetManager.h.
References modelAssetManager.
| MaterialShader * EngineCore::AssetManager::getShaderByName | ( | const PipelineNames & | shaderName | ) |
Definition at line 181 of file AssetManager.cpp.
References shadersByName.
| MaterialShader * EngineCore::AssetManager::getShaderByName | ( | const std::string & | shaderName | ) |
Definition at line 176 of file AssetManager.cpp.
References getShaderByName(), and materialNameFromString().
Referenced by getShaderByName().
| uint32_t EngineCore::AssetManager::getShaderCount | ( | ) | const |
Definition at line 164 of file AssetManager.cpp.
References shaders.
| std::vector< MaterialShader * > EngineCore::AssetManager::getShaders | ( | ) | const |
Definition at line 168 of file AssetManager.cpp.
References shaders.
| Ecs::TextureAssetPipeline & EngineCore::AssetManager::getTextureAssetPipeline | ( | ) |
Definition at line 268 of file AssetManager.cpp.
References texturePipeline.
|
nodiscard |
Gets the descriptor index of a loaded texture by path.
| path | Path to the texture (relative or absolute) |
Definition at line 295 of file AssetManager.cpp.
References textureMutex, textures, and TRACY_LOCK_GUARD.
Referenced by EngineCore::RenderingDataManager::getValidTextureIndex(), EngineCore::RenderingDataManager::onTextureLoaded(), and EngineCore::RenderingDataManager::uploadMaterialBuffers().
| std::vector< VkDescriptorImageInfo > EngineCore::AssetManager::getTextureDescriptorInfos | ( | ) | const |
Definition at line 151 of file AssetManager.cpp.
References textureData.
|
inlinenodiscard |
Gets the texture handle registry for O(1) descriptor index lookups.
Definition at line 293 of file AssetManager.h.
References textureHandleRegistry_.
Referenced by EngineCore::RenderingDataManager::initializeDefaultTextures(), EngineCore::RenderingDataManager::onTextureLoaded(), and EngineCore::RenderingDataManager::uploadMaterialBuffers().
| std::vector< Texture * > EngineCore::AssetManager::getTexturesToUpload | ( | ) |
Definition at line 189 of file AssetManager.cpp.
References texturesToCopyImageData.
|
nodiscard |
Definition at line 99 of file AssetManager.cpp.
References getAllMeshes().
|
private |
Definition at line 434 of file AssetManager.h.
References context, EngineCore::MaterialShader::getPipelineNameFromString(), and materialStorageBuffers.
| void EngineCore::AssetManager::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.
| path | Where the gltf file is |
Definition at line 61 of file AssetManager.cpp.
References modelAssetManager, modelAssetPipeline, and TRACY_ZONE_SCOPED_NAMED.
Referenced by getMeshAsset(), and EngineCore::GltfSpawner::spawnAll().
| void EngineCore::AssetManager::loadEcsTexture | ( | const std::filesystem::path & | path | ) |
Loads a texture (.png / .jpg / .exr)
| path | where the texture is |
Definition at line 82 of file AssetManager.cpp.
References textureAssetManager, texturePipeline, and TRACY_ZONE_SCOPED_NAMED.
Referenced by EngineCore::RenderingDataManager::initializeDefaultTextures().
| void EngineCore::AssetManager::logAllLoadedAssets | ( | ) | const |
Definition at line 111 of file AssetManager.cpp.
| PipelineNames EngineCore::AssetManager::materialNameFromString | ( | const std::string & | string | ) |
Definition at line 172 of file AssetManager.cpp.
References EngineCore::DIFFUSE_FLAT_COLOR.
Referenced by getShaderByName().
|
private |
Definition at line 344 of file AssetManager.cpp.
References context, EngineCore::Mesh::createMeshName(), EngineCore::GltfLoader::GltfMeshData::getName(), meshAllocator, meshData, meshes, meshesMutex, meshIndexMap, renderer, TRACY_LOCK_GUARD, and TRACY_ZONE_SCOPED_NAMED.
| MaterialShader * EngineCore::AssetManager::registerShader | ( | MaterialShader | shader, |
| const PipelineNames & | materialName ) |
Definition at line 197 of file AssetManager.cpp.
References shaderAllocator, shaderData, shaderOffsets, shaders, and shadersByName.
|
private |
Registers a texture with the texture manager which prevents the same texture from being loaded twice.
| path | path to the texture |
| texture | the texture to register |
Definition at line 304 of file AssetManager.cpp.
References EngineCore::Texture::createResources(), EngineCore::Texture::descriptorIndex, renderer, textureAllocator, textureData, textureIndexMap, textureMutex, textures, and TRACY_LOCK_GUARD.
Referenced by EngineCore::RenderingDataManager::onTextureLoaded().
| void EngineCore::AssetManager::reloadMeshOffsets | ( | ) |
Definition at line 116 of file AssetManager.cpp.
References meshData, and meshOffsets.
| void EngineCore::AssetManager::setRenderingDataManager | ( | RenderingDataManager * | renderingDataManager | ) |
Sets the RenderingDataManager on asset pipelines for hook notifications.
| renderingDataManager | Pointer to the RenderingDataManager |
Definition at line 56 of file AssetManager.cpp.
References modelAssetPipeline, RenderingDataManager, and texturePipeline.
| void EngineCore::AssetManager::unloadAllData | ( | ) | const |
Definition at line 276 of file AssetManager.cpp.
References materialAssetManager, meshAssetManager, modelAssetManager, textureAssetManager, and TRACY_ZONE_SCOPED_NAMED.
|
private |
Definition at line 370 of file AssetManager.cpp.
References meshData, meshes, meshesMutex, meshIndexMap, meshOffsets, TRACY_LOCK_GUARD, and TRACY_ZONE_SCOPED_NAMED.
| void EngineCore::AssetManager::unregisterShader | ( | MaterialShader * | shader | ) |
Definition at line 209 of file AssetManager.cpp.
References shaderData, shaderOffsets, and shaders.
|
private |
Definition at line 329 of file AssetManager.cpp.
References textureData, textureIndexMap, textureMutex, textures, and TRACY_LOCK_GUARD.
|
private |
Definition at line 124 of file AssetManager.h.
Referenced by AssetManager().
|
private |
Definition at line 426 of file AssetManager.h.
|
private |
Definition at line 385 of file AssetManager.h.
Referenced by AssetManager(), initMaterialStorageBuffer(), and registerMesh().
|
private |
Definition at line 315 of file AssetManager.h.
|
private |
Definition at line 339 of file AssetManager.h.
|
private |
Definition at line 305 of file AssetManager.h.
Referenced by AssetManager(), AssetManager(), getMaterialAssetManager(), unloadAllData(), and ~AssetManager().
|
private |
Definition at line 376 of file AssetManager.h.
Referenced by cleanup(), getMaterialStorageBufferByName(), and initMaterialStorageBuffer().
|
private |
Definition at line 423 of file AssetManager.h.
Referenced by AssetManager(), AssetManager(), cleanup(), getAllMeshes(), and registerMesh().
|
private |
Definition at line 304 of file AssetManager.h.
Referenced by AssetManager(), AssetManager(), getMeshAsset(), getMeshAsset(), getMeshAssetManager(), unloadAllData(), and ~AssetManager().
|
private |
Definition at line 422 of file AssetManager.h.
Referenced by cleanup(), getAllMeshes(), registerMesh(), reloadMeshOffsets(), and unregisterMesh().
|
private |
Definition at line 424 of file AssetManager.h.
Referenced by cleanup(), doesMeshAlreadyExist(), getMeshletCount(), getMeshPrimitivesFromMeshes(), getMeshPrimitivesFromMeshes(), logAllLoadedAssets(), registerMesh(), and unregisterMesh().
|
private |
Definition at line 417 of file AssetManager.h.
Referenced by registerMesh(), and unregisterMesh().
|
private |
Definition at line 390 of file AssetManager.h.
Referenced by AssetManager(), registerMesh(), and unregisterMesh().
|
private |
Definition at line 318 of file AssetManager.h.
|
private |
Definition at line 317 of file AssetManager.h.
|
private |
Definition at line 427 of file AssetManager.h.
Referenced by getMeshOffset(), getMeshOffsets(), reloadMeshOffsets(), and unregisterMesh().
|
private |
Definition at line 306 of file AssetManager.h.
Referenced by AssetManager(), AssetManager(), getModelAssetManager(), loadEcsModel(), unloadAllData(), and ~AssetManager().
|
private |
Definition at line 313 of file AssetManager.h.
Referenced by AssetManager(), AssetManager(), getMeshAssetPipeline(), loadEcsModel(), and setRenderingDataManager().
|
private |
Definition at line 319 of file AssetManager.h.
|
private |
Definition at line 320 of file AssetManager.h.
|
private |
Definition at line 386 of file AssetManager.h.
Referenced by attachToRenderer(), registerMesh(), and registerTexture().
|
private |
Definition at line 125 of file AssetManager.h.
Referenced by setRenderingDataManager().
|
private |
Definition at line 378 of file AssetManager.h.
Referenced by registerShader().
|
private |
Definition at line 379 of file AssetManager.h.
Referenced by registerShader(), and unregisterShader().
|
private |
Definition at line 383 of file AssetManager.h.
Referenced by registerShader(), and unregisterShader().
|
private |
Definition at line 380 of file AssetManager.h.
Referenced by getShaderCount(), getShaders(), registerShader(), and unregisterShader().
|
private |
Definition at line 381 of file AssetManager.h.
Referenced by getShaderByName(), and registerShader().
|
private |
Definition at line 393 of file AssetManager.h.
Referenced by AssetManager(), AssetManager(), and registerTexture().
|
private |
Definition at line 302 of file AssetManager.h.
Referenced by AssetManager(), AssetManager(), loadEcsTexture(), unloadAllData(), and ~AssetManager().
|
private |
Definition at line 392 of file AssetManager.h.
Referenced by cleanup(), getTextureDescriptorInfos(), registerTexture(), and unregisterTexture().
|
private |
Registry for type-safe texture handles.
Definition at line 311 of file AssetManager.h.
Referenced by getTextureHandleRegistry().
|
private |
Definition at line 389 of file AssetManager.h.
Referenced by AssetManager(), registerTexture(), and unregisterTexture().
|
private |
Definition at line 416 of file AssetManager.h.
Referenced by doesTextureAlreadyExist(), getTextureDescriptorIndex(), registerTexture(), and unregisterTexture().
|
private |
Definition at line 303 of file AssetManager.h.
Referenced by AssetManager(), AssetManager(), getTextureAssetPipeline(), loadEcsTexture(), and setRenderingDataManager().
|
private |
Definition at line 388 of file AssetManager.h.
Referenced by cleanup(), doesTextureAlreadyExist(), getImageCount(), getTextureDescriptorIndex(), logAllLoadedAssets(), registerTexture(), and unregisterTexture().
|
private |
Definition at line 430 of file AssetManager.h.
Referenced by getTexturesToUpload().
|
private |
Definition at line 429 of file AssetManager.h.
|
private |
Definition at line 300 of file AssetManager.h.
Referenced by getCalculationPool(), and ~AssetManager().
|
private |
Definition at line 299 of file AssetManager.h.
Referenced by AssetManager(), AssetManager(), getAssetLoaderPool(), and ~AssetManager().