ShaderNode: Add automatic variables

This commit is contained in:
Lynix
2020-05-26 20:30:24 +02:00
parent 09e08255fb
commit d96bc9db6e
12 changed files with 143 additions and 19 deletions

View File

@@ -139,7 +139,7 @@ namespace Nz
void GlslWriter::Write(const ShaderAst::AssignOp& node)
{
Write(node.variable);
Write(node.left);
switch (node.op)
{

View File

@@ -8,6 +8,11 @@
namespace Nz::ShaderAst
{
ExpressionCategory Expression::GetExpressionCategory() const
{
return ExpressionCategory::RValue;
}
void ExpressionStatement::Register(ShaderWriter& visitor)
{
expression->Register(visitor);
@@ -43,6 +48,10 @@ namespace Nz::ShaderAst
visitor.Write(*this);
}
ExpressionCategory Variable::GetExpressionCategory() const
{
return ExpressionCategory::LValue;
}
ExpressionType Variable::GetExpressionType() const
{
@@ -60,7 +69,7 @@ namespace Nz::ShaderAst
}
void BuiltinVariable::Register(ShaderWriter& visitor)
void BuiltinVariable::Register(ShaderWriter& /*visitor*/)
{
}
@@ -72,12 +81,12 @@ namespace Nz::ShaderAst
ExpressionType AssignOp::GetExpressionType() const
{
return variable->GetExpressionType();
return left->GetExpressionType();
}
void AssignOp::Register(ShaderWriter& visitor)
{
variable->Register(visitor);
left->Register(visitor);
right->Register(visitor);
}
@@ -102,6 +111,7 @@ namespace Nz::ShaderAst
case ShaderAst::BinaryType::Equality:
exprType = ExpressionType::Boolean;
break;
}
NazaraAssert(exprType != ShaderAst::ExpressionType::Void, "Unhandled builtin");
@@ -178,7 +188,12 @@ namespace Nz::ShaderAst
}
ExpressionType ShaderAst::SwizzleOp::GetExpressionType() const
ExpressionCategory SwizzleOp::GetExpressionCategory() const
{
return ExpressionCategory::LValue;
}
ExpressionType SwizzleOp::GetExpressionType() const
{
return static_cast<ExpressionType>(UnderlyingCast(GetComponentType(expression->GetExpressionType())) + componentCount - 1);
}