3#include <vulkan/vulkan.hpp>
22 vk::DescriptorType type_,
23 vk::ShaderStageFlags stages_,
44 vk::ShaderStageFlags stages, uint32_t
count = 1)
49 void add_storage_buffer(uint32_t binding, vk::ShaderStageFlags stages = vk::ShaderStageFlagBits::eCompute)
51 add_binding(binding, vk::DescriptorType::eStorageBuffer, stages);
54 void add_uniform_buffer(uint32_t binding, vk::ShaderStageFlags stages = vk::ShaderStageFlagBits::eCompute)
56 add_binding(binding, vk::DescriptorType::eUniformBuffer, stages);
59 void add_storage_image(uint32_t binding, vk::ShaderStageFlags stages = vk::ShaderStageFlagBits::eCompute)
61 add_binding(binding, vk::DescriptorType::eStorageImage, stages);
64 void add_sampled_image(uint32_t binding, vk::ShaderStageFlags stages = vk::ShaderStageFlagBits::eCompute)
66 add_binding(binding, vk::DescriptorType::eCombinedImageSampler, stages);
87 vk::DeviceSize range = VK_WHOLE_SIZE);
90 vk::ImageView image_view,
91 vk::ImageLayout layout = vk::ImageLayout::eGeneral);
94 vk::ImageView image_view,
96 vk::ImageLayout layout = vk::ImageLayout::eShaderReadOnlyOptimal);
158 void cleanup(vk::Device
device);
175 vk::DescriptorSetLayout create_layout(
190 vk::DescriptorSet allocate_set(
192 vk::DescriptorSetLayout layout);
212 vk::DescriptorSet set,
215 vk::DeviceSize
offset = 0,
216 vk::DeviceSize range = VK_WHOLE_SIZE);
233 vk::DescriptorSet set,
235 vk::ImageView image_view,
236 vk::Sampler sampler =
nullptr,
237 vk::ImageLayout layout = vk::ImageLayout::eGeneral);
250 vk::DescriptorSet set,
252 vk::Sampler sampler);
265 void update_combined_image_sampler(
267 vk::DescriptorSet set,
269 vk::ImageView image_view,
271 vk::ImageLayout layout = vk::ImageLayout::eShaderReadOnlyOptimal);
283 void update_input_attachment(
285 vk::DescriptorSet set,
287 vk::ImageView image_view,
288 vk::ImageLayout layout = vk::ImageLayout::eShaderReadOnlyOptimal);
306 void copy_descriptor_set(
308 vk::DescriptorSet
src,
309 vk::DescriptorSet
dst,
310 uint32_t copy_count = 0);
320 std::vector<vk::DescriptorSet> allocate_sets(
322 const std::vector<vk::DescriptorSetLayout>& layouts);
334 const std::vector<vk::WriteDescriptorSet>& writes);
344 void reset_pools(vk::Device
device);
352 return { m_allocated_count, m_pool_capacity };
356 vk::Device m_device =
nullptr;
359 size_t m_current_pool_index = 0;
360 uint32_t m_pool_size = 1024;
361 uint32_t m_allocated_count = 0;
362 uint32_t m_pool_capacity = 0;
380 vk::DescriptorPool create_pool(vk::Device
device, uint32_t max_sets);
387 bool grow_pools(vk::Device
device);
std::shared_ptr< NetworkGeometryBuffer > buffer
vk::PhysicalDevice device
vk::PhysicalDeviceType type
std::vector< vk::DescriptorBufferInfo > m_buffer_infos
std::vector< vk::WriteDescriptorSet > m_writes
std::vector< vk::DescriptorImageInfo > m_image_infos
Fluent interface for batching descriptor updates.
std::unordered_map< size_t, size_t > m_layout_cache
std::pair< uint32_t, uint32_t > get_pool_stats() const
Get current pool utilization.
VKDescriptorManager(const VKDescriptorManager &)=delete
VKDescriptorManager()=default
VKDescriptorManager & operator=(const VKDescriptorManager &)=delete
std::vector< vk::DescriptorPool > m_pools
std::vector< vk::DescriptorSetLayout > m_layouts
Manages descriptor pools, layouts, and set allocation.
vk::DescriptorType type
Type (storage buffer, uniform, etc.)
vk::ShaderStageFlags stage_flags
Which shader stages access this.
uint32_t count
Array size (1 for non-arrays)
uint32_t binding
Binding index within set.
DescriptorBinding(uint32_t binding_, vk::DescriptorType type_, vk::ShaderStageFlags stages_, uint32_t count_=1)
Describes a single descriptor binding in a set.
std::vector< DescriptorBinding > bindings
void add_sampled_image(uint32_t binding, vk::ShaderStageFlags stages=vk::ShaderStageFlagBits::eCompute)
void add_storage_image(uint32_t binding, vk::ShaderStageFlags stages=vk::ShaderStageFlagBits::eCompute)
void add_storage_buffer(uint32_t binding, vk::ShaderStageFlags stages=vk::ShaderStageFlagBits::eCompute)
void add_uniform_buffer(uint32_t binding, vk::ShaderStageFlags stages=vk::ShaderStageFlagBits::eCompute)
void add_binding(uint32_t binding, vk::DescriptorType type, vk::ShaderStageFlags stages, uint32_t count=1)
Configuration for creating a descriptor set layout.