Add a few helper functions
This commit is contained in:
parent
f280cff0a2
commit
830ec6ac94
|
|
@ -39,6 +39,7 @@ namespace Nz
|
|||
MaterialSettings(MaterialSettings&&) = delete;
|
||||
~MaterialSettings() = default;
|
||||
|
||||
inline const Builder& GetBuilderData() const;
|
||||
inline const std::vector<Condition>& GetConditions() const;
|
||||
inline std::size_t GetConditionIndex(const std::string_view& name) const;
|
||||
inline std::size_t GetPredefinedBindingIndex(PredefinedShaderBinding binding) const;
|
||||
|
|
|
|||
|
|
@ -54,6 +54,11 @@ namespace Nz
|
|||
m_pipelineLayout = Graphics::Instance()->GetRenderDevice().InstantiateRenderPipelineLayout(std::move(info));
|
||||
}
|
||||
|
||||
inline auto MaterialSettings::GetBuilderData() const -> const Builder&
|
||||
{
|
||||
return m_data;
|
||||
}
|
||||
|
||||
inline auto MaterialSettings::GetConditions() const -> const std::vector<Condition>&
|
||||
{
|
||||
return m_data.conditions;
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
#include <Nazara/Shader/Config.hpp>
|
||||
#include <Nazara/Shader/ShaderLangLexer.hpp>
|
||||
#include <Nazara/Shader/Ast/Nodes.hpp>
|
||||
#include <filesystem>
|
||||
|
||||
namespace Nz::ShaderLang
|
||||
{
|
||||
|
|
@ -123,6 +124,9 @@ namespace Nz::ShaderLang
|
|||
|
||||
Context* m_context;
|
||||
};
|
||||
|
||||
inline ShaderAst::StatementPtr Parse(const std::vector<Token>& tokens);
|
||||
NAZARA_SHADER_API ShaderAst::StatementPtr Parse(const std::filesystem::path& sourcePath);
|
||||
}
|
||||
|
||||
#include <Nazara/Shader/ShaderLangParser.inl>
|
||||
|
|
|
|||
|
|
@ -11,6 +11,12 @@ namespace Nz::ShaderLang
|
|||
m_context(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
inline ShaderAst::StatementPtr Parse(const std::vector<Token>& tokens)
|
||||
{
|
||||
Parser parser;
|
||||
return parser.Parse(tokens);
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Shader/DebugOff.hpp>
|
||||
|
|
|
|||
|
|
@ -1006,5 +1006,25 @@ namespace Nz::ShaderLang
|
|||
default: return -1;
|
||||
}
|
||||
}
|
||||
|
||||
ShaderAst::StatementPtr Parse(const std::filesystem::path& sourcePath)
|
||||
{
|
||||
File file(sourcePath);
|
||||
if (!file.Open(OpenMode_ReadOnly | OpenMode_Text))
|
||||
{
|
||||
NazaraError("Failed to open \"" + sourcePath.generic_u8string() + '"');
|
||||
return {};
|
||||
}
|
||||
|
||||
std::size_t length = static_cast<std::size_t>(file.GetSize());
|
||||
|
||||
std::vector<Nz::UInt8> source(length);
|
||||
if (file.Read(&source[0], length) != length)
|
||||
{
|
||||
NazaraError("Failed to read program file");
|
||||
return {};
|
||||
}
|
||||
|
||||
return Parse(Tokenize(std::string_view(reinterpret_cast<const char*>(source.data()), source.size())));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue