Improved VKDescriptorBindingManage
This commit is contained in:
parent
ff6a644e8f
commit
5f1c60a24a
2
CMUtil
2
CMUtil
@ -1 +1 @@
|
||||
Subproject commit d789bc24237c08028d53467d34a15fe18b92414e
|
||||
Subproject commit 953ecf8079845ddfd8d31d62c945c9a5206b2199
|
@ -26,7 +26,10 @@ constexpr size_t VK_DESCRIPTOR_TYPE_RANGE_SIZE=VK_DESCRIPTOR_TYPE_END_RANGE-VK_D
|
||||
#endif//VK_DESCRIPTOR_TYPE_RANGE_SIZE
|
||||
|
||||
using CharPointerList=hgl::List<const char *>;
|
||||
using BindingMapping=Map<uint32_t,int>;
|
||||
using BindingMapping =Map<uint32_t,int>;
|
||||
|
||||
using BindingMap =Map<AnsiString, int>;
|
||||
using BindingMapArray =BindingMap[VK_DESCRIPTOR_TYPE_RANGE_SIZE];
|
||||
|
||||
class VulkanInstance;
|
||||
class GPUPhysicalDevice;
|
||||
|
@ -1,8 +1,9 @@
|
||||
#ifndef HGL_GRAPH_DESCRIPTOR_BINDING_MANAGE_INCLUDE
|
||||
#ifndef HGL_GRAPH_DESCRIPTOR_BINDING_MANAGE_INCLUDE
|
||||
#define HGL_GRAPH_DESCRIPTOR_BINDING_MANAGE_INCLUDE
|
||||
|
||||
#include<hgl/type/Map.h>
|
||||
#include<hgl/type/String.h>
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/graph/VKDescriptorSetType.h>
|
||||
namespace hgl
|
||||
{
|
||||
@ -11,10 +12,15 @@ namespace hgl
|
||||
class DeviceBuffer;
|
||||
class Texture;
|
||||
class Material;
|
||||
class MaterialParameters;
|
||||
|
||||
/**
|
||||
* 描述符绑定器<Br>
|
||||
* 一般用于注册通用数据,为材质进行自动绑定。
|
||||
*/
|
||||
class DescriptorBinding
|
||||
{
|
||||
DescriptorSetType set_type;
|
||||
DescriptorSetType set_type; ///<描述符合集类型
|
||||
|
||||
Map<AnsiString,DeviceBuffer *> ubo_map;
|
||||
Map<AnsiString,DeviceBuffer *> ssbo_map;
|
||||
@ -93,6 +99,12 @@ namespace hgl
|
||||
texture_map.DeleteByValue(tex);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
void BindUBO(MaterialParameters *,const BindingMap &);
|
||||
|
||||
public:
|
||||
|
||||
bool Bind(Material *);
|
||||
};//class DescriptorBinding
|
||||
}//namespace graph
|
||||
|
@ -5,9 +5,6 @@
|
||||
#include<hgl/graph/VKShaderDescriptorSet.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
using BindingMap=Map<AnsiString,int>;
|
||||
using BindingMapArray=BindingMap[VK_DESCRIPTOR_TYPE_RANGE_SIZE];
|
||||
|
||||
class MaterialDescriptorManager
|
||||
{
|
||||
UTF8String mtl_name;
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user