used DescriptorBinding in Global Binding
This commit is contained in:
91
inc/hgl/graph/VKDescriptorBindingManage.h
Normal file
91
inc/hgl/graph/VKDescriptorBindingManage.h
Normal file
@@ -0,0 +1,91 @@
|
||||
#ifndef HGL_GRAPH_DESCRIPTOR_BINDING_MANAGE_INCLUDE
|
||||
#define HGL_GRAPH_DESCRIPTOR_BINDING_MANAGE_INCLUDE
|
||||
|
||||
#include<hgl/type/Map.h>
|
||||
namespace hgl
|
||||
{
|
||||
namespace graph
|
||||
{
|
||||
class DeviceBuffer;
|
||||
class Texture;
|
||||
class MaterialParameters;
|
||||
|
||||
class DescriptorBinding
|
||||
{
|
||||
Map<AnsiString,DeviceBuffer *> ubo_map;
|
||||
Map<AnsiString,DeviceBuffer *> ssbo_map;
|
||||
Map<AnsiString,Texture *> texture_map;
|
||||
|
||||
public:
|
||||
|
||||
bool AddUBO(const AnsiString &name,DeviceBuffer *buf)
|
||||
{
|
||||
if(!buf)return(false);
|
||||
if(name.IsEmpty())return(false);
|
||||
|
||||
return ubo_map.Add(name,buf);
|
||||
}
|
||||
|
||||
DeviceBuffer *GetUBO(const AnsiString &name)
|
||||
{
|
||||
if(name.IsEmpty())return(nullptr);
|
||||
|
||||
return GetListObject(ubo_map,name);
|
||||
}
|
||||
|
||||
void RemoveUBO(DeviceBuffer *buf)
|
||||
{
|
||||
if(!buf)return;
|
||||
|
||||
ubo_map.DeleteByValue(buf);
|
||||
}
|
||||
|
||||
bool AddSSBO(const AnsiString &name,DeviceBuffer *buf)
|
||||
{
|
||||
if(!buf)return(false);
|
||||
if(name.IsEmpty())return(false);
|
||||
|
||||
return ssbo_map.Add(name,buf);
|
||||
}
|
||||
|
||||
DeviceBuffer *GetSSBO(const AnsiString &name)
|
||||
{
|
||||
if(name.IsEmpty())return(nullptr);
|
||||
|
||||
return GetListObject(ssbo_map,name);
|
||||
}
|
||||
|
||||
void RemoveSSBO(DeviceBuffer *buf)
|
||||
{
|
||||
if(!buf)return;
|
||||
|
||||
ssbo_map.DeleteByValue(buf);
|
||||
}
|
||||
|
||||
bool AddTexture(const AnsiString &name,Texture *tex)
|
||||
{
|
||||
if(!tex)return(false);
|
||||
if(name.IsEmpty())return(false);
|
||||
|
||||
return texture_map.Add(name,tex);
|
||||
}
|
||||
|
||||
Texture *GetTexture(const AnsiString &name)
|
||||
{
|
||||
if(name.IsEmpty())return(nullptr);
|
||||
|
||||
return GetListObject(texture_map,name);
|
||||
}
|
||||
|
||||
void RemoveTexture(Texture *tex)
|
||||
{
|
||||
if(!tex)return;
|
||||
|
||||
texture_map.DeleteByValue(tex);
|
||||
}
|
||||
|
||||
bool Bind(MaterialParameters *);
|
||||
};//class DescriptorBinding
|
||||
}//namespace graph
|
||||
}//namespace hgl
|
||||
#endif//HGL_GRAPH_DESCRIPTOR_BINDING_MANAGE_INCLUDE
|
@@ -15,6 +15,8 @@
|
||||
#include<hgl/graph/font/TextPrimitive.h>
|
||||
#include<hgl/type/ResManage.h>
|
||||
#include<hgl/shadergen/MaterialCreateInfo.h>
|
||||
#include<hgl/graph/VKDescriptorBindingManage.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
using MaterialID =int;
|
||||
using MaterialInstanceID =int;
|
||||
@@ -47,8 +49,7 @@ class RenderResource
|
||||
IDResManage<TextureID, Texture> rm_textures; ///<纹理合集
|
||||
IDResManage<RenderableID, Renderable> rm_renderables; ///<渲染实例集合集
|
||||
|
||||
Map<AnsiString,DeviceBuffer *> global_buffer_map; ///<全局Buffer(UBO/SSBO)
|
||||
Map<AnsiString,Texture *> global_texture_map; ///<全局Texture
|
||||
DescriptorBinding global_binding; ///<全局属性描述符绑定管理
|
||||
|
||||
public:
|
||||
|
||||
@@ -68,13 +69,10 @@ public: //Add
|
||||
|
||||
public: //全局属性(对应shader中的PerGlobal set合集)
|
||||
|
||||
void SetGlobal(const AnsiString &name,DeviceBuffer *buf);
|
||||
void AddGlobalUBO(const AnsiString &name,DeviceBuffer *buf){global_binding.AddUBO(name,buf);}
|
||||
void AddGlobalSSBO(const AnsiString &name,DeviceBuffer *buf){global_binding.AddSSBO(name,buf);}
|
||||
|
||||
DeviceBuffer *GetGlobal(const AnsiString &name);
|
||||
|
||||
void Free(DeviceBuffer *);
|
||||
|
||||
void BindGlobalDescriptor(MaterialInstance *);
|
||||
bool BindGlobal(MaterialInstance *mi){return global_binding.Bind(mi->GetMP(DescriptorSetType::Global));}
|
||||
|
||||
public: // VBO/VAO
|
||||
|
||||
|
Reference in New Issue
Block a user