ULRE/inc/hgl/graph/VKMaterialDescriptorSets.h

52 lines
1.7 KiB
C
Raw Normal View History

2021-09-13 20:39:25 +08:00
#ifndef HGL_GRAPH_VULKAN_MATERIAL_DESCRIPTOR_SETS_INCLUDE
#define HGL_GRAPH_VULKAN_MATERIAL_DESCRIPTOR_SETS_INCLUDE
#include<hgl/graph/VK.h>
VK_NAMESPACE_BEGIN
struct ShaderDescriptor
{
char name[128];
VkDescriptorType desc_type;
DescriptorSetType set_type;
uint32_t set;
uint32_t binding;
uint32_t stage_flag;
};
using ShaderDescriptorList=List<ShaderDescriptor *>;
class MaterialDescriptorSets
{
ShaderDescriptor *sd_list;
uint sd_count;
ShaderDescriptorList descriptor_list[VK_DESCRIPTOR_TYPE_RANGE_SIZE];
Map<AnsiString,ShaderDescriptor *> sd_by_name;
Map<AnsiString,int> binding_map[VK_DESCRIPTOR_TYPE_RANGE_SIZE];
int *binding_list[VK_DESCRIPTOR_TYPE_RANGE_SIZE];
private:
DescriptorSetLayoutCreateInfo sds[size_t(DescriptorSetType::RANGE_SIZE)];
2021-09-13 20:39:25 +08:00
public:
MaterialDescriptorSets(ShaderDescriptor *,const uint);
~MaterialDescriptorSets();
const int GetBinding(const VkDescriptorType &desc_type,const AnsiString &name)const;
const int GetUBO (const AnsiString &name,bool dynamic)const{return GetBinding(dynamic?VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,name);}
const int GetSSBO (const AnsiString &name,bool dynamic)const{return GetBinding(dynamic?VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,name);}
const int GetSampler (const AnsiString &name )const{return GetBinding(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, name);}
2021-09-13 20:39:25 +08:00
const DescriptorSetLayoutCreateInfo *GetBinding(const DescriptorSetType &type)const{return sds+size_t(type);}
2021-09-13 20:39:25 +08:00
};//class MaterialDescriptorSets
VK_NAMESPACE_END
#endif//HGL_GRAPH_VULKAN_MATERIAL_DESCRIPTOR_SETS_INCLUDE