2023-03-17 10:08:41 +08:00
|
|
|
#ifndef HGL_SHADER_CREATE_INFO_INCLUDE
|
|
|
|
#define HGL_SHADER_CREATE_INFO_INCLUDE
|
2023-03-06 14:06:20 +08:00
|
|
|
|
2023-03-15 11:09:51 +08:00
|
|
|
#include<hgl/graph/VertexAttrib.h>
|
2023-03-21 18:05:48 +08:00
|
|
|
#include<hgl/graph/VK.h>
|
2023-05-19 22:21:49 +08:00
|
|
|
#include<hgl/graph/VKInterpolation.h>
|
2023-05-06 22:19:50 +08:00
|
|
|
#include<hgl/type/StringList.h>
|
2023-03-19 20:17:02 +08:00
|
|
|
|
2023-03-21 18:05:48 +08:00
|
|
|
namespace hgl{namespace graph
|
2023-03-19 20:17:02 +08:00
|
|
|
{
|
2023-03-21 18:05:48 +08:00
|
|
|
struct SPVData;
|
2023-03-15 11:09:51 +08:00
|
|
|
|
2023-03-17 10:14:07 +08:00
|
|
|
class MaterialDescriptorInfo;
|
|
|
|
class ShaderDescriptorInfo;
|
2023-03-15 11:09:51 +08:00
|
|
|
|
2023-05-22 14:30:38 +08:00
|
|
|
struct UBODescriptor;
|
|
|
|
|
2023-03-17 10:08:41 +08:00
|
|
|
class ShaderCreateInfo
|
2023-03-06 14:06:20 +08:00
|
|
|
{
|
2023-03-09 23:21:52 +08:00
|
|
|
protected:
|
|
|
|
|
2023-03-06 14:06:20 +08:00
|
|
|
VkShaderStageFlagBits shader_stage; ///<着色器阶段
|
|
|
|
|
2023-03-22 15:58:59 +08:00
|
|
|
MaterialDescriptorInfo *mdi;
|
2023-03-09 23:21:52 +08:00
|
|
|
|
2023-03-06 14:06:20 +08:00
|
|
|
protected:
|
|
|
|
|
2023-06-02 20:45:19 +08:00
|
|
|
AnsiStringList define_macro_list;
|
|
|
|
AnsiStringList define_value_list;
|
|
|
|
uint32_t define_macro_max_length;
|
|
|
|
uint32_t define_value_max_length;
|
|
|
|
|
2023-03-08 21:41:57 +08:00
|
|
|
AnsiString output_struct;
|
|
|
|
|
2023-06-01 14:47:05 +08:00
|
|
|
AnsiString mi_codes;
|
|
|
|
|
2023-10-07 23:35:22 +08:00
|
|
|
List<const char *> function_list;
|
2023-05-31 20:14:13 +08:00
|
|
|
AnsiString main_function;
|
2023-05-06 22:19:50 +08:00
|
|
|
|
2023-03-08 21:41:57 +08:00
|
|
|
AnsiString final_shader;
|
|
|
|
|
2023-03-21 18:05:48 +08:00
|
|
|
SPVData *spv_data;
|
2023-03-19 20:17:02 +08:00
|
|
|
|
2023-03-08 21:41:57 +08:00
|
|
|
protected:
|
|
|
|
|
2023-03-09 23:21:52 +08:00
|
|
|
virtual bool ProcHeader(){return(true);}
|
2023-06-02 20:45:19 +08:00
|
|
|
|
|
|
|
virtual bool ProcDefine();
|
2023-09-21 22:11:20 +08:00
|
|
|
virtual bool ProcLayout(){return(true);}
|
2023-06-02 20:45:19 +08:00
|
|
|
|
2023-03-09 23:21:52 +08:00
|
|
|
virtual bool ProcSubpassInput();
|
2023-03-17 10:08:41 +08:00
|
|
|
virtual bool ProcInput(ShaderCreateInfo *);
|
2023-03-09 23:21:52 +08:00
|
|
|
virtual bool ProcOutput();
|
|
|
|
|
|
|
|
virtual bool ProcStruct();
|
|
|
|
|
2023-06-01 14:47:05 +08:00
|
|
|
virtual bool ProcMI();
|
|
|
|
|
2023-03-09 23:21:52 +08:00
|
|
|
virtual bool ProcUBO();
|
|
|
|
virtual bool ProcSSBO();
|
2023-09-21 22:11:20 +08:00
|
|
|
virtual bool ProcConstantID();
|
2023-03-10 02:15:26 +08:00
|
|
|
virtual bool ProcSampler();
|
2023-03-08 21:41:57 +08:00
|
|
|
|
2023-03-15 17:50:33 +08:00
|
|
|
bool CompileToSPV();
|
|
|
|
|
2023-03-06 14:06:20 +08:00
|
|
|
public:
|
|
|
|
|
2023-03-17 10:14:07 +08:00
|
|
|
ShaderDescriptorInfo *sdm;
|
2023-03-06 14:06:20 +08:00
|
|
|
|
|
|
|
VkShaderStageFlagBits GetShaderStage()const{return shader_stage;}
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2023-03-17 10:14:07 +08:00
|
|
|
ShaderCreateInfo(VkShaderStageFlagBits ss,MaterialDescriptorInfo *m);
|
2023-03-17 10:08:41 +08:00
|
|
|
virtual ~ShaderCreateInfo();
|
2023-03-06 14:06:20 +08:00
|
|
|
|
2023-06-02 20:45:19 +08:00
|
|
|
bool AddDefine(const AnsiString &m,const AnsiString &v);
|
|
|
|
|
2023-05-19 22:21:49 +08:00
|
|
|
int AddOutput(const graph::VAT &type,const AnsiString &name,Interpolation inter=Interpolation::Smooth);
|
|
|
|
int AddOutput(const AnsiString &type,const AnsiString &name,Interpolation inter=Interpolation::Smooth);
|
2023-03-06 14:06:20 +08:00
|
|
|
|
2023-10-07 23:35:22 +08:00
|
|
|
void AddFunction(const char *str){function_list.Add(str);}
|
2023-03-06 21:30:32 +08:00
|
|
|
|
2023-06-01 14:47:05 +08:00
|
|
|
void SetMaterialInstance(UBODescriptor *,const AnsiString &);
|
2023-10-07 23:35:22 +08:00
|
|
|
void AddMaterialInstanceOutput();
|
|
|
|
|
2023-05-31 20:14:13 +08:00
|
|
|
void SetMain(const AnsiString &str){main_function=str;}
|
2023-10-10 02:48:02 +08:00
|
|
|
void SetMain(const char *str,const int len)
|
|
|
|
{
|
|
|
|
main_function.SetString(str,len);
|
|
|
|
}
|
2023-05-31 20:14:13 +08:00
|
|
|
|
2023-03-08 21:41:57 +08:00
|
|
|
const AnsiString &GetOutputStruct()const{return output_struct;}
|
2023-03-14 22:22:35 +08:00
|
|
|
const AnsiString &GetShaderSource()const{return final_shader;}
|
|
|
|
|
2023-03-17 10:08:41 +08:00
|
|
|
bool CreateShader(ShaderCreateInfo *);
|
2023-03-19 20:17:02 +08:00
|
|
|
|
2023-03-21 18:05:48 +08:00
|
|
|
const uint32 *GetSPVData()const;
|
2023-03-19 20:23:54 +08:00
|
|
|
const size_t GetSPVSize()const;
|
2023-03-17 10:08:41 +08:00
|
|
|
};//class ShaderCreateInfo
|
2023-03-21 18:05:48 +08:00
|
|
|
}}//namespace hgl::graph
|
2023-03-17 10:08:41 +08:00
|
|
|
#endif//HGL_SHADER_CREATE_INFO_INCLUDE
|