Shader: Add module ID (UUID)

This commit is contained in:
Jérôme Leclercq
2022-03-05 15:25:27 +01:00
parent 43ac86e85c
commit 53728200ac
9 changed files with 72 additions and 46 deletions

View File

@@ -8,26 +8,43 @@
#define NAZARA_SHADER_AST_MODULE_HPP
#include <Nazara/Prerequisites.hpp>
#include <Nazara/Core/Uuid.hpp>
#include <Nazara/Shader/Config.hpp>
#include <Nazara/Shader/Ast/Nodes.hpp>
#include <memory>
namespace Nz::ShaderAst
{
struct Module;
class Module;
using ModulePtr = std::shared_ptr<Module>;
struct Module
class Module
{
struct Metadata
{
UInt32 shaderLangVersion;
};
public:
struct Metadata;
std::shared_ptr<const Metadata> metadata;
MultiStatementPtr rootNode;
inline Module(UInt32 shaderLangVersion);
inline Module(std::shared_ptr<const Metadata> metadata);
inline Module(std::shared_ptr<const Metadata> metadata, MultiStatementPtr rootNode);
Module(const Module&) = default;
Module(Module&&) noexcept = default;
~Module() = default;
Module& operator=(const Module&) = default;
Module& operator=(Module&&) noexcept = default;
std::shared_ptr<const Metadata> metadata;
MultiStatementPtr rootNode;
struct Metadata
{
UInt32 shaderLangVersion;
Uuid moduleId;
};
};
}
#include <Nazara/Shader/Ast/Module.inl>
#endif // NAZARA_SHADER_AST_MODULE_HPP

View File

@@ -0,0 +1,33 @@
// Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com)
// This file is part of the "Nazara Engine - Shader module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Shader/Ast/Module.hpp>
#include <Nazara/Shader/ShaderBuilder.hpp>
#include <Nazara/Shader/Debug.hpp>
namespace Nz::ShaderAst
{
inline Module::Module(UInt32 shaderLangVersion)
{
auto mutMetadata = std::make_shared<Metadata>();
mutMetadata->moduleId = Uuid::Generate();
mutMetadata->shaderLangVersion = shaderLangVersion;
metadata = std::move(mutMetadata);
rootNode = ShaderBuilder::MultiStatement();
}
inline Module::Module(std::shared_ptr<const Metadata> metadata) :
Module(std::move(metadata), ShaderBuilder::MultiStatement())
{
}
inline Module::Module(std::shared_ptr<const Metadata> Metadata, MultiStatementPtr RootNode) :
metadata(std::move(Metadata)),
rootNode(std::move(RootNode))
{
}
}
#include <Nazara/Shader/DebugOff.hpp>