base struct of ShaderMaker

This commit is contained in:
hyzboy 2019-12-15 20:51:11 +08:00
parent 751caa1db8
commit 791a034085
3 changed files with 64 additions and 6 deletions

View File

@ -4,16 +4,26 @@
#include<hgl/graph/shader/node/finished.h>
#include<hgl/graph/shader/node/vertex_input.h>
BEGIN_SHADER_NAMESPACE
using NodeList=List<node::Node *>;
class ShaderMaker
{
node::Finished *fin_node;
protected:
List<node::VertexInput *> vi_list; ///<顶点输入节点列表
// List<node::Texture *> tex_list; ///<纹理输入节点列表
// List<node::UBO *> ubo_list; ///<UBO输入节点列表
// List<node::Function *> func_list; ///<材质函数节点列表
NodeList node_list[node::NodeType::NODE_TYPE_RANGE_SIZE];
protected:
virtual void MakeHeader();
virtual void MakeVertexInput(const NodeList &);
virtual void MakeConstValue(const NodeList &);
virtual void MakeTextureInput(const NodeList &);
virtual void MakeUBOInput(const NodeList &);
virtual void MakeOutput();
virtual void MakeFinished();
public:

View File

@ -4,7 +4,7 @@
#include<hgl/graph/shader/common.h>
BEGIN_SHADER_NODE_NAMESPACE
enum class NodeType
enum class NodeType:int
{
VertexInput=0, ///<顶点输入流节点

View File

@ -1,6 +1,7 @@
#include<hgl/graph/shader/ShaderMaker.h>
#include<hgl/graph/shader/param/in.h>
#include<hgl/type/Set.h>
#include<hgl/log/LogInfo.h>
BEGIN_SHADER_NAMESPACE
bool ShaderMaker::Check()
@ -12,6 +13,7 @@ bool ShaderMaker::Check()
Set<node::Node *> prev; //等待检测的节点合集
node::Node *cur,*nn;
node::NodeType type;
node::InputParamList *ipl;
int i,count;
param::InputParam **ip;
@ -26,6 +28,15 @@ bool ShaderMaker::Check()
for(i=0;i<count;i++)
{
type=cur->GetNodeType();
if(type<node::NodeType::BEGIN_NODE_TYPE_RANGE
||type>node::NodeType::END_NODE_TYPE_RANGE)
{
LOG_ERROR(U8_TEXT("node type error!"));
return(false);
}
if(!(*ip)->Check())
return(false);
@ -44,6 +55,7 @@ bool ShaderMaker::Check()
ip++;
}
node_list[int(type)-int(node::NodeType::BEGIN_NODE_TYPE_RANGE)].Add(cur);
prev.Delete(cur);
post.Add(cur);
}
@ -51,11 +63,47 @@ bool ShaderMaker::Check()
return(true);
}
void ShaderMaker::MakeHeader()
{
}
void ShaderMaker::MakeVertexInput(const NodeList &nl)
{
}
void ShaderMaker::MakeConstValue(const NodeList &nl)
{
}
void ShaderMaker::MakeTextureInput(const NodeList &nl)
{
}
void ShaderMaker::MakeUBOInput(const NodeList &nl)
{
}
void ShaderMaker::MakeOutput()
{
}
void ShaderMaker::MakeFinished()
{
}
bool ShaderMaker::Make()
{
if(!Check())
return(false);
MakeHeader();
MakeVertexInput( node_list[int(node::NodeType::VertexInput )-int(node::NodeType::BEGIN_NODE_TYPE_RANGE)]);
MakeConstValue( node_list[int(node::NodeType::Const )-int(node::NodeType::BEGIN_NODE_TYPE_RANGE)]);
MakeTextureInput( node_list[int(node::NodeType::Texture )-int(node::NodeType::BEGIN_NODE_TYPE_RANGE)]);
MakeUBOInput( node_list[int(node::NodeType::UBO )-int(node::NodeType::BEGIN_NODE_TYPE_RANGE)]);
MakeOutput();
MakeFinished();
return(true);
}
END_SHADER_NAMESPACE