|
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, RuntimeTexture *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 51 of file TextureHandleRegistry.h.
|
default |
Referenced by operator=(), operator=(), TextureHandleRegistry(), and TextureHandleRegistry().
|
default |
|
delete |
|
delete |
| void Engine::Assets::Textures::TextureHandleRegistry::clear | ( | ) |
Clear all registry entries (typically called on shutdown)
|
nodiscard |
Get the total number of registered texture handles.
|
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 75 of file TextureHandleRegistry.h.
References getOrCreateHandleImpl().
|
private |
Internal implementation of getOrCreateHandle.
Referenced by getOrCreateHandle().
|
nodiscard |
Get the path associated with a handle (for debugging/validation)
| handle | The texture handle |
|
nodiscard |
Get the texture type for a handle.
| handle | The texture handle |
|
nodiscard |
Get the texture type for a path (if registered)
Used during texture loading to determine the correct VkFormat.
| path | The texture path |
| void Engine::Assets::Textures::TextureHandleRegistry::onTextureLoaded | ( | const std::filesystem::path & | path, |
| RuntimeTexture * | 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 |
| void Engine::Assets::Textures::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 |
|
delete |
|
delete |
|
nodiscard |
Resolve a handle to its descriptor index (O(1) operation)
| handle | The texture handle to resolve |
|
private |
Definition at line 166 of file TextureHandleRegistry.h.
|
mutableprivate |
Definition at line 168 of file TextureHandleRegistry.h.
|
private |
Definition at line 167 of file TextureHandleRegistry.h.