Add shader type
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#define NAZARA_SHADER_AST_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Renderer/Enums.hpp>
|
||||
#include <Nazara/Renderer/ShaderExpressionType.hpp>
|
||||
#include <Nazara/Renderer/ShaderNodes.hpp>
|
||||
#include <optional>
|
||||
@@ -27,7 +28,9 @@ namespace Nz
|
||||
struct Uniform;
|
||||
struct VariableBase;
|
||||
|
||||
ShaderAst() = default;
|
||||
inline ShaderAst(ShaderStageType shaderStage);
|
||||
ShaderAst(const ShaderAst&) = default;
|
||||
ShaderAst(ShaderAst&&) = default;
|
||||
~ShaderAst() = default;
|
||||
|
||||
void AddFunction(std::string name, ShaderNodes::StatementPtr statement, std::vector<FunctionParameter> parameters = {}, ShaderNodes::BasicType returnType = ShaderNodes::BasicType::Void);
|
||||
@@ -45,6 +48,7 @@ namespace Nz
|
||||
inline const InputOutput& GetOutput(std::size_t i) const;
|
||||
inline std::size_t GetOutputCount() const;
|
||||
inline const std::vector<InputOutput>& GetOutputs() const;
|
||||
inline ShaderStageType GetStage() const;
|
||||
inline const Struct& GetStruct(std::size_t i) const;
|
||||
inline std::size_t GetStructCount() const;
|
||||
inline const std::vector<Struct>& GetStructs() const;
|
||||
@@ -52,6 +56,9 @@ namespace Nz
|
||||
inline std::size_t GetUniformCount() const;
|
||||
inline const std::vector<Uniform>& GetUniforms() const;
|
||||
|
||||
ShaderAst& operator=(const ShaderAst&) = default;
|
||||
ShaderAst& operator=(ShaderAst&&) = default;
|
||||
|
||||
struct VariableBase
|
||||
{
|
||||
std::string name;
|
||||
@@ -99,6 +106,7 @@ namespace Nz
|
||||
std::vector<InputOutput> m_outputs;
|
||||
std::vector<Struct> m_structs;
|
||||
std::vector<Uniform> m_uniforms;
|
||||
ShaderStageType m_stage;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,11 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
inline ShaderAst::ShaderAst(ShaderStageType shaderStage) :
|
||||
m_stage(shaderStage)
|
||||
{
|
||||
}
|
||||
|
||||
inline auto ShaderAst::GetFunction(std::size_t i) const -> const Function&
|
||||
{
|
||||
assert(i < m_functions.size());
|
||||
@@ -55,6 +60,11 @@ namespace Nz
|
||||
return m_outputs;
|
||||
}
|
||||
|
||||
inline ShaderStageType ShaderAst::GetStage() const
|
||||
{
|
||||
return m_stage;
|
||||
}
|
||||
|
||||
inline auto ShaderAst::GetStruct(std::size_t i) const -> const Struct&
|
||||
{
|
||||
assert(i < m_structs.size());
|
||||
|
||||
@@ -19,8 +19,8 @@ namespace Nz
|
||||
{
|
||||
public:
|
||||
ShaderWriter() = default;
|
||||
ShaderWriter(const ShaderWriter&) = delete;
|
||||
ShaderWriter(ShaderWriter&&) = delete;
|
||||
ShaderWriter(const ShaderWriter&) = default;
|
||||
ShaderWriter(ShaderWriter&&) = default;
|
||||
virtual ~ShaderWriter();
|
||||
|
||||
virtual std::string Generate(const ShaderAst& shader) = 0;
|
||||
|
||||
Reference in New Issue
Block a user