2#include "TextureHandle.h"
3#include "TextureIdentity.h"
7#include <unordered_map>
8#include <unordered_set>
98 template <TextureType Type>
181 const std::filesystem::path & path,
184 uint32_t descriptorIndex
196 uint32_t descriptorIndex
206 const std::filesystem::path & path,
208 uint32_t descriptorIndex
Runtime-owned Vulkan texture resource.
Type-erased texture handle for runtime storage.
static constexpr uint32_t INVALID_ID
Sentinel ID for an invalid handle.
void onTextureUnloaded(const std::filesystem::path &path, TextureType type)
Marks a registered path/type identity as not 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 setDescriptorSlot(TextureHandle handle, uint32_t descriptorIndex)
Assign a stable descriptor slot to a handle before the image is resident.
uint32_t resolveDescriptorSlot(TextureHandle handle) const
Resolve a handle to its stable descriptor slot.
TextureType getTextureTypeForPath(const std::filesystem::path &path) const
Get the texture type for a path (if registered)
TextureHandleRegistry()=default
Creates an empty texture handle registry.
void onTextureLoaded(const std::filesystem::path &path, TextureType type, RuntimeTexture *texture, uint32_t descriptorIndex)
Called when a texture finishes loading.
void onTextureUnloaded(const std::filesystem::path &path)
Called when a texture is unloaded.
void clear()
Clear all registry entries (typically called on shutdown)
TextureType getTextureType(TextureHandle handle) const
Get the texture type for a handle.
~TextureHandleRegistry()=default
Destroys the registry without owning registered RuntimeTexture objects.
void onTextureLoaded(const TextureIdentityKey &identity, RuntimeTexture *texture, uint32_t descriptorIndex)
Marks a registered texture identity as resident.
std::unordered_map< std::string, std::vector< uint32_t > > pathToHandleIds_
TextureHandleRegistry(const TextureHandleRegistry &)=delete
Copy construction is disabled because the registry contains synchronization state.
bool isResident(TextureHandle handle) const
True if the handle currently has a resident RuntimeTexture.
TextureHandleRegistry(TextureHandleRegistry &&)=delete
Move construction is disabled because handles refer to stable registry IDs.
TypedTextureHandle< Type > getOrCreateHandle(const std::filesystem::path &path)
Get or create a typed handle for a texture path.
TextureHandleRegistry & operator=(TextureHandleRegistry &&)=delete
Move assignment is disabled because handles refer to stable registry IDs.
TextureHandle getOrCreateHandle(const std::filesystem::path &path, TextureType type)
Gets or creates an untyped handle for a texture path and semantic type.
RuntimeTexture * resolveTexture(TextureHandle handle) const
Resolves a resident handle to its runtime Vulkan texture.
std::unordered_map< TextureIdentityKey, uint32_t, TextureIdentityKeyHash > identityToHandleId_
TextureIdentityKey getIdentityForHandle(TextureHandle handle) const
Gets the path/type identity associated with a handle.
size_t getHandleCount() const
Get the total number of registered texture handles.
TextureHandleRegistry & operator=(const TextureHandleRegistry &)=delete
Copy assignment is disabled because registry entries must remain stable.
TextureHandle getOrCreateHandleImpl(const std::filesystem::path &path, TextureType type)
Internal implementation of getOrCreateHandle.
std::vector< Entry > entries_
uint32_t resolveDescriptorIndex(TextureHandle handle) const
Resolve a handle to its descriptor index (O(1) operation)
std::filesystem::path getPathForHandle(TextureHandle handle) const
Get the path associated with a handle (for debugging/validation)
Type-safe texture handle wrapper providing compile-time type safety.
TextureType
Represents the semantic type of a texture, determining its Vulkan format.
@ Unknown
Fallback type, uses SRGB as default.
Registry entry storing texture metadata.
std::filesystem::path path
TextureIdentityKey identity
Path and semantic type pair that uniquely identifies a texture handle.