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