2023-03-03 23:02:40 +08:00
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include<hgl/type/Map.h>
|
2023-03-09 23:21:52 +08:00
|
|
|
|
#include<hgl/type/StringList.h>
|
2023-03-03 23:02:40 +08:00
|
|
|
|
#include<hgl/graph/VKShaderStage.h>
|
|
|
|
|
#include<hgl/graph/VKDescriptorSetType.h>
|
2023-03-17 10:14:07 +08:00
|
|
|
|
#include<hgl/shadergen/MaterialDescriptorInfo.h>
|
2023-03-03 23:02:40 +08:00
|
|
|
|
|
2023-03-21 18:05:48 +08:00
|
|
|
|
namespace hgl{namespace graph
|
|
|
|
|
{
|
2023-03-15 11:32:38 +08:00
|
|
|
|
using UBODescriptorList=List<const UBODescriptor *>;
|
|
|
|
|
using SamplerDescriptorList=List<const SamplerDescriptor *>;
|
|
|
|
|
using ConstValueDescriptorList=ObjectList<ConstValueDescriptor>;
|
|
|
|
|
using SubpassInputDescriptorList=ObjectList<SubpassInputDescriptor>;
|
2023-03-04 05:11:51 +08:00
|
|
|
|
|
2023-03-03 23:02:40 +08:00
|
|
|
|
/**
|
|
|
|
|
* Shader数据管理器,用于生成正式Shader前的资源统计
|
|
|
|
|
*/
|
2023-03-17 10:14:07 +08:00
|
|
|
|
class ShaderDescriptorInfo
|
2023-03-03 23:02:40 +08:00
|
|
|
|
{
|
2023-03-17 16:06:11 +08:00
|
|
|
|
VkShaderStageFlagBits stage_flag;
|
2023-03-08 21:41:57 +08:00
|
|
|
|
|
2023-03-03 23:02:40 +08:00
|
|
|
|
ShaderStageIO stage_io;
|
2023-03-14 22:22:35 +08:00
|
|
|
|
|
2023-03-09 23:21:52 +08:00
|
|
|
|
AnsiStringList struct_list; //用到的结构列表
|
|
|
|
|
|
2023-03-17 21:06:05 +08:00
|
|
|
|
//ubo/object在这里以及MaterialDescriptorInfo中均有一份,mdi中的用于产生set/binding号,这里的用于产生shader
|
2023-03-15 11:32:38 +08:00
|
|
|
|
UBODescriptorList ubo_list;
|
|
|
|
|
SamplerDescriptorList sampler_list;
|
2023-03-03 23:02:40 +08:00
|
|
|
|
|
2023-03-15 11:32:38 +08:00
|
|
|
|
ConstValueDescriptorList const_value_list;
|
|
|
|
|
SubpassInputDescriptorList subpass_input;
|
2023-03-03 23:02:40 +08:00
|
|
|
|
|
|
|
|
|
ShaderPushConstant push_constant;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
2023-03-17 10:14:07 +08:00
|
|
|
|
ShaderDescriptorInfo(VkShaderStageFlagBits);
|
|
|
|
|
~ShaderDescriptorInfo()=default;
|
2023-03-03 23:02:40 +08:00
|
|
|
|
|
2023-03-17 16:06:11 +08:00
|
|
|
|
const VkShaderStageFlagBits GetStageFlag()const { return stage_flag; }
|
|
|
|
|
const AnsiString GetStageName()const { return AnsiString(GetShaderStageName(stage_flag)); }
|
2023-03-14 22:22:35 +08:00
|
|
|
|
|
2023-03-03 23:02:40 +08:00
|
|
|
|
public:
|
|
|
|
|
|
2023-03-15 11:32:38 +08:00
|
|
|
|
const ShaderStageIO & GetShaderStageIO()const{return stage_io;}
|
2023-03-03 23:02:40 +08:00
|
|
|
|
|
2023-03-15 11:32:38 +08:00
|
|
|
|
const AnsiStringList & GetStructList()const{return struct_list;}
|
2023-03-09 23:21:52 +08:00
|
|
|
|
|
2023-03-15 11:32:38 +08:00
|
|
|
|
const UBODescriptorList & GetUBOList()const{return ubo_list;}
|
|
|
|
|
const SamplerDescriptorList & GetSamplerList()const{return sampler_list;}
|
2023-03-03 23:02:40 +08:00
|
|
|
|
|
2023-03-15 11:32:38 +08:00
|
|
|
|
const ConstValueDescriptorList & GetConstList()const{return const_value_list;}
|
2023-03-03 23:02:40 +08:00
|
|
|
|
|
2023-03-15 11:32:38 +08:00
|
|
|
|
const SubpassInputDescriptorList & GetSubpassInputList()const{return subpass_input;}
|
2023-03-14 22:22:35 +08:00
|
|
|
|
|
2023-03-03 23:02:40 +08:00
|
|
|
|
public:
|
|
|
|
|
|
2023-03-17 16:06:11 +08:00
|
|
|
|
bool AddInput(ShaderAttribute *);
|
|
|
|
|
bool AddOutput(ShaderAttribute *);
|
2023-03-03 23:02:40 +08:00
|
|
|
|
|
2023-03-04 05:11:51 +08:00
|
|
|
|
bool AddUBO(DescriptorSetType type,const UBODescriptor *sd);
|
|
|
|
|
bool AddSampler(DescriptorSetType type,const SamplerDescriptor *sd);
|
2023-03-03 23:02:40 +08:00
|
|
|
|
|
|
|
|
|
bool AddConstValue(ConstValueDescriptor *sd);
|
|
|
|
|
bool AddSubpassInput(const AnsiString name,uint8_t index);
|
|
|
|
|
|
|
|
|
|
void SetPushConstant(const AnsiString name,uint8_t offset,uint8_t size);
|
|
|
|
|
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
|
void DebugOutput(int);
|
|
|
|
|
#endif//_DEBUG
|
2023-03-17 10:14:07 +08:00
|
|
|
|
};//class ShaderDescriptorInfo
|
2023-03-21 18:05:48 +08:00
|
|
|
|
}}//namespace hgl::graph
|