#pragma once #include struct DescriptorLayoutBuilder { std::vector bindings; void add_binding(uint32_t binding, VkDescriptorType type, uint32_t count = 1); void clear(); VkDescriptorSetLayout build(VkDevice device, VkShaderStageFlags shaderStages, void *pNext = nullptr, VkDescriptorSetLayoutCreateFlags flags = 0); }; struct DescriptorWriter { std::deque imageInfos; std::deque bufferInfos; std::vector writes; void write_image(int binding, VkImageView image, VkSampler sampler, VkImageLayout layout, VkDescriptorType type); void write_buffer(int binding, VkBuffer buffer, size_t size, size_t offset, VkDescriptorType type); void clear(); void update_set(VkDevice device, VkDescriptorSet set); }; struct DescriptorAllocator { struct PoolSizeRatio { VkDescriptorType type; float ratio; }; VkDescriptorPool pool; void init_pool(VkDevice device, uint32_t maxSets, std::span poolRatios); void clear_descriptors(VkDevice device); void destroy_pool(VkDevice device); VkDescriptorSet allocate(VkDevice device, VkDescriptorSetLayout layout); }; struct DescriptorAllocatorGrowable { public: struct PoolSizeRatio { VkDescriptorType type; float ratio; }; void init(VkDevice device, uint32_t initialSets, std::span poolRatios); void clear_pools(VkDevice device); void destroy_pools(VkDevice device); VkDescriptorSet allocate(VkDevice device, VkDescriptorSetLayout layout, void *pNext = nullptr); private: VkDescriptorPool get_pool(VkDevice device); VkDescriptorPool create_pool(VkDevice device, uint32_t setCount, std::span poolRatios); std::vector ratios; std::vector fullPools; std::vector readyPools; uint32_t setsPerPool; };