Vulkan Schnee 0.0.1
High-performance rendering engine
Loading...
Searching...
No Matches
TextureHandle.h
Go to the documentation of this file.
1#pragma once
2#include "TextureType.h"
3#include <cassert>
4#include <cstdint>
5
6namespace EngineCore {
7
18public:
19 static constexpr uint32_t INVALID_ID = 0xFFFFFFFF;
20
21 TextureHandle() = default;
22 TextureHandle(uint32_t id, TextureType type) : id_(id), type_(type) {}
23
27 [[nodiscard]] bool isValid() const { return id_ != INVALID_ID; }
28
32 [[nodiscard]] uint32_t getId() const { return id_; }
33
37 [[nodiscard]] TextureType getType() const { return type_; }
38
39 bool operator==(const TextureHandle& other) const {
40 return id_ == other.id_ && type_ == other.type_;
41 }
42
43 bool operator!=(const TextureHandle& other) const {
44 return !(*this == other);
45 }
46
47private:
48 uint32_t id_ = INVALID_ID;
50};
51
74template<TextureType Type>
76public:
77 TypedTextureHandle() = default;
78
84 explicit TypedTextureHandle(TextureHandle base) : base_(base) {
85 assert((base.getType() == Type || !base.isValid()) &&
86 "TextureHandle type mismatch in TypedTextureHandle construction");
87 }
88
92 [[nodiscard]] bool isValid() const { return base_.isValid(); }
93
97 [[nodiscard]] TextureHandle getBase() const { return base_; }
98
102 [[nodiscard]] uint32_t getId() const { return base_.getId(); }
103
107 [[nodiscard]] static constexpr TextureType getType() { return Type; }
108
112 operator TextureHandle() const { return base_; }
113
114 bool operator==(const TypedTextureHandle& other) const {
115 return base_ == other.base_;
116 }
117
118 bool operator!=(const TypedTextureHandle& other) const {
119 return !(*this == other);
120 }
121
122private:
124};
125
126// Convenience type aliases for common texture types
132
133} // namespace EngineCore
Type-erased texture handle for runtime storage.
static constexpr uint32_t INVALID_ID
TextureType getType() const
Get the texture type for this handle.
bool operator!=(const TextureHandle &other) const
bool isValid() const
Check if this handle points to a valid registry entry.
TextureHandle(uint32_t id, TextureType type)
uint32_t getId() const
Get the registry ID for this handle.
bool operator==(const TextureHandle &other) const
Type-safe texture handle wrapper providing compile-time type safety.
static constexpr TextureType getType()
Get the texture type (compile-time constant)
bool operator==(const TypedTextureHandle &other) const
TypedTextureHandle(TextureHandle base)
Construct from a base TextureHandle.
TextureHandle getBase() const
Get the underlying base handle.
bool operator!=(const TypedTextureHandle &other) const
uint32_t getId() const
Get the registry ID for this handle.
bool isValid() const
Check if this handle points to a valid registry entry.
Log category system implementation.
TypedTextureHandle< TextureType::MetallicRoughness > MetallicRoughnessTextureHandle
TypedTextureHandle< TextureType::Lightmap > LightmapTextureHandle
TypedTextureHandle< TextureType::Emissive > EmissiveTextureHandle
TypedTextureHandle< TextureType::Normal > NormalTextureHandle
TypedTextureHandle< TextureType::BaseColor > AlbedoTextureHandle
TextureType
Represents the semantic type of a texture, determining its Vulkan format.
Definition TextureType.h:18
@ Unknown
Fallback type, uses SRGB as default.
Definition TextureType.h:24