optimized MaterialDescriptorSets
This commit is contained in:
@@ -9,16 +9,14 @@ class MaterialDescriptorSets
|
|||||||
{
|
{
|
||||||
UTF8String mtl_name;
|
UTF8String mtl_name;
|
||||||
|
|
||||||
//ShaderDescriptorList sd_list_by_set_type[DESCRIPTOR_SET_TYPE_COUNT];
|
|
||||||
bool set_has_desc[DESCRIPTOR_SET_TYPE_COUNT];
|
bool set_has_desc[DESCRIPTOR_SET_TYPE_COUNT];
|
||||||
|
|
||||||
// Map<AnsiString,ShaderDescriptor *> sd_by_name;
|
|
||||||
Map<AnsiString,int> binding_map[VK_DESCRIPTOR_TYPE_RANGE_SIZE];
|
Map<AnsiString,int> binding_map[VK_DESCRIPTOR_TYPE_RANGE_SIZE];
|
||||||
|
|
||||||
// int *binding_list[VK_DESCRIPTOR_TYPE_RANGE_SIZE];
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
VkDescriptorSetLayoutBinding *all_dslb;
|
||||||
|
|
||||||
DescriptorSetLayoutCreateInfo dsl_ci[DESCRIPTOR_SET_TYPE_COUNT];
|
DescriptorSetLayoutCreateInfo dsl_ci[DESCRIPTOR_SET_TYPE_COUNT];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@@ -22,6 +22,8 @@ MaterialDescriptorSets::MaterialDescriptorSets(const UTF8String &name,ShaderDesc
|
|||||||
|
|
||||||
hgl_zero(set_has_desc);
|
hgl_zero(set_has_desc);
|
||||||
|
|
||||||
|
uint dslb_count=0;
|
||||||
|
|
||||||
{
|
{
|
||||||
ENUM_CLASS_FOR(DescriptorSetType,int,i)
|
ENUM_CLASS_FOR(DescriptorSetType,int,i)
|
||||||
{
|
{
|
||||||
@@ -38,59 +40,43 @@ MaterialDescriptorSets::MaterialDescriptorSets(const UTF8String &name,ShaderDesc
|
|||||||
&&sp->desc_type<=VK_DESCRIPTOR_TYPE_END_RANGE)
|
&&sp->desc_type<=VK_DESCRIPTOR_TYPE_END_RANGE)
|
||||||
sd_list_by_desc_type[(size_t)sp->desc_type].Add(sp);
|
sd_list_by_desc_type[(size_t)sp->desc_type].Add(sp);
|
||||||
|
|
||||||
// sd_by_name.Add(sp->name,sp);
|
|
||||||
binding_map[size_t(sp->desc_type)].Add(sp->name,sp->binding);
|
binding_map[size_t(sp->desc_type)].Add(sp->name,sp->binding);
|
||||||
|
|
||||||
++dsl_ci[size_t(sp->set_type)].bindingCount;
|
++dsl_ci[size_t(sp->set_type)].bindingCount;
|
||||||
|
|
||||||
//sd_list_by_set_type[size_t(sp->set_type)].Add(sp);
|
++dslb_count;
|
||||||
|
|
||||||
set_has_desc[size_t(sp->set_type)]=true;
|
set_has_desc[size_t(sp->set_type)]=true;
|
||||||
|
|
||||||
++sp;
|
++sp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
all_dslb=new VkDescriptorSetLayoutBinding[dslb_count];
|
||||||
|
|
||||||
VkDescriptorSetLayoutBinding *dsl_bind[DESCRIPTOR_SET_TYPE_COUNT];
|
VkDescriptorSetLayoutBinding *dsl_bind[DESCRIPTOR_SET_TYPE_COUNT];
|
||||||
|
VkDescriptorSetLayoutBinding *dslp=all_dslb;
|
||||||
|
|
||||||
{
|
{
|
||||||
ENUM_CLASS_FOR(DescriptorSetType,int,i)
|
ENUM_CLASS_FOR(DescriptorSetType,int,i)
|
||||||
if(dsl_ci[i].bindingCount>0)
|
if(dsl_ci[i].bindingCount>0)
|
||||||
{
|
{
|
||||||
dsl_ci[i].pBindings=new VkDescriptorSetLayoutBinding[dsl_ci[i].bindingCount];
|
dsl_ci[i].pBindings=dslp;
|
||||||
dsl_bind[i]=(VkDescriptorSetLayoutBinding *)dsl_ci[i].pBindings;
|
dsl_bind[i]=dslp;
|
||||||
|
dslp+=dsl_ci[i].bindingCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
ShaderDescriptorList *sdl=sd_list_by_desc_type;
|
ShaderDescriptor *sp=sd_list;
|
||||||
ShaderDescriptor **sdp;
|
|
||||||
|
|
||||||
for(uint i=VK_DESCRIPTOR_TYPE_BEGIN_RANGE;
|
for(uint i=0;i<sd_count;i++)
|
||||||
i<=VK_DESCRIPTOR_TYPE_END_RANGE;i++)
|
|
||||||
{
|
{
|
||||||
if(sdl->GetCount()>0)
|
WriteDescriptorSetLayoutBinding(dsl_bind[size_t(sp->set_type)],sp);
|
||||||
{
|
|
||||||
// binding_list[i]=new int[sdl->GetCount()];
|
|
||||||
|
|
||||||
sdp=sdl->GetData();
|
++dsl_bind[size_t(sp->set_type)];
|
||||||
for(int j=0;j<sdl->GetCount();j++)
|
|
||||||
{
|
|
||||||
// binding_list[i][j]=(*sdp)->binding;
|
|
||||||
|
|
||||||
WriteDescriptorSetLayoutBinding(dsl_bind[size_t((*sdp)->set_type)],
|
++sp;
|
||||||
*sdp);
|
|
||||||
|
|
||||||
++dsl_bind[size_t((*sdp)->set_type)];
|
|
||||||
|
|
||||||
++sdp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//else
|
|
||||||
//{
|
|
||||||
// binding_list[i]=nullptr;
|
|
||||||
//}
|
|
||||||
|
|
||||||
++sdl;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -98,16 +84,7 @@ MaterialDescriptorSets::MaterialDescriptorSets(const UTF8String &name,ShaderDesc
|
|||||||
|
|
||||||
MaterialDescriptorSets::~MaterialDescriptorSets()
|
MaterialDescriptorSets::~MaterialDescriptorSets()
|
||||||
{
|
{
|
||||||
ENUM_CLASS_FOR(DescriptorSetType,int,i)
|
delete[] all_dslb;
|
||||||
if(dsl_ci[i].bindingCount)
|
|
||||||
delete[] dsl_ci[i].pBindings;
|
|
||||||
|
|
||||||
//for(uint i=VK_DESCRIPTOR_TYPE_BEGIN_RANGE;
|
|
||||||
// i<=VK_DESCRIPTOR_TYPE_END_RANGE;i++)
|
|
||||||
//{
|
|
||||||
// if(binding_list[i])
|
|
||||||
// delete[] binding_list[i];
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const int MaterialDescriptorSets::GetBinding(const VkDescriptorType &desc_type,const AnsiString &name)const
|
const int MaterialDescriptorSets::GetBinding(const VkDescriptorType &desc_type,const AnsiString &name)const
|
||||||
|
Reference in New Issue
Block a user