Vulkan Schnee 0.0.1
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 <FrameProcessing.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)
void submitAsset (const std::filesystem::path &asset)
 Requests the load of a gltf file.
void tick (bool async=true)
void setRenderingDataManager (Core::RenderingDataManager *renderingDataManager)
 Sets the RenderingDataManager to notify when meshes/materials are loaded.
void setTextureAssetPipeline (TextureAssetPipeline *pipeline)
 Sets the TextureAssetPipeline for async lightmap loading.
std::vector< CompletedMeshletGenerationtakePendingMeshletCompletions ()
 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 ()

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::MeshAssetManagermeshAssetManager_ = nullptr
Assets::MaterialAssetManagermaterialAssetManager_ = nullptr
Assets::ModelAssetManager * modelAssetManager_ = nullptr
Assets::SkinAssetManagerskinAssetManager_ = nullptr
Assets::AnimationAssetManageranimationAssetManager_ = nullptr
Assets::TextureAssetManagertextureAssetManager_ = nullptr
Core::RenderingDataManager * renderingDataManager_ = nullptr
Core::AssetManagerassetManager_ = nullptr
 For TextureHandleRegistry access.
TextureAssetPipelinetextureAssetPipeline_ = nullptr
 For async lightmap loading.
NamedThreadPoolthreadPool_ = new NamedThreadPool( 2, "Gltf loader" )
Assets::Loaders::GltfLoaderloader_ = new Assets::Loaders::GltfLoader(threadPool_)
std::vector< std::filesystem::path > assetQueue_
std::vector< GltfModelFuturemodelLoadingFutures_
std::vector< MaterialLoadingDatamaterialResults_
std::vector< std::future< PrimitiveDataLoading > > primitiveDataFutures_
std::vector< std::future< CompletedMeshletGeneration > > meshletGenerationFutures_
std::vector< CompletedMeshletGenerationpendingMeshletCompletions_
std::vector< Ktx2LoadFuturependingKtx2Futures_
NamedThreadPoolassetLoaderPool_ = 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 107 of file FrameProcessing.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

Member Function Documentation

◆ discardPendingWork()

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

◆ 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 156 of file FrameProcessing.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

◆ 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 135 of file FrameProcessing.h.

References renderingDataManager_.

◆ setTextureAssetPipeline()

void Engine::Ecs::ModelAssetPipeline::setTextureAssetPipeline ( TextureAssetPipeline * pipeline)
inline

Sets the TextureAssetPipeline for async lightmap loading.

Parameters
pipelinePointer to the TextureAssetPipeline

Definition at line 141 of file FrameProcessing.h.

References textureAssetPipeline_.

◆ 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)

Member Data Documentation

◆ animationAssetManager_

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

Definition at line 195 of file FrameProcessing.h.

◆ assetLoaderPool_

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

Definition at line 216 of file FrameProcessing.h.

◆ assetManager_

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

For TextureHandleRegistry access.

Definition at line 198 of file FrameProcessing.h.

◆ assetQueue_

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

Definition at line 204 of file FrameProcessing.h.

Referenced by hasPendingWork().

◆ loader_

Assets::Loaders::GltfLoader* Engine::Ecs::ModelAssetPipeline::loader_ = new Assets::Loaders::GltfLoader(threadPool_)
private

Definition at line 202 of file FrameProcessing.h.

◆ materialAssetManager_

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

Definition at line 192 of file FrameProcessing.h.

◆ materialResults_

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

Definition at line 206 of file FrameProcessing.h.

Referenced by hasPendingWork().

◆ meshAssetManager_

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

Definition at line 191 of file FrameProcessing.h.

◆ meshletGenerationFutures_

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

Definition at line 208 of file FrameProcessing.h.

Referenced by hasPendingWork().

◆ modelAssetManager_

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

Definition at line 193 of file FrameProcessing.h.

◆ modelLoadingFutures_

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

Definition at line 205 of file FrameProcessing.h.

Referenced by hasPendingWork().

◆ pendingKtx2Futures_

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

Definition at line 214 of file FrameProcessing.h.

Referenced by hasPendingWork().

◆ pendingMeshletCompletions_

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

Definition at line 211 of file FrameProcessing.h.

Referenced by hasPendingWork().

◆ primitiveDataFutures_

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

Definition at line 207 of file FrameProcessing.h.

Referenced by hasPendingWork().

◆ renderingDataManager_

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

Definition at line 197 of file FrameProcessing.h.

Referenced by setRenderingDataManager().

◆ skinAssetManager_

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

Definition at line 194 of file FrameProcessing.h.

◆ textureAssetManager_

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

Definition at line 196 of file FrameProcessing.h.

◆ textureAssetPipeline_

TextureAssetPipeline* Engine::Ecs::ModelAssetPipeline::textureAssetPipeline_ = nullptr
private

For async lightmap loading.

Definition at line 199 of file FrameProcessing.h.

Referenced by setTextureAssetPipeline().

◆ threadPool_

NamedThreadPool* Engine::Ecs::ModelAssetPipeline::threadPool_ = new NamedThreadPool( 2, "Gltf loader" )
private

Definition at line 201 of file FrameProcessing.h.


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