ShaderLang: Add support for length intrinsic

This commit is contained in:
Jérôme Leclercq
2021-05-14 02:02:12 +02:00
parent 24f7b75654
commit 51ecff2912
8 changed files with 65 additions and 7 deletions

View File

@@ -466,6 +466,21 @@ namespace Nz::ShaderAst
break;
}
case IntrinsicType::Length:
{
if (clone->parameters.size() != 1)
throw AstError{ "Expected only one parameters" };
for (auto& param : clone->parameters)
MandatoryExpr(param);
const ExpressionType& type = GetExpressionType(*clone->parameters.front());
if (!IsVectorType(type))
throw AstError{ "Expected a vector" };
break;
}
case IntrinsicType::SampleTexture:
{
if (clone->parameters.size() != 2)
@@ -479,6 +494,8 @@ namespace Nz::ShaderAst
if (!IsVectorType(GetExpressionType(*clone->parameters[1])))
throw AstError{ "Second parameter must be a vector" };
break;
}
}
@@ -496,6 +513,7 @@ namespace Nz::ShaderAst
}
case IntrinsicType::DotProduct:
case IntrinsicType::Length:
{
ExpressionType type = GetExpressionType(*clone->parameters.front());
if (!IsVectorType(type))