|
Vulkan Schnee 0.0.1
High-performance rendering engine
|
Central registry for texture handles, providing O(1) descriptor index lookup. More...
#include <TextureHandleRegistry.h>
Classes | |
| struct | Entry |
| Registry entry storing texture metadata. More... | |
Public Member Functions | |
| TextureHandleRegistry ()=default | |
| ~TextureHandleRegistry ()=default | |
| TextureHandleRegistry (const TextureHandleRegistry &)=delete | |
| TextureHandleRegistry & | operator= (const TextureHandleRegistry &)=delete |
| TextureHandleRegistry (TextureHandleRegistry &&)=delete | |
| TextureHandleRegistry & | operator= (TextureHandleRegistry &&)=delete |
| template<TextureType Type> | |
| TypedTextureHandle< Type > | getOrCreateHandle (const std::filesystem::path &path) |
| Get or create a typed handle for a texture path. | |
| uint32_t | resolveDescriptorIndex (TextureHandle handle) const |
| Resolve a handle to its descriptor index (O(1) operation) | |
| TextureType | getTextureType (TextureHandle handle) const |
| Get the texture type for a handle. | |
| TextureType | getTextureTypeForPath (const std::filesystem::path &path) const |
| Get the texture type for a path (if registered) | |
| void | onTextureLoaded (const std::filesystem::path &path, Texture *texture, uint32_t descriptorIndex) |
| Called when a texture finishes loading. | |
| void | onTextureUnloaded (const std::filesystem::path &path) |
| Called when a texture is unloaded. | |
| size_t | getHandleCount () const |
| Get the total number of registered texture handles. | |
| std::filesystem::path | getPathForHandle (TextureHandle handle) const |
| Get the path associated with a handle (for debugging/validation) | |
| void | clear () |
| Clear all registry entries (typically called on shutdown) | |
Private Member Functions | |
| TextureHandle | getOrCreateHandleImpl (const std::filesystem::path &path, TextureType type) |
| Internal implementation of getOrCreateHandle. | |
Private Attributes | |
| std::vector< Entry > | entries_ |
| std::unordered_map< std::string, uint32_t > | pathToHandleId_ |
| std::shared_mutex | mutex_ |
Central registry for texture handles, providing O(1) descriptor index lookup.
The TextureHandleRegistry solves two problems:
At import time (GLTF loading):
When texture loads asynchronously:
At material buffer upload (hot path):
Definition at line 49 of file TextureHandleRegistry.h.
|
default |
Referenced by operator=(), operator=(), TextureHandleRegistry(), and TextureHandleRegistry().
|
default |
|
delete |
|
delete |
| void EngineCore::TextureHandleRegistry::clear | ( | ) |
Clear all registry entries (typically called on shutdown)
Definition at line 175 of file TextureHandleRegistry.cpp.
References entries_, mutex_, and pathToHandleId_.
|
nodiscard |
Get the total number of registered texture handles.
Definition at line 155 of file TextureHandleRegistry.cpp.
|
inline |
Get or create a typed handle for a texture path.
This can be called before the texture is actually loaded. The handle will initially resolve to INVALID descriptor index (0xFFFFFFFF) until the texture finishes loading and onTextureLoaded() is called.
| Type | The semantic texture type |
| path | Path to the texture file |
Definition at line 72 of file TextureHandleRegistry.h.
References getOrCreateHandleImpl().
Referenced by EngineCore::RenderingDataManager::initializeDefaultTextures(), Ecs::ModelAssetPipeline::processModel(), and Ecs::ModelAssetPipeline::processTextures().
|
private |
Internal implementation of getOrCreateHandle.
Definition at line 23 of file TextureHandleRegistry.cpp.
References EngineCore::TextureHandleRegistry::Entry::descriptorIndex, entries_, EngineCore::TextureHandle::INVALID_ID, mutex_, EngineCore::TextureHandleRegistry::Entry::path, pathToHandleId_, EngineCore::TextureHandleRegistry::Entry::texture, and EngineCore::TextureHandleRegistry::Entry::type.
Referenced by getOrCreateHandle().
|
nodiscard |
Get the path associated with a handle (for debugging/validation)
| handle | The texture handle |
Definition at line 160 of file TextureHandleRegistry.cpp.
References entries_, EngineCore::TextureHandle::getId(), EngineCore::TextureHandle::isValid(), and mutex_.
Referenced by EngineCore::RenderingDataManager::uploadMaterialBuffers().
|
nodiscard |
Get the texture type for a handle.
| handle | The texture handle |
Definition at line 88 of file TextureHandleRegistry.cpp.
References entries_, EngineCore::TextureHandle::getId(), EngineCore::TextureHandle::isValid(), mutex_, and EngineCore::Unknown.
|
nodiscard |
Get the texture type for a path (if registered)
Used during texture loading to determine the correct VkFormat.
| path | The texture path |
Definition at line 103 of file TextureHandleRegistry.cpp.
References entries_, mutex_, pathToHandleId_, and EngineCore::Unknown.
Referenced by EngineCore::RenderingDataManager::onTextureLoaded().
| void EngineCore::TextureHandleRegistry::onTextureLoaded | ( | const std::filesystem::path & | path, |
| Texture * | texture, | ||
| uint32_t | descriptorIndex ) |
Called when a texture finishes loading.
Updates the registry entry with the loaded texture and its descriptor index.
| path | Path to the texture that was loaded |
| texture | Pointer to the loaded Texture object |
| descriptorIndex | The descriptor index assigned to this texture |
Definition at line 117 of file TextureHandleRegistry.cpp.
References EngineCore::TextureHandleRegistry::Entry::descriptorIndex, entries_, mutex_, pathToHandleId_, and EngineCore::TextureHandleRegistry::Entry::texture.
Referenced by EngineCore::RenderingDataManager::onTextureLoaded().
| void EngineCore::TextureHandleRegistry::onTextureUnloaded | ( | const std::filesystem::path & | path | ) |
Called when a texture is unloaded.
Resets the descriptor index to INVALID but keeps the handle valid.
| path | Path to the texture that was unloaded |
Definition at line 137 of file TextureHandleRegistry.cpp.
References EngineCore::TextureHandleRegistry::Entry::descriptorIndex, entries_, EngineCore::TextureHandle::INVALID_ID, mutex_, pathToHandleId_, and EngineCore::TextureHandleRegistry::Entry::texture.
|
delete |
|
delete |
|
nodiscard |
Resolve a handle to its descriptor index (O(1) operation)
| handle | The texture handle to resolve |
Definition at line 71 of file TextureHandleRegistry.cpp.
References entries_, EngineCore::TextureHandle::getId(), EngineCore::TextureHandle::INVALID_ID, EngineCore::TextureHandle::isValid(), and mutex_.
Referenced by EngineCore::RenderingDataManager::uploadMaterialBuffers().
|
private |
Definition at line 157 of file TextureHandleRegistry.h.
Referenced by clear(), getHandleCount(), getOrCreateHandleImpl(), getPathForHandle(), getTextureType(), getTextureTypeForPath(), onTextureLoaded(), onTextureUnloaded(), and resolveDescriptorIndex().
|
mutableprivate |
Definition at line 159 of file TextureHandleRegistry.h.
Referenced by clear(), getHandleCount(), getOrCreateHandleImpl(), getPathForHandle(), getTextureType(), getTextureTypeForPath(), onTextureLoaded(), onTextureUnloaded(), and resolveDescriptorIndex().
|
private |
Definition at line 158 of file TextureHandleRegistry.h.
Referenced by clear(), getOrCreateHandleImpl(), getTextureTypeForPath(), onTextureLoaded(), and onTextureUnloaded().