2023-03-03 23:02:40 +08:00
|
|
|
|
#pragma once
|
|
|
|
|
|
2023-03-20 22:09:37 +08:00
|
|
|
|
#include<hgl/graph/VKShaderDescriptorSet.h>
|
2023-06-02 20:45:19 +08:00
|
|
|
|
#include<hgl/graph/mtl/ShaderBuffer.h>
|
2023-03-03 23:02:40 +08:00
|
|
|
|
#include<hgl/type/Map.h>
|
|
|
|
|
|
2023-03-21 18:05:48 +08:00
|
|
|
|
namespace hgl{namespace graph{
|
2023-03-03 23:02:40 +08:00
|
|
|
|
/**
|
|
|
|
|
* 材质描述符管理</p>
|
|
|
|
|
* 该类使用于SHADER生成前,用于统计编号set/binding
|
|
|
|
|
*/
|
2023-03-17 10:14:07 +08:00
|
|
|
|
class MaterialDescriptorInfo
|
2023-03-03 23:02:40 +08:00
|
|
|
|
{
|
2023-03-21 14:15:33 +08:00
|
|
|
|
uint descriptor_count;
|
2023-03-03 23:02:40 +08:00
|
|
|
|
ShaderDescriptorSetArray desc_set_array;
|
|
|
|
|
|
2023-03-09 23:21:52 +08:00
|
|
|
|
Map<AnsiString,AnsiString> struct_map;
|
2023-03-04 16:57:50 +08:00
|
|
|
|
Map<AnsiString,UBODescriptor *> ubo_map;
|
|
|
|
|
Map<AnsiString,SamplerDescriptor *> sampler_map;
|
2023-03-04 05:11:51 +08:00
|
|
|
|
|
2023-03-03 23:02:40 +08:00
|
|
|
|
public:
|
|
|
|
|
|
2023-03-17 10:14:07 +08:00
|
|
|
|
MaterialDescriptorInfo();
|
|
|
|
|
~MaterialDescriptorInfo()=default;
|
2023-03-03 23:02:40 +08:00
|
|
|
|
|
2023-03-09 23:21:52 +08:00
|
|
|
|
bool AddStruct(const AnsiString &name,const AnsiString &code)
|
2023-03-04 05:11:51 +08:00
|
|
|
|
{
|
2023-03-09 23:21:52 +08:00
|
|
|
|
struct_map.Add(name,code);
|
2023-03-04 05:11:51 +08:00
|
|
|
|
return(true);
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-02 20:45:19 +08:00
|
|
|
|
bool AddStruct(const ShaderBufferSource &ss)
|
|
|
|
|
{
|
|
|
|
|
return(AddStruct(ss.struct_name,ss.codes));
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-22 14:30:38 +08:00
|
|
|
|
bool GetStruct(const AnsiString &name,AnsiString &code)
|
2023-03-04 05:11:51 +08:00
|
|
|
|
{
|
2023-03-09 23:21:52 +08:00
|
|
|
|
return(struct_map.Get(name,code));
|
2023-03-04 05:11:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-03-09 23:21:52 +08:00
|
|
|
|
bool hasStruct(const AnsiString &name) const
|
2023-03-04 05:11:51 +08:00
|
|
|
|
{
|
2024-10-05 22:51:27 +08:00
|
|
|
|
return(struct_map.ContainsKey(name));
|
2023-03-04 05:11:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-05-22 14:30:38 +08:00
|
|
|
|
const UBODescriptor *AddUBO(uint32_t shader_stage_flag_bits,DescriptorSetType set_type,UBODescriptor *sd);
|
|
|
|
|
const SamplerDescriptor *AddSampler(uint32_t shader_stage_flag_bits,DescriptorSetType set_type,SamplerDescriptor *sd);
|
2023-03-03 23:02:40 +08:00
|
|
|
|
|
2023-03-04 16:57:50 +08:00
|
|
|
|
UBODescriptor *GetUBO(const AnsiString &name);
|
|
|
|
|
SamplerDescriptor *GetSampler(const AnsiString &name);
|
|
|
|
|
|
2023-03-03 23:02:40 +08:00
|
|
|
|
const DescriptorSetType GetSetType(const AnsiString &)const;
|
|
|
|
|
|
|
|
|
|
void Resort(); //排序产生set号与binding号
|
2023-03-20 13:35:04 +08:00
|
|
|
|
|
2023-03-21 14:15:33 +08:00
|
|
|
|
const uint GetCount()const
|
|
|
|
|
{
|
|
|
|
|
return descriptor_count;
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-20 22:09:37 +08:00
|
|
|
|
const ShaderDescriptorSetArray &Get()const
|
|
|
|
|
{
|
|
|
|
|
return desc_set_array;
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-20 13:35:04 +08:00
|
|
|
|
const bool hasSet(const DescriptorSetType &type)const
|
|
|
|
|
{
|
|
|
|
|
return desc_set_array[size_t(type)].count>0;
|
|
|
|
|
}
|
2023-03-21 18:05:48 +08:00
|
|
|
|
};//class MaterialDescriptorInfo
|
|
|
|
|
}}//namespace hgl::graph
|