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

Registry store for material asset handles. More...

#include <AssetRegistry.h>

Collaboration diagram for Engine::Core::MaterialStore:

Classes

struct  Record
 Stored metadata for one material handle slot. More...

Public Member Functions

 MaterialStore (AssetManager *assetManager=nullptr)
 Creates a material store backed by an optional asset manager.
void setAssetManager (AssetManager *assetManager)
 Sets the asset manager used when new material handles request payload loading.
Assets::MaterialHandle load (const Asset::MeshPath &materialPath)
 Gets or creates a stable handle for an authored material path.
Assets::MaterialHandle registerRuntimeMaterial (Asset::MeshPath materialPath, std::unique_ptr< Assets::Material > material)
 Registers a runtime material payload and returns its stable material handle.
bool isValid (Assets::MaterialHandle handle) const
 Checks whether a material handle refers to a live slot in this store.
const Asset::MeshPath * path (Assets::MaterialHandle handle) const
 Returns the authored material path for a material handle.

Static Private Member Functions

static std::string keyFor (const Asset::MeshPath &materialPath)
 Builds the deduplication key for a material path and material name.

Private Attributes

AssetManager * assetManager_ = nullptr
 Optional bridge used to request and register legacy materials.
std::vector< Record > records_
 Slot storage indexed by MaterialHandle::index.
std::unordered_map< std::string, uint32_t > pathToIndex_
 Deduplication map from keyFor() to slot index.

Detailed Description

Registry store for material asset handles.

MaterialStore maps authored material paths to stable MaterialHandle values and can bridge those handles back to legacy material asset refs.

Definition at line 158 of file AssetRegistry.h.

Constructor & Destructor Documentation

◆ MaterialStore()

Engine::Core::MaterialStore::MaterialStore ( AssetManager * assetManager = nullptr)
explicit

Creates a material store backed by an optional asset manager.

Parameters
assetManagerAsset manager used to request material payload loads, or nullptr for handle-only use.

Member Function Documentation

◆ isValid()

bool Engine::Core::MaterialStore::isValid ( Assets::MaterialHandle handle) const
nodiscard

Checks whether a material handle refers to a live slot in this store.

Parameters
handleHandle to validate.
Returns
True when the handle index and generation match a stored record.

◆ keyFor()

std::string Engine::Core::MaterialStore::keyFor ( const Asset::MeshPath & materialPath)
staticnodiscardprivate

Builds the deduplication key for a material path and material name.

Parameters
materialPathMaterial source path and material name.
Returns
Stable string key used by pathToIndex_.

◆ load()

Assets::MaterialHandle Engine::Core::MaterialStore::load ( const Asset::MeshPath & materialPath)
nodiscard

Gets or creates a stable handle for an authored material path.

Parameters
materialPathEngine-relative source path and material name.
Returns
Existing or newly created material handle, or a null handle for an empty path.
Exceptions
std::invalid_argumentwhen materialPath contains an absolute source path.

◆ path()

const Asset::MeshPath * Engine::Core::MaterialStore::path ( Assets::MaterialHandle handle) const
nodiscard

Returns the authored material path for a material handle.

Parameters
handleHandle to look up.
Returns
Pointer to the stored material path, or nullptr when the handle is invalid.

◆ registerRuntimeMaterial()

Assets::MaterialHandle Engine::Core::MaterialStore::registerRuntimeMaterial ( Asset::MeshPath materialPath,
std::unique_ptr< Assets::Material > material )
nodiscard

Registers a runtime material payload and returns its stable material handle.

Parameters
materialPathEngine-relative path and material name used as the registry key.
materialMaterial payload to transfer to the attached asset manager.
Returns
Material handle, or a null handle when materialPath is empty or material is null.

◆ setAssetManager()

void Engine::Core::MaterialStore::setAssetManager ( AssetManager * assetManager)

Sets the asset manager used when new material handles request payload loading.

Parameters
assetManagerAsset manager to use, or nullptr to disable payload load requests.

Member Data Documentation

◆ assetManager_

AssetManager* Engine::Core::MaterialStore::assetManager_ = nullptr
private

Optional bridge used to request and register legacy materials.

Definition at line 222 of file AssetRegistry.h.

◆ pathToIndex_

std::unordered_map<std::string, uint32_t> Engine::Core::MaterialStore::pathToIndex_
private

Deduplication map from keyFor() to slot index.

Definition at line 224 of file AssetRegistry.h.

◆ records_

std::vector<Record> Engine::Core::MaterialStore::records_
private

Slot storage indexed by MaterialHandle::index.

Definition at line 223 of file AssetRegistry.h.


The documentation for this class was generated from the following file:
  • /workspace/magerbeton/gl3-vulkan/code/Engine/include/Engine/Asset/AssetRegistry.h