18#ifndef INCLUDED_RENDERER_BACKEND_VULKAN_DESCRIPTORMANAGER
19#define INCLUDED_RENDERER_BACKEND_VULKAN_DESCRIPTORMANAGER
26#include <glad/vulkan.h>
29#include <unordered_map>
57 VkDescriptorType type,
const uint32_t size);
60 VkDescriptorType type, VkDescriptorSetLayout layout,
61 const std::vector<DeviceObjectUID>& texturesUID,
62 const std::vector<CTexture*>& textures);
85 VkDescriptorSet
set = VK_NULL_HANDLE;
94 VkDescriptorType type, VkDescriptorSetLayout layout,
95 const std::vector<DeviceObjectUID>& uids);
115 std::unordered_map<DeviceObjectUID, int16_t>
map;
117 std::array<DescriptorIndexingBindingMap, NUMBER_OF_BINDINGS_PER_DESCRIPTOR_INDEXING_SET>
124 VkDescriptorType
type = VK_DESCRIPTOR_TYPE_MAX_ENUM;
136 std::unordered_map<SingleTypeCacheKey, VkDescriptorSet, SingleTypeCacheKeyHash>
m_SingleTypeSets;
142template<
typename DeviceObject>
147 const uint32_t size, std::unordered_map<CStrIntern, uint32_t> mapping)
159 return it !=
m_Mapping.end() ? it->second : -1;
162 void SetObject(
const int32_t bindingSlot, DeviceObject*
object)
178 VkDescriptorSet descriptorSet =
181 ENSURE(descriptorSet != VK_NULL_HANDLE);
183 return descriptorSet;
200 const std::unordered_map<CStrIntern, uint32_t>
m_Mapping;
Interned 8-bit strings.
Definition: CStrIntern.h:38
Definition: DescriptorManager.h:45
std::pair< VkDescriptorSetLayout, std::vector< DeviceObjectUID > > SingleTypeCacheKey
Definition: DescriptorManager.h:131
static constexpr uint32_t NUMBER_OF_BINDINGS_PER_DESCRIPTOR_INDEXING_SET
Definition: DescriptorManager.h:108
CDevice * m_Device
Definition: DescriptorManager.h:97
bool UseDescriptorIndexing() const
Definition: DescriptorManager.h:50
const VkDescriptorSet & GetDescriptorIndexingSet()
Definition: DescriptorManager.h:72
uint32_t GetUniformSet() const
Definition: DescriptorManager.cpp:309
VkDescriptorSetLayout GetSingleTypeDescritorSetLayout(VkDescriptorType type, const uint32_t size)
Definition: DescriptorManager.cpp:205
std::unique_ptr< ITexture > m_ErrorTexture
Definition: DescriptorManager.h:138
const VkDescriptorSetLayout & GetUniformDescriptorSetLayout() const
Definition: DescriptorManager.h:71
std::unordered_map< SingleTypeCacheKey, VkDescriptorSet, SingleTypeCacheKeyHash > m_SingleTypeSets
Definition: DescriptorManager.h:136
const VkDescriptorSetLayout & GetDescriptorIndexingSetLayout() const
Definition: DescriptorManager.h:70
static constexpr uint32_t DESCRIPTOR_INDEXING_BINDING_SIZE
Definition: DescriptorManager.h:107
bool m_UseDescriptorIndexing
Definition: DescriptorManager.h:99
std::vector< VkDescriptorSetLayout > m_DescriptorSetLayouts
Definition: DescriptorManager.h:105
std::pair< VkDescriptorSet, bool > GetSingleTypeDescritorSetImpl(VkDescriptorType type, VkDescriptorSetLayout layout, const std::vector< DeviceObjectUID > &uids)
Definition: DescriptorManager.cpp:220
std::unordered_map< DeviceObjectUID, uint32_t > m_TextureToBindingMap
Definition: DescriptorManager.h:119
uint32_t GetTextureDescriptor(CTexture *texture)
Definition: DescriptorManager.cpp:314
VkDescriptorSetLayout m_UniformDescriptorSetLayout
Definition: DescriptorManager.h:104
VkDescriptorPool m_DescriptorIndexingPool
Definition: DescriptorManager.h:101
std::array< DescriptorIndexingBindingMap, NUMBER_OF_BINDINGS_PER_DESCRIPTOR_INDEXING_SET > m_DescriptorIndexingBindings
Definition: DescriptorManager.h:118
VkDescriptorSetLayout m_DescriptorIndexingSetLayout
Definition: DescriptorManager.h:103
VkDescriptorSet m_DescriptorIndexingSet
Definition: DescriptorManager.h:102
std::unordered_map< VkDescriptorType, std::vector< SingleTypePool > > m_SingleTypePools
Definition: DescriptorManager.h:121
void OnTextureDestroy(const DeviceObjectUID uid)
Definition: DescriptorManager.cpp:361
VkDescriptorSet GetSingleTypeDescritorSet(VkDescriptorType type, VkDescriptorSetLayout layout, const std::vector< DeviceObjectUID > &texturesUID, const std::vector< CTexture * > &textures)
Definition: DescriptorManager.cpp:262
CDescriptorManager(CDevice *device, const bool useDescriptorIndexing)
Definition: DescriptorManager.cpp:41
std::unordered_map< DeviceObjectUID, std::vector< SingleTypePoolReference > > m_UIDToSingleTypePoolMap
Definition: DescriptorManager.h:129
SingleTypePool & GetSingleTypePool(const VkDescriptorType type, const uint32_t size)
Definition: DescriptorManager.cpp:158
~CDescriptorManager()
Definition: DescriptorManager.cpp:134
const std::vector< VkDescriptorSetLayout > & GetDescriptorSetLayouts() const
Definition: DescriptorManager.h:74
CDescriptorManager & GetDescriptorManager()
Definition: Device.h:163
Definition: DescriptorManager.h:144
VkDescriptorSetLayout GetDescriptorSetLayout()
Definition: DescriptorManager.h:193
std::vector< DeviceObject * > m_BoundDeviceObjects
Definition: DescriptorManager.h:206
CSingleTypeDescriptorSetBinding(CDevice *device, const VkDescriptorType type, const uint32_t size, std::unordered_map< CStrIntern, uint32_t > mapping)
Definition: DescriptorManager.h:146
bool m_Outdated
Definition: DescriptorManager.h:202
void Unbind()
Definition: DescriptorManager.h:186
VkDescriptorSetLayout m_DescriptorSetLayout
Definition: DescriptorManager.h:204
int32_t GetBindingSlot(const CStrIntern name) const
Definition: DescriptorManager.h:156
void SetObject(const int32_t bindingSlot, DeviceObject *object)
Definition: DescriptorManager.h:162
const std::vector< DeviceObject * > & GetBoundDeviceObjects() const
Definition: DescriptorManager.h:195
const VkDescriptorType m_Type
Definition: DescriptorManager.h:199
VkDescriptorSet UpdateAndReturnDescriptorSet()
Definition: DescriptorManager.h:173
CDevice *const m_Device
Definition: DescriptorManager.h:198
const std::unordered_map< CStrIntern, uint32_t > m_Mapping
Definition: DescriptorManager.h:200
std::vector< DeviceObjectUID > m_BoundUIDs
Definition: DescriptorManager.h:207
bool IsOutdated() const
Definition: DescriptorManager.h:171
#define ENSURE(expr)
ensure the expression <expr> evaluates to non-zero.
Definition: debug.h:277
static constexpr DeviceObjectUID INVALID_DEVICE_OBJECT_UID
Definition: DeviceObjectUID.h:41
uint32_t DeviceObjectUID
Unique identifier for a device object.
Definition: DeviceObjectUID.h:40
Backend
Definition: Backend.h:28
Definition: VideoMode.h:29
Definition: ShaderDefines.cpp:31
Definition: DescriptorManager.h:111
std::vector< int16_t > elements
Definition: DescriptorManager.h:114
std::unordered_map< DeviceObjectUID, int16_t > map
Definition: DescriptorManager.h:115
int16_t firstFreeIndex
Definition: DescriptorManager.h:113
Definition: DescriptorManager.h:133
size_t operator()(const SingleTypeCacheKey &key) const
Definition: DescriptorManager.cpp:211
Definition: DescriptorManager.h:123
VkDescriptorType type
Definition: DescriptorManager.h:124
int16_t elementIndex
Definition: DescriptorManager.h:126
uint32_t version
Definition: DescriptorManager.h:125
uint8_t size
Definition: DescriptorManager.h:127
Definition: DescriptorManager.h:84
uint32_t version
Definition: DescriptorManager.h:86
VkDescriptorSet set
Definition: DescriptorManager.h:85
int16_t nextFreeIndex
Definition: DescriptorManager.h:87
Definition: DescriptorManager.h:78
static constexpr int16_t INVALID_INDEX
Definition: DescriptorManager.h:82
int16_t firstFreeIndex
Definition: DescriptorManager.h:81
VkDescriptorPool pool
Definition: DescriptorManager.h:80
std::vector< Element > elements
Definition: DescriptorManager.h:89
VkDescriptorSetLayout layout
Definition: DescriptorManager.h:79
unsigned int uint32_t
Definition: wposix_types.h:53
short int16_t
Definition: wposix_types.h:38
unsigned char uint8_t
Definition: wposix_types.h:51
pthread_key_t key
Definition: wpthread.cpp:140