Improved VKDescriptorBindingManage
This commit is contained in:
@@ -3,6 +3,27 @@
|
||||
#include<hgl/graph/VKMaterialInstance.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
void DescriptorBinding::BindUBO(MaterialParameters *mp,const BindingMap &binding_map)
|
||||
{
|
||||
DeviceBuffer* buf = nullptr;
|
||||
|
||||
if (binding_map.GetCount() > 0)
|
||||
{
|
||||
const auto* dp = binding_map.GetDataList();
|
||||
const uint count = binding_map.GetCount();
|
||||
|
||||
for (uint i = 0; i < count; i++)
|
||||
{
|
||||
buf = GetUBO((*dp)->key);
|
||||
|
||||
if (buf)
|
||||
mp->BindUBO((*dp)->value, buf, false);
|
||||
|
||||
++dp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool DescriptorBinding::Bind(Material *mtl)
|
||||
{
|
||||
if(!mtl)
|
||||
@@ -15,47 +36,13 @@ bool DescriptorBinding::Bind(Material *mtl)
|
||||
|
||||
const BindingMapArray &bma=mp->GetBindingMap();
|
||||
|
||||
const BindingMap &ubo_bm=bma[VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER];
|
||||
const BindingMap &ubo_dynamic_bm=bma[VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC];
|
||||
|
||||
// const BindingMap &ssbo_bm=bma[VK_DESCRIPTOR_TYPE_STORAGE_BUFFER];
|
||||
// const BindingMap &ssbo_dynamic_bm=bma[VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC];
|
||||
|
||||
// const BindingMap &texture_bm=bma[VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER];
|
||||
|
||||
DeviceBuffer *buf=nullptr;
|
||||
|
||||
if(ubo_bm.GetCount()>0)
|
||||
{
|
||||
const auto *dp=ubo_bm.GetDataList();
|
||||
const uint count=ubo_bm.GetCount();
|
||||
|
||||
for(uint i=0;i<count;i++)
|
||||
{
|
||||
buf=GetUBO((*dp)->key);
|
||||
|
||||
if(buf)
|
||||
mp->BindUBO((*dp)->value,buf,false);
|
||||
|
||||
++dp;
|
||||
}
|
||||
}
|
||||
|
||||
if(ubo_dynamic_bm.GetCount()>0)
|
||||
{
|
||||
const auto *dp=ubo_dynamic_bm.GetDataList();
|
||||
const uint count=ubo_dynamic_bm.GetCount();
|
||||
|
||||
for(uint i=0;i<count;i++)
|
||||
{
|
||||
buf=GetUBO((*dp)->key);
|
||||
|
||||
if(buf)
|
||||
mp->BindUBO((*dp)->value,buf,true);
|
||||
|
||||
++dp;
|
||||
}
|
||||
}
|
||||
BindUBO(mp,bma[VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER]);
|
||||
BindUBO(mp,bma[VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC]);
|
||||
|
||||
mp->Update();
|
||||
return(true);
|
||||
|
Reference in New Issue
Block a user