Shader: Replace select_opt by const_select
This commit is contained in:
@@ -347,18 +347,6 @@ namespace Nz::ShaderAst
|
||||
return clone;
|
||||
}
|
||||
|
||||
ExpressionPtr AstCloner::Clone(SelectOptionExpression& node)
|
||||
{
|
||||
auto clone = std::make_unique<SelectOptionExpression>();
|
||||
clone->optionName = node.optionName;
|
||||
clone->falsePath = CloneExpression(node.falsePath);
|
||||
clone->truePath = CloneExpression(node.truePath);
|
||||
|
||||
clone->cachedExpressionType = node.cachedExpressionType;
|
||||
|
||||
return clone;
|
||||
}
|
||||
|
||||
ExpressionPtr AstCloner::Clone(SwizzleExpression& node)
|
||||
{
|
||||
auto clone = std::make_unique<SwizzleExpression>();
|
||||
|
||||
@@ -83,12 +83,6 @@ namespace Nz::ShaderAst
|
||||
param->Visit(*this);
|
||||
}
|
||||
|
||||
void AstRecursiveVisitor::Visit(SelectOptionExpression& node)
|
||||
{
|
||||
node.truePath->Visit(*this);
|
||||
node.falsePath->Visit(*this);
|
||||
}
|
||||
|
||||
void AstRecursiveVisitor::Visit(SwizzleExpression& node)
|
||||
{
|
||||
node.expression->Visit(*this);
|
||||
|
||||
@@ -170,13 +170,6 @@ namespace Nz::ShaderAst
|
||||
Node(param);
|
||||
}
|
||||
|
||||
void AstSerializerBase::Serialize(SelectOptionExpression& node)
|
||||
{
|
||||
Value(node.optionName);
|
||||
Node(node.truePath);
|
||||
Node(node.falsePath);
|
||||
}
|
||||
|
||||
void AstSerializerBase::Serialize(SwizzleExpression& node)
|
||||
{
|
||||
SizeT(node.componentCount);
|
||||
|
||||
@@ -82,20 +82,6 @@ namespace Nz::ShaderAst
|
||||
m_expressionCategory = ExpressionCategory::RValue;
|
||||
}
|
||||
|
||||
void ShaderAstValueCategory::Visit(SelectOptionExpression& node)
|
||||
{
|
||||
node.truePath->Visit(*this);
|
||||
ExpressionCategory trueExprCategory = m_expressionCategory;
|
||||
|
||||
node.falsePath->Visit(*this);
|
||||
ExpressionCategory falseExprCategory = m_expressionCategory;
|
||||
|
||||
if (trueExprCategory == ExpressionCategory::RValue || falseExprCategory == ExpressionCategory::RValue)
|
||||
m_expressionCategory = ExpressionCategory::RValue;
|
||||
else
|
||||
m_expressionCategory = ExpressionCategory::LValue;
|
||||
}
|
||||
|
||||
void ShaderAstValueCategory::Visit(SwizzleExpression& node)
|
||||
{
|
||||
node.expression->Visit(*this);
|
||||
|
||||
@@ -632,27 +632,6 @@ namespace Nz::ShaderAst
|
||||
return clone;
|
||||
}
|
||||
|
||||
ExpressionPtr SanitizeVisitor::Clone(SelectOptionExpression& node)
|
||||
{
|
||||
MandatoryExpr(node.truePath);
|
||||
MandatoryExpr(node.falsePath);
|
||||
|
||||
const Identifier* identifier = FindIdentifier(node.optionName);
|
||||
if (!identifier)
|
||||
throw AstError{ "unknown constant " + node.optionName };
|
||||
|
||||
if (identifier->type != Identifier::Type::Constant)
|
||||
throw AstError{ "expected constant identifier" };
|
||||
|
||||
if (GetExpressionType(m_context->constantValues[identifier->index]) != ExpressionType{ PrimitiveType::Boolean })
|
||||
throw AstError{ "constant is not a boolean" };
|
||||
|
||||
if (std::get<bool>(m_context->constantValues[identifier->index]))
|
||||
return CloneExpression(node.truePath);
|
||||
else
|
||||
return CloneExpression(node.falsePath);
|
||||
}
|
||||
|
||||
ExpressionPtr SanitizeVisitor::Clone(SwizzleExpression& node)
|
||||
{
|
||||
if (node.componentCount > 4)
|
||||
|
||||
Reference in New Issue
Block a user