Shader: Fix unit tests

This commit is contained in:
Jérôme Leclercq 2022-03-09 07:26:51 +01:00
parent be9bdc4705
commit 3c290c1d0e
3 changed files with 12 additions and 2 deletions

View File

@ -39,6 +39,8 @@ namespace Nz::ShaderAst
bool HasValue() const;
void Reset();
ExpressionValue& operator=(const ExpressionValue&) = default;
ExpressionValue& operator=(ExpressionValue&&) noexcept = default;

View File

@ -67,6 +67,12 @@ namespace Nz::ShaderAst
{
return !std::holds_alternative<std::monostate>(m_value);
}
template<typename T>
void ExpressionValue<T>::Reset()
{
m_value = {};
}
}
#include <Nazara/Shader/DebugOff.hpp>

View File

@ -887,9 +887,11 @@ namespace Nz::ShaderAst
}
if (node.returnType.HasValue())
{
clone->returnType = ResolveType(node.returnType);
else
clone->returnType = ExpressionType{ NoType{} };
if (clone->returnType.HasValue() && IsNoType(clone->returnType.GetResultingValue()))
clone->returnType.Reset(); //< handle void as no return type
}
if (node.depthWrite.HasValue())
clone->depthWrite = ComputeExprValue(node.depthWrite);