2023-03-22 15:58:59 +08:00
|
|
|
|
#ifndef HGL_GRAPH_VULKAN_MATERIAL_PARAMETERS_INCLUDE
|
2021-06-16 10:41:04 +08:00
|
|
|
|
#define HGL_GRAPH_VULKAN_MATERIAL_PARAMETERS_INCLUDE
|
2020-01-20 15:39:39 +08:00
|
|
|
|
|
2020-10-21 11:43:18 +08:00
|
|
|
|
#include<hgl/graph/VK.h>
|
2020-09-05 17:54:21 +08:00
|
|
|
|
#include<hgl/type/String.h>
|
2023-02-13 11:50:55 +08:00
|
|
|
|
#include<hgl/graph/VKDescriptorSet.h>
|
2023-03-02 20:19:25 +08:00
|
|
|
|
#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
|
2021-06-16 10:41:04 +08:00
|
|
|
|
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
|
|
|
|
|
2023-02-23 12:31:42 +08:00
|
|
|
|
DescriptorSetType set_type;
|
2021-06-16 10:41:04 +08:00
|
|
|
|
|
2023-02-23 12:31:42 +08:00
|
|
|
|
DescriptorSet *descriptor_set;
|
2020-01-20 15:39:39 +08:00
|
|
|
|
|
2021-06-16 10:41:04 +08:00
|
|
|
|
public:
|
|
|
|
|
|
2023-02-23 12:31:42 +08:00
|
|
|
|
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);} ///<获取总共需要绑定的描述符数量
|
2023-03-25 23:11:43 +08:00
|
|
|
|
const BindingMapArray & GetBindingMap ()const{return desc_manager->GetBindingMap(set_type);}
|
2023-03-22 02:35:05 +08:00
|
|
|
|
|
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();} ///<是否全部绑好了
|
2021-09-27 20:55:27 +08:00
|
|
|
|
|
2020-01-20 15:39:39 +08:00
|
|
|
|
public:
|
|
|
|
|
|
2023-02-23 12:31:42 +08:00
|
|
|
|
#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)
|
2023-06-12 16:30:16 +08:00
|
|
|
|
MP_TYPE_IS(PerMaterial)
|
2023-02-22 21:50:18 +08:00
|
|
|
|
MP_TYPE_IS(PerFrame)
|
2021-06-16 10:41:04 +08:00
|
|
|
|
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 *);
|
2021-06-16 10:41:04 +08:00
|
|
|
|
virtual ~MaterialParameters();
|
2020-01-20 15:39:39 +08:00
|
|
|
|
|
2023-03-27 12:00:53 +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 *);
|
|
|
|
|
|
2022-10-14 17:52:35 +08:00
|
|
|
|
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);
|
2022-03-28 17:41:25 +08:00
|
|
|
|
bool BindInputAttachment(const AnsiString &name,ImageView *);
|
2020-01-20 15:39:39 +08:00
|
|
|
|
|
|
|
|
|
void Update();
|
2021-06-16 10:41:04 +08:00
|
|
|
|
};//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
|