Shader: Serialize cached expression type

This commit is contained in:
Jérôme Leclercq
2022-03-09 12:32:48 +01:00
parent d45ba6696f
commit ce93b61c91
3 changed files with 30 additions and 1 deletions

View File

@@ -126,6 +126,23 @@ namespace Nz::ShaderAst
Enum(optVal.value());
}
inline void AstSerializerBase::OptType(std::optional<ExpressionType>& optType)
{
bool isWriting = IsWriting();
bool hasValue;
if (isWriting)
hasValue = optType.has_value();
Value(hasValue);
if (!isWriting && hasValue)
optType.emplace();
if (optType.has_value())
Type(optType.value());
}
template<typename T>
void AstSerializerBase::OptVal(std::optional<T>& optVal)
{