Shader: Rename VariableExpression to VariableValueExpression
This commit is contained in:
parent
1401c46d44
commit
d45ba6696f
|
|
@ -56,7 +56,7 @@ namespace Nz::ShaderAst
|
||||||
virtual ExpressionPtr Clone(IntrinsicFunctionExpression& node);
|
virtual ExpressionPtr Clone(IntrinsicFunctionExpression& node);
|
||||||
virtual ExpressionPtr Clone(StructTypeExpression& node);
|
virtual ExpressionPtr Clone(StructTypeExpression& node);
|
||||||
virtual ExpressionPtr Clone(SwizzleExpression& node);
|
virtual ExpressionPtr Clone(SwizzleExpression& node);
|
||||||
virtual ExpressionPtr Clone(VariableExpression& node);
|
virtual ExpressionPtr Clone(VariableValueExpression& node);
|
||||||
virtual ExpressionPtr Clone(UnaryExpression& node);
|
virtual ExpressionPtr Clone(UnaryExpression& node);
|
||||||
|
|
||||||
virtual StatementPtr Clone(BranchStatement& node);
|
virtual StatementPtr Clone(BranchStatement& node);
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ namespace Nz::ShaderAst
|
||||||
inline bool Compare(const IntrinsicFunctionExpression& lhs, const IntrinsicFunctionExpression& rhs);
|
inline bool Compare(const IntrinsicFunctionExpression& lhs, const IntrinsicFunctionExpression& rhs);
|
||||||
inline bool Compare(const StructTypeExpression& lhs, const StructTypeExpression& rhs);
|
inline bool Compare(const StructTypeExpression& lhs, const StructTypeExpression& rhs);
|
||||||
inline bool Compare(const SwizzleExpression& lhs, const SwizzleExpression& rhs);
|
inline bool Compare(const SwizzleExpression& lhs, const SwizzleExpression& rhs);
|
||||||
inline bool Compare(const VariableExpression& lhs, const VariableExpression& rhs);
|
inline bool Compare(const VariableValueExpression& lhs, const VariableValueExpression& rhs);
|
||||||
inline bool Compare(const UnaryExpression& lhs, const UnaryExpression& rhs);
|
inline bool Compare(const UnaryExpression& lhs, const UnaryExpression& rhs);
|
||||||
|
|
||||||
inline bool Compare(const BranchStatement& lhs, const BranchStatement& rhs);
|
inline bool Compare(const BranchStatement& lhs, const BranchStatement& rhs);
|
||||||
|
|
|
||||||
|
|
@ -399,7 +399,7 @@ namespace Nz::ShaderAst
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool Compare(const VariableExpression& lhs, const VariableExpression& rhs)
|
inline bool Compare(const VariableValueExpression& lhs, const VariableValueExpression& rhs)
|
||||||
{
|
{
|
||||||
if (!Compare(lhs.variableId, rhs.variableId))
|
if (!Compare(lhs.variableId, rhs.variableId))
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ NAZARA_SHADERAST_EXPRESSION(IntrinsicExpression)
|
||||||
NAZARA_SHADERAST_EXPRESSION(IntrinsicFunctionExpression)
|
NAZARA_SHADERAST_EXPRESSION(IntrinsicFunctionExpression)
|
||||||
NAZARA_SHADERAST_EXPRESSION(StructTypeExpression)
|
NAZARA_SHADERAST_EXPRESSION(StructTypeExpression)
|
||||||
NAZARA_SHADERAST_EXPRESSION(SwizzleExpression)
|
NAZARA_SHADERAST_EXPRESSION(SwizzleExpression)
|
||||||
NAZARA_SHADERAST_EXPRESSION(VariableExpression)
|
NAZARA_SHADERAST_EXPRESSION(VariableValueExpression)
|
||||||
NAZARA_SHADERAST_EXPRESSION(UnaryExpression)
|
NAZARA_SHADERAST_EXPRESSION(UnaryExpression)
|
||||||
NAZARA_SHADERAST_STATEMENT(BranchStatement)
|
NAZARA_SHADERAST_STATEMENT(BranchStatement)
|
||||||
NAZARA_SHADERAST_STATEMENT(ConditionalStatement)
|
NAZARA_SHADERAST_STATEMENT(ConditionalStatement)
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ namespace Nz::ShaderAst
|
||||||
void Visit(IntrinsicFunctionExpression& node) override;
|
void Visit(IntrinsicFunctionExpression& node) override;
|
||||||
void Visit(StructTypeExpression& node) override;
|
void Visit(StructTypeExpression& node) override;
|
||||||
void Visit(SwizzleExpression& node) override;
|
void Visit(SwizzleExpression& node) override;
|
||||||
void Visit(VariableExpression& node) override;
|
void Visit(VariableValueExpression& node) override;
|
||||||
void Visit(UnaryExpression& node) override;
|
void Visit(UnaryExpression& node) override;
|
||||||
|
|
||||||
void Visit(BranchStatement& node) override;
|
void Visit(BranchStatement& node) override;
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ namespace Nz::ShaderAst
|
||||||
void Serialize(IntrinsicFunctionExpression& node);
|
void Serialize(IntrinsicFunctionExpression& node);
|
||||||
void Serialize(StructTypeExpression& node);
|
void Serialize(StructTypeExpression& node);
|
||||||
void Serialize(SwizzleExpression& node);
|
void Serialize(SwizzleExpression& node);
|
||||||
void Serialize(VariableExpression& node);
|
void Serialize(VariableValueExpression& node);
|
||||||
void Serialize(UnaryExpression& node);
|
void Serialize(UnaryExpression& node);
|
||||||
|
|
||||||
void Serialize(BranchStatement& node);
|
void Serialize(BranchStatement& node);
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ namespace Nz::ShaderAst
|
||||||
void Visit(IntrinsicFunctionExpression& node) override;
|
void Visit(IntrinsicFunctionExpression& node) override;
|
||||||
void Visit(StructTypeExpression& node) override;
|
void Visit(StructTypeExpression& node) override;
|
||||||
void Visit(SwizzleExpression& node) override;
|
void Visit(SwizzleExpression& node) override;
|
||||||
void Visit(VariableExpression& node) override;
|
void Visit(VariableValueExpression& node) override;
|
||||||
void Visit(UnaryExpression& node) override;
|
void Visit(UnaryExpression& node) override;
|
||||||
|
|
||||||
ExpressionCategory m_expressionCategory;
|
ExpressionCategory m_expressionCategory;
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ namespace Nz::ShaderAst
|
||||||
using AstRecursiveVisitor::Visit;
|
using AstRecursiveVisitor::Visit;
|
||||||
|
|
||||||
void Visit(CallFunctionExpression& node) override;
|
void Visit(CallFunctionExpression& node) override;
|
||||||
void Visit(VariableExpression& node) override;
|
void Visit(VariableValueExpression& node) override;
|
||||||
|
|
||||||
void Visit(DeclareExternalStatement& node) override;
|
void Visit(DeclareExternalStatement& node) override;
|
||||||
void Visit(DeclareFunctionStatement& node) override;
|
void Visit(DeclareFunctionStatement& node) override;
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ namespace Nz::ShaderAst
|
||||||
|
|
||||||
ExpressionPtr Clone(FunctionExpression& node) override;
|
ExpressionPtr Clone(FunctionExpression& node) override;
|
||||||
ExpressionPtr Clone(StructTypeExpression& node) override;
|
ExpressionPtr Clone(StructTypeExpression& node) override;
|
||||||
ExpressionPtr Clone(VariableExpression& node) override;
|
ExpressionPtr Clone(VariableValueExpression& node) override;
|
||||||
|
|
||||||
void HandleType(ExpressionValue<ExpressionType>& exprType);
|
void HandleType(ExpressionValue<ExpressionType>& exprType);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -208,6 +208,7 @@ namespace Nz::ShaderAst
|
||||||
};
|
};
|
||||||
|
|
||||||
struct NAZARA_SHADER_API VariableExpression : Expression
|
struct NAZARA_SHADER_API VariableExpression : Expression
|
||||||
|
struct NAZARA_SHADER_API VariableValueExpression : Expression
|
||||||
{
|
{
|
||||||
NodeType GetType() const override;
|
NodeType GetType() const override;
|
||||||
void Visit(AstExpressionVisitor& visitor) override;
|
void Visit(AstExpressionVisitor& visitor) override;
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ namespace Nz::ShaderAst
|
||||||
ExpressionPtr Clone(IntrinsicExpression& node) override;
|
ExpressionPtr Clone(IntrinsicExpression& node) override;
|
||||||
ExpressionPtr Clone(SwizzleExpression& node) override;
|
ExpressionPtr Clone(SwizzleExpression& node) override;
|
||||||
ExpressionPtr Clone(UnaryExpression& node) override;
|
ExpressionPtr Clone(UnaryExpression& node) override;
|
||||||
ExpressionPtr Clone(VariableExpression& node) override;
|
ExpressionPtr Clone(VariableValueExpression& node) override;
|
||||||
|
|
||||||
StatementPtr Clone(BranchStatement& node) override;
|
StatementPtr Clone(BranchStatement& node) override;
|
||||||
StatementPtr Clone(ConditionalStatement& node) override;
|
StatementPtr Clone(ConditionalStatement& node) override;
|
||||||
|
|
@ -166,7 +166,7 @@ namespace Nz::ShaderAst
|
||||||
void Validate(IntrinsicExpression& node);
|
void Validate(IntrinsicExpression& node);
|
||||||
void Validate(SwizzleExpression& node);
|
void Validate(SwizzleExpression& node);
|
||||||
void Validate(UnaryExpression& node);
|
void Validate(UnaryExpression& node);
|
||||||
void Validate(VariableExpression& node);
|
void Validate(VariableValueExpression& node);
|
||||||
ExpressionType ValidateBinaryOp(BinaryType op, const ExpressionPtr& leftExpr, const ExpressionPtr& rightExpr);
|
ExpressionType ValidateBinaryOp(BinaryType op, const ExpressionPtr& leftExpr, const ExpressionPtr& rightExpr);
|
||||||
|
|
||||||
enum class IdentifierCategory
|
enum class IdentifierCategory
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ namespace Nz
|
||||||
void Visit(ShaderAst::ConstantValueExpression& node) override;
|
void Visit(ShaderAst::ConstantValueExpression& node) override;
|
||||||
void Visit(ShaderAst::IntrinsicExpression& node) override;
|
void Visit(ShaderAst::IntrinsicExpression& node) override;
|
||||||
void Visit(ShaderAst::SwizzleExpression& node) override;
|
void Visit(ShaderAst::SwizzleExpression& node) override;
|
||||||
void Visit(ShaderAst::VariableExpression& node) override;
|
void Visit(ShaderAst::VariableValueExpression& node) override;
|
||||||
void Visit(ShaderAst::UnaryExpression& node) override;
|
void Visit(ShaderAst::UnaryExpression& node) override;
|
||||||
|
|
||||||
void Visit(ShaderAst::BranchStatement& node) override;
|
void Visit(ShaderAst::BranchStatement& node) override;
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ namespace Nz
|
||||||
void Visit(ShaderAst::IntrinsicExpression& node) override;
|
void Visit(ShaderAst::IntrinsicExpression& node) override;
|
||||||
void Visit(ShaderAst::StructTypeExpression& node) override;
|
void Visit(ShaderAst::StructTypeExpression& node) override;
|
||||||
void Visit(ShaderAst::SwizzleExpression& node) override;
|
void Visit(ShaderAst::SwizzleExpression& node) override;
|
||||||
void Visit(ShaderAst::VariableExpression& node) override;
|
void Visit(ShaderAst::VariableValueExpression& node) override;
|
||||||
void Visit(ShaderAst::UnaryExpression& node) override;
|
void Visit(ShaderAst::UnaryExpression& node) override;
|
||||||
|
|
||||||
void Visit(ShaderAst::BranchStatement& node) override;
|
void Visit(ShaderAst::BranchStatement& node) override;
|
||||||
|
|
|
||||||
|
|
@ -19,142 +19,142 @@ namespace Nz::ShaderBuilder
|
||||||
{
|
{
|
||||||
struct AccessIndex
|
struct AccessIndex
|
||||||
{
|
{
|
||||||
inline std::unique_ptr<ShaderAst::AccessIndexExpression> operator()(ShaderAst::ExpressionPtr expr, Int32 index) const;
|
inline ShaderAst::AccessIndexExpressionPtr operator()(ShaderAst::ExpressionPtr expr, Int32 index) const;
|
||||||
inline std::unique_ptr<ShaderAst::AccessIndexExpression> operator()(ShaderAst::ExpressionPtr expr, const std::vector<Int32>& indexConstants) const;
|
inline ShaderAst::AccessIndexExpressionPtr operator()(ShaderAst::ExpressionPtr expr, const std::vector<Int32>& indexConstants) const;
|
||||||
inline std::unique_ptr<ShaderAst::AccessIndexExpression> operator()(ShaderAst::ExpressionPtr expr, ShaderAst::ExpressionPtr indexExpression) const;
|
inline ShaderAst::AccessIndexExpressionPtr operator()(ShaderAst::ExpressionPtr expr, ShaderAst::ExpressionPtr indexExpression) const;
|
||||||
inline std::unique_ptr<ShaderAst::AccessIndexExpression> operator()(ShaderAst::ExpressionPtr expr, std::vector<ShaderAst::ExpressionPtr> indexExpressions) const;
|
inline ShaderAst::AccessIndexExpressionPtr operator()(ShaderAst::ExpressionPtr expr, std::vector<ShaderAst::ExpressionPtr> indexExpressions) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct AccessMember
|
struct AccessMember
|
||||||
{
|
{
|
||||||
inline std::unique_ptr<ShaderAst::AccessIdentifierExpression> operator()(ShaderAst::ExpressionPtr expr, std::vector<std::string> memberIdentifiers) const;
|
inline ShaderAst::AccessIdentifierExpressionPtr operator()(ShaderAst::ExpressionPtr expr, std::vector<std::string> memberIdentifiers) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Assign
|
struct Assign
|
||||||
{
|
{
|
||||||
inline std::unique_ptr<ShaderAst::AssignExpression> operator()(ShaderAst::AssignType op, ShaderAst::ExpressionPtr left, ShaderAst::ExpressionPtr right) const;
|
inline ShaderAst::AssignExpressionPtr operator()(ShaderAst::AssignType op, ShaderAst::ExpressionPtr left, ShaderAst::ExpressionPtr right) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Binary
|
struct Binary
|
||||||
{
|
{
|
||||||
inline std::unique_ptr<ShaderAst::BinaryExpression> operator()(ShaderAst::BinaryType op, ShaderAst::ExpressionPtr left, ShaderAst::ExpressionPtr right) const;
|
inline ShaderAst::BinaryExpressionPtr operator()(ShaderAst::BinaryType op, ShaderAst::ExpressionPtr left, ShaderAst::ExpressionPtr right) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<bool Const>
|
template<bool Const>
|
||||||
struct Branch
|
struct Branch
|
||||||
{
|
{
|
||||||
inline std::unique_ptr<ShaderAst::BranchStatement> operator()(ShaderAst::ExpressionPtr condition, ShaderAst::StatementPtr truePath, ShaderAst::StatementPtr falsePath = nullptr) const;
|
inline ShaderAst::BranchStatementPtr operator()(ShaderAst::ExpressionPtr condition, ShaderAst::StatementPtr truePath, ShaderAst::StatementPtr falsePath = nullptr) const;
|
||||||
inline std::unique_ptr<ShaderAst::BranchStatement> operator()(std::vector<ShaderAst::BranchStatement::ConditionalStatement> condStatements, ShaderAst::StatementPtr elseStatement = nullptr) const;
|
inline ShaderAst::BranchStatementPtr operator()(std::vector<ShaderAst::BranchStatement::ConditionalStatement> condStatements, ShaderAst::StatementPtr elseStatement = nullptr) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CallFunction
|
struct CallFunction
|
||||||
{
|
{
|
||||||
inline std::unique_ptr<ShaderAst::CallFunctionExpression> operator()(std::string functionName, std::vector<ShaderAst::ExpressionPtr> parameters) const;
|
inline ShaderAst::CallFunctionExpressionPtr operator()(std::string functionName, std::vector<ShaderAst::ExpressionPtr> parameters) const;
|
||||||
inline std::unique_ptr<ShaderAst::CallFunctionExpression> operator()(ShaderAst::ExpressionPtr functionExpr, std::vector<ShaderAst::ExpressionPtr> parameters) const;
|
inline ShaderAst::CallFunctionExpressionPtr operator()(ShaderAst::ExpressionPtr functionExpr, std::vector<ShaderAst::ExpressionPtr> parameters) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Cast
|
struct Cast
|
||||||
{
|
{
|
||||||
inline std::unique_ptr<ShaderAst::CastExpression> operator()(ShaderAst::ExpressionValue<ShaderAst::ExpressionType> targetType, ShaderAst::ExpressionPtr expression) const;
|
inline ShaderAst::CastExpressionPtr operator()(ShaderAst::ExpressionValue<ShaderAst::ExpressionType> targetType, ShaderAst::ExpressionPtr expression) const;
|
||||||
inline std::unique_ptr<ShaderAst::CastExpression> operator()(ShaderAst::ExpressionValue<ShaderAst::ExpressionType> targetType, std::array<ShaderAst::ExpressionPtr, 4> expressions) const;
|
inline ShaderAst::CastExpressionPtr operator()(ShaderAst::ExpressionValue<ShaderAst::ExpressionType> targetType, std::array<ShaderAst::ExpressionPtr, 4> expressions) const;
|
||||||
inline std::unique_ptr<ShaderAst::CastExpression> operator()(ShaderAst::ExpressionValue<ShaderAst::ExpressionType> targetType, std::vector<ShaderAst::ExpressionPtr> expressions) const;
|
inline ShaderAst::CastExpressionPtr operator()(ShaderAst::ExpressionValue<ShaderAst::ExpressionType> targetType, std::vector<ShaderAst::ExpressionPtr> expressions) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ConditionalExpression
|
struct ConditionalExpression
|
||||||
{
|
{
|
||||||
inline std::unique_ptr<ShaderAst::ConditionalExpression> operator()(ShaderAst::ExpressionPtr condition, ShaderAst::ExpressionPtr truePath, ShaderAst::ExpressionPtr falsePath) const;
|
inline ShaderAst::ConditionalExpressionPtr operator()(ShaderAst::ExpressionPtr condition, ShaderAst::ExpressionPtr truePath, ShaderAst::ExpressionPtr falsePath) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ConditionalStatement
|
struct ConditionalStatement
|
||||||
{
|
{
|
||||||
inline std::unique_ptr<ShaderAst::ConditionalStatement> operator()(ShaderAst::ExpressionPtr condition, ShaderAst::StatementPtr statement) const;
|
inline ShaderAst::ConditionalStatementPtr operator()(ShaderAst::ExpressionPtr condition, ShaderAst::StatementPtr statement) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Constant
|
struct Constant
|
||||||
{
|
{
|
||||||
inline std::unique_ptr<ShaderAst::ConstantValueExpression> operator()(ShaderAst::ConstantValue value) const;
|
inline ShaderAst::ConstantValueExpressionPtr operator()(ShaderAst::ConstantValue value) const;
|
||||||
template<typename T> std::unique_ptr<ShaderAst::ConstantValueExpression> operator()(ShaderAst::ExpressionType type, T value) const;
|
template<typename T> ShaderAst::ConstantValueExpressionPtr operator()(ShaderAst::ExpressionType type, T value) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DeclareAlias
|
struct DeclareAlias
|
||||||
{
|
{
|
||||||
inline std::unique_ptr<ShaderAst::DeclareAliasStatement> operator()(std::string name, ShaderAst::ExpressionPtr expression) const;
|
inline ShaderAst::DeclareAliasStatementPtr operator()(std::string name, ShaderAst::ExpressionPtr expression) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DeclareConst
|
struct DeclareConst
|
||||||
{
|
{
|
||||||
inline std::unique_ptr<ShaderAst::DeclareConstStatement> operator()(std::string name, ShaderAst::ExpressionPtr initialValue) const;
|
inline ShaderAst::DeclareConstStatementPtr operator()(std::string name, ShaderAst::ExpressionPtr initialValue) const;
|
||||||
inline std::unique_ptr<ShaderAst::DeclareConstStatement> operator()(std::string name, ShaderAst::ExpressionValue<ShaderAst::ExpressionType> type, ShaderAst::ExpressionPtr initialValue = nullptr) const;
|
inline ShaderAst::DeclareConstStatementPtr operator()(std::string name, ShaderAst::ExpressionValue<ShaderAst::ExpressionType> type, ShaderAst::ExpressionPtr initialValue = nullptr) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DeclareFunction
|
struct DeclareFunction
|
||||||
{
|
{
|
||||||
inline std::unique_ptr<ShaderAst::DeclareFunctionStatement> operator()(std::string name, ShaderAst::StatementPtr statement) const;
|
inline ShaderAst::DeclareFunctionStatementPtr operator()(std::string name, ShaderAst::StatementPtr statement) const;
|
||||||
inline std::unique_ptr<ShaderAst::DeclareFunctionStatement> operator()(std::string name, std::vector<ShaderAst::DeclareFunctionStatement::Parameter> parameters, std::vector<ShaderAst::StatementPtr> statements, ShaderAst::ExpressionValue<ShaderAst::ExpressionType> returnType = ShaderAst::ExpressionType{ ShaderAst::NoType{} }) const;
|
inline ShaderAst::DeclareFunctionStatementPtr operator()(std::string name, std::vector<ShaderAst::DeclareFunctionStatement::Parameter> parameters, std::vector<ShaderAst::StatementPtr> statements, ShaderAst::ExpressionValue<ShaderAst::ExpressionType> returnType = ShaderAst::ExpressionType{ ShaderAst::NoType{} }) const;
|
||||||
inline std::unique_ptr<ShaderAst::DeclareFunctionStatement> operator()(std::optional<ShaderStageType> entryStage, std::string name, ShaderAst::StatementPtr statement) const;
|
inline ShaderAst::DeclareFunctionStatementPtr operator()(std::optional<ShaderStageType> entryStage, std::string name, ShaderAst::StatementPtr statement) const;
|
||||||
inline std::unique_ptr<ShaderAst::DeclareFunctionStatement> operator()(std::optional<ShaderStageType> entryStage, std::string name, std::vector<ShaderAst::DeclareFunctionStatement::Parameter> parameters, std::vector<ShaderAst::StatementPtr> statements, ShaderAst::ExpressionValue<ShaderAst::ExpressionType> returnType = ShaderAst::ExpressionType{ ShaderAst::NoType{} }) const;
|
inline ShaderAst::DeclareFunctionStatementPtr operator()(std::optional<ShaderStageType> entryStage, std::string name, std::vector<ShaderAst::DeclareFunctionStatement::Parameter> parameters, std::vector<ShaderAst::StatementPtr> statements, ShaderAst::ExpressionValue<ShaderAst::ExpressionType> returnType = ShaderAst::ExpressionType{ ShaderAst::NoType{} }) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DeclareOption
|
struct DeclareOption
|
||||||
{
|
{
|
||||||
inline std::unique_ptr<ShaderAst::DeclareOptionStatement> operator()(std::string name, ShaderAst::ExpressionValue<ShaderAst::ExpressionType> type, ShaderAst::ExpressionPtr initialValue = nullptr) const;
|
inline ShaderAst::DeclareOptionStatementPtr operator()(std::string name, ShaderAst::ExpressionValue<ShaderAst::ExpressionType> type, ShaderAst::ExpressionPtr initialValue = nullptr) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DeclareStruct
|
struct DeclareStruct
|
||||||
{
|
{
|
||||||
inline std::unique_ptr<ShaderAst::DeclareStructStatement> operator()(ShaderAst::StructDescription description, ShaderAst::ExpressionValue<bool> isExported) const;
|
inline ShaderAst::DeclareStructStatementPtr operator()(ShaderAst::StructDescription description, ShaderAst::ExpressionValue<bool> isExported) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DeclareVariable
|
struct DeclareVariable
|
||||||
{
|
{
|
||||||
inline std::unique_ptr<ShaderAst::DeclareVariableStatement> operator()(std::string name, ShaderAst::ExpressionPtr initialValue) const;
|
inline ShaderAst::DeclareVariableStatementPtr operator()(std::string name, ShaderAst::ExpressionPtr initialValue) const;
|
||||||
inline std::unique_ptr<ShaderAst::DeclareVariableStatement> operator()(std::string name, ShaderAst::ExpressionValue<ShaderAst::ExpressionType> type, ShaderAst::ExpressionPtr initialValue = nullptr) const;
|
inline ShaderAst::DeclareVariableStatementPtr operator()(std::string name, ShaderAst::ExpressionValue<ShaderAst::ExpressionType> type, ShaderAst::ExpressionPtr initialValue = nullptr) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ExpressionStatement
|
struct ExpressionStatement
|
||||||
{
|
{
|
||||||
inline std::unique_ptr<ShaderAst::ExpressionStatement> operator()(ShaderAst::ExpressionPtr expression) const;
|
inline ShaderAst::ExpressionStatementPtr operator()(ShaderAst::ExpressionPtr expression) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct For
|
struct For
|
||||||
{
|
{
|
||||||
inline std::unique_ptr<ShaderAst::ForStatement> operator()(std::string varName, ShaderAst::ExpressionPtr fromExpression, ShaderAst::ExpressionPtr toExpression, ShaderAst::StatementPtr statement) const;
|
inline ShaderAst::ForStatementPtr operator()(std::string varName, ShaderAst::ExpressionPtr fromExpression, ShaderAst::ExpressionPtr toExpression, ShaderAst::StatementPtr statement) const;
|
||||||
inline std::unique_ptr<ShaderAst::ForStatement> operator()(std::string varName, ShaderAst::ExpressionPtr fromExpression, ShaderAst::ExpressionPtr toExpression, ShaderAst::ExpressionPtr stepExpression, ShaderAst::StatementPtr statement) const;
|
inline ShaderAst::ForStatementPtr operator()(std::string varName, ShaderAst::ExpressionPtr fromExpression, ShaderAst::ExpressionPtr toExpression, ShaderAst::ExpressionPtr stepExpression, ShaderAst::StatementPtr statement) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ForEach
|
struct ForEach
|
||||||
{
|
{
|
||||||
inline std::unique_ptr<ShaderAst::ForEachStatement> operator()(std::string varName, ShaderAst::ExpressionPtr expression, ShaderAst::StatementPtr statement) const;
|
inline ShaderAst::ForEachStatementPtr operator()(std::string varName, ShaderAst::ExpressionPtr expression, ShaderAst::StatementPtr statement) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Function
|
struct Function
|
||||||
{
|
{
|
||||||
inline std::unique_ptr<ShaderAst::FunctionExpression> operator()(std::size_t funcId) const;
|
inline ShaderAst::FunctionExpressionPtr operator()(std::size_t funcId) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Identifier
|
struct Identifier
|
||||||
{
|
{
|
||||||
inline std::unique_ptr<ShaderAst::IdentifierExpression> operator()(std::string name) const;
|
inline ShaderAst::IdentifierExpressionPtr operator()(std::string name) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Import
|
struct Import
|
||||||
{
|
{
|
||||||
inline std::unique_ptr<ShaderAst::ImportStatement> operator()(std::vector<std::string> modulePath) const;
|
inline ShaderAst::ImportStatementPtr operator()(std::vector<std::string> modulePath) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Intrinsic
|
struct Intrinsic
|
||||||
{
|
{
|
||||||
inline std::unique_ptr<ShaderAst::IntrinsicExpression> operator()(ShaderAst::IntrinsicType intrinsicType, std::vector<ShaderAst::ExpressionPtr> parameters) const;
|
inline ShaderAst::IntrinsicExpressionPtr operator()(ShaderAst::IntrinsicType intrinsicType, std::vector<ShaderAst::ExpressionPtr> parameters) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct IntrinsicFunction
|
struct IntrinsicFunction
|
||||||
{
|
{
|
||||||
inline std::unique_ptr<ShaderAst::IntrinsicFunctionExpression> operator()(std::size_t intrinsicFunctionId, ShaderAst::IntrinsicType intrinsicType) const;
|
inline ShaderAst::IntrinsicFunctionExpressionPtr operator()(std::size_t intrinsicFunctionId, ShaderAst::IntrinsicType intrinsicType) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Multi
|
struct Multi
|
||||||
{
|
{
|
||||||
inline std::unique_ptr<ShaderAst::MultiStatement> operator()(std::vector<ShaderAst::StatementPtr> statements = {}) const;
|
inline ShaderAst::MultiStatementPtr operator()(std::vector<ShaderAst::StatementPtr> statements = {}) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
|
@ -165,38 +165,38 @@ namespace Nz::ShaderBuilder
|
||||||
|
|
||||||
struct Return
|
struct Return
|
||||||
{
|
{
|
||||||
inline std::unique_ptr<ShaderAst::ReturnStatement> operator()(ShaderAst::ExpressionPtr expr = nullptr) const;
|
inline ShaderAst::ReturnStatementPtr operator()(ShaderAst::ExpressionPtr expr = nullptr) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Scoped
|
struct Scoped
|
||||||
{
|
{
|
||||||
inline std::unique_ptr<ShaderAst::ScopedStatement> operator()(ShaderAst::StatementPtr statement) const;
|
inline ShaderAst::ScopedStatementPtr operator()(ShaderAst::StatementPtr statement) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct StructType
|
struct StructType
|
||||||
{
|
{
|
||||||
inline std::unique_ptr<ShaderAst::StructTypeExpression> operator()(std::size_t structTypeId) const;
|
inline ShaderAst::StructTypeExpressionPtr operator()(std::size_t structTypeId) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Swizzle
|
struct Swizzle
|
||||||
{
|
{
|
||||||
inline std::unique_ptr<ShaderAst::SwizzleExpression> operator()(ShaderAst::ExpressionPtr expression, std::array<UInt32, 4> swizzleComponents, std::size_t componentCount) const;
|
inline ShaderAst::SwizzleExpressionPtr operator()(ShaderAst::ExpressionPtr expression, std::array<UInt32, 4> swizzleComponents, std::size_t componentCount) const;
|
||||||
inline std::unique_ptr<ShaderAst::SwizzleExpression> operator()(ShaderAst::ExpressionPtr expression, std::vector<UInt32> swizzleComponents) const;
|
inline ShaderAst::SwizzleExpressionPtr operator()(ShaderAst::ExpressionPtr expression, std::vector<UInt32> swizzleComponents) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Unary
|
struct Unary
|
||||||
{
|
{
|
||||||
inline std::unique_ptr<ShaderAst::UnaryExpression> operator()(ShaderAst::UnaryType op, ShaderAst::ExpressionPtr expression) const;
|
inline ShaderAst::UnaryExpressionPtr operator()(ShaderAst::UnaryType op, ShaderAst::ExpressionPtr expression) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Variable
|
struct Variable
|
||||||
{
|
{
|
||||||
inline std::unique_ptr<ShaderAst::VariableExpression> operator()(std::size_t variableId, ShaderAst::ExpressionType expressionType) const;
|
inline ShaderAst::VariableValueExpressionPtr operator()(std::size_t variableId, ShaderAst::ExpressionType expressionType) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct While
|
struct While
|
||||||
{
|
{
|
||||||
inline std::unique_ptr<ShaderAst::WhileStatement> operator()(ShaderAst::ExpressionPtr condition, ShaderAst::StatementPtr body) const;
|
inline ShaderAst::WhileStatementPtr operator()(ShaderAst::ExpressionPtr condition, ShaderAst::StatementPtr body) const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
namespace Nz::ShaderBuilder
|
namespace Nz::ShaderBuilder
|
||||||
{
|
{
|
||||||
inline std::unique_ptr<ShaderAst::AccessIdentifierExpression> Impl::AccessMember::operator()(ShaderAst::ExpressionPtr expr, std::vector<std::string> memberIdentifiers) const
|
inline ShaderAst::AccessIdentifierExpressionPtr Impl::AccessMember::operator()(ShaderAst::ExpressionPtr expr, std::vector<std::string> memberIdentifiers) const
|
||||||
{
|
{
|
||||||
auto accessMemberNode = std::make_unique<ShaderAst::AccessIdentifierExpression>();
|
auto accessMemberNode = std::make_unique<ShaderAst::AccessIdentifierExpression>();
|
||||||
accessMemberNode->expr = std::move(expr);
|
accessMemberNode->expr = std::move(expr);
|
||||||
|
|
@ -17,7 +17,7 @@ namespace Nz::ShaderBuilder
|
||||||
return accessMemberNode;
|
return accessMemberNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::unique_ptr<ShaderAst::AccessIndexExpression> Impl::AccessIndex::operator()(ShaderAst::ExpressionPtr expr, Int32 index) const
|
inline ShaderAst::AccessIndexExpressionPtr Impl::AccessIndex::operator()(ShaderAst::ExpressionPtr expr, Int32 index) const
|
||||||
{
|
{
|
||||||
auto accessMemberNode = std::make_unique<ShaderAst::AccessIndexExpression>();
|
auto accessMemberNode = std::make_unique<ShaderAst::AccessIndexExpression>();
|
||||||
accessMemberNode->expr = std::move(expr);
|
accessMemberNode->expr = std::move(expr);
|
||||||
|
|
@ -26,7 +26,7 @@ namespace Nz::ShaderBuilder
|
||||||
return accessMemberNode;
|
return accessMemberNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::unique_ptr<ShaderAst::AccessIndexExpression> Impl::AccessIndex::operator()(ShaderAst::ExpressionPtr expr, const std::vector<Int32>& indexConstants) const
|
inline ShaderAst::AccessIndexExpressionPtr Impl::AccessIndex::operator()(ShaderAst::ExpressionPtr expr, const std::vector<Int32>& indexConstants) const
|
||||||
{
|
{
|
||||||
auto accessMemberNode = std::make_unique<ShaderAst::AccessIndexExpression>();
|
auto accessMemberNode = std::make_unique<ShaderAst::AccessIndexExpression>();
|
||||||
accessMemberNode->expr = std::move(expr);
|
accessMemberNode->expr = std::move(expr);
|
||||||
|
|
@ -38,7 +38,7 @@ namespace Nz::ShaderBuilder
|
||||||
return accessMemberNode;
|
return accessMemberNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::unique_ptr<ShaderAst::AccessIndexExpression> Impl::AccessIndex::operator()(ShaderAst::ExpressionPtr expr, ShaderAst::ExpressionPtr indexExpression) const
|
inline ShaderAst::AccessIndexExpressionPtr Impl::AccessIndex::operator()(ShaderAst::ExpressionPtr expr, ShaderAst::ExpressionPtr indexExpression) const
|
||||||
{
|
{
|
||||||
auto accessMemberNode = std::make_unique<ShaderAst::AccessIndexExpression>();
|
auto accessMemberNode = std::make_unique<ShaderAst::AccessIndexExpression>();
|
||||||
accessMemberNode->expr = std::move(expr);
|
accessMemberNode->expr = std::move(expr);
|
||||||
|
|
@ -47,7 +47,7 @@ namespace Nz::ShaderBuilder
|
||||||
return accessMemberNode;
|
return accessMemberNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::unique_ptr<ShaderAst::AccessIndexExpression> Impl::AccessIndex::operator()(ShaderAst::ExpressionPtr expr, std::vector<ShaderAst::ExpressionPtr> indexExpressions) const
|
inline ShaderAst::AccessIndexExpressionPtr Impl::AccessIndex::operator()(ShaderAst::ExpressionPtr expr, std::vector<ShaderAst::ExpressionPtr> indexExpressions) const
|
||||||
{
|
{
|
||||||
auto accessMemberNode = std::make_unique<ShaderAst::AccessIndexExpression>();
|
auto accessMemberNode = std::make_unique<ShaderAst::AccessIndexExpression>();
|
||||||
accessMemberNode->expr = std::move(expr);
|
accessMemberNode->expr = std::move(expr);
|
||||||
|
|
@ -56,7 +56,7 @@ namespace Nz::ShaderBuilder
|
||||||
return accessMemberNode;
|
return accessMemberNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::unique_ptr<ShaderAst::AssignExpression> Impl::Assign::operator()(ShaderAst::AssignType op, ShaderAst::ExpressionPtr left, ShaderAst::ExpressionPtr right) const
|
inline ShaderAst::AssignExpressionPtr Impl::Assign::operator()(ShaderAst::AssignType op, ShaderAst::ExpressionPtr left, ShaderAst::ExpressionPtr right) const
|
||||||
{
|
{
|
||||||
auto assignNode = std::make_unique<ShaderAst::AssignExpression>();
|
auto assignNode = std::make_unique<ShaderAst::AssignExpression>();
|
||||||
assignNode->op = op;
|
assignNode->op = op;
|
||||||
|
|
@ -66,7 +66,7 @@ namespace Nz::ShaderBuilder
|
||||||
return assignNode;
|
return assignNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::unique_ptr<ShaderAst::BinaryExpression> Impl::Binary::operator()(ShaderAst::BinaryType op, ShaderAst::ExpressionPtr left, ShaderAst::ExpressionPtr right) const
|
inline ShaderAst::BinaryExpressionPtr Impl::Binary::operator()(ShaderAst::BinaryType op, ShaderAst::ExpressionPtr left, ShaderAst::ExpressionPtr right) const
|
||||||
{
|
{
|
||||||
auto binaryNode = std::make_unique<ShaderAst::BinaryExpression>();
|
auto binaryNode = std::make_unique<ShaderAst::BinaryExpression>();
|
||||||
binaryNode->op = op;
|
binaryNode->op = op;
|
||||||
|
|
@ -77,7 +77,7 @@ namespace Nz::ShaderBuilder
|
||||||
}
|
}
|
||||||
|
|
||||||
template<bool Const>
|
template<bool Const>
|
||||||
std::unique_ptr<ShaderAst::BranchStatement> Impl::Branch<Const>::operator()(ShaderAst::ExpressionPtr condition, ShaderAst::StatementPtr truePath, ShaderAst::StatementPtr falsePath) const
|
ShaderAst::BranchStatementPtr Impl::Branch<Const>::operator()(ShaderAst::ExpressionPtr condition, ShaderAst::StatementPtr truePath, ShaderAst::StatementPtr falsePath) const
|
||||||
{
|
{
|
||||||
auto branchNode = std::make_unique<ShaderAst::BranchStatement>();
|
auto branchNode = std::make_unique<ShaderAst::BranchStatement>();
|
||||||
|
|
||||||
|
|
@ -92,7 +92,7 @@ namespace Nz::ShaderBuilder
|
||||||
}
|
}
|
||||||
|
|
||||||
template<bool Const>
|
template<bool Const>
|
||||||
std::unique_ptr<ShaderAst::BranchStatement> Impl::Branch<Const>::operator()(std::vector<ShaderAst::BranchStatement::ConditionalStatement> condStatements, ShaderAst::StatementPtr elseStatement) const
|
ShaderAst::BranchStatementPtr Impl::Branch<Const>::operator()(std::vector<ShaderAst::BranchStatement::ConditionalStatement> condStatements, ShaderAst::StatementPtr elseStatement) const
|
||||||
{
|
{
|
||||||
auto branchNode = std::make_unique<ShaderAst::BranchStatement>();
|
auto branchNode = std::make_unique<ShaderAst::BranchStatement>();
|
||||||
branchNode->condStatements = std::move(condStatements);
|
branchNode->condStatements = std::move(condStatements);
|
||||||
|
|
@ -102,7 +102,7 @@ namespace Nz::ShaderBuilder
|
||||||
return branchNode;
|
return branchNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::unique_ptr<ShaderAst::CallFunctionExpression> Impl::CallFunction::operator()(std::string functionName, std::vector<ShaderAst::ExpressionPtr> parameters) const
|
inline ShaderAst::CallFunctionExpressionPtr Impl::CallFunction::operator()(std::string functionName, std::vector<ShaderAst::ExpressionPtr> parameters) const
|
||||||
{
|
{
|
||||||
auto callFunctionExpression = std::make_unique<ShaderAst::CallFunctionExpression>();
|
auto callFunctionExpression = std::make_unique<ShaderAst::CallFunctionExpression>();
|
||||||
callFunctionExpression->targetFunction = ShaderBuilder::Identifier(std::move(functionName));
|
callFunctionExpression->targetFunction = ShaderBuilder::Identifier(std::move(functionName));
|
||||||
|
|
@ -111,7 +111,7 @@ namespace Nz::ShaderBuilder
|
||||||
return callFunctionExpression;
|
return callFunctionExpression;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::unique_ptr<ShaderAst::CallFunctionExpression> Impl::CallFunction::operator()(ShaderAst::ExpressionPtr functionExpr, std::vector<ShaderAst::ExpressionPtr> parameters) const
|
inline ShaderAst::CallFunctionExpressionPtr Impl::CallFunction::operator()(ShaderAst::ExpressionPtr functionExpr, std::vector<ShaderAst::ExpressionPtr> parameters) const
|
||||||
{
|
{
|
||||||
auto callFunctionExpression = std::make_unique<ShaderAst::CallFunctionExpression>();
|
auto callFunctionExpression = std::make_unique<ShaderAst::CallFunctionExpression>();
|
||||||
callFunctionExpression->targetFunction = std::move(functionExpr);
|
callFunctionExpression->targetFunction = std::move(functionExpr);
|
||||||
|
|
@ -120,7 +120,7 @@ namespace Nz::ShaderBuilder
|
||||||
return callFunctionExpression;
|
return callFunctionExpression;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::unique_ptr<ShaderAst::CastExpression> Impl::Cast::operator()(ShaderAst::ExpressionValue<ShaderAst::ExpressionType> targetType, ShaderAst::ExpressionPtr expression) const
|
inline ShaderAst::CastExpressionPtr Impl::Cast::operator()(ShaderAst::ExpressionValue<ShaderAst::ExpressionType> targetType, ShaderAst::ExpressionPtr expression) const
|
||||||
{
|
{
|
||||||
auto castNode = std::make_unique<ShaderAst::CastExpression>();
|
auto castNode = std::make_unique<ShaderAst::CastExpression>();
|
||||||
castNode->targetType = std::move(targetType);
|
castNode->targetType = std::move(targetType);
|
||||||
|
|
@ -129,7 +129,7 @@ namespace Nz::ShaderBuilder
|
||||||
return castNode;
|
return castNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::unique_ptr<ShaderAst::CastExpression> Impl::Cast::operator()(ShaderAst::ExpressionValue<ShaderAst::ExpressionType> targetType, std::array<ShaderAst::ExpressionPtr, 4> expressions) const
|
inline ShaderAst::CastExpressionPtr Impl::Cast::operator()(ShaderAst::ExpressionValue<ShaderAst::ExpressionType> targetType, std::array<ShaderAst::ExpressionPtr, 4> expressions) const
|
||||||
{
|
{
|
||||||
auto castNode = std::make_unique<ShaderAst::CastExpression>();
|
auto castNode = std::make_unique<ShaderAst::CastExpression>();
|
||||||
castNode->expressions = std::move(expressions);
|
castNode->expressions = std::move(expressions);
|
||||||
|
|
@ -138,7 +138,7 @@ namespace Nz::ShaderBuilder
|
||||||
return castNode;
|
return castNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::unique_ptr<ShaderAst::CastExpression> Impl::Cast::operator()(ShaderAst::ExpressionValue<ShaderAst::ExpressionType> targetType, std::vector<ShaderAst::ExpressionPtr> expressions) const
|
inline ShaderAst::CastExpressionPtr Impl::Cast::operator()(ShaderAst::ExpressionValue<ShaderAst::ExpressionType> targetType, std::vector<ShaderAst::ExpressionPtr> expressions) const
|
||||||
{
|
{
|
||||||
auto castNode = std::make_unique<ShaderAst::CastExpression>();
|
auto castNode = std::make_unique<ShaderAst::CastExpression>();
|
||||||
castNode->targetType = std::move(targetType);
|
castNode->targetType = std::move(targetType);
|
||||||
|
|
@ -150,7 +150,7 @@ namespace Nz::ShaderBuilder
|
||||||
return castNode;
|
return castNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::unique_ptr<ShaderAst::ConditionalExpression> Impl::ConditionalExpression::operator()(ShaderAst::ExpressionPtr condition, ShaderAst::ExpressionPtr truePath, ShaderAst::ExpressionPtr falsePath) const
|
inline ShaderAst::ConditionalExpressionPtr Impl::ConditionalExpression::operator()(ShaderAst::ExpressionPtr condition, ShaderAst::ExpressionPtr truePath, ShaderAst::ExpressionPtr falsePath) const
|
||||||
{
|
{
|
||||||
auto condExprNode = std::make_unique<ShaderAst::ConditionalExpression>();
|
auto condExprNode = std::make_unique<ShaderAst::ConditionalExpression>();
|
||||||
condExprNode->condition = std::move(condition);
|
condExprNode->condition = std::move(condition);
|
||||||
|
|
@ -160,7 +160,7 @@ namespace Nz::ShaderBuilder
|
||||||
return condExprNode;
|
return condExprNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::unique_ptr<ShaderAst::ConditionalStatement> Impl::ConditionalStatement::operator()(ShaderAst::ExpressionPtr condition, ShaderAst::StatementPtr statement) const
|
inline ShaderAst::ConditionalStatementPtr Impl::ConditionalStatement::operator()(ShaderAst::ExpressionPtr condition, ShaderAst::StatementPtr statement) const
|
||||||
{
|
{
|
||||||
auto condStatementNode = std::make_unique<ShaderAst::ConditionalStatement>();
|
auto condStatementNode = std::make_unique<ShaderAst::ConditionalStatement>();
|
||||||
condStatementNode->condition = std::move(condition);
|
condStatementNode->condition = std::move(condition);
|
||||||
|
|
@ -169,7 +169,7 @@ namespace Nz::ShaderBuilder
|
||||||
return condStatementNode;
|
return condStatementNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::unique_ptr<ShaderAst::ConstantValueExpression> Impl::Constant::operator()(ShaderAst::ConstantValue value) const
|
inline ShaderAst::ConstantValueExpressionPtr Impl::Constant::operator()(ShaderAst::ConstantValue value) const
|
||||||
{
|
{
|
||||||
auto constantNode = std::make_unique<ShaderAst::ConstantValueExpression>();
|
auto constantNode = std::make_unique<ShaderAst::ConstantValueExpression>();
|
||||||
constantNode->value = std::move(value);
|
constantNode->value = std::move(value);
|
||||||
|
|
@ -179,7 +179,7 @@ namespace Nz::ShaderBuilder
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
std::unique_ptr<ShaderAst::ConstantValueExpression> Impl::Constant::operator()(ShaderAst::ExpressionType type, T value) const
|
ShaderAst::ConstantValueExpressionPtr Impl::Constant::operator()(ShaderAst::ExpressionType type, T value) const
|
||||||
{
|
{
|
||||||
assert(IsPrimitiveType(type));
|
assert(IsPrimitiveType(type));
|
||||||
|
|
||||||
|
|
@ -195,7 +195,7 @@ namespace Nz::ShaderBuilder
|
||||||
throw std::runtime_error("unexpected primitive type");
|
throw std::runtime_error("unexpected primitive type");
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::unique_ptr<ShaderAst::DeclareAliasStatement> Impl::DeclareAlias::operator()(std::string name, ShaderAst::ExpressionPtr expression) const
|
inline ShaderAst::DeclareAliasStatementPtr Impl::DeclareAlias::operator()(std::string name, ShaderAst::ExpressionPtr expression) const
|
||||||
{
|
{
|
||||||
auto declareAliasNode = std::make_unique<ShaderAst::DeclareAliasStatement>();
|
auto declareAliasNode = std::make_unique<ShaderAst::DeclareAliasStatement>();
|
||||||
declareAliasNode->name = std::move(name);
|
declareAliasNode->name = std::move(name);
|
||||||
|
|
@ -204,7 +204,7 @@ namespace Nz::ShaderBuilder
|
||||||
return declareAliasNode;
|
return declareAliasNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::unique_ptr<ShaderAst::DeclareConstStatement> Impl::DeclareConst::operator()(std::string name, ShaderAst::ExpressionPtr initialValue) const
|
inline ShaderAst::DeclareConstStatementPtr Impl::DeclareConst::operator()(std::string name, ShaderAst::ExpressionPtr initialValue) const
|
||||||
{
|
{
|
||||||
auto declareConstNode = std::make_unique<ShaderAst::DeclareConstStatement>();
|
auto declareConstNode = std::make_unique<ShaderAst::DeclareConstStatement>();
|
||||||
declareConstNode->name = std::move(name);
|
declareConstNode->name = std::move(name);
|
||||||
|
|
@ -213,7 +213,7 @@ namespace Nz::ShaderBuilder
|
||||||
return declareConstNode;
|
return declareConstNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::unique_ptr<ShaderAst::DeclareConstStatement> Impl::DeclareConst::operator()(std::string name, ShaderAst::ExpressionValue<ShaderAst::ExpressionType> type, ShaderAst::ExpressionPtr initialValue) const
|
inline ShaderAst::DeclareConstStatementPtr Impl::DeclareConst::operator()(std::string name, ShaderAst::ExpressionValue<ShaderAst::ExpressionType> type, ShaderAst::ExpressionPtr initialValue) const
|
||||||
{
|
{
|
||||||
auto declareConstNode = std::make_unique<ShaderAst::DeclareConstStatement>();
|
auto declareConstNode = std::make_unique<ShaderAst::DeclareConstStatement>();
|
||||||
declareConstNode->name = std::move(name);
|
declareConstNode->name = std::move(name);
|
||||||
|
|
@ -223,7 +223,7 @@ namespace Nz::ShaderBuilder
|
||||||
return declareConstNode;
|
return declareConstNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::unique_ptr<ShaderAst::DeclareFunctionStatement> Impl::DeclareFunction::operator()(std::string name, ShaderAst::StatementPtr statement) const
|
inline ShaderAst::DeclareFunctionStatementPtr Impl::DeclareFunction::operator()(std::string name, ShaderAst::StatementPtr statement) const
|
||||||
{
|
{
|
||||||
auto declareFunctionNode = std::make_unique<ShaderAst::DeclareFunctionStatement>();
|
auto declareFunctionNode = std::make_unique<ShaderAst::DeclareFunctionStatement>();
|
||||||
declareFunctionNode->name = std::move(name);
|
declareFunctionNode->name = std::move(name);
|
||||||
|
|
@ -232,7 +232,7 @@ namespace Nz::ShaderBuilder
|
||||||
return declareFunctionNode;
|
return declareFunctionNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::unique_ptr<ShaderAst::DeclareFunctionStatement> Impl::DeclareFunction::operator()(std::string name, std::vector<ShaderAst::DeclareFunctionStatement::Parameter> parameters, std::vector<ShaderAst::StatementPtr> statements, ShaderAst::ExpressionValue<ShaderAst::ExpressionType> returnType) const
|
inline ShaderAst::DeclareFunctionStatementPtr Impl::DeclareFunction::operator()(std::string name, std::vector<ShaderAst::DeclareFunctionStatement::Parameter> parameters, std::vector<ShaderAst::StatementPtr> statements, ShaderAst::ExpressionValue<ShaderAst::ExpressionType> returnType) const
|
||||||
{
|
{
|
||||||
auto declareFunctionNode = std::make_unique<ShaderAst::DeclareFunctionStatement>();
|
auto declareFunctionNode = std::make_unique<ShaderAst::DeclareFunctionStatement>();
|
||||||
declareFunctionNode->name = std::move(name);
|
declareFunctionNode->name = std::move(name);
|
||||||
|
|
@ -243,7 +243,7 @@ namespace Nz::ShaderBuilder
|
||||||
return declareFunctionNode;
|
return declareFunctionNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::unique_ptr<ShaderAst::DeclareFunctionStatement> Impl::DeclareFunction::operator()(std::optional<ShaderStageType> entryStage, std::string name, ShaderAst::StatementPtr statement) const
|
inline ShaderAst::DeclareFunctionStatementPtr Impl::DeclareFunction::operator()(std::optional<ShaderStageType> entryStage, std::string name, ShaderAst::StatementPtr statement) const
|
||||||
{
|
{
|
||||||
auto declareFunctionNode = std::make_unique<ShaderAst::DeclareFunctionStatement>();
|
auto declareFunctionNode = std::make_unique<ShaderAst::DeclareFunctionStatement>();
|
||||||
declareFunctionNode->name = std::move(name);
|
declareFunctionNode->name = std::move(name);
|
||||||
|
|
@ -255,7 +255,7 @@ namespace Nz::ShaderBuilder
|
||||||
return declareFunctionNode;
|
return declareFunctionNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::unique_ptr<ShaderAst::DeclareFunctionStatement> Impl::DeclareFunction::operator()(std::optional<ShaderStageType> entryStage, std::string name, std::vector<ShaderAst::DeclareFunctionStatement::Parameter> parameters, std::vector<ShaderAst::StatementPtr> statements, ShaderAst::ExpressionValue<ShaderAst::ExpressionType> returnType) const
|
inline ShaderAst::DeclareFunctionStatementPtr Impl::DeclareFunction::operator()(std::optional<ShaderStageType> entryStage, std::string name, std::vector<ShaderAst::DeclareFunctionStatement::Parameter> parameters, std::vector<ShaderAst::StatementPtr> statements, ShaderAst::ExpressionValue<ShaderAst::ExpressionType> returnType) const
|
||||||
{
|
{
|
||||||
auto declareFunctionNode = std::make_unique<ShaderAst::DeclareFunctionStatement>();
|
auto declareFunctionNode = std::make_unique<ShaderAst::DeclareFunctionStatement>();
|
||||||
declareFunctionNode->name = std::move(name);
|
declareFunctionNode->name = std::move(name);
|
||||||
|
|
@ -269,7 +269,7 @@ namespace Nz::ShaderBuilder
|
||||||
return declareFunctionNode;
|
return declareFunctionNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::unique_ptr<ShaderAst::DeclareOptionStatement> Impl::DeclareOption::operator()(std::string name, ShaderAst::ExpressionValue<ShaderAst::ExpressionType> type, ShaderAst::ExpressionPtr initialValue) const
|
inline ShaderAst::DeclareOptionStatementPtr Impl::DeclareOption::operator()(std::string name, ShaderAst::ExpressionValue<ShaderAst::ExpressionType> type, ShaderAst::ExpressionPtr initialValue) const
|
||||||
{
|
{
|
||||||
auto declareOptionNode = std::make_unique<ShaderAst::DeclareOptionStatement>();
|
auto declareOptionNode = std::make_unique<ShaderAst::DeclareOptionStatement>();
|
||||||
declareOptionNode->optName = std::move(name);
|
declareOptionNode->optName = std::move(name);
|
||||||
|
|
@ -279,7 +279,7 @@ namespace Nz::ShaderBuilder
|
||||||
return declareOptionNode;
|
return declareOptionNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::unique_ptr<ShaderAst::DeclareStructStatement> Impl::DeclareStruct::operator()(ShaderAst::StructDescription description, ShaderAst::ExpressionValue<bool> isExported) const
|
inline ShaderAst::DeclareStructStatementPtr Impl::DeclareStruct::operator()(ShaderAst::StructDescription description, ShaderAst::ExpressionValue<bool> isExported) const
|
||||||
{
|
{
|
||||||
auto declareStructNode = std::make_unique<ShaderAst::DeclareStructStatement>();
|
auto declareStructNode = std::make_unique<ShaderAst::DeclareStructStatement>();
|
||||||
declareStructNode->description = std::move(description);
|
declareStructNode->description = std::move(description);
|
||||||
|
|
@ -288,7 +288,7 @@ namespace Nz::ShaderBuilder
|
||||||
return declareStructNode;
|
return declareStructNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::unique_ptr<ShaderAst::DeclareVariableStatement> Impl::DeclareVariable::operator()(std::string name, ShaderAst::ExpressionPtr initialValue) const
|
inline ShaderAst::DeclareVariableStatementPtr Impl::DeclareVariable::operator()(std::string name, ShaderAst::ExpressionPtr initialValue) const
|
||||||
{
|
{
|
||||||
auto declareVariableNode = std::make_unique<ShaderAst::DeclareVariableStatement>();
|
auto declareVariableNode = std::make_unique<ShaderAst::DeclareVariableStatement>();
|
||||||
declareVariableNode->varName = std::move(name);
|
declareVariableNode->varName = std::move(name);
|
||||||
|
|
@ -297,7 +297,7 @@ namespace Nz::ShaderBuilder
|
||||||
return declareVariableNode;
|
return declareVariableNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::unique_ptr<ShaderAst::DeclareVariableStatement> Impl::DeclareVariable::operator()(std::string name, ShaderAst::ExpressionValue<ShaderAst::ExpressionType> type, ShaderAst::ExpressionPtr initialValue) const
|
inline ShaderAst::DeclareVariableStatementPtr Impl::DeclareVariable::operator()(std::string name, ShaderAst::ExpressionValue<ShaderAst::ExpressionType> type, ShaderAst::ExpressionPtr initialValue) const
|
||||||
{
|
{
|
||||||
auto declareVariableNode = std::make_unique<ShaderAst::DeclareVariableStatement>();
|
auto declareVariableNode = std::make_unique<ShaderAst::DeclareVariableStatement>();
|
||||||
declareVariableNode->varName = std::move(name);
|
declareVariableNode->varName = std::move(name);
|
||||||
|
|
@ -307,7 +307,7 @@ namespace Nz::ShaderBuilder
|
||||||
return declareVariableNode;
|
return declareVariableNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::unique_ptr<ShaderAst::ExpressionStatement> Impl::ExpressionStatement::operator()(ShaderAst::ExpressionPtr expression) const
|
inline ShaderAst::ExpressionStatementPtr Impl::ExpressionStatement::operator()(ShaderAst::ExpressionPtr expression) const
|
||||||
{
|
{
|
||||||
auto expressionStatementNode = std::make_unique<ShaderAst::ExpressionStatement>();
|
auto expressionStatementNode = std::make_unique<ShaderAst::ExpressionStatement>();
|
||||||
expressionStatementNode->expression = std::move(expression);
|
expressionStatementNode->expression = std::move(expression);
|
||||||
|
|
@ -315,7 +315,7 @@ namespace Nz::ShaderBuilder
|
||||||
return expressionStatementNode;
|
return expressionStatementNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::unique_ptr<ShaderAst::ForStatement> Impl::For::operator()(std::string varName, ShaderAst::ExpressionPtr fromExpression, ShaderAst::ExpressionPtr toExpression, ShaderAst::StatementPtr statement) const
|
inline ShaderAst::ForStatementPtr Impl::For::operator()(std::string varName, ShaderAst::ExpressionPtr fromExpression, ShaderAst::ExpressionPtr toExpression, ShaderAst::StatementPtr statement) const
|
||||||
{
|
{
|
||||||
auto forNode = std::make_unique<ShaderAst::ForStatement>();
|
auto forNode = std::make_unique<ShaderAst::ForStatement>();
|
||||||
forNode->fromExpr = std::move(fromExpression);
|
forNode->fromExpr = std::move(fromExpression);
|
||||||
|
|
@ -326,7 +326,7 @@ namespace Nz::ShaderBuilder
|
||||||
return forNode;
|
return forNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::unique_ptr<ShaderAst::ForStatement> Impl::For::operator()(std::string varName, ShaderAst::ExpressionPtr fromExpression, ShaderAst::ExpressionPtr toExpression, ShaderAst::ExpressionPtr stepExpression, ShaderAst::StatementPtr statement) const
|
inline ShaderAst::ForStatementPtr Impl::For::operator()(std::string varName, ShaderAst::ExpressionPtr fromExpression, ShaderAst::ExpressionPtr toExpression, ShaderAst::ExpressionPtr stepExpression, ShaderAst::StatementPtr statement) const
|
||||||
{
|
{
|
||||||
auto forNode = std::make_unique<ShaderAst::ForStatement>();
|
auto forNode = std::make_unique<ShaderAst::ForStatement>();
|
||||||
forNode->fromExpr = std::move(fromExpression);
|
forNode->fromExpr = std::move(fromExpression);
|
||||||
|
|
@ -338,7 +338,7 @@ namespace Nz::ShaderBuilder
|
||||||
return forNode;
|
return forNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<ShaderAst::ForEachStatement> Impl::ForEach::operator()(std::string varName, ShaderAst::ExpressionPtr expression, ShaderAst::StatementPtr statement) const
|
ShaderAst::ForEachStatementPtr Impl::ForEach::operator()(std::string varName, ShaderAst::ExpressionPtr expression, ShaderAst::StatementPtr statement) const
|
||||||
{
|
{
|
||||||
auto forEachNode = std::make_unique<ShaderAst::ForEachStatement>();
|
auto forEachNode = std::make_unique<ShaderAst::ForEachStatement>();
|
||||||
forEachNode->expression = std::move(expression);
|
forEachNode->expression = std::move(expression);
|
||||||
|
|
@ -348,7 +348,7 @@ namespace Nz::ShaderBuilder
|
||||||
return forEachNode;
|
return forEachNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::unique_ptr<ShaderAst::FunctionExpression> Impl::Function::operator()(std::size_t funcId) const
|
inline ShaderAst::FunctionExpressionPtr Impl::Function::operator()(std::size_t funcId) const
|
||||||
{
|
{
|
||||||
auto intrinsicTypeExpr = std::make_unique<ShaderAst::FunctionExpression>();
|
auto intrinsicTypeExpr = std::make_unique<ShaderAst::FunctionExpression>();
|
||||||
intrinsicTypeExpr->cachedExpressionType = ShaderAst::FunctionType{ funcId };
|
intrinsicTypeExpr->cachedExpressionType = ShaderAst::FunctionType{ funcId };
|
||||||
|
|
@ -357,7 +357,7 @@ namespace Nz::ShaderBuilder
|
||||||
return intrinsicTypeExpr;
|
return intrinsicTypeExpr;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::unique_ptr<ShaderAst::IdentifierExpression> Impl::Identifier::operator()(std::string name) const
|
inline ShaderAst::IdentifierExpressionPtr Impl::Identifier::operator()(std::string name) const
|
||||||
{
|
{
|
||||||
auto identifierNode = std::make_unique<ShaderAst::IdentifierExpression>();
|
auto identifierNode = std::make_unique<ShaderAst::IdentifierExpression>();
|
||||||
identifierNode->identifier = std::move(name);
|
identifierNode->identifier = std::move(name);
|
||||||
|
|
@ -365,7 +365,7 @@ namespace Nz::ShaderBuilder
|
||||||
return identifierNode;
|
return identifierNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::unique_ptr<ShaderAst::ImportStatement> Impl::Import::operator()(std::vector<std::string> modulePath) const
|
inline ShaderAst::ImportStatementPtr Impl::Import::operator()(std::vector<std::string> modulePath) const
|
||||||
{
|
{
|
||||||
auto importNode = std::make_unique<ShaderAst::ImportStatement>();
|
auto importNode = std::make_unique<ShaderAst::ImportStatement>();
|
||||||
importNode->modulePath = std::move(modulePath);
|
importNode->modulePath = std::move(modulePath);
|
||||||
|
|
@ -373,7 +373,7 @@ namespace Nz::ShaderBuilder
|
||||||
return importNode;
|
return importNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::unique_ptr<ShaderAst::IntrinsicExpression> Impl::Intrinsic::operator()(ShaderAst::IntrinsicType intrinsicType, std::vector<ShaderAst::ExpressionPtr> parameters) const
|
inline ShaderAst::IntrinsicExpressionPtr Impl::Intrinsic::operator()(ShaderAst::IntrinsicType intrinsicType, std::vector<ShaderAst::ExpressionPtr> parameters) const
|
||||||
{
|
{
|
||||||
auto intrinsicExpression = std::make_unique<ShaderAst::IntrinsicExpression>();
|
auto intrinsicExpression = std::make_unique<ShaderAst::IntrinsicExpression>();
|
||||||
intrinsicExpression->intrinsic = intrinsicType;
|
intrinsicExpression->intrinsic = intrinsicType;
|
||||||
|
|
@ -382,7 +382,7 @@ namespace Nz::ShaderBuilder
|
||||||
return intrinsicExpression;
|
return intrinsicExpression;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::unique_ptr<ShaderAst::IntrinsicFunctionExpression> Impl::IntrinsicFunction::operator()(std::size_t intrinsicFunctionId, ShaderAst::IntrinsicType intrinsicType) const
|
inline ShaderAst::IntrinsicFunctionExpressionPtr Impl::IntrinsicFunction::operator()(std::size_t intrinsicFunctionId, ShaderAst::IntrinsicType intrinsicType) const
|
||||||
{
|
{
|
||||||
auto intrinsicTypeExpr = std::make_unique<ShaderAst::IntrinsicFunctionExpression>();
|
auto intrinsicTypeExpr = std::make_unique<ShaderAst::IntrinsicFunctionExpression>();
|
||||||
intrinsicTypeExpr->cachedExpressionType = ShaderAst::IntrinsicFunctionType{ intrinsicType };
|
intrinsicTypeExpr->cachedExpressionType = ShaderAst::IntrinsicFunctionType{ intrinsicType };
|
||||||
|
|
@ -391,7 +391,7 @@ namespace Nz::ShaderBuilder
|
||||||
return intrinsicTypeExpr;
|
return intrinsicTypeExpr;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::unique_ptr<ShaderAst::MultiStatement> Impl::Multi::operator()(std::vector<ShaderAst::StatementPtr> statements) const
|
inline ShaderAst::MultiStatementPtr Impl::Multi::operator()(std::vector<ShaderAst::StatementPtr> statements) const
|
||||||
{
|
{
|
||||||
auto multiStatement = std::make_unique<ShaderAst::MultiStatement>();
|
auto multiStatement = std::make_unique<ShaderAst::MultiStatement>();
|
||||||
multiStatement->statements = std::move(statements);
|
multiStatement->statements = std::move(statements);
|
||||||
|
|
@ -405,7 +405,7 @@ namespace Nz::ShaderBuilder
|
||||||
return std::make_unique<T>();
|
return std::make_unique<T>();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::unique_ptr<ShaderAst::ReturnStatement> Impl::Return::operator()(ShaderAst::ExpressionPtr expr) const
|
inline ShaderAst::ReturnStatementPtr Impl::Return::operator()(ShaderAst::ExpressionPtr expr) const
|
||||||
{
|
{
|
||||||
auto returnNode = std::make_unique<ShaderAst::ReturnStatement>();
|
auto returnNode = std::make_unique<ShaderAst::ReturnStatement>();
|
||||||
returnNode->returnExpr = std::move(expr);
|
returnNode->returnExpr = std::move(expr);
|
||||||
|
|
@ -413,7 +413,7 @@ namespace Nz::ShaderBuilder
|
||||||
return returnNode;
|
return returnNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::unique_ptr<ShaderAst::ScopedStatement> Impl::Scoped::operator()(ShaderAst::StatementPtr statement) const
|
inline ShaderAst::ScopedStatementPtr Impl::Scoped::operator()(ShaderAst::StatementPtr statement) const
|
||||||
{
|
{
|
||||||
auto scopedNode = std::make_unique<ShaderAst::ScopedStatement>();
|
auto scopedNode = std::make_unique<ShaderAst::ScopedStatement>();
|
||||||
scopedNode->statement = std::move(statement);
|
scopedNode->statement = std::move(statement);
|
||||||
|
|
@ -421,7 +421,7 @@ namespace Nz::ShaderBuilder
|
||||||
return scopedNode;
|
return scopedNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::unique_ptr<ShaderAst::StructTypeExpression> Impl::StructType::operator()(std::size_t structTypeId) const
|
inline ShaderAst::StructTypeExpressionPtr Impl::StructType::operator()(std::size_t structTypeId) const
|
||||||
{
|
{
|
||||||
auto structTypeExpr = std::make_unique<ShaderAst::StructTypeExpression>();
|
auto structTypeExpr = std::make_unique<ShaderAst::StructTypeExpression>();
|
||||||
structTypeExpr->cachedExpressionType = ShaderAst::StructType{ structTypeId };
|
structTypeExpr->cachedExpressionType = ShaderAst::StructType{ structTypeId };
|
||||||
|
|
@ -430,7 +430,7 @@ namespace Nz::ShaderBuilder
|
||||||
return structTypeExpr;
|
return structTypeExpr;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::unique_ptr<ShaderAst::SwizzleExpression> Impl::Swizzle::operator()(ShaderAst::ExpressionPtr expression, std::array<UInt32, 4> swizzleComponents, std::size_t componentCount) const
|
inline ShaderAst::SwizzleExpressionPtr Impl::Swizzle::operator()(ShaderAst::ExpressionPtr expression, std::array<UInt32, 4> swizzleComponents, std::size_t componentCount) const
|
||||||
{
|
{
|
||||||
assert(componentCount > 0);
|
assert(componentCount > 0);
|
||||||
assert(componentCount <= 4);
|
assert(componentCount <= 4);
|
||||||
|
|
@ -443,7 +443,7 @@ namespace Nz::ShaderBuilder
|
||||||
return swizzleNode;
|
return swizzleNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::unique_ptr<ShaderAst::SwizzleExpression> Impl::Swizzle::operator()(ShaderAst::ExpressionPtr expression, std::vector<UInt32> swizzleComponents) const
|
inline ShaderAst::SwizzleExpressionPtr Impl::Swizzle::operator()(ShaderAst::ExpressionPtr expression, std::vector<UInt32> swizzleComponents) const
|
||||||
{
|
{
|
||||||
auto swizzleNode = std::make_unique<ShaderAst::SwizzleExpression>();
|
auto swizzleNode = std::make_unique<ShaderAst::SwizzleExpression>();
|
||||||
swizzleNode->expression = std::move(expression);
|
swizzleNode->expression = std::move(expression);
|
||||||
|
|
@ -459,7 +459,7 @@ namespace Nz::ShaderBuilder
|
||||||
return swizzleNode;
|
return swizzleNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::unique_ptr<ShaderAst::UnaryExpression> Impl::Unary::operator()(ShaderAst::UnaryType op, ShaderAst::ExpressionPtr expression) const
|
inline ShaderAst::UnaryExpressionPtr Impl::Unary::operator()(ShaderAst::UnaryType op, ShaderAst::ExpressionPtr expression) const
|
||||||
{
|
{
|
||||||
auto unaryNode = std::make_unique<ShaderAst::UnaryExpression>();
|
auto unaryNode = std::make_unique<ShaderAst::UnaryExpression>();
|
||||||
unaryNode->expression = std::move(expression);
|
unaryNode->expression = std::move(expression);
|
||||||
|
|
@ -468,16 +468,16 @@ namespace Nz::ShaderBuilder
|
||||||
return unaryNode;
|
return unaryNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::unique_ptr<ShaderAst::VariableExpression> Impl::Variable::operator()(std::size_t variableId, ShaderAst::ExpressionType expressionType) const
|
inline ShaderAst::VariableValueExpressionPtr Impl::Variable::operator()(std::size_t variableId, ShaderAst::ExpressionType expressionType) const
|
||||||
{
|
{
|
||||||
auto varNode = std::make_unique<ShaderAst::VariableExpression>();
|
auto varNode = std::make_unique<ShaderAst::VariableValueExpression>();
|
||||||
varNode->variableId = variableId;
|
varNode->variableId = variableId;
|
||||||
varNode->cachedExpressionType = std::move(expressionType);
|
varNode->cachedExpressionType = std::move(expressionType);
|
||||||
|
|
||||||
return varNode;
|
return varNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::unique_ptr<ShaderAst::WhileStatement> Impl::While::operator()(ShaderAst::ExpressionPtr condition, ShaderAst::StatementPtr body) const
|
inline ShaderAst::WhileStatementPtr Impl::While::operator()(ShaderAst::ExpressionPtr condition, ShaderAst::StatementPtr body) const
|
||||||
{
|
{
|
||||||
auto whileNode = std::make_unique<ShaderAst::WhileStatement>();
|
auto whileNode = std::make_unique<ShaderAst::WhileStatement>();
|
||||||
whileNode->condition = std::move(condition);
|
whileNode->condition = std::move(condition);
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,6 @@ namespace Nz
|
||||||
void Visit(ShaderAst::DeclareVariableStatement& node) override;
|
void Visit(ShaderAst::DeclareVariableStatement& node) override;
|
||||||
void Visit(ShaderAst::DiscardStatement& node) override;
|
void Visit(ShaderAst::DiscardStatement& node) override;
|
||||||
void Visit(ShaderAst::ExpressionStatement& node) override;
|
void Visit(ShaderAst::ExpressionStatement& node) override;
|
||||||
void Visit(ShaderAst::ImportStatement& node) override;
|
|
||||||
void Visit(ShaderAst::IntrinsicExpression& node) override;
|
void Visit(ShaderAst::IntrinsicExpression& node) override;
|
||||||
void Visit(ShaderAst::MultiStatement& node) override;
|
void Visit(ShaderAst::MultiStatement& node) override;
|
||||||
void Visit(ShaderAst::NoOpStatement& node) override;
|
void Visit(ShaderAst::NoOpStatement& node) override;
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ namespace Nz
|
||||||
|
|
||||||
using AstExpressionVisitorExcept::Visit;
|
using AstExpressionVisitorExcept::Visit;
|
||||||
void Visit(ShaderAst::AccessIndexExpression& node) override;
|
void Visit(ShaderAst::AccessIndexExpression& node) override;
|
||||||
void Visit(ShaderAst::VariableExpression& node) override;
|
void Visit(ShaderAst::VariableValueExpression& node) override;
|
||||||
|
|
||||||
SpirvExpressionLoad& operator=(const SpirvExpressionLoad&) = delete;
|
SpirvExpressionLoad& operator=(const SpirvExpressionLoad&) = delete;
|
||||||
SpirvExpressionLoad& operator=(SpirvExpressionLoad&&) = delete;
|
SpirvExpressionLoad& operator=(SpirvExpressionLoad&&) = delete;
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ namespace Nz
|
||||||
using AstExpressionVisitorExcept::Visit;
|
using AstExpressionVisitorExcept::Visit;
|
||||||
void Visit(ShaderAst::AccessIndexExpression& node) override;
|
void Visit(ShaderAst::AccessIndexExpression& node) override;
|
||||||
void Visit(ShaderAst::SwizzleExpression& node) override;
|
void Visit(ShaderAst::SwizzleExpression& node) override;
|
||||||
void Visit(ShaderAst::VariableExpression& node) override;
|
void Visit(ShaderAst::VariableValueExpression& node) override;
|
||||||
|
|
||||||
SpirvExpressionStore& operator=(const SpirvExpressionStore&) = delete;
|
SpirvExpressionStore& operator=(const SpirvExpressionStore&) = delete;
|
||||||
SpirvExpressionStore& operator=(SpirvExpressionStore&&) = delete;
|
SpirvExpressionStore& operator=(SpirvExpressionStore&&) = delete;
|
||||||
|
|
|
||||||
|
|
@ -471,9 +471,9 @@ namespace Nz::ShaderAst
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
ExpressionPtr AstCloner::Clone(VariableExpression& node)
|
ExpressionPtr AstCloner::Clone(VariableValueExpression& node)
|
||||||
{
|
{
|
||||||
auto clone = std::make_unique<VariableExpression>();
|
auto clone = std::make_unique<VariableValueExpression>();
|
||||||
clone->variableId = node.variableId;
|
clone->variableId = node.variableId;
|
||||||
|
|
||||||
clone->cachedExpressionType = node.cachedExpressionType;
|
clone->cachedExpressionType = node.cachedExpressionType;
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ namespace Nz::ShaderAst
|
||||||
node.expression->Visit(*this);
|
node.expression->Visit(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AstRecursiveVisitor::Visit(VariableExpression& /*node*/)
|
void AstRecursiveVisitor::Visit(VariableValueExpression& /*node*/)
|
||||||
{
|
{
|
||||||
/* Nothing to do */
|
/* Nothing to do */
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -177,7 +177,7 @@ namespace Nz::ShaderAst
|
||||||
Enum(node.components[i]);
|
Enum(node.components[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AstSerializerBase::Serialize(VariableExpression& node)
|
void AstSerializerBase::Serialize(VariableValueExpression& node)
|
||||||
{
|
{
|
||||||
SizeT(node.variableId);
|
SizeT(node.variableId);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,7 @@ namespace Nz::ShaderAst
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShaderAstValueCategory::Visit(VariableExpression& /*node*/)
|
void ShaderAstValueCategory::Visit(VariableValueExpression& /*node*/)
|
||||||
{
|
{
|
||||||
m_expressionCategory = ExpressionCategory::LValue;
|
m_expressionCategory = ExpressionCategory::LValue;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -161,7 +161,7 @@ namespace Nz::ShaderAst
|
||||||
m_currentVariableDeclIndex = {};
|
m_currentVariableDeclIndex = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void DependencyCheckerVisitor::Visit(VariableExpression& node)
|
void DependencyCheckerVisitor::Visit(VariableValueExpression& node)
|
||||||
{
|
{
|
||||||
assert(m_currentFunctionIndex);
|
assert(m_currentFunctionIndex);
|
||||||
if (m_currentVariableDeclIndex)
|
if (m_currentVariableDeclIndex)
|
||||||
|
|
|
||||||
|
|
@ -157,9 +157,9 @@ namespace Nz::ShaderAst
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
ExpressionPtr IndexRemapperVisitor::Clone(VariableExpression& node)
|
ExpressionPtr IndexRemapperVisitor::Clone(VariableValueExpression& node)
|
||||||
{
|
{
|
||||||
VariableExpressionPtr clone = static_unique_pointer_cast<VariableExpression>(AstCloner::Clone(node));
|
VariableValueExpressionPtr clone = static_unique_pointer_cast<VariableValueExpression>(AstCloner::Clone(node));
|
||||||
|
|
||||||
assert(clone->variableId);
|
assert(clone->variableId);
|
||||||
clone->variableId = Retrieve(m_context->newVarIndices, clone->variableId);
|
clone->variableId = Retrieve(m_context->newVarIndices, clone->variableId);
|
||||||
|
|
|
||||||
|
|
@ -684,9 +684,9 @@ namespace Nz::ShaderAst
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
ExpressionPtr SanitizeVisitor::Clone(VariableExpression& node)
|
ExpressionPtr SanitizeVisitor::Clone(VariableValueExpression& node)
|
||||||
{
|
{
|
||||||
auto clone = static_unique_pointer_cast<VariableExpression>(AstCloner::Clone(node));
|
auto clone = static_unique_pointer_cast<VariableValueExpression>(AstCloner::Clone(node));
|
||||||
Validate(*clone);
|
Validate(*clone);
|
||||||
|
|
||||||
return clone;
|
return clone;
|
||||||
|
|
@ -1678,7 +1678,7 @@ namespace Nz::ShaderAst
|
||||||
case IdentifierCategory::Variable:
|
case IdentifierCategory::Variable:
|
||||||
{
|
{
|
||||||
// Replace IdentifierExpression by VariableExpression
|
// Replace IdentifierExpression by VariableExpression
|
||||||
auto varExpr = std::make_unique<VariableExpression>();
|
auto varExpr = std::make_unique<VariableValueExpression>();
|
||||||
varExpr->cachedExpressionType = m_context->variableTypes.Retrieve(identifierData->index);
|
varExpr->cachedExpressionType = m_context->variableTypes.Retrieve(identifierData->index);
|
||||||
varExpr->variableId = identifierData->index;
|
varExpr->variableId = identifierData->index;
|
||||||
|
|
||||||
|
|
@ -1731,7 +1731,7 @@ namespace Nz::ShaderAst
|
||||||
auto variableDeclaration = ShaderBuilder::DeclareVariable("cachedResult", std::move(expression)); //< Validation will prevent name-clash if required
|
auto variableDeclaration = ShaderBuilder::DeclareVariable("cachedResult", std::move(expression)); //< Validation will prevent name-clash if required
|
||||||
Validate(*variableDeclaration);
|
Validate(*variableDeclaration);
|
||||||
|
|
||||||
auto varExpr = std::make_unique<VariableExpression>();
|
auto varExpr = std::make_unique<VariableValueExpression>();
|
||||||
varExpr->variableId = *variableDeclaration->varIndex;
|
varExpr->variableId = *variableDeclaration->varIndex;
|
||||||
|
|
||||||
m_context->currentStatementList->push_back(std::move(variableDeclaration));
|
m_context->currentStatementList->push_back(std::move(variableDeclaration));
|
||||||
|
|
@ -2903,7 +2903,7 @@ namespace Nz::ShaderAst
|
||||||
node.cachedExpressionType = exprType;
|
node.cachedExpressionType = exprType;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SanitizeVisitor::Validate(VariableExpression& node)
|
void SanitizeVisitor::Validate(VariableValueExpression& node)
|
||||||
{
|
{
|
||||||
node.cachedExpressionType = m_context->variableTypes.Retrieve(node.variableId);
|
node.cachedExpressionType = m_context->variableTypes.Retrieve(node.variableId);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1002,7 +1002,7 @@ namespace Nz
|
||||||
Visit(node.expression);
|
Visit(node.expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlslWriter::Visit(ShaderAst::VariableExpression& node)
|
void GlslWriter::Visit(ShaderAst::VariableValueExpression& node)
|
||||||
{
|
{
|
||||||
const std::string& varName = Retrieve(m_currentState->variableNames, node.variableId);
|
const std::string& varName = Retrieve(m_currentState->variableNames, node.variableId);
|
||||||
Append(varName);
|
Append(varName);
|
||||||
|
|
|
||||||
|
|
@ -116,9 +116,9 @@ namespace Nz
|
||||||
ShaderAst::Module* module;
|
ShaderAst::Module* module;
|
||||||
std::size_t currentModuleIndex;
|
std::size_t currentModuleIndex;
|
||||||
std::stringstream stream;
|
std::stringstream stream;
|
||||||
std::unordered_map<std::size_t, Identifier> constantNames;
|
std::unordered_map<std::size_t, Identifier> constants;
|
||||||
std::unordered_map<std::size_t, Identifier> structs;
|
std::unordered_map<std::size_t, Identifier> structs;
|
||||||
std::unordered_map<std::size_t, Identifier> variableNames;
|
std::unordered_map<std::size_t, Identifier> variables;
|
||||||
std::vector<std::string> moduleNames;
|
std::vector<std::string> moduleNames;
|
||||||
bool isInEntryPoint = false;
|
bool isInEntryPoint = false;
|
||||||
unsigned int indentLevel = 0;
|
unsigned int indentLevel = 0;
|
||||||
|
|
@ -661,8 +661,8 @@ namespace Nz
|
||||||
identifier.moduleIndex = m_currentState->currentModuleIndex;
|
identifier.moduleIndex = m_currentState->currentModuleIndex;
|
||||||
identifier.name = std::move(constantName);
|
identifier.name = std::move(constantName);
|
||||||
|
|
||||||
assert(m_currentState->constantNames.find(constantIndex) == m_currentState->constantNames.end());
|
assert(m_currentState->constants.find(constantIndex) == m_currentState->constants.end());
|
||||||
m_currentState->constantNames.emplace(constantIndex, std::move(identifier));
|
m_currentState->constants.emplace(constantIndex, std::move(identifier));
|
||||||
}
|
}
|
||||||
|
|
||||||
void LangWriter::RegisterStruct(std::size_t structIndex, std::string structName)
|
void LangWriter::RegisterStruct(std::size_t structIndex, std::string structName)
|
||||||
|
|
@ -681,8 +681,8 @@ namespace Nz
|
||||||
identifier.moduleIndex = m_currentState->currentModuleIndex;
|
identifier.moduleIndex = m_currentState->currentModuleIndex;
|
||||||
identifier.name = std::move(varName);
|
identifier.name = std::move(varName);
|
||||||
|
|
||||||
assert(m_currentState->variableNames.find(varIndex) == m_currentState->variableNames.end());
|
assert(m_currentState->variables.find(varIndex) == m_currentState->variables.end());
|
||||||
m_currentState->variableNames.emplace(varIndex, std::move(identifier));
|
m_currentState->variables.emplace(varIndex, std::move(identifier));
|
||||||
}
|
}
|
||||||
|
|
||||||
void LangWriter::ScopeVisit(ShaderAst::Statement& node)
|
void LangWriter::ScopeVisit(ShaderAst::Statement& node)
|
||||||
|
|
@ -911,7 +911,7 @@ namespace Nz
|
||||||
|
|
||||||
void LangWriter::Visit(ShaderAst::ConstantExpression& node)
|
void LangWriter::Visit(ShaderAst::ConstantExpression& node)
|
||||||
{
|
{
|
||||||
AppendIdentifier(m_currentState->constantNames, node.constantId);
|
AppendIdentifier(m_currentState->constants, node.constantId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LangWriter::Visit(ShaderAst::DeclareExternalStatement& node)
|
void LangWriter::Visit(ShaderAst::DeclareExternalStatement& node)
|
||||||
|
|
@ -1201,9 +1201,9 @@ namespace Nz
|
||||||
Append(componentStr[node.components[i]]);
|
Append(componentStr[node.components[i]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LangWriter::Visit(ShaderAst::VariableExpression& node)
|
void LangWriter::Visit(ShaderAst::VariableValueExpression& node)
|
||||||
{
|
{
|
||||||
AppendIdentifier(m_currentState->variableNames, node.variableId);
|
AppendIdentifier(m_currentState->variables, node.variableId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LangWriter::Visit(ShaderAst::UnaryExpression& node)
|
void LangWriter::Visit(ShaderAst::UnaryExpression& node)
|
||||||
|
|
|
||||||
|
|
@ -1106,7 +1106,7 @@ namespace Nz
|
||||||
PushResultId(resultId);
|
PushResultId(resultId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpirvAstVisitor::Visit(ShaderAst::VariableExpression& node)
|
void SpirvAstVisitor::Visit(ShaderAst::VariableValueExpression& node)
|
||||||
{
|
{
|
||||||
SpirvExpressionLoad loadVisitor(m_writer, *this, *m_currentBlock);
|
SpirvExpressionLoad loadVisitor(m_writer, *this, *m_currentBlock);
|
||||||
PushResultId(loadVisitor.Evaluate(node));
|
PushResultId(loadVisitor.Evaluate(node));
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,7 @@ namespace Nz
|
||||||
}, m_value);
|
}, m_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpirvExpressionLoad::Visit(ShaderAst::VariableExpression& node)
|
void SpirvExpressionLoad::Visit(ShaderAst::VariableValueExpression& node)
|
||||||
{
|
{
|
||||||
const auto& var = m_visitor.GetVariable(node.variableId);
|
const auto& var = m_visitor.GetVariable(node.variableId);
|
||||||
m_value = Pointer{ var.storage, var.pointerId, var.pointedTypeId };
|
m_value = Pointer{ var.storage, var.pointerId, var.pointedTypeId };
|
||||||
|
|
|
||||||
|
|
@ -156,7 +156,7 @@ namespace Nz
|
||||||
}, m_value);
|
}, m_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpirvExpressionStore::Visit(ShaderAst::VariableExpression& node)
|
void SpirvExpressionStore::Visit(ShaderAst::VariableValueExpression& node)
|
||||||
{
|
{
|
||||||
const auto& var = m_visitor.GetVariable(node.variableId);
|
const auto& var = m_visitor.GetVariable(node.variableId);
|
||||||
m_value = Pointer{ var.storage, var.pointerId };
|
m_value = Pointer{ var.storage, var.pointerId };
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue