Vulkan Schnee 0.0.1 (22840dc8)
High-performance rendering engine
Loading...
Searching...
No Matches
Engine::Ecs::ModelAssetPipeline Class Reference

The model asset pipeline loads a gltf scene and loads and loads the mesh and material data. The material data requests the textures it needs. More...

#include <ModelAssetPipeline.h>

Collaboration diagram for Engine::Ecs::ModelAssetPipeline:

Public Member Functions

 ModelAssetPipeline (Assets::MeshAssetManager *meshAssetManager, Assets::MaterialAssetManager *materialAssetManager, Assets::ModelAssetManager *modelAssetManager, Assets::SkinAssetManager *skinAssetManager, Assets::AnimationAssetManager *animationAssetManager, Assets::TextureAssetManager *textureAssetManager, NamedThreadPool *assetLoaderPool, Core::AssetManager *assetManager=nullptr)
 Create a model asset loading pipeline.
 ~ModelAssetPipeline ()
 Destroy the pipeline and its owned glTF loader resources.
void submitAsset (const std::filesystem::path &asset)
 Requests the load of a gltf file.
void tick (bool async=true)
 Advances all stages of the model loading pipeline.
void setRenderingDataManager (Core::RenderingDataManager *renderingDataManager)
 Sets the RenderingDataManager to notify when meshes/materials are loaded.
void setAssetImportPipeline (AssetImportPipeline *pipeline)
 Sets the master AssetImportPipeline for async lightmap loading.
std::vector< CompletedMeshletGeneration > takePendingMeshletCompletions ()
 Get and clear pending meshlet completions. Call this at a safe point to retrieve completed meshlet generations that need to be written to the registry.
bool hasPendingWork () const
 Check if the pipeline still has in-flight work (loading, meshlet generation, etc.) Used to defer buffer rebuilds until all meshes from a model have finished processing.
void discardPendingWork ()
 Clears all queued and in-flight model loading work.

Private Member Functions

void submitLoadModel (bool async=true)
void processModel (bool async=true)
void processSkinData (bool async=true)
void processMaterial (bool async=true)
void processMeshData (bool async=true)
void processKtx2Textures (bool async=true)
void processTextures (Assets::Model *modelAsset, const std::shared_ptr< tinygltf::Model > &gltfModel, const std::filesystem::path &modelPath)
 Extracts and registers texture assets from loaded glTF models.

Private Attributes

Assets::MeshAssetManager * meshAssetManager_ = nullptr
Assets::MaterialAssetManager * materialAssetManager_ = nullptr
Assets::ModelAssetManager * modelAssetManager_ = nullptr
Assets::SkinAssetManager * skinAssetManager_ = nullptr
Assets::AnimationAssetManager * animationAssetManager_ = nullptr
Assets::TextureAssetManager * textureAssetManager_ = nullptr
Core::RenderingDataManager * renderingDataManager_ = nullptr
Core::AssetManager * assetManager_ = nullptr
 For TextureHandleRegistry access.
AssetImportPipeline * assetImportPipeline_ = nullptr
 For async lightmap loading.
NamedThreadPool * threadPool_ = nullptr
Assets::Loaders::GltfLoader * loader_ = nullptr
std::vector< std::filesystem::path > assetQueue_
std::vector< GltfModelFuture > modelLoadingFutures_
std::vector< MaterialLoadingData > materialResults_
std::vector< std::future< PrimitiveDataLoading > > primitiveDataFutures_
std::vector< std::future< CompletedMeshletGeneration > > meshletGenerationFutures_
std::vector< CompletedMeshletGeneration > pendingMeshletCompletions_
std::vector< Ktx2LoadFuture > pendingKtx2Futures_
NamedThreadPool * assetLoaderPool_ = nullptr

Detailed Description

The model asset pipeline loads a gltf scene and loads and loads the mesh and material data. The material data requests the textures it needs.

Definition at line 41 of file ModelAssetPipeline.h.

Constructor & Destructor Documentation

◆ ModelAssetPipeline()

Engine::Ecs::ModelAssetPipeline::ModelAssetPipeline ( Assets::MeshAssetManager * meshAssetManager,
Assets::MaterialAssetManager * materialAssetManager,
Assets::ModelAssetManager * modelAssetManager,
Assets::SkinAssetManager * skinAssetManager,
Assets::AnimationAssetManager * animationAssetManager,
Assets::TextureAssetManager * textureAssetManager,
NamedThreadPool * assetLoaderPool,
Core::AssetManager * assetManager = nullptr )
explicit

Create a model asset loading pipeline.

Parameters
meshAssetManagerManager that owns mesh assets
materialAssetManagerManager that owns material assets
modelAssetManagerManager that owns model assets
skinAssetManagerManager that owns skin assets
animationAssetManagerManager that owns animation assets
textureAssetManagerManager that owns texture assets referenced by models
assetLoaderPoolThread pool used for model loading work
assetManagerOptional asset manager for texture handle registry access

◆ ~ModelAssetPipeline()

Engine::Ecs::ModelAssetPipeline::~ModelAssetPipeline ( )

Destroy the pipeline and its owned glTF loader resources.

Member Function Documentation

◆ discardPendingWork()

void Engine::Ecs::ModelAssetPipeline::discardPendingWork ( )

Clears all queued and in-flight model loading work.

◆ hasPendingWork()

bool Engine::Ecs::ModelAssetPipeline::hasPendingWork ( ) const
inlinenodiscard

Check if the pipeline still has in-flight work (loading, meshlet generation, etc.) Used to defer buffer rebuilds until all meshes from a model have finished processing.

Returns
true if there are pending model loads, primitive data, or meshlet generations

Definition at line 110 of file ModelAssetPipeline.h.

References assetQueue_, materialResults_, meshletGenerationFutures_, modelLoadingFutures_, pendingKtx2Futures_, pendingMeshletCompletions_, and primitiveDataFutures_.

◆ processKtx2Textures()

void Engine::Ecs::ModelAssetPipeline::processKtx2Textures ( bool async = true)
private

◆ processMaterial()

void Engine::Ecs::ModelAssetPipeline::processMaterial ( bool async = true)
private

◆ processMeshData()

void Engine::Ecs::ModelAssetPipeline::processMeshData ( bool async = true)
private

◆ processModel()

void Engine::Ecs::ModelAssetPipeline::processModel ( bool async = true)
private

◆ processSkinData()

void Engine::Ecs::ModelAssetPipeline::processSkinData ( bool async = true)
private

◆ processTextures()

void Engine::Ecs::ModelAssetPipeline::processTextures ( Assets::Model * modelAsset,
const std::shared_ptr< tinygltf::Model > & gltfModel,
const std::filesystem::path & modelPath )
private

Extracts and registers texture assets from loaded glTF models.

Called during processModel() to extract images from model.images[] and create GltfTextureAsset entries in the TextureAssetManager.

Parameters
modelAssetThe model asset containing the loaded tinygltf::Model
gltfModelModel to extract the textures from
modelPathPath to the glTF file for resolving texture paths

◆ setAssetImportPipeline()

void Engine::Ecs::ModelAssetPipeline::setAssetImportPipeline ( AssetImportPipeline * pipeline)
inline

Sets the master AssetImportPipeline for async lightmap loading.

Parameters
pipelinePointer to the AssetImportPipeline

Definition at line 95 of file ModelAssetPipeline.h.

References assetImportPipeline_.

◆ setRenderingDataManager()

void Engine::Ecs::ModelAssetPipeline::setRenderingDataManager ( Core::RenderingDataManager * renderingDataManager)
inline

Sets the RenderingDataManager to notify when meshes/materials are loaded.

Parameters
renderingDataManagerPointer to the RenderingDataManager

Definition at line 89 of file ModelAssetPipeline.h.

References renderingDataManager_.

◆ submitAsset()

void Engine::Ecs::ModelAssetPipeline::submitAsset ( const std::filesystem::path & asset)

Requests the load of a gltf file.

Parameters
assetpath to the asset to load. Only use relative paths!

◆ submitLoadModel()

void Engine::Ecs::ModelAssetPipeline::submitLoadModel ( bool async = true)
private

◆ takePendingMeshletCompletions()

std::vector< CompletedMeshletGeneration > Engine::Ecs::ModelAssetPipeline::takePendingMeshletCompletions ( )

Get and clear pending meshlet completions. Call this at a safe point to retrieve completed meshlet generations that need to be written to the registry.

Returns
Vector of completed meshlet generation results

◆ tick()

void Engine::Ecs::ModelAssetPipeline::tick ( bool async = true)

Advances all stages of the model loading pipeline.

Parameters
asyncWhether to poll asynchronous work without blocking

Member Data Documentation

◆ animationAssetManager_

Assets::AnimationAssetManager* Engine::Ecs::ModelAssetPipeline::animationAssetManager_ = nullptr
private

Definition at line 152 of file ModelAssetPipeline.h.

◆ assetImportPipeline_

AssetImportPipeline* Engine::Ecs::ModelAssetPipeline::assetImportPipeline_ = nullptr
private

For async lightmap loading.

Definition at line 156 of file ModelAssetPipeline.h.

Referenced by setAssetImportPipeline().

◆ assetLoaderPool_

NamedThreadPool* Engine::Ecs::ModelAssetPipeline::assetLoaderPool_ = nullptr
private

Definition at line 173 of file ModelAssetPipeline.h.

◆ assetManager_

Core::AssetManager* Engine::Ecs::ModelAssetPipeline::assetManager_ = nullptr
private

For TextureHandleRegistry access.

Definition at line 155 of file ModelAssetPipeline.h.

◆ assetQueue_

std::vector<std::filesystem::path> Engine::Ecs::ModelAssetPipeline::assetQueue_
private

Definition at line 161 of file ModelAssetPipeline.h.

Referenced by hasPendingWork().

◆ loader_

Assets::Loaders::GltfLoader* Engine::Ecs::ModelAssetPipeline::loader_ = nullptr
private

Definition at line 159 of file ModelAssetPipeline.h.

◆ materialAssetManager_

Assets::MaterialAssetManager* Engine::Ecs::ModelAssetPipeline::materialAssetManager_ = nullptr
private

Definition at line 149 of file ModelAssetPipeline.h.

◆ materialResults_

std::vector<MaterialLoadingData> Engine::Ecs::ModelAssetPipeline::materialResults_
private

Definition at line 163 of file ModelAssetPipeline.h.

Referenced by hasPendingWork().

◆ meshAssetManager_

Assets::MeshAssetManager* Engine::Ecs::ModelAssetPipeline::meshAssetManager_ = nullptr
private

Definition at line 148 of file ModelAssetPipeline.h.

◆ meshletGenerationFutures_

std::vector<std::future<CompletedMeshletGeneration> > Engine::Ecs::ModelAssetPipeline::meshletGenerationFutures_
private

Definition at line 165 of file ModelAssetPipeline.h.

Referenced by hasPendingWork().

◆ modelAssetManager_

Assets::ModelAssetManager* Engine::Ecs::ModelAssetPipeline::modelAssetManager_ = nullptr
private

Definition at line 150 of file ModelAssetPipeline.h.

◆ modelLoadingFutures_

std::vector<GltfModelFuture> Engine::Ecs::ModelAssetPipeline::modelLoadingFutures_
private

Definition at line 162 of file ModelAssetPipeline.h.

Referenced by hasPendingWork().

◆ pendingKtx2Futures_

std::vector<Ktx2LoadFuture> Engine::Ecs::ModelAssetPipeline::pendingKtx2Futures_
private

Definition at line 171 of file ModelAssetPipeline.h.

Referenced by hasPendingWork().

◆ pendingMeshletCompletions_

std::vector<CompletedMeshletGeneration> Engine::Ecs::ModelAssetPipeline::pendingMeshletCompletions_
private

Definition at line 168 of file ModelAssetPipeline.h.

Referenced by hasPendingWork().

◆ primitiveDataFutures_

std::vector<std::future<PrimitiveDataLoading> > Engine::Ecs::ModelAssetPipeline::primitiveDataFutures_
private

Definition at line 164 of file ModelAssetPipeline.h.

Referenced by hasPendingWork().

◆ renderingDataManager_

Core::RenderingDataManager* Engine::Ecs::ModelAssetPipeline::renderingDataManager_ = nullptr
private

Definition at line 154 of file ModelAssetPipeline.h.

Referenced by setRenderingDataManager().

◆ skinAssetManager_

Assets::SkinAssetManager* Engine::Ecs::ModelAssetPipeline::skinAssetManager_ = nullptr
private

Definition at line 151 of file ModelAssetPipeline.h.

◆ textureAssetManager_

Assets::TextureAssetManager* Engine::Ecs::ModelAssetPipeline::textureAssetManager_ = nullptr
private

Definition at line 153 of file ModelAssetPipeline.h.

◆ threadPool_

NamedThreadPool* Engine::Ecs::ModelAssetPipeline::threadPool_ = nullptr
private

Definition at line 158 of file ModelAssetPipeline.h.


The documentation for this class was generated from the following file: