Shader: Add support for max/min intrinsic
This commit is contained in:
@@ -448,6 +448,8 @@ namespace Nz::ShaderAst
|
||||
{
|
||||
case IntrinsicType::CrossProduct:
|
||||
case IntrinsicType::DotProduct:
|
||||
case IntrinsicType::Max:
|
||||
case IntrinsicType::Min:
|
||||
{
|
||||
if (clone->parameters.size() != 2)
|
||||
throw AstError { "Expected two parameters" };
|
||||
@@ -523,6 +525,21 @@ namespace Nz::ShaderAst
|
||||
break;
|
||||
}
|
||||
|
||||
case IntrinsicType::Max:
|
||||
case IntrinsicType::Min:
|
||||
{
|
||||
const ExpressionType& type = GetExpressionType(*clone->parameters.front());
|
||||
if (!IsPrimitiveType(type) && !IsVectorType(type))
|
||||
throw AstError{ "max and min only work with primitive and vector types" };
|
||||
|
||||
if ((IsPrimitiveType(type) && std::get<PrimitiveType>(type) == PrimitiveType::Boolean) ||
|
||||
(IsVectorType(type) && std::get<VectorType>(type).type == PrimitiveType::Boolean))
|
||||
throw AstError{ "max and min do not work with booleans" };
|
||||
|
||||
clone->cachedExpressionType = type;
|
||||
break;
|
||||
}
|
||||
|
||||
case IntrinsicType::SampleTexture:
|
||||
{
|
||||
clone->cachedExpressionType = VectorType{ 4, std::get<SamplerType>(GetExpressionType(*clone->parameters.front())).sampledType };
|
||||
|
||||
Reference in New Issue
Block a user