Renderer/ShaderAst: Add Swizzle
This commit is contained in:
@@ -278,6 +278,34 @@ namespace Nz
|
||||
}
|
||||
}
|
||||
|
||||
void GlslWriter::Write(const ShaderAst::SwizzleOp& node)
|
||||
{
|
||||
Write(node.expression);
|
||||
Append(".");
|
||||
|
||||
for (std::size_t i = 0; i < node.componentCount; ++i)
|
||||
{
|
||||
switch (node.components[i])
|
||||
{
|
||||
case ShaderAst::SwizzleComponent::First:
|
||||
Append("x");
|
||||
break;
|
||||
|
||||
case ShaderAst::SwizzleComponent::Second:
|
||||
Append("y");
|
||||
break;
|
||||
|
||||
case ShaderAst::SwizzleComponent::Third:
|
||||
Append("z");
|
||||
break;
|
||||
|
||||
case ShaderAst::SwizzleComponent::Fourth:
|
||||
Append("w");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GlslWriter::Append(ShaderAst::BuiltinEntry builtin)
|
||||
{
|
||||
switch (builtin)
|
||||
|
||||
@@ -163,5 +163,21 @@ namespace Nz { namespace ShaderAst
|
||||
{
|
||||
visitor.Write(*this);
|
||||
}
|
||||
|
||||
|
||||
ExpressionType ShaderAst::SwizzleOp::GetExpressionType() const
|
||||
{
|
||||
return GetComponentType(expression->GetExpressionType());
|
||||
}
|
||||
|
||||
void SwizzleOp::Register(ShaderWriter& visitor)
|
||||
{
|
||||
expression->Register(visitor);
|
||||
}
|
||||
|
||||
void SwizzleOp::Visit(ShaderWriter& visitor)
|
||||
{
|
||||
visitor.Write(*this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user