ULRE/inc/hgl/graph/VKMaterialParameters.h

61 lines
2.4 KiB
C
Raw Normal View History

2023-03-22 15:58:59 +08:00
#ifndef HGL_GRAPH_VULKAN_MATERIAL_PARAMETERS_INCLUDE
#define HGL_GRAPH_VULKAN_MATERIAL_PARAMETERS_INCLUDE
2020-01-20 15:39:39 +08:00
#include<hgl/graph/VK.h>
2020-09-05 17:54:21 +08:00
#include<hgl/type/String.h>
#include<hgl/graph/VKDescriptorSet.h>
#include<hgl/graph/VKDescriptorSetType.h>
2023-03-22 21:40:49 +08:00
#include<hgl/graph/VKMaterialDescriptorManager.h>
#include<hgl/graph/VKArrayBuffer.h>
2020-01-20 15:39:39 +08:00
VK_NAMESPACE_BEGIN
class MaterialParameters
2020-01-20 15:39:39 +08:00
{
2023-03-22 21:40:49 +08:00
protected:
2023-03-21 21:46:16 +08:00
const MaterialDescriptorManager *desc_manager;
2020-01-20 15:39:39 +08:00
DescriptorSetType set_type;
DescriptorSet *descriptor_set;
2020-01-20 15:39:39 +08:00
public:
const DescriptorSetType GetType (){return set_type;}
DescriptorSet * GetDescriptorSet (){return descriptor_set;}
const VkDescriptorSet GetVkDescriptorSet ()const{return descriptor_set->GetDescriptorSet();}
2020-01-20 15:39:39 +08:00
2023-03-22 15:58:59 +08:00
const uint32_t GetDescriptorCount ()const{return desc_manager->GetBindCount(set_type);} ///<获取总共需要绑定的描述符数量
const BindingMapArray & GetBindingMap ()const{return desc_manager->GetBindingMap(set_type);}
2023-03-22 15:58:59 +08:00
const uint32_t GetBoundCount ()const{return descriptor_set->GetCount();} ///<获取已经绑好的数量
const bool IsReady ()const{return descriptor_set->IsReady();} ///<是否全部绑好了
2020-01-20 15:39:39 +08:00
public:
#define MP_TYPE_IS(name) const bool is##name()const{return set_type==DescriptorSetType::name;}
2023-02-22 21:50:18 +08:00
MP_TYPE_IS(Instance)
MP_TYPE_IS(PerMaterial)
2023-02-22 21:50:18 +08:00
MP_TYPE_IS(PerFrame)
MP_TYPE_IS(Global)
#undef MP_TYPE_IS
2020-01-20 15:39:39 +08:00
public:
2023-06-06 21:03:13 +08:00
MaterialParameters(const MaterialDescriptorManager *,const DescriptorSetType &type,DescriptorSet *);
virtual ~MaterialParameters();
2020-01-20 15:39:39 +08:00
bool BindUBO(const int &index,DeviceBuffer *ubo,bool dynamic=false);
bool BindSSBO(const int &index,DeviceBuffer *ubo,bool dynamic=false);
bool BindImageSampler(const int &index,Texture *tex,Sampler *sampler);
bool BindInputAttachment(const int &index,ImageView *);
bool BindUBO(const AnsiString &name,DeviceBuffer *ubo,bool dynamic=false);
bool BindSSBO(const AnsiString &name,DeviceBuffer *ubo,bool dynamic=false);
2023-02-23 13:25:05 +08:00
bool BindImageSampler(const AnsiString &name,Texture *tex,Sampler *sampler);
bool BindInputAttachment(const AnsiString &name,ImageView *);
2020-01-20 15:39:39 +08:00
void Update();
};//class MaterialParameters
2020-01-20 15:39:39 +08:00
VK_NAMESPACE_END
2023-03-22 15:58:59 +08:00
#endif//HGL_GRAPH_VULKAN_MATERIAL_PARAMETERS_INCLUDE