2019-04-30 16:42:59 +08:00
|
|
|
|
#include<hgl/graph/vulkan/VKDescriptorSets.h>
|
|
|
|
|
#include<hgl/graph/vulkan/VKDevice.h>
|
2019-04-19 00:46:49 +08:00
|
|
|
|
|
|
|
|
|
VK_NAMESPACE_BEGIN
|
2019-05-06 21:11:10 +08:00
|
|
|
|
VkDescriptorSet DescriptorSets::GetDescriptorSet(const uint32_t binding)const
|
2019-04-19 00:46:49 +08:00
|
|
|
|
{
|
2019-04-28 21:25:52 +08:00
|
|
|
|
int index;
|
2019-04-19 00:46:49 +08:00
|
|
|
|
|
2019-05-06 21:11:10 +08:00
|
|
|
|
if(!index_by_binding->Get(binding,index))
|
2019-04-28 21:25:52 +08:00
|
|
|
|
return(nullptr);
|
2019-04-19 00:46:49 +08:00
|
|
|
|
|
2019-04-28 21:25:52 +08:00
|
|
|
|
return desc_set_list[index];
|
2019-04-23 02:46:47 +08:00
|
|
|
|
}
|
2019-04-19 00:46:49 +08:00
|
|
|
|
|
2019-05-05 21:30:55 +08:00
|
|
|
|
DescriptorSets::~DescriptorSets()
|
2019-04-23 02:46:47 +08:00
|
|
|
|
{
|
2019-04-28 21:25:52 +08:00
|
|
|
|
//if(count>0)
|
|
|
|
|
// vkFreeDescriptorSets(device->GetDevice(),device->GetDescriptorPool(),count,desc_set_list);
|
2019-04-23 02:46:47 +08:00
|
|
|
|
|
2019-04-28 21:25:52 +08:00
|
|
|
|
delete[] desc_set_list;
|
2019-04-19 00:46:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-05-05 21:30:55 +08:00
|
|
|
|
bool DescriptorSets::UpdateUBO(const uint32_t binding,const VkDescriptorBufferInfo *buf_info)
|
2019-04-19 00:46:49 +08:00
|
|
|
|
{
|
2019-05-05 21:30:55 +08:00
|
|
|
|
VkDescriptorSet set=GetDescriptorSet(binding);
|
2019-04-19 00:46:49 +08:00
|
|
|
|
|
2019-05-05 21:30:55 +08:00
|
|
|
|
VkWriteDescriptorSet writeDescriptorSet = {};
|
2019-04-28 16:06:53 +08:00
|
|
|
|
|
2019-05-05 21:30:55 +08:00
|
|
|
|
writeDescriptorSet.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
|
|
|
|
|
writeDescriptorSet.dstSet = set;
|
|
|
|
|
writeDescriptorSet.descriptorCount = 1;
|
|
|
|
|
writeDescriptorSet.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
|
|
|
|
|
writeDescriptorSet.pBufferInfo = buf_info;
|
|
|
|
|
writeDescriptorSet.dstBinding = binding;
|
2019-04-23 02:46:47 +08:00
|
|
|
|
|
2019-05-05 21:30:55 +08:00
|
|
|
|
vkUpdateDescriptorSets(*device,1,&writeDescriptorSet,0,nullptr);
|
|
|
|
|
return(true);
|
2019-04-19 00:46:49 +08:00
|
|
|
|
}
|
|
|
|
|
VK_NAMESPACE_END
|