2019-05-05 21:30:55 +08:00
|
|
|
|
#pragma once
|
|
|
|
|
|
2020-11-30 17:56:40 +08:00
|
|
|
|
#include<hgl/graph/VK.h>
|
2020-06-09 19:40:08 +08:00
|
|
|
|
#include<hgl/graph/shader/ShaderResource.h>
|
|
|
|
|
#include<hgl/type/Map.h>
|
2021-06-21 20:49:25 +08:00
|
|
|
|
#include<hgl/type/Sets.h>
|
2019-05-05 21:30:55 +08:00
|
|
|
|
VK_NAMESPACE_BEGIN
|
|
|
|
|
class DescriptorSets;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 描述符合集创造器
|
|
|
|
|
*/
|
|
|
|
|
class DescriptorSetLayoutCreater
|
|
|
|
|
{
|
2020-09-19 23:49:32 +08:00
|
|
|
|
VkDevice device;
|
|
|
|
|
VkDescriptorPool pool;
|
2019-05-05 21:30:55 +08:00
|
|
|
|
|
2021-06-21 20:49:25 +08:00
|
|
|
|
Sets<uint32_t> all_set;
|
|
|
|
|
Sets<uint32_t> all_binding;
|
2021-06-15 21:19:28 +08:00
|
|
|
|
|
2021-06-21 20:49:25 +08:00
|
|
|
|
struct ShaderDescriptorSet
|
|
|
|
|
{
|
|
|
|
|
List<VkDescriptorSetLayoutBinding> binding_list;
|
|
|
|
|
VkDescriptorSetLayout layout;
|
|
|
|
|
};
|
|
|
|
|
|
2021-06-22 14:48:08 +08:00
|
|
|
|
ShaderDescriptorSet sds[size_t(DescriptorSetType::RANGE_SIZE)];
|
2021-06-21 20:49:25 +08:00
|
|
|
|
|
2021-06-22 14:48:08 +08:00
|
|
|
|
VkDescriptorSetLayout fin_dsl[size_t(DescriptorSetType::RANGE_SIZE)];
|
2021-06-21 20:49:25 +08:00
|
|
|
|
uint32_t fin_dsl_count;
|
2019-05-05 21:30:55 +08:00
|
|
|
|
|
2019-07-06 16:46:19 +08:00
|
|
|
|
VkPipelineLayout pipeline_layout=VK_NULL_HANDLE;
|
2019-05-05 21:30:55 +08:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
2021-06-21 20:49:25 +08:00
|
|
|
|
DescriptorSetLayoutCreater(VkDevice dev,VkDescriptorPool dp)
|
|
|
|
|
{
|
2021-06-22 14:48:08 +08:00
|
|
|
|
ENUM_CLASS_FOR(DescriptorSetType,int,i)
|
2021-06-21 20:49:25 +08:00
|
|
|
|
sds[i].layout=nullptr;
|
|
|
|
|
|
|
|
|
|
hgl_zero(fin_dsl);
|
|
|
|
|
fin_dsl_count=0;
|
|
|
|
|
device=dev;pool=dp;
|
|
|
|
|
}
|
2019-05-05 21:30:55 +08:00
|
|
|
|
~DescriptorSetLayoutCreater();
|
|
|
|
|
|
2021-06-15 17:43:06 +08:00
|
|
|
|
void Bind(const ShaderDescriptorList *sd_list,VkDescriptorType type,VkShaderStageFlagBits stage);
|
2020-06-09 19:40:08 +08:00
|
|
|
|
|
|
|
|
|
void Bind(const ShaderDescriptorList *sdl,VkShaderStageFlagBits stage)
|
2019-05-06 22:33:21 +08:00
|
|
|
|
{
|
|
|
|
|
for(uint32_t i=VK_DESCRIPTOR_TYPE_BEGIN_RANGE;i<=VK_DESCRIPTOR_TYPE_END_RANGE;i++)
|
2019-05-20 17:52:23 +08:00
|
|
|
|
{
|
2021-06-15 17:43:06 +08:00
|
|
|
|
if(sdl->GetCount()>0)
|
|
|
|
|
Bind(sdl,(VkDescriptorType)i,stage);
|
2020-06-09 19:40:08 +08:00
|
|
|
|
|
|
|
|
|
++sdl;
|
2019-05-20 17:52:23 +08:00
|
|
|
|
}
|
2019-05-06 22:33:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-05-19 13:02:35 +08:00
|
|
|
|
//以下代码不再需要,使用一个void Bind(const ShaderResource &sr,VkShaderStageFlagBits stage)即可全部替代,而且更方便,但以此为提示
|
2019-05-06 22:33:21 +08:00
|
|
|
|
//
|
|
|
|
|
//#define DESC_SET_BIND_FUNC(name,vkname) void Bind##name(const uint32_t binding,VkShaderStageFlagBits stage_flag){Bind(binding,VK_DESCRIPTOR_TYPE_##vkname,stage_flag);} \
|
|
|
|
|
// void Bind##name(const uint32_t *binding,const uint32_t count,VkShaderStageFlagBits stage_flag){Bind(binding,count,VK_DESCRIPTOR_TYPE_##vkname,stage_flag);}
|
|
|
|
|
//
|
|
|
|
|
// DESC_SET_BIND_FUNC(Sampler, SAMPLER);
|
|
|
|
|
//
|
|
|
|
|
// DESC_SET_BIND_FUNC(CombinedImageSampler, COMBINED_IMAGE_SAMPLER);
|
|
|
|
|
// DESC_SET_BIND_FUNC(SampledImage, SAMPLED_IMAGE);
|
|
|
|
|
// DESC_SET_BIND_FUNC(StorageImage, STORAGE_IMAGE);
|
|
|
|
|
//
|
|
|
|
|
// DESC_SET_BIND_FUNC(UTBO, UNIFORM_TEXEL_BUFFER);
|
|
|
|
|
// DESC_SET_BIND_FUNC(SSTBO, STORAGE_TEXEL_BUFFER);
|
|
|
|
|
// DESC_SET_BIND_FUNC(UBO, UNIFORM_BUFFER);
|
|
|
|
|
// DESC_SET_BIND_FUNC(SSBO, STORAGE_BUFFER);
|
|
|
|
|
// DESC_SET_BIND_FUNC(UBODynamic, UNIFORM_BUFFER_DYNAMIC);
|
|
|
|
|
// DESC_SET_BIND_FUNC(SSBODynamic, STORAGE_BUFFER_DYNAMIC);
|
|
|
|
|
//
|
|
|
|
|
// DESC_SET_BIND_FUNC(InputAttachment, INPUT_ATTACHMENT);
|
|
|
|
|
//
|
|
|
|
|
//#undef DESC_SET_BIND_FUNC
|
2019-05-05 21:30:55 +08:00
|
|
|
|
|
|
|
|
|
bool CreatePipelineLayout();
|
|
|
|
|
|
|
|
|
|
const VkPipelineLayout GetPipelineLayout()const{return pipeline_layout;}
|
|
|
|
|
|
2021-06-22 14:48:08 +08:00
|
|
|
|
DescriptorSets *Create(const DescriptorSetType &type)const;
|
2019-05-05 21:30:55 +08:00
|
|
|
|
};//class DescriptorSetLayoutCreater
|
|
|
|
|
VK_NAMESPACE_END
|