supported multi DescriptorSets.

This commit is contained in:
2021-06-15 17:58:27 +08:00
parent e734acad00
commit 32d895136b
2 changed files with 21 additions and 4 deletions

View File

@@ -44,7 +44,12 @@ void DescriptorSetLayoutCreater::Bind(const ShaderDescriptorList *sd_list,VkDesc
p->stageFlags = stageFlags;
p->pImmutableSamplers = nullptr;
index_by_binding.Add(sd.binding,fin_count+old_count);
if(sd.name[0]=='r'
&&sd.name[1]=='i'
&&sd.name[2]=='_')
index_by_binding_ri.Add(sd.binding,fin_count+old_count);
else
index_by_binding.Add(sd.binding,fin_count+old_count);
++p;
++fin_count;
@@ -91,7 +96,7 @@ bool DescriptorSetLayoutCreater::CreatePipelineLayout()
return(true);
}
DescriptorSets *DescriptorSetLayoutCreater::Create()
DescriptorSets *DescriptorSetLayoutCreater::Create(const DescriptorSetType &type)
{
if(!pipeline_layout||!dsl)
return(nullptr);
@@ -112,6 +117,12 @@ DescriptorSets *DescriptorSetLayoutCreater::Create()
if(vkAllocateDescriptorSets(device,&alloc_info,&desc_set)!=VK_SUCCESS)
return(nullptr);
return(new DescriptorSets(device,count,pipeline_layout,desc_set,&index_by_binding));
if(type==DescriptorSetType::Material)
return(new DescriptorSets(device,count,pipeline_layout,desc_set,&index_by_binding));
else
if(type==DescriptorSetType::Renderable)
return(new DescriptorSets(device,count,pipeline_layout,desc_set,&index_by_binding_ri));
else
return(nullptr);
}
VK_NAMESPACE_END

View File

@@ -6,6 +6,12 @@
VK_NAMESPACE_BEGIN
class DescriptorSets;
enum class DescriptorSetType
{
Material=0,
Renderable,
};//
/**
* 描述符合集创造器
*/
@@ -65,6 +71,6 @@ public:
const VkPipelineLayout GetPipelineLayout()const{return pipeline_layout;}
DescriptorSets *Create();
DescriptorSets *Create(const DescriptorSetType &type=DescriptorSetType::Material);
};//class DescriptorSetLayoutCreater
VK_NAMESPACE_END