This commit is contained in:
2024-06-19 14:03:46 +08:00
parent 806bf5dfdd
commit 2f49e80122
13 changed files with 306 additions and 79 deletions

View File

@@ -1,5 +1,6 @@
#pragma once
#include<hgl/type/String.h>
#include<hgl/graph/VertexAttrib.h>
#include<hgl/graph/VKInterpolation.h>
#include<hgl/graph/VKSamplerType.h>
@@ -242,6 +243,8 @@ namespace hgl
const char *GetTypename()const;
bool ParseTypeString(const char *str);
const uint64 ToCode()const{return svt_code;}
const bool FromCode(const uint64 code)
{
@@ -383,6 +386,10 @@ namespace hgl
ShaderVariable *items;
public:
const bool IsEmpty()const{return !items||count<=0;}
public:
ShaderVariableArray()
@@ -510,6 +517,33 @@ namespace hgl
hgl_cpy(items,src->items,src->count);
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
using SVArray=ShaderVariableArray;

View File

@@ -52,6 +52,9 @@ protected:
virtual bool ProcLayout(){return(true);}
virtual bool ProcInput(ShaderCreateInfo *);
virtual bool IsEmptyOutput()const=0;
virtual void GetOutputStrcutString(AnsiString &){}
virtual bool ProcOutput();
virtual bool ProcStruct();

View File

@@ -11,10 +11,13 @@ class ShaderCreateInfoFragment:public ShaderCreateInfo
protected:
bool IsEmptyOutput()const override{return false;/*这个返回啥无所谓因为Fragment Shader走自己的ProcOutput*/ }
bool ProcOutput() override;
void AddMaterialInstanceOutput() override{};
public:
ShaderDescriptorInfo *GetSDI()override{return &fsdi;}
public:

View File

@@ -13,6 +13,9 @@ class ShaderCreateInfoGeometry:public ShaderCreateInfo
uint32_t max_vertices;
public:
bool IsEmptyOutput()const override{return gsdi.IsEmptyOutput();}
void GetOutputStrcutString(AnsiString &str) override;
ShaderDescriptorInfo *GetSDI()override{return &gsdi;}

View File

@@ -13,6 +13,9 @@ namespace hgl
bool ProcSubpassInput();
bool ProcInput(ShaderCreateInfo *) override;
bool IsEmptyOutput()const override{return vsdi.IsEmptyOutput();}
void GetOutputStrcutString(AnsiString &str) override;
public:

View File

@@ -80,6 +80,9 @@ public:
IArray &GetInput(){return input;}
OArray &GetOutput(){return output;}
const bool IsEmptyInput()const{return input.IsEmpty();}
const bool IsEmptyOutput()const{return output.IsEmpty();}
};//class CustomShaderDescriptorInfo
class VertexShaderDescriptorInfo:public CustomShaderDescriptorInfo<VK_SHADER_STAGE_VERTEX_BIT,VIAArray,VIA,SVArray,ShaderVariable >