yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
f65d756bf
master
1// vk-descriptor-allocator.h 2 3#pragma once 4 5#include "core/slang-list.h" 6#include "vk-api.h" 7 8namespace gfx 9{ 10struct VulkanDescriptorSet 11{ 12VkDescriptorSet handle ; 13VkDescriptorPool pool ; 14}; 15class DescriptorSetAllocator 16{ 17public : 18Slang ::List < VkDescriptorPool > pools ; 19const VulkanApi * m_api ; 20VkDescriptorPool newPool (); 21VkDescriptorPool getPool () 22 { 23if (pools .getCount ()) 24return pools .getLast (); 25return newPool (); 26 } 27VulkanDescriptorSet allocate (VkDescriptorSetLayout layout ); 28void free (VulkanDescriptorSet set ) 29 { 30m_api -> vkFreeDescriptorSets (m_api -> m_device ,set .pool ,1 ,& set .handle ); 31 } 32void reset () 33 { 34for (autopool :pools ) 35m_api -> vkResetDescriptorPool (m_api -> m_device ,pool ,0 ); 36 } 37void close () 38 { 39for (autopool :pools ) 40m_api -> vkDestroyDescriptorPool (m_api -> m_device ,pool ,nullptr ); 41 } 42}; 43}// namespace gfx