增加DescriptorPool创建

This commit is contained in:
HuYingzhuo 2019-04-12 16:35:44 +08:00
parent 7461b7edf3
commit f80a4ecf54
3 changed files with 37 additions and 0 deletions

View File

@ -130,6 +130,9 @@ RenderSurfaceAttribute::RenderSurfaceAttribute(VkInstance inst,VkPhysicalDevice
RenderSurfaceAttribute::~RenderSurfaceAttribute()
{
if(desc_pool)
vkDestroyDescriptorPool(device,desc_pool,nullptr);
if(depth.view)
vkDestroyImageView(device,depth.view,nullptr);

View File

@ -47,6 +47,8 @@ struct RenderSurfaceAttribute
VkImageView view =nullptr;
}depth;
VkDescriptorPool desc_pool =nullptr;
public:
RenderSurfaceAttribute(VkInstance inst,VkPhysicalDevice pd,VkSurfaceKHR s);

View File

@ -259,6 +259,33 @@ namespace
return(true);
}
VkDescriptorPool CreateDescriptorPool(VkDevice device,int sets_count)
{
constexpr size_t DESC_POOL_COUNT=1;
VkDescriptorPoolSize pool_size[DESC_POOL_COUNT];
for(size_t i=0;i<DESC_POOL_COUNT;i++)
{
pool_size[i].type=VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
pool_size[i].descriptorCount=1;
}
VkDescriptorPoolCreateInfo dp_create_info={};
dp_create_info.sType=VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
dp_create_info.pNext=NULL;
dp_create_info.maxSets=sets_count;
dp_create_info.poolSizeCount=DESC_POOL_COUNT;
dp_create_info.pPoolSizes=pool_size;
VkDescriptorPool desc_pool;
if(!vkCreateDescriptorPool(device,&dp_create_info,nullptr,&desc_pool))
return(nullptr);
return desc_pool;
}
}//namespace
RenderSurface *CreateRenderSuface(VkInstance inst,VkPhysicalDevice physical_device,Window *win)
@ -296,6 +323,11 @@ RenderSurface *CreateRenderSuface(VkInstance inst,VkPhysicalDevice physical_devi
if(!CreateDepthBuffer(rsa))
return(nullptr);
rsa->desc_pool=CreateDescriptorPool(rsa->device,1);
if(!rsa->desc_pool)
return(nullptr);
return(new RenderSurface(rsa));
}
VK_NAMESPACE_END