[WIP]
This commit is contained in:
parent
806bf5dfdd
commit
2f49e80122
@ -1 +1 @@
|
|||||||
Subproject commit 78b650ebfec0bbcbff948284ebf54344f8413275
|
Subproject commit b0955107a7d55ec050cb8cec2378ffbacd228096
|
@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include<hgl/type/String.h>
|
||||||
#include<hgl/graph/VertexAttrib.h>
|
#include<hgl/graph/VertexAttrib.h>
|
||||||
#include<hgl/graph/VKInterpolation.h>
|
#include<hgl/graph/VKInterpolation.h>
|
||||||
#include<hgl/graph/VKSamplerType.h>
|
#include<hgl/graph/VKSamplerType.h>
|
||||||
@ -242,6 +243,8 @@ namespace hgl
|
|||||||
|
|
||||||
const char *GetTypename()const;
|
const char *GetTypename()const;
|
||||||
|
|
||||||
|
bool ParseTypeString(const char *str);
|
||||||
|
|
||||||
const uint64 ToCode()const{return svt_code;}
|
const uint64 ToCode()const{return svt_code;}
|
||||||
const bool FromCode(const uint64 code)
|
const bool FromCode(const uint64 code)
|
||||||
{
|
{
|
||||||
@ -383,6 +386,10 @@ namespace hgl
|
|||||||
|
|
||||||
ShaderVariable *items;
|
ShaderVariable *items;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
const bool IsEmpty()const{return !items||count<=0;}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ShaderVariableArray()
|
ShaderVariableArray()
|
||||||
@ -510,6 +517,33 @@ namespace hgl
|
|||||||
hgl_cpy(items,src->items,src->count);
|
hgl_cpy(items,src->items,src->count);
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ToString(AnsiString &output_string)
|
||||||
|
{
|
||||||
|
if(IsEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
const ShaderVariable *sv=items;
|
||||||
|
|
||||||
|
for(uint i=0;i<count;i++)
|
||||||
|
{
|
||||||
|
output_string+=" ";
|
||||||
|
|
||||||
|
if(sv->interpolation!=Interpolation::Smooth)
|
||||||
|
{
|
||||||
|
output_string+=InterpolationName[size_t(sv->interpolation)];
|
||||||
|
|
||||||
|
output_string+=" ";
|
||||||
|
}
|
||||||
|
|
||||||
|
output_string+=sv->type.GetTypename();
|
||||||
|
output_string+=" ";
|
||||||
|
output_string+=sv->name;
|
||||||
|
output_string+=";\n";
|
||||||
|
|
||||||
|
++sv;
|
||||||
|
}
|
||||||
|
}
|
||||||
};//struct ShaderVariableArray
|
};//struct ShaderVariableArray
|
||||||
|
|
||||||
using SVArray=ShaderVariableArray;
|
using SVArray=ShaderVariableArray;
|
||||||
|
@ -52,6 +52,9 @@ protected:
|
|||||||
virtual bool ProcLayout(){return(true);}
|
virtual bool ProcLayout(){return(true);}
|
||||||
|
|
||||||
virtual bool ProcInput(ShaderCreateInfo *);
|
virtual bool ProcInput(ShaderCreateInfo *);
|
||||||
|
|
||||||
|
virtual bool IsEmptyOutput()const=0;
|
||||||
|
virtual void GetOutputStrcutString(AnsiString &){}
|
||||||
virtual bool ProcOutput();
|
virtual bool ProcOutput();
|
||||||
|
|
||||||
virtual bool ProcStruct();
|
virtual bool ProcStruct();
|
||||||
|
@ -11,8 +11,11 @@ class ShaderCreateInfoFragment:public ShaderCreateInfo
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
bool IsEmptyOutput()const override{return false;/*这个返回啥无所谓,因为Fragment Shader走自己的ProcOutput*/ }
|
||||||
bool ProcOutput() override;
|
bool ProcOutput() override;
|
||||||
|
|
||||||
|
void AddMaterialInstanceOutput() override{};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ShaderDescriptorInfo *GetSDI()override{return &fsdi;}
|
ShaderDescriptorInfo *GetSDI()override{return &fsdi;}
|
||||||
|
@ -14,6 +14,9 @@ class ShaderCreateInfoGeometry:public ShaderCreateInfo
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
bool IsEmptyOutput()const override{return gsdi.IsEmptyOutput();}
|
||||||
|
void GetOutputStrcutString(AnsiString &str) override;
|
||||||
|
|
||||||
ShaderDescriptorInfo *GetSDI()override{return &gsdi;}
|
ShaderDescriptorInfo *GetSDI()override{return &gsdi;}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -14,6 +14,9 @@ namespace hgl
|
|||||||
bool ProcSubpassInput();
|
bool ProcSubpassInput();
|
||||||
bool ProcInput(ShaderCreateInfo *) override;
|
bool ProcInput(ShaderCreateInfo *) override;
|
||||||
|
|
||||||
|
bool IsEmptyOutput()const override{return vsdi.IsEmptyOutput();}
|
||||||
|
void GetOutputStrcutString(AnsiString &str) override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ShaderDescriptorInfo *GetSDI()override{return &vsdi;}
|
ShaderDescriptorInfo *GetSDI()override{return &vsdi;}
|
||||||
|
@ -80,6 +80,9 @@ public:
|
|||||||
|
|
||||||
IArray &GetInput(){return input;}
|
IArray &GetInput(){return input;}
|
||||||
OArray &GetOutput(){return output;}
|
OArray &GetOutput(){return output;}
|
||||||
|
|
||||||
|
const bool IsEmptyInput()const{return input.IsEmpty();}
|
||||||
|
const bool IsEmptyOutput()const{return output.IsEmpty();}
|
||||||
};//class CustomShaderDescriptorInfo
|
};//class CustomShaderDescriptorInfo
|
||||||
|
|
||||||
class VertexShaderDescriptorInfo:public CustomShaderDescriptorInfo<VK_SHADER_STAGE_VERTEX_BIT,VIAArray,VIA,SVArray,ShaderVariable >
|
class VertexShaderDescriptorInfo:public CustomShaderDescriptorInfo<VK_SHADER_STAGE_VERTEX_BIT,VIAArray,VIA,SVArray,ShaderVariable >
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include<hgl/graph/VKSamplerType.h>
|
#include<hgl/graph/VKSamplerType.h>
|
||||||
#include<hgl/graph/VKPrimitiveType.h>
|
#include<hgl/graph/VKPrimitiveType.h>
|
||||||
#include<hgl/graph/VKDescriptorSetType.h>
|
#include<hgl/graph/VKDescriptorSetType.h>
|
||||||
|
#include<hgl/graph/mtl/ShaderVariableType.h>
|
||||||
|
|
||||||
namespace material_file
|
namespace material_file
|
||||||
{
|
{
|
||||||
@ -14,13 +15,6 @@ namespace material_file
|
|||||||
|
|
||||||
constexpr size_t SHADER_RESOURCE_NAME_MAX_LENGTH=VERTEX_ATTRIB_NAME_MAX_LENGTH;
|
constexpr size_t SHADER_RESOURCE_NAME_MAX_LENGTH=VERTEX_ATTRIB_NAME_MAX_LENGTH;
|
||||||
|
|
||||||
struct ShaderIOAttrib
|
|
||||||
{
|
|
||||||
VAType vat;
|
|
||||||
|
|
||||||
char name[VERTEX_ATTRIB_NAME_MAX_LENGTH];
|
|
||||||
};
|
|
||||||
|
|
||||||
struct MaterialInstanceData
|
struct MaterialInstanceData
|
||||||
{
|
{
|
||||||
const char *code;
|
const char *code;
|
||||||
@ -61,8 +55,6 @@ namespace material_file
|
|||||||
const char * code;
|
const char * code;
|
||||||
uint code_length;
|
uint code_length;
|
||||||
|
|
||||||
List<ShaderIOAttrib> output;
|
|
||||||
|
|
||||||
List<SamplerData> sampler;
|
List<SamplerData> sampler;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -76,6 +68,19 @@ namespace material_file
|
|||||||
}
|
}
|
||||||
|
|
||||||
const VkShaderStageFlagBits GetShaderStage()const{return shader_stage;}
|
const VkShaderStageFlagBits GetShaderStage()const{return shader_stage;}
|
||||||
|
|
||||||
|
virtual void AddOutput(const ShaderVariable &sv);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct VertexShaderData:public ShaderData
|
||||||
|
{
|
||||||
|
List<ShaderVariable> output;
|
||||||
|
|
||||||
|
VertexShaderData():ShaderData(VK_SHADER_STAGE_VERTEX_BIT){}
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
void AddOutput(const ShaderVariable &sv)override{output.Add(sv);}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GeometryShaderData:public ShaderData
|
struct GeometryShaderData:public ShaderData
|
||||||
@ -84,9 +89,26 @@ namespace material_file
|
|||||||
Prim output_prim;
|
Prim output_prim;
|
||||||
uint max_vertices=0;
|
uint max_vertices=0;
|
||||||
|
|
||||||
|
List<ShaderVariable> output;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
using ShaderData::ShaderData;
|
GeometryShaderData():ShaderData(VK_SHADER_STAGE_GEOMETRY_BIT){}
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
void AddOutput(const ShaderVariable &sv)override{output.Add(sv);}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct FragmentShaderData:public ShaderData
|
||||||
|
{
|
||||||
|
List<VIA> output;
|
||||||
|
|
||||||
|
FragmentShaderData():ShaderData(VK_SHADER_STAGE_FRAGMENT_BIT){}
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
void AddOutput(const ShaderVariable &sv)override{}
|
||||||
};
|
};
|
||||||
|
|
||||||
using ShaderDataMap=ObjectMap<VkShaderStageFlagBits,ShaderData>;
|
using ShaderDataMap=ObjectMap<VkShaderStageFlagBits,ShaderData>;
|
||||||
@ -109,7 +131,7 @@ namespace material_file
|
|||||||
|
|
||||||
MaterialInstanceData mi{};
|
MaterialInstanceData mi{};
|
||||||
|
|
||||||
List<ShaderIOAttrib> vi; ///<Vertex Input
|
List<VIA> via; ///<Vertex Input
|
||||||
|
|
||||||
UBODataList ubo_list;
|
UBODataList ubo_list;
|
||||||
|
|
||||||
|
@ -346,13 +346,39 @@ namespace
|
|||||||
}
|
}
|
||||||
};//struct MaterialInstanceBlockParse
|
};//struct MaterialInstanceBlockParse
|
||||||
|
|
||||||
bool ParseUniformAttrib(ShaderIOAttrib *ua,const char *str)
|
bool ParseVertexInputAttrib(VIA *via,const char *str)
|
||||||
{
|
{
|
||||||
const char *sp;
|
const char *sp;
|
||||||
|
|
||||||
while(*str==' '||*str=='\t')++str;
|
while(*str==' '||*str=='\t')++str;
|
||||||
|
|
||||||
if(!ParseVertexAttribType(&(ua->vat),str))
|
VAType vat;
|
||||||
|
|
||||||
|
if(!ParseVertexAttribType(&(vat),str))
|
||||||
|
return(false);
|
||||||
|
|
||||||
|
via->basetype=uint8(vat.basetype);
|
||||||
|
via->vec_size=vat.vec_size;
|
||||||
|
|
||||||
|
while(*str!=' '&&*str!='\t')++str;
|
||||||
|
while(*str==' '||*str=='\t')++str;
|
||||||
|
|
||||||
|
sp=str;
|
||||||
|
|
||||||
|
while(hgl::iscodechar(*str))++str;
|
||||||
|
|
||||||
|
hgl::strcpy(via->name,SHADER_RESOURCE_NAME_MAX_LENGTH,sp,str-sp);
|
||||||
|
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ParseUniformAttrib(ShaderVariable *sv,const char *str)
|
||||||
|
{
|
||||||
|
const char *sp;
|
||||||
|
|
||||||
|
while(*str==' '||*str=='\t')++str;
|
||||||
|
|
||||||
|
if(!sv->type.ParseTypeString(str))
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
while(*str!=' '&&*str!='\t')++str;
|
while(*str!=' '&&*str!='\t')++str;
|
||||||
@ -362,20 +388,20 @@ namespace
|
|||||||
|
|
||||||
while(hgl::iscodechar(*str))++str;
|
while(hgl::iscodechar(*str))++str;
|
||||||
|
|
||||||
hgl::strcpy(ua->name,SHADER_RESOURCE_NAME_MAX_LENGTH,sp,str-sp);
|
hgl::strcpy(sv->name,SHADER_RESOURCE_NAME_MAX_LENGTH,sp,str-sp);
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct VertexInputBlockParse:public TextParse
|
struct VertexInputBlockParse:public TextParse
|
||||||
{
|
{
|
||||||
List<ShaderIOAttrib> *vi_list=nullptr;
|
List<VIA> *via_list=nullptr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
VertexInputBlockParse(List<ShaderIOAttrib> *ual)
|
VertexInputBlockParse(List<VIA> *ual)
|
||||||
{
|
{
|
||||||
vi_list=ual;
|
via_list=ual;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OnLine(char *text,const int len) override
|
bool OnLine(char *text,const int len) override
|
||||||
@ -383,10 +409,10 @@ namespace
|
|||||||
if(!text||!*text||len<=0)
|
if(!text||!*text||len<=0)
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
ShaderIOAttrib ua;
|
VIA via;
|
||||||
|
|
||||||
if(ParseUniformAttrib(&ua,text))
|
if(ParseVertexInputAttrib(&via,text))
|
||||||
vi_list->Add(ua);
|
via_list->Add(via);
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
@ -434,10 +460,10 @@ namespace
|
|||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
ShaderIOAttrib ua;
|
ShaderVariable sv;
|
||||||
|
|
||||||
if(ParseUniformAttrib(&ua,text))
|
if(ParseUniformAttrib(&sv,text))
|
||||||
shader_data->output.Add(ua);
|
shader_data->AddOutput(sv);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(hgl::stricmp(text,"Code",4)==0)
|
if(hgl::stricmp(text,"Code",4)==0)
|
||||||
|
@ -118,20 +118,6 @@ bool ShaderCreateInfo::AddSampler(DescriptorSetType type,const SamplerDescriptor
|
|||||||
return GetSDI()->AddSampler(type,sd);
|
return GetSDI()->AddSampler(type,sd);
|
||||||
}
|
}
|
||||||
|
|
||||||
//int ShaderCreateInfo::AddOutput(const ShaderVariableType &type,const AnsiString &name,Interpolation inter=Interpolation::Smooth)
|
|
||||||
//{
|
|
||||||
// VertexInputAttribute *ss=new VertexInputAttribute;
|
|
||||||
//
|
|
||||||
// hgl::strcpy(ss->name,sizeof(ss->name),name.c_str());
|
|
||||||
//
|
|
||||||
// ss->basetype =(uint8)type.base_type;
|
|
||||||
// ss->vec_size = type.vec_size;
|
|
||||||
// ss->interpolation = inter;
|
|
||||||
//
|
|
||||||
// return sdi->AddOutput(ss);
|
|
||||||
//
|
|
||||||
//}
|
|
||||||
|
|
||||||
void ShaderCreateInfo::SetMaterialInstance(UBODescriptor *ubo,const AnsiString &mi)
|
void ShaderCreateInfo::SetMaterialInstance(UBODescriptor *ubo,const AnsiString &mi)
|
||||||
{
|
{
|
||||||
AddUBO(DescriptorSetType::PerMaterial,ubo);
|
AddUBO(DescriptorSetType::PerMaterial,ubo);
|
||||||
@ -166,42 +152,17 @@ bool ShaderCreateInfo::ProcInput(ShaderCreateInfo *last_sc)
|
|||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToStringList(AnsiString &output_struct,const SVArray &sv_array)
|
|
||||||
{
|
|
||||||
const ShaderVariable *sv=sv_array.items;
|
|
||||||
|
|
||||||
for(uint i=0;i<sv_array.count;i++)
|
|
||||||
{
|
|
||||||
output_struct+=" ";
|
|
||||||
|
|
||||||
if(sv->interpolation!=Interpolation::Smooth)
|
|
||||||
{
|
|
||||||
output_struct+=InterpolationName[size_t(sv->interpolation)];
|
|
||||||
|
|
||||||
output_struct+=" ";
|
|
||||||
}
|
|
||||||
|
|
||||||
output_struct+=sv->type.GetTypename();
|
|
||||||
output_struct+=" ";
|
|
||||||
output_struct+=sv->name;
|
|
||||||
output_struct+=";\n";
|
|
||||||
|
|
||||||
++sv;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ShaderCreateInfo::ProcOutput()
|
bool ShaderCreateInfo::ProcOutput()
|
||||||
{
|
{
|
||||||
output_struct.Clear();
|
output_struct.Clear();
|
||||||
|
|
||||||
const SVArray &sv_array=GetSDI()->GetOutput();
|
if(IsEmptyOutput())
|
||||||
|
return(true);
|
||||||
if(sv_array.count<=0)return(true);
|
|
||||||
|
|
||||||
output_struct=GetShaderStageName(shader_stage);
|
output_struct=GetShaderStageName(shader_stage);
|
||||||
output_struct+="_Output\n{\n";
|
output_struct+="_Output\n{\n";
|
||||||
|
|
||||||
ToStringList(output_struct,sv_array);
|
GetOutputStrcutString(output_struct);
|
||||||
|
|
||||||
output_struct+="}";
|
output_struct+="}";
|
||||||
|
|
||||||
@ -214,7 +175,7 @@ bool ShaderCreateInfo::ProcOutput()
|
|||||||
|
|
||||||
bool ShaderCreateInfo::ProcStruct()
|
bool ShaderCreateInfo::ProcStruct()
|
||||||
{
|
{
|
||||||
const AnsiStringList &struct_list=sdi->GetStructList();
|
const AnsiStringList &struct_list=GetSDI()->GetStructList();
|
||||||
|
|
||||||
AnsiString codes;
|
AnsiString codes;
|
||||||
|
|
||||||
@ -246,7 +207,7 @@ bool ShaderCreateInfo::ProcMI()
|
|||||||
|
|
||||||
bool ShaderCreateInfo::ProcUBO()
|
bool ShaderCreateInfo::ProcUBO()
|
||||||
{
|
{
|
||||||
auto ubo_list=sdi->GetUBOList();
|
auto ubo_list=GetSDI()->GetUBOList();
|
||||||
|
|
||||||
const int count=ubo_list.GetCount();
|
const int count=ubo_list.GetCount();
|
||||||
|
|
||||||
@ -290,7 +251,7 @@ bool ShaderCreateInfo::ProcSSBO()
|
|||||||
|
|
||||||
bool ShaderCreateInfo::ProcConstantID()
|
bool ShaderCreateInfo::ProcConstantID()
|
||||||
{
|
{
|
||||||
auto const_list=sdi->GetConstList();
|
auto const_list=GetSDI()->GetConstList();
|
||||||
|
|
||||||
const int count=const_list.GetCount();
|
const int count=const_list.GetCount();
|
||||||
|
|
||||||
@ -320,7 +281,7 @@ bool ShaderCreateInfo::ProcConstantID()
|
|||||||
|
|
||||||
bool ShaderCreateInfo::ProcSampler()
|
bool ShaderCreateInfo::ProcSampler()
|
||||||
{
|
{
|
||||||
auto sampler_list=sdi->GetSamplerList();
|
auto sampler_list=GetSDI()->GetSamplerList();
|
||||||
|
|
||||||
const int count=sampler_list.GetCount();
|
const int count=sampler_list.GetCount();
|
||||||
|
|
||||||
|
@ -38,6 +38,11 @@ namespace hgl
|
|||||||
return gsdi.AddOutput(sv);
|
return gsdi.AddOutput(sv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ShaderCreateInfoGeometry::GetOutputStrcutString(AnsiString &str)
|
||||||
|
{
|
||||||
|
gsdi.GetOutput().ToString(str);
|
||||||
|
}
|
||||||
|
|
||||||
bool ShaderCreateInfoGeometry::ProcLayout()
|
bool ShaderCreateInfoGeometry::ProcLayout()
|
||||||
{
|
{
|
||||||
final_shader+="layout("+input_prim+") in;\n"
|
final_shader+="layout("+input_prim+") in;\n"
|
||||||
|
@ -12,14 +12,6 @@ void ShaderCreateInfoVertex::AddMaterialInstanceOutput()
|
|||||||
{
|
{
|
||||||
AddOutput(SVT_UINT,mtl::func::MI_ID_OUTPUT,Interpolation::Flat);
|
AddOutput(SVT_UINT,mtl::func::MI_ID_OUTPUT,Interpolation::Flat);
|
||||||
AddFunction(mtl::func::MF_HandoverMI_VS);
|
AddFunction(mtl::func::MF_HandoverMI_VS);
|
||||||
}
|
|
||||||
else
|
|
||||||
if(shader_stage==VK_SHADER_STAGE_GEOMETRY_BIT)
|
|
||||||
{
|
|
||||||
AddFunction(MF_HandoverMI_GS);
|
|
||||||
}
|
|
||||||
//else
|
|
||||||
//AddFunction(MF_HandoverMI_OTHER);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ShaderCreateInfoVertex::AddInput(const VAType &type,const AnsiString &name,const VkVertexInputRate input_rate,const VertexInputGroup &group)
|
int ShaderCreateInfoVertex::AddInput(const VAType &type,const AnsiString &name,const VkVertexInputRate input_rate,const VertexInputGroup &group)
|
||||||
@ -140,4 +132,9 @@ bool ShaderCreateInfoVertex::ProcInput(ShaderCreateInfo *)
|
|||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ShaderCreateInfoVertex::GetOutputStrcutString(AnsiString &str)
|
||||||
|
{
|
||||||
|
vsdi.GetOutput().ToString(str);
|
||||||
|
}
|
||||||
VK_NAMESPACE_END
|
VK_NAMESPACE_END
|
||||||
|
@ -99,4 +99,171 @@ const char *ShaderVariableType::GetTypename()const
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ShaderVariableType::ParseTypeString(const char *str)
|
||||||
|
{
|
||||||
|
if(!str||!*str)
|
||||||
|
return(false);
|
||||||
|
|
||||||
|
if(str[0]=='b')
|
||||||
|
{
|
||||||
|
if(str[1]=='o'&&str[2]=='o'&&str[3]=='l')
|
||||||
|
{
|
||||||
|
base_type=SVBaseType::Scalar;
|
||||||
|
scalar.type=VABaseType::Bool;
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(str[1]=='v'&&str[2]=='e'&&str[3]=='c')
|
||||||
|
{
|
||||||
|
base_type=SVBaseType::Vector;
|
||||||
|
vector.type=VABaseType::Bool;
|
||||||
|
vector.vec_size=str[4]-'0';
|
||||||
|
return(vector.vec_size>=2&&vector.vec_size<=4);
|
||||||
|
}
|
||||||
|
|
||||||
|
return(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(str[1]=='i')
|
||||||
|
{
|
||||||
|
if(str[2]=='n'&&str[3]=='t')
|
||||||
|
{
|
||||||
|
base_type=SVBaseType::Scalar;
|
||||||
|
scalar.type=VABaseType::Int;
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(str[2]=='v'&&str[3]=='e'&&str[4]=='c')
|
||||||
|
{
|
||||||
|
base_type=SVBaseType::Vector;
|
||||||
|
vector.type=VABaseType::Int;
|
||||||
|
vector.vec_size=str[5]-'0';
|
||||||
|
return(vector.vec_size>=2&&vector.vec_size<=4);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(str[1]=='m'&&str[2]=='a'&&str[3]=='g'&&str[4]=='e')
|
||||||
|
{
|
||||||
|
int name_len=5;
|
||||||
|
while(iscodechar(str[name_len]))
|
||||||
|
++name_len;
|
||||||
|
|
||||||
|
base_type=SVBaseType::Image;
|
||||||
|
image.type=ParseShaderImageType(str,name_len);
|
||||||
|
return(image.type!=ShaderImageType::Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
return(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(str[1]=='u')
|
||||||
|
{
|
||||||
|
if(str[2]=='i'&&str[3]=='n'&&str[4]=='t')
|
||||||
|
{
|
||||||
|
base_type=SVBaseType::Scalar;
|
||||||
|
scalar.type=VABaseType::UInt;
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(str[2]=='v'&&str[3]=='e'&&str[4]=='c')
|
||||||
|
{
|
||||||
|
base_type=SVBaseType::Vector;
|
||||||
|
vector.type=VABaseType::UInt;
|
||||||
|
vector.vec_size=str[5]-'0';
|
||||||
|
return(vector.vec_size>=2&&vector.vec_size<=4);
|
||||||
|
}
|
||||||
|
|
||||||
|
return(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(str[1]=='f')
|
||||||
|
{
|
||||||
|
if(str[2]=='l'&&str[3]=='o'&&str[4]=='a'&&str[5]=='t')
|
||||||
|
{
|
||||||
|
base_type=SVBaseType::Scalar;
|
||||||
|
scalar.type=VABaseType::Float;
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(str[0]=='v')
|
||||||
|
{
|
||||||
|
if(str[1]=='e'&&str[2]=='c')
|
||||||
|
{
|
||||||
|
base_type=SVBaseType::Vector;
|
||||||
|
vector.type=VABaseType::Float;
|
||||||
|
vector.vec_size=str[3]-'0';
|
||||||
|
return(vector.vec_size>=2&&vector.vec_size<=4);
|
||||||
|
}
|
||||||
|
|
||||||
|
return(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(str[1]=='d')
|
||||||
|
{
|
||||||
|
if(str[2]=='o'&&str[3]=='u'&&str[4]=='b'&&str[5]=='l'&&str[6]=='e')
|
||||||
|
{
|
||||||
|
base_type=SVBaseType::Scalar;
|
||||||
|
scalar.type=VABaseType::Double;
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(str[2]=='m'&&str[3]=='a'&&str[4]=='t')
|
||||||
|
{
|
||||||
|
base_type=SVBaseType::Matrix;
|
||||||
|
matrix.type=VABaseType::Double;
|
||||||
|
matrix.n=str[5]-'0';
|
||||||
|
|
||||||
|
if(str[6]=='x')
|
||||||
|
{
|
||||||
|
matrix.m=str[7]-'0';
|
||||||
|
return(matrix.m>=2&&matrix.m<=4);
|
||||||
|
}
|
||||||
|
|
||||||
|
matrix.m=0;
|
||||||
|
return(matrix.n>=2&&matrix.n<=4);
|
||||||
|
}
|
||||||
|
|
||||||
|
return(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(str[0]=='m')
|
||||||
|
{
|
||||||
|
if(str[1]=='a'&&str[2]=='t')
|
||||||
|
{
|
||||||
|
base_type=SVBaseType::Matrix;
|
||||||
|
matrix.type=VABaseType::Float;
|
||||||
|
matrix.n=str[3]-'0';
|
||||||
|
|
||||||
|
if(str[4]=='x')
|
||||||
|
{
|
||||||
|
matrix.m=str[5]-'0';
|
||||||
|
return(matrix.m>=2&&matrix.m<=4);
|
||||||
|
}
|
||||||
|
|
||||||
|
matrix.m=0;
|
||||||
|
return(matrix.n>=2&&matrix.n<=4);
|
||||||
|
}
|
||||||
|
|
||||||
|
return(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(hgl::strcmp(str,"sampler",7)==0)
|
||||||
|
{
|
||||||
|
int name_len=7;
|
||||||
|
while(iscodechar(str[name_len]))
|
||||||
|
++name_len;
|
||||||
|
|
||||||
|
base_type=SVBaseType::Sampler;
|
||||||
|
sampler.type=ParseSamplerType(str,name_len);
|
||||||
|
return(sampler.type!=SamplerType::Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(hgl::strcmp(str,"atomic_uint",11)==0)
|
||||||
|
{
|
||||||
|
base_type=SVBaseType::AtomicCounter;
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
VK_NAMESPACE_END
|
VK_NAMESPACE_END
|
||||||
|
Loading…
x
Reference in New Issue
Block a user