Add a few helper functions
This commit is contained in:
parent
f280cff0a2
commit
830ec6ac94
|
|
@ -39,6 +39,7 @@ namespace Nz
|
||||||
MaterialSettings(MaterialSettings&&) = delete;
|
MaterialSettings(MaterialSettings&&) = delete;
|
||||||
~MaterialSettings() = default;
|
~MaterialSettings() = default;
|
||||||
|
|
||||||
|
inline const Builder& GetBuilderData() const;
|
||||||
inline const std::vector<Condition>& GetConditions() const;
|
inline const std::vector<Condition>& GetConditions() const;
|
||||||
inline std::size_t GetConditionIndex(const std::string_view& name) const;
|
inline std::size_t GetConditionIndex(const std::string_view& name) const;
|
||||||
inline std::size_t GetPredefinedBindingIndex(PredefinedShaderBinding binding) const;
|
inline std::size_t GetPredefinedBindingIndex(PredefinedShaderBinding binding) const;
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,11 @@ namespace Nz
|
||||||
m_pipelineLayout = Graphics::Instance()->GetRenderDevice().InstantiateRenderPipelineLayout(std::move(info));
|
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>&
|
inline auto MaterialSettings::GetConditions() const -> const std::vector<Condition>&
|
||||||
{
|
{
|
||||||
return m_data.conditions;
|
return m_data.conditions;
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@
|
||||||
#include <Nazara/Shader/Config.hpp>
|
#include <Nazara/Shader/Config.hpp>
|
||||||
#include <Nazara/Shader/ShaderLangLexer.hpp>
|
#include <Nazara/Shader/ShaderLangLexer.hpp>
|
||||||
#include <Nazara/Shader/Ast/Nodes.hpp>
|
#include <Nazara/Shader/Ast/Nodes.hpp>
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
namespace Nz::ShaderLang
|
namespace Nz::ShaderLang
|
||||||
{
|
{
|
||||||
|
|
@ -123,6 +124,9 @@ namespace Nz::ShaderLang
|
||||||
|
|
||||||
Context* m_context;
|
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>
|
#include <Nazara/Shader/ShaderLangParser.inl>
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,12 @@ namespace Nz::ShaderLang
|
||||||
m_context(nullptr)
|
m_context(nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline ShaderAst::StatementPtr Parse(const std::vector<Token>& tokens)
|
||||||
|
{
|
||||||
|
Parser parser;
|
||||||
|
return parser.Parse(tokens);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <Nazara/Shader/DebugOff.hpp>
|
#include <Nazara/Shader/DebugOff.hpp>
|
||||||
|
|
|
||||||
|
|
@ -1007,4 +1007,24 @@ namespace Nz::ShaderLang
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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