Central registry for texture handles, providing O(1) descriptor index lookup.
More...
|
| | TextureHandleRegistry ()=default |
| | Creates an empty texture handle registry.
|
| | ~TextureHandleRegistry ()=default |
| | Destroys the registry without owning registered RuntimeTexture objects.
|
| | TextureHandleRegistry (const TextureHandleRegistry &)=delete |
| | Copy construction is disabled because the registry contains synchronization state.
|
| TextureHandleRegistry & | operator= (const TextureHandleRegistry &)=delete |
| | Copy assignment is disabled because registry entries must remain stable.
|
| | TextureHandleRegistry (TextureHandleRegistry &&)=delete |
| | Move construction is disabled because handles refer to stable registry IDs.
|
| TextureHandleRegistry & | operator= (TextureHandleRegistry &&)=delete |
| | Move assignment is disabled because handles refer to stable registry IDs.
|
| template<TextureType Type> |
| TypedTextureHandle< Type > | getOrCreateHandle (const std::filesystem::path &path) |
| | Get or create a typed handle for a texture path.
|
| TextureHandle | getOrCreateHandle (const std::filesystem::path &path, TextureType type) |
| | Gets or creates an untyped handle for a texture path and semantic type.
|
| uint32_t | resolveDescriptorIndex (TextureHandle handle) const |
| | Resolve a handle to its descriptor index (O(1) operation)
|
| uint32_t | resolveDescriptorSlot (TextureHandle handle) const |
| | Resolve a handle to its stable descriptor slot.
|
| bool | isResident (TextureHandle handle) const |
| | True if the handle currently has a resident RuntimeTexture.
|
| RuntimeTexture * | resolveTexture (TextureHandle handle) const |
| | Resolves a resident handle to its runtime Vulkan texture.
|
| void | setDescriptorSlot (TextureHandle handle, uint32_t descriptorIndex) |
| | Assign a stable descriptor slot to a handle before the image is resident.
|
| TextureIdentityKey | getIdentityForHandle (TextureHandle handle) const |
| | Gets the path/type identity associated with a handle.
|
| 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, TextureType type, RuntimeTexture *texture, uint32_t descriptorIndex) |
| | Called when a texture finishes loading.
|
| void | onTextureLoaded (const TextureIdentityKey &identity, RuntimeTexture *texture, uint32_t descriptorIndex) |
| | Marks a registered texture identity as resident.
|
| void | onTextureLoaded (const std::filesystem::path &path, RuntimeTexture *texture, uint32_t descriptorIndex) |
| | Marks a path as resident when it resolves to one registered texture type.
|
| void | onTextureUnloaded (const std::filesystem::path &path) |
| | Called when a texture is unloaded.
|
| void | onTextureUnloaded (const std::filesystem::path &path, TextureType type) |
| | Marks a registered path/type identity as not resident.
|
| 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)
|
Central registry for texture handles, providing O(1) descriptor index lookup.
The TextureHandleRegistry solves two problems:
- Performance: Instead of doing path-to-descriptor-index lookups via string hashing on every material buffer upload, handles can be resolved to indices via array indexing.
- Type Safety: The registry tracks the semantic type of each texture, ensuring that textures are created with the correct VkFormat (SRGB vs UNORM).
Usage Flow
At import time (GLTF loading):
materialAsset->setNormalTextureHandle(handle);
@ Normal
Linear data for normal maps (UNORM format for 8-bit)
When texture loads asynchronously:
TextureType type = registry.getTextureTypeForPath(texturePath);
Texture vulkanTexture(imageData, type, context);
Texture* registered = assetManager->registerTexture(texturePath, std::move(vulkanTexture));
registry.onTextureLoaded(texturePath, registered, registered->getDescriptorIndex());
Wrapper for texture data.
TextureType
Represents the semantic type of a texture, determining its Vulkan format.
At material buffer upload (hot path):
uint32_t descriptorIndex = registry.resolveDescriptorIndex(handle);
Definition at line 53 of file TextureHandleRegistry.h.
| TypedTextureHandle< Type > Engine::Assets::Textures::TextureHandleRegistry::getOrCreateHandle |
( |
const std::filesystem::path & | path | ) |
|
|
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.
- Template Parameters
-
| Type | The semantic texture type |
- Parameters
-
| path | Path to the texture file |
- Returns
- A type-safe handle for this texture
Definition at line 99 of file TextureHandleRegistry.h.
References getOrCreateHandle().
Referenced by getOrCreateHandle().