Renderer: Rename enums
ExpressionType => BasicType ShaderAst::Type => ShaderExpressionType
This commit is contained in:
parent
c7a8091e68
commit
1d2fb88198
|
|
@ -44,9 +44,9 @@ namespace Nz
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Append(ShaderAst::Type type);
|
void Append(ShaderExpressionType type);
|
||||||
void Append(ShaderNodes::BuiltinEntry builtin);
|
void Append(ShaderNodes::BuiltinEntry builtin);
|
||||||
void Append(ShaderNodes::ExpressionType type);
|
void Append(ShaderNodes::BasicType type);
|
||||||
void Append(ShaderNodes::MemoryLayout layout);
|
void Append(ShaderNodes::MemoryLayout layout);
|
||||||
template<typename T> void Append(const T& param);
|
template<typename T> void Append(const T& param);
|
||||||
void AppendCommentSection(const std::string& section);
|
void AppendCommentSection(const std::string& section);
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ namespace Nz
|
||||||
std::visit([&](auto&& arg)
|
std::visit([&](auto&& arg)
|
||||||
{
|
{
|
||||||
using T = std::decay_t<decltype(arg)>;
|
using T = std::decay_t<decltype(arg)>;
|
||||||
if constexpr (std::is_same_v<T, ShaderNodes::ExpressionType>)
|
if constexpr (std::is_same_v<T, ShaderNodes::BasicType>)
|
||||||
{
|
{
|
||||||
Append(arg);
|
Append(arg);
|
||||||
Append(" ");
|
Append(" ");
|
||||||
|
|
|
||||||
|
|
@ -8,11 +8,10 @@
|
||||||
#define NAZARA_SHADER_AST_HPP
|
#define NAZARA_SHADER_AST_HPP
|
||||||
|
|
||||||
#include <Nazara/Prerequisites.hpp>
|
#include <Nazara/Prerequisites.hpp>
|
||||||
|
#include <Nazara/Renderer/ShaderExpressionType.hpp>
|
||||||
#include <Nazara/Renderer/ShaderNodes.hpp>
|
#include <Nazara/Renderer/ShaderNodes.hpp>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <string>
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <variant>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace Nz
|
namespace Nz
|
||||||
|
|
@ -28,16 +27,14 @@ namespace Nz
|
||||||
struct Uniform;
|
struct Uniform;
|
||||||
struct VariableBase;
|
struct VariableBase;
|
||||||
|
|
||||||
using Type = std::variant<ShaderNodes::ExpressionType, std::string>;
|
|
||||||
|
|
||||||
ShaderAst() = default;
|
ShaderAst() = default;
|
||||||
~ShaderAst() = default;
|
~ShaderAst() = default;
|
||||||
|
|
||||||
void AddFunction(std::string name, ShaderNodes::StatementPtr statement, std::vector<FunctionParameter> parameters = {}, ShaderNodes::ExpressionType returnType = ShaderNodes::ExpressionType::Void);
|
void AddFunction(std::string name, ShaderNodes::StatementPtr statement, std::vector<FunctionParameter> parameters = {}, ShaderNodes::BasicType returnType = ShaderNodes::BasicType::Void);
|
||||||
void AddInput(std::string name, Type type, std::optional<std::size_t> locationIndex);
|
void AddInput(std::string name, ShaderExpressionType type, std::optional<std::size_t> locationIndex);
|
||||||
void AddOutput(std::string name, Type type, std::optional<std::size_t> locationIndex);
|
void AddOutput(std::string name, ShaderExpressionType type, std::optional<std::size_t> locationIndex);
|
||||||
void AddStruct(std::string name, std::vector<StructMember> members);
|
void AddStruct(std::string name, std::vector<StructMember> members);
|
||||||
void AddUniform(std::string name, Type type, std::optional<std::size_t> bindingIndex, std::optional<ShaderNodes::MemoryLayout> memoryLayout);
|
void AddUniform(std::string name, ShaderExpressionType type, std::optional<std::size_t> bindingIndex, std::optional<ShaderNodes::MemoryLayout> memoryLayout);
|
||||||
|
|
||||||
inline const Function& GetFunction(std::size_t i) const;
|
inline const Function& GetFunction(std::size_t i) const;
|
||||||
inline std::size_t GetFunctionCount() const;
|
inline std::size_t GetFunctionCount() const;
|
||||||
|
|
@ -58,7 +55,7 @@ namespace Nz
|
||||||
struct VariableBase
|
struct VariableBase
|
||||||
{
|
{
|
||||||
std::string name;
|
std::string name;
|
||||||
Type type;
|
ShaderExpressionType type;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FunctionParameter : VariableBase
|
struct FunctionParameter : VariableBase
|
||||||
|
|
@ -69,7 +66,7 @@ namespace Nz
|
||||||
{
|
{
|
||||||
std::string name;
|
std::string name;
|
||||||
std::vector<FunctionParameter> parameters;
|
std::vector<FunctionParameter> parameters;
|
||||||
ShaderNodes::ExpressionType returnType;
|
ShaderNodes::BasicType returnType;
|
||||||
ShaderNodes::StatementPtr statement;
|
ShaderNodes::StatementPtr statement;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -93,7 +90,7 @@ namespace Nz
|
||||||
struct StructMember
|
struct StructMember
|
||||||
{
|
{
|
||||||
std::string name;
|
std::string name;
|
||||||
Type type;
|
ShaderExpressionType type;
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ namespace Nz::ShaderBuilder
|
||||||
constexpr BinOpBuilder<ShaderNodes::BinaryType::Substract> Substract;
|
constexpr BinOpBuilder<ShaderNodes::BinaryType::Substract> Substract;
|
||||||
constexpr GenBuilder<ShaderNodes::UniformVariable> Uniform;
|
constexpr GenBuilder<ShaderNodes::UniformVariable> Uniform;
|
||||||
|
|
||||||
template<ShaderNodes::ExpressionType Type, typename... Args> std::shared_ptr<ShaderNodes::Cast> Cast(Args&&... args);
|
template<ShaderNodes::BasicType Type, typename... Args> std::shared_ptr<ShaderNodes::Cast> Cast(Args&&... args);
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <Nazara/Renderer/ShaderBuilder.inl>
|
#include <Nazara/Renderer/ShaderBuilder.inl>
|
||||||
|
|
|
||||||
|
|
@ -28,21 +28,21 @@ namespace Nz::ShaderBuilder
|
||||||
|
|
||||||
inline std::shared_ptr<ShaderNodes::Variable> BuiltinBuilder::operator()(ShaderNodes::BuiltinEntry builtin) const
|
inline std::shared_ptr<ShaderNodes::Variable> BuiltinBuilder::operator()(ShaderNodes::BuiltinEntry builtin) const
|
||||||
{
|
{
|
||||||
ShaderNodes::ExpressionType exprType = ShaderNodes::ExpressionType::Void;
|
ShaderNodes::BasicType exprType = ShaderNodes::BasicType::Void;
|
||||||
|
|
||||||
switch (builtin)
|
switch (builtin)
|
||||||
{
|
{
|
||||||
case ShaderNodes::BuiltinEntry::VertexPosition:
|
case ShaderNodes::BuiltinEntry::VertexPosition:
|
||||||
exprType = ShaderNodes::ExpressionType::Float4;
|
exprType = ShaderNodes::BasicType::Float4;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
NazaraAssert(exprType != ShaderNodes::ExpressionType::Void, "Unhandled builtin");
|
NazaraAssert(exprType != ShaderNodes::BasicType::Void, "Unhandled builtin");
|
||||||
|
|
||||||
return ShaderNodes::BuiltinVariable::Build(builtin, exprType);
|
return ShaderNodes::BuiltinVariable::Build(builtin, exprType);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<ShaderNodes::ExpressionType Type, typename... Args>
|
template<ShaderNodes::BasicType Type, typename... Args>
|
||||||
std::shared_ptr<ShaderNodes::Cast> Cast(Args&&... args)
|
std::shared_ptr<ShaderNodes::Cast> Cast(Args&&... args)
|
||||||
{
|
{
|
||||||
return ShaderNodes::Cast::Build(Type, std::forward<Args>(args)...);
|
return ShaderNodes::Cast::Build(Type, std::forward<Args>(args)...);
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,19 @@ namespace Nz::ShaderNodes
|
||||||
Simple //< =
|
Simple //< =
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class BasicType
|
||||||
|
{
|
||||||
|
Boolean, // bool
|
||||||
|
Float1, // float
|
||||||
|
Float2, // vec2
|
||||||
|
Float3, // vec3
|
||||||
|
Float4, // vec4
|
||||||
|
Mat4x4, // mat4
|
||||||
|
Sampler2D, // sampler2D
|
||||||
|
|
||||||
|
Void // void
|
||||||
|
};
|
||||||
|
|
||||||
enum class BinaryType
|
enum class BinaryType
|
||||||
{
|
{
|
||||||
Add, //< +
|
Add, //< +
|
||||||
|
|
@ -37,19 +50,6 @@ namespace Nz::ShaderNodes
|
||||||
RValue
|
RValue
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class ExpressionType
|
|
||||||
{
|
|
||||||
Boolean, // bool
|
|
||||||
Float1, // float
|
|
||||||
Float2, // vec2
|
|
||||||
Float3, // vec3
|
|
||||||
Float4, // vec4
|
|
||||||
Mat4x4, // mat4
|
|
||||||
Sampler2D, // sampler2D
|
|
||||||
|
|
||||||
Void // void
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class IntrinsicType
|
enum class IntrinsicType
|
||||||
{
|
{
|
||||||
CrossProduct,
|
CrossProduct,
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
// Copyright (C) 2020 Jérôme Leclercq
|
||||||
|
// This file is part of the "Nazara Engine - Renderer module"
|
||||||
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef NAZARA_SHADER_EXPRESSIONTYPE_HPP
|
||||||
|
#define NAZARA_SHADER_EXPRESSIONTYPE_HPP
|
||||||
|
|
||||||
|
#include <Nazara/Prerequisites.hpp>
|
||||||
|
#include <Nazara/Renderer/ShaderNodes.hpp>
|
||||||
|
#include <string>
|
||||||
|
#include <variant>
|
||||||
|
|
||||||
|
namespace Nz
|
||||||
|
{
|
||||||
|
using ShaderExpressionType = std::variant<ShaderNodes::BasicType, std::string>;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // NAZARA_SHADER_EXPRESSIONTYPE_HPP
|
||||||
|
|
@ -38,8 +38,8 @@ namespace Nz
|
||||||
|
|
||||||
virtual void Visit(ShaderVisitor& visitor) = 0;
|
virtual void Visit(ShaderVisitor& visitor) = 0;
|
||||||
|
|
||||||
static inline unsigned int GetComponentCount(ExpressionType type);
|
static inline unsigned int GetComponentCount(BasicType type);
|
||||||
static inline ExpressionType GetComponentType(ExpressionType type);
|
static inline BasicType GetComponentType(BasicType type);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
inline Node(NodeType type, bool isStatement);
|
inline Node(NodeType type, bool isStatement);
|
||||||
|
|
@ -59,7 +59,7 @@ namespace Nz
|
||||||
inline Expression(NodeType type);
|
inline Expression(NodeType type);
|
||||||
|
|
||||||
virtual ExpressionCategory GetExpressionCategory() const;
|
virtual ExpressionCategory GetExpressionCategory() const;
|
||||||
virtual ExpressionType GetExpressionType() const = 0;
|
virtual BasicType GetExpressionType() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Statement;
|
class Statement;
|
||||||
|
|
@ -125,7 +125,7 @@ namespace Nz
|
||||||
inline Identifier();
|
inline Identifier();
|
||||||
|
|
||||||
ExpressionCategory GetExpressionCategory() const override;
|
ExpressionCategory GetExpressionCategory() const override;
|
||||||
ExpressionType GetExpressionType() const override;
|
BasicType GetExpressionType() const override;
|
||||||
void Visit(ShaderVisitor& visitor) override;
|
void Visit(ShaderVisitor& visitor) override;
|
||||||
|
|
||||||
VariablePtr var;
|
VariablePtr var;
|
||||||
|
|
@ -139,7 +139,7 @@ namespace Nz
|
||||||
{
|
{
|
||||||
inline AssignOp();
|
inline AssignOp();
|
||||||
|
|
||||||
ExpressionType GetExpressionType() const override;
|
BasicType GetExpressionType() const override;
|
||||||
void Visit(ShaderVisitor& visitor) override;
|
void Visit(ShaderVisitor& visitor) override;
|
||||||
|
|
||||||
AssignType op;
|
AssignType op;
|
||||||
|
|
@ -153,7 +153,7 @@ namespace Nz
|
||||||
{
|
{
|
||||||
inline BinaryOp();
|
inline BinaryOp();
|
||||||
|
|
||||||
ExpressionType GetExpressionType() const override;
|
BasicType GetExpressionType() const override;
|
||||||
void Visit(ShaderVisitor& visitor) override;
|
void Visit(ShaderVisitor& visitor) override;
|
||||||
|
|
||||||
BinaryType op;
|
BinaryType op;
|
||||||
|
|
@ -187,24 +187,24 @@ namespace Nz
|
||||||
{
|
{
|
||||||
inline Cast();
|
inline Cast();
|
||||||
|
|
||||||
ExpressionType GetExpressionType() const override;
|
BasicType GetExpressionType() const override;
|
||||||
void Visit(ShaderVisitor& visitor) override;
|
void Visit(ShaderVisitor& visitor) override;
|
||||||
|
|
||||||
ExpressionType exprType;
|
BasicType exprType;
|
||||||
std::array<ExpressionPtr, 4> expressions;
|
std::array<ExpressionPtr, 4> expressions;
|
||||||
|
|
||||||
static inline std::shared_ptr<Cast> Build(ExpressionType castTo, ExpressionPtr first, ExpressionPtr second = nullptr, ExpressionPtr third = nullptr, ExpressionPtr fourth = nullptr);
|
static inline std::shared_ptr<Cast> Build(BasicType castTo, ExpressionPtr first, ExpressionPtr second = nullptr, ExpressionPtr third = nullptr, ExpressionPtr fourth = nullptr);
|
||||||
static inline std::shared_ptr<Cast> Build(ExpressionType castTo, ExpressionPtr* expressions, std::size_t expressionCount);
|
static inline std::shared_ptr<Cast> Build(BasicType castTo, ExpressionPtr* expressions, std::size_t expressionCount);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct NAZARA_RENDERER_API Constant : public Expression
|
struct NAZARA_RENDERER_API Constant : public Expression
|
||||||
{
|
{
|
||||||
inline Constant();
|
inline Constant();
|
||||||
|
|
||||||
ExpressionType GetExpressionType() const override;
|
BasicType GetExpressionType() const override;
|
||||||
void Visit(ShaderVisitor& visitor) override;
|
void Visit(ShaderVisitor& visitor) override;
|
||||||
|
|
||||||
ExpressionType exprType;
|
BasicType exprType;
|
||||||
|
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
|
|
@ -227,7 +227,7 @@ namespace Nz
|
||||||
inline SwizzleOp();
|
inline SwizzleOp();
|
||||||
|
|
||||||
ExpressionCategory GetExpressionCategory() const override;
|
ExpressionCategory GetExpressionCategory() const override;
|
||||||
ExpressionType GetExpressionType() const override;
|
BasicType GetExpressionType() const override;
|
||||||
void Visit(ShaderVisitor& visitor) override;
|
void Visit(ShaderVisitor& visitor) override;
|
||||||
|
|
||||||
std::array<SwizzleComponent, 4> components;
|
std::array<SwizzleComponent, 4> components;
|
||||||
|
|
@ -243,7 +243,7 @@ namespace Nz
|
||||||
{
|
{
|
||||||
inline Sample2D();
|
inline Sample2D();
|
||||||
|
|
||||||
ExpressionType GetExpressionType() const override;
|
BasicType GetExpressionType() const override;
|
||||||
void Visit(ShaderVisitor& visitor) override;
|
void Visit(ShaderVisitor& visitor) override;
|
||||||
|
|
||||||
ExpressionPtr sampler;
|
ExpressionPtr sampler;
|
||||||
|
|
@ -258,7 +258,7 @@ namespace Nz
|
||||||
{
|
{
|
||||||
inline IntrinsicCall();
|
inline IntrinsicCall();
|
||||||
|
|
||||||
ExpressionType GetExpressionType() const override;
|
BasicType GetExpressionType() const override;
|
||||||
void Visit(ShaderVisitor& visitor) override;
|
void Visit(ShaderVisitor& visitor) override;
|
||||||
|
|
||||||
IntrinsicType intrinsic;
|
IntrinsicType intrinsic;
|
||||||
|
|
|
||||||
|
|
@ -23,20 +23,20 @@ namespace Nz::ShaderNodes
|
||||||
return m_isStatement;
|
return m_isStatement;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline unsigned int Node::GetComponentCount(ExpressionType type)
|
inline unsigned int Node::GetComponentCount(BasicType type)
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case ExpressionType::Float2:
|
case BasicType::Float2:
|
||||||
return 2;
|
return 2;
|
||||||
|
|
||||||
case ExpressionType::Float3:
|
case BasicType::Float3:
|
||||||
return 3;
|
return 3;
|
||||||
|
|
||||||
case ExpressionType::Float4:
|
case BasicType::Float4:
|
||||||
return 4;
|
return 4;
|
||||||
|
|
||||||
case ExpressionType::Mat4x4:
|
case BasicType::Mat4x4:
|
||||||
return 4;
|
return 4;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
@ -44,17 +44,17 @@ namespace Nz::ShaderNodes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline ExpressionType Node::GetComponentType(ExpressionType type)
|
inline BasicType Node::GetComponentType(BasicType type)
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case ExpressionType::Float2:
|
case BasicType::Float2:
|
||||||
case ExpressionType::Float3:
|
case BasicType::Float3:
|
||||||
case ExpressionType::Float4:
|
case BasicType::Float4:
|
||||||
return ExpressionType::Float1;
|
return BasicType::Float1;
|
||||||
|
|
||||||
case ExpressionType::Mat4x4:
|
case BasicType::Mat4x4:
|
||||||
return ExpressionType::Float4;
|
return BasicType::Float4;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return type;
|
return type;
|
||||||
|
|
@ -198,7 +198,7 @@ namespace Nz::ShaderNodes
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::shared_ptr<Cast> Cast::Build(ExpressionType castTo, ExpressionPtr first, ExpressionPtr second, ExpressionPtr third, ExpressionPtr fourth)
|
inline std::shared_ptr<Cast> Cast::Build(BasicType castTo, ExpressionPtr first, ExpressionPtr second, ExpressionPtr third, ExpressionPtr fourth)
|
||||||
{
|
{
|
||||||
auto node = std::make_shared<Cast>();
|
auto node = std::make_shared<Cast>();
|
||||||
node->exprType = castTo;
|
node->exprType = castTo;
|
||||||
|
|
@ -207,7 +207,7 @@ namespace Nz::ShaderNodes
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::shared_ptr<Cast> Cast::Build(ExpressionType castTo, ExpressionPtr* Expressions, std::size_t expressionCount)
|
inline std::shared_ptr<Cast> Cast::Build(BasicType castTo, ExpressionPtr* Expressions, std::size_t expressionCount)
|
||||||
{
|
{
|
||||||
auto node = std::make_shared<Cast>();
|
auto node = std::make_shared<Cast>();
|
||||||
node->exprType = castTo;
|
node->exprType = castTo;
|
||||||
|
|
@ -226,7 +226,7 @@ namespace Nz::ShaderNodes
|
||||||
inline std::shared_ptr<Constant> Constant::Build(bool value)
|
inline std::shared_ptr<Constant> Constant::Build(bool value)
|
||||||
{
|
{
|
||||||
auto node = std::make_shared<Constant>();
|
auto node = std::make_shared<Constant>();
|
||||||
node->exprType = ExpressionType::Boolean;
|
node->exprType = BasicType::Boolean;
|
||||||
node->values.bool1 = value;
|
node->values.bool1 = value;
|
||||||
|
|
||||||
return node;
|
return node;
|
||||||
|
|
@ -235,7 +235,7 @@ namespace Nz::ShaderNodes
|
||||||
inline std::shared_ptr<Constant> Constant::Build(float value)
|
inline std::shared_ptr<Constant> Constant::Build(float value)
|
||||||
{
|
{
|
||||||
auto node = std::make_shared<Constant>();
|
auto node = std::make_shared<Constant>();
|
||||||
node->exprType = ExpressionType::Float1;
|
node->exprType = BasicType::Float1;
|
||||||
node->values.vec1 = value;
|
node->values.vec1 = value;
|
||||||
|
|
||||||
return node;
|
return node;
|
||||||
|
|
@ -244,7 +244,7 @@ namespace Nz::ShaderNodes
|
||||||
inline std::shared_ptr<Constant> Constant::Build(const Vector2f& value)
|
inline std::shared_ptr<Constant> Constant::Build(const Vector2f& value)
|
||||||
{
|
{
|
||||||
auto node = std::make_shared<Constant>();
|
auto node = std::make_shared<Constant>();
|
||||||
node->exprType = ExpressionType::Float2;
|
node->exprType = BasicType::Float2;
|
||||||
node->values.vec2 = value;
|
node->values.vec2 = value;
|
||||||
|
|
||||||
return node;
|
return node;
|
||||||
|
|
@ -253,7 +253,7 @@ namespace Nz::ShaderNodes
|
||||||
inline std::shared_ptr<Constant> Constant::Build(const Vector3f& value)
|
inline std::shared_ptr<Constant> Constant::Build(const Vector3f& value)
|
||||||
{
|
{
|
||||||
auto node = std::make_shared<Constant>();
|
auto node = std::make_shared<Constant>();
|
||||||
node->exprType = ExpressionType::Float3;
|
node->exprType = BasicType::Float3;
|
||||||
node->values.vec3 = value;
|
node->values.vec3 = value;
|
||||||
|
|
||||||
return node;
|
return node;
|
||||||
|
|
@ -262,7 +262,7 @@ namespace Nz::ShaderNodes
|
||||||
inline std::shared_ptr<Constant> Constant::Build(const Vector4f& value)
|
inline std::shared_ptr<Constant> Constant::Build(const Vector4f& value)
|
||||||
{
|
{
|
||||||
auto node = std::make_shared<Constant>();
|
auto node = std::make_shared<Constant>();
|
||||||
node->exprType = ExpressionType::Float4;
|
node->exprType = BasicType::Float4;
|
||||||
node->values.vec4 = value;
|
node->values.vec4 = value;
|
||||||
|
|
||||||
return node;
|
return node;
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,7 @@ namespace Nz
|
||||||
private:
|
private:
|
||||||
bool IsWriting() const override;
|
bool IsWriting() const override;
|
||||||
void Node(ShaderNodes::NodePtr& node) override;
|
void Node(ShaderNodes::NodePtr& node) override;
|
||||||
void Type(ShaderAst::Type& type);
|
void Type(ShaderExpressionType& type);
|
||||||
void Value(bool& val) override;
|
void Value(bool& val) override;
|
||||||
void Value(float& val) override;
|
void Value(float& val) override;
|
||||||
void Value(std::string& val) override;
|
void Value(std::string& val) override;
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ namespace Nz
|
||||||
const ShaderNodes::ExpressionPtr& MandatoryExpr(const ShaderNodes::ExpressionPtr& node);
|
const ShaderNodes::ExpressionPtr& MandatoryExpr(const ShaderNodes::ExpressionPtr& node);
|
||||||
const ShaderNodes::NodePtr& MandatoryNode(const ShaderNodes::NodePtr& node);
|
const ShaderNodes::NodePtr& MandatoryNode(const ShaderNodes::NodePtr& node);
|
||||||
void TypeMustMatch(const ShaderNodes::ExpressionPtr& left, const ShaderNodes::ExpressionPtr& right);
|
void TypeMustMatch(const ShaderNodes::ExpressionPtr& left, const ShaderNodes::ExpressionPtr& right);
|
||||||
void TypeMustMatch(const ShaderAst::Type& left, const ShaderAst::Type& right);
|
void TypeMustMatch(const ShaderExpressionType& left, const ShaderExpressionType& right);
|
||||||
|
|
||||||
using ShaderVisitor::Visit;
|
using ShaderVisitor::Visit;
|
||||||
void Visit(const ShaderNodes::AssignOp& node) override;
|
void Visit(const ShaderNodes::AssignOp& node) override;
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ namespace Nz
|
||||||
virtual VariableType GetType() const = 0;
|
virtual VariableType GetType() const = 0;
|
||||||
virtual void Visit(ShaderVarVisitor& visitor) = 0;
|
virtual void Visit(ShaderVarVisitor& visitor) = 0;
|
||||||
|
|
||||||
ExpressionType type;
|
BasicType type;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct BuiltinVariable;
|
struct BuiltinVariable;
|
||||||
|
|
@ -48,7 +48,7 @@ namespace Nz
|
||||||
VariableType GetType() const override;
|
VariableType GetType() const override;
|
||||||
void Visit(ShaderVarVisitor& visitor) override;
|
void Visit(ShaderVarVisitor& visitor) override;
|
||||||
|
|
||||||
static inline std::shared_ptr<BuiltinVariable> Build(BuiltinEntry entry, ExpressionType varType);
|
static inline std::shared_ptr<BuiltinVariable> Build(BuiltinEntry entry, BasicType varType);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct NamedVariable;
|
struct NamedVariable;
|
||||||
|
|
@ -69,7 +69,7 @@ namespace Nz
|
||||||
VariableType GetType() const override;
|
VariableType GetType() const override;
|
||||||
void Visit(ShaderVarVisitor& visitor) override;
|
void Visit(ShaderVarVisitor& visitor) override;
|
||||||
|
|
||||||
static inline std::shared_ptr<InputVariable> Build(std::string varName, ExpressionType varType);
|
static inline std::shared_ptr<InputVariable> Build(std::string varName, BasicType varType);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LocalVariable;
|
struct LocalVariable;
|
||||||
|
|
@ -81,7 +81,7 @@ namespace Nz
|
||||||
VariableType GetType() const override;
|
VariableType GetType() const override;
|
||||||
void Visit(ShaderVarVisitor& visitor) override;
|
void Visit(ShaderVarVisitor& visitor) override;
|
||||||
|
|
||||||
static inline std::shared_ptr<LocalVariable> Build(std::string varName, ExpressionType varType);
|
static inline std::shared_ptr<LocalVariable> Build(std::string varName, BasicType varType);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct OutputVariable;
|
struct OutputVariable;
|
||||||
|
|
@ -93,7 +93,7 @@ namespace Nz
|
||||||
VariableType GetType() const override;
|
VariableType GetType() const override;
|
||||||
void Visit(ShaderVarVisitor& visitor) override;
|
void Visit(ShaderVarVisitor& visitor) override;
|
||||||
|
|
||||||
static inline std::shared_ptr<OutputVariable> Build(std::string varName, ExpressionType varType);
|
static inline std::shared_ptr<OutputVariable> Build(std::string varName, BasicType varType);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ParameterVariable;
|
struct ParameterVariable;
|
||||||
|
|
@ -105,7 +105,7 @@ namespace Nz
|
||||||
VariableType GetType() const override;
|
VariableType GetType() const override;
|
||||||
void Visit(ShaderVarVisitor& visitor) override;
|
void Visit(ShaderVarVisitor& visitor) override;
|
||||||
|
|
||||||
static inline std::shared_ptr<ParameterVariable> Build(std::string varName, ExpressionType varType);
|
static inline std::shared_ptr<ParameterVariable> Build(std::string varName, BasicType varType);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct UniformVariable;
|
struct UniformVariable;
|
||||||
|
|
@ -117,7 +117,7 @@ namespace Nz
|
||||||
VariableType GetType() const override;
|
VariableType GetType() const override;
|
||||||
void Visit(ShaderVarVisitor& visitor) override;
|
void Visit(ShaderVarVisitor& visitor) override;
|
||||||
|
|
||||||
static inline std::shared_ptr<UniformVariable> Build(std::string varName, ExpressionType varType);
|
static inline std::shared_ptr<UniformVariable> Build(std::string varName, BasicType varType);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
namespace Nz::ShaderNodes
|
namespace Nz::ShaderNodes
|
||||||
{
|
{
|
||||||
inline std::shared_ptr<BuiltinVariable> BuiltinVariable::Build(BuiltinEntry variable, ExpressionType varType)
|
inline std::shared_ptr<BuiltinVariable> BuiltinVariable::Build(BuiltinEntry variable, BasicType varType)
|
||||||
{
|
{
|
||||||
auto node = std::make_shared<BuiltinVariable>();
|
auto node = std::make_shared<BuiltinVariable>();
|
||||||
node->entry = variable;
|
node->entry = variable;
|
||||||
|
|
@ -16,7 +16,7 @@ namespace Nz::ShaderNodes
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::shared_ptr<InputVariable> InputVariable::Build(std::string varName, ExpressionType varType)
|
inline std::shared_ptr<InputVariable> InputVariable::Build(std::string varName, BasicType varType)
|
||||||
{
|
{
|
||||||
auto node = std::make_shared<InputVariable>();
|
auto node = std::make_shared<InputVariable>();
|
||||||
node->name = std::move(varName);
|
node->name = std::move(varName);
|
||||||
|
|
@ -25,7 +25,7 @@ namespace Nz::ShaderNodes
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::shared_ptr<LocalVariable> LocalVariable::Build(std::string varName, ExpressionType varType)
|
inline std::shared_ptr<LocalVariable> LocalVariable::Build(std::string varName, BasicType varType)
|
||||||
{
|
{
|
||||||
auto node = std::make_shared<LocalVariable>();
|
auto node = std::make_shared<LocalVariable>();
|
||||||
node->name = std::move(varName);
|
node->name = std::move(varName);
|
||||||
|
|
@ -34,7 +34,7 @@ namespace Nz::ShaderNodes
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::shared_ptr<OutputVariable> OutputVariable::Build(std::string varName, ExpressionType varType)
|
inline std::shared_ptr<OutputVariable> OutputVariable::Build(std::string varName, BasicType varType)
|
||||||
{
|
{
|
||||||
auto node = std::make_shared<OutputVariable>();
|
auto node = std::make_shared<OutputVariable>();
|
||||||
node->name = std::move(varName);
|
node->name = std::move(varName);
|
||||||
|
|
@ -43,7 +43,7 @@ namespace Nz::ShaderNodes
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::shared_ptr<ParameterVariable> ParameterVariable::Build(std::string varName, ExpressionType varType)
|
inline std::shared_ptr<ParameterVariable> ParameterVariable::Build(std::string varName, BasicType varType)
|
||||||
{
|
{
|
||||||
auto node = std::make_shared<ParameterVariable>();
|
auto node = std::make_shared<ParameterVariable>();
|
||||||
node->name = std::move(varName);
|
node->name = std::move(varName);
|
||||||
|
|
@ -52,7 +52,7 @@ namespace Nz::ShaderNodes
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::shared_ptr<UniformVariable> UniformVariable::Build(std::string varName, ExpressionType varType)
|
inline std::shared_ptr<UniformVariable> UniformVariable::Build(std::string varName, BasicType varType)
|
||||||
{
|
{
|
||||||
auto node = std::make_shared<UniformVariable>();
|
auto node = std::make_shared<UniformVariable>();
|
||||||
node->name = std::move(varName);
|
node->name = std::move(varName);
|
||||||
|
|
|
||||||
|
|
@ -278,6 +278,8 @@ namespace Nz::GL
|
||||||
glGetIntegerv(GL_VIEWPORT, res.data());
|
glGetIntegerv(GL_VIEWPORT, res.data());
|
||||||
m_state.viewport = { res[0], res[1], res[2], res[3] };
|
m_state.viewport = { res[0], res[1], res[2], res[3] };
|
||||||
|
|
||||||
|
EnableVerticalSync(false);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,13 @@ namespace Nz::GL
|
||||||
|
|
||||||
void WGLContext::EnableVerticalSync(bool enabled)
|
void WGLContext::EnableVerticalSync(bool enabled)
|
||||||
{
|
{
|
||||||
|
if (wglSwapIntervalEXT)
|
||||||
|
{
|
||||||
|
if (!SetCurrentContext(this))
|
||||||
|
return;
|
||||||
|
|
||||||
|
wglSwapIntervalEXT(enabled);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WGLContext::SwapBuffers()
|
void WGLContext::SwapBuffers()
|
||||||
|
|
|
||||||
|
|
@ -163,7 +163,7 @@ namespace Nz
|
||||||
m_environment = std::move(environment);
|
m_environment = std::move(environment);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlslWriter::Append(ShaderAst::Type type)
|
void GlslWriter::Append(ShaderExpressionType type)
|
||||||
{
|
{
|
||||||
std::visit([&](auto&& arg)
|
std::visit([&](auto&& arg)
|
||||||
{
|
{
|
||||||
|
|
@ -181,32 +181,32 @@ namespace Nz
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlslWriter::Append(ShaderNodes::ExpressionType type)
|
void GlslWriter::Append(ShaderNodes::BasicType type)
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case ShaderNodes::ExpressionType::Boolean:
|
case ShaderNodes::BasicType::Boolean:
|
||||||
Append("bool");
|
Append("bool");
|
||||||
break;
|
break;
|
||||||
case ShaderNodes::ExpressionType::Float1:
|
case ShaderNodes::BasicType::Float1:
|
||||||
Append("float");
|
Append("float");
|
||||||
break;
|
break;
|
||||||
case ShaderNodes::ExpressionType::Float2:
|
case ShaderNodes::BasicType::Float2:
|
||||||
Append("vec2");
|
Append("vec2");
|
||||||
break;
|
break;
|
||||||
case ShaderNodes::ExpressionType::Float3:
|
case ShaderNodes::BasicType::Float3:
|
||||||
Append("vec3");
|
Append("vec3");
|
||||||
break;
|
break;
|
||||||
case ShaderNodes::ExpressionType::Float4:
|
case ShaderNodes::BasicType::Float4:
|
||||||
Append("vec4");
|
Append("vec4");
|
||||||
break;
|
break;
|
||||||
case ShaderNodes::ExpressionType::Mat4x4:
|
case ShaderNodes::BasicType::Mat4x4:
|
||||||
Append("mat4");
|
Append("mat4");
|
||||||
break;
|
break;
|
||||||
case ShaderNodes::ExpressionType::Sampler2D:
|
case ShaderNodes::BasicType::Sampler2D:
|
||||||
Append("sampler2D");
|
Append("sampler2D");
|
||||||
break;
|
break;
|
||||||
case ShaderNodes::ExpressionType::Void:
|
case ShaderNodes::BasicType::Void:
|
||||||
Append("void");
|
Append("void");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -395,23 +395,23 @@ namespace Nz
|
||||||
{
|
{
|
||||||
switch (node.exprType)
|
switch (node.exprType)
|
||||||
{
|
{
|
||||||
case ShaderNodes::ExpressionType::Boolean:
|
case ShaderNodes::BasicType::Boolean:
|
||||||
Append((node.values.bool1) ? "true" : "false");
|
Append((node.values.bool1) ? "true" : "false");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ShaderNodes::ExpressionType::Float1:
|
case ShaderNodes::BasicType::Float1:
|
||||||
Append(std::to_string(node.values.vec1));
|
Append(std::to_string(node.values.vec1));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ShaderNodes::ExpressionType::Float2:
|
case ShaderNodes::BasicType::Float2:
|
||||||
Append("vec2(" + std::to_string(node.values.vec2.x) + ", " + std::to_string(node.values.vec2.y) + ")");
|
Append("vec2(" + std::to_string(node.values.vec2.x) + ", " + std::to_string(node.values.vec2.y) + ")");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ShaderNodes::ExpressionType::Float3:
|
case ShaderNodes::BasicType::Float3:
|
||||||
Append("vec3(" + std::to_string(node.values.vec3.x) + ", " + std::to_string(node.values.vec3.y) + ", " + std::to_string(node.values.vec3.z) + ")");
|
Append("vec3(" + std::to_string(node.values.vec3.x) + ", " + std::to_string(node.values.vec3.y) + ", " + std::to_string(node.values.vec3.z) + ")");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ShaderNodes::ExpressionType::Float4:
|
case ShaderNodes::BasicType::Float4:
|
||||||
Append("vec4(" + std::to_string(node.values.vec4.x) + ", " + std::to_string(node.values.vec4.y) + ", " + std::to_string(node.values.vec4.z) + ", " + std::to_string(node.values.vec4.w) + ")");
|
Append("vec4(" + std::to_string(node.values.vec4.x) + ", " + std::to_string(node.values.vec4.y) + ", " + std::to_string(node.values.vec4.z) + ", " + std::to_string(node.values.vec4.w) + ")");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
namespace Nz
|
namespace Nz
|
||||||
{
|
{
|
||||||
void ShaderAst::AddFunction(std::string name, ShaderNodes::StatementPtr statement, std::vector<FunctionParameter> parameters, ShaderNodes::ExpressionType returnType)
|
void ShaderAst::AddFunction(std::string name, ShaderNodes::StatementPtr statement, std::vector<FunctionParameter> parameters, ShaderNodes::BasicType returnType)
|
||||||
{
|
{
|
||||||
auto& functionEntry = m_functions.emplace_back();
|
auto& functionEntry = m_functions.emplace_back();
|
||||||
functionEntry.name = std::move(name);
|
functionEntry.name = std::move(name);
|
||||||
|
|
@ -16,7 +16,7 @@ namespace Nz
|
||||||
functionEntry.statement = std::move(statement);
|
functionEntry.statement = std::move(statement);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShaderAst::AddInput(std::string name, Type type, std::optional<std::size_t> locationIndex)
|
void ShaderAst::AddInput(std::string name, ShaderExpressionType type, std::optional<std::size_t> locationIndex)
|
||||||
{
|
{
|
||||||
auto& inputEntry = m_inputs.emplace_back();
|
auto& inputEntry = m_inputs.emplace_back();
|
||||||
inputEntry.name = std::move(name);
|
inputEntry.name = std::move(name);
|
||||||
|
|
@ -24,7 +24,7 @@ namespace Nz
|
||||||
inputEntry.type = std::move(type);
|
inputEntry.type = std::move(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShaderAst::AddOutput(std::string name, Type type, std::optional<std::size_t> locationIndex)
|
void ShaderAst::AddOutput(std::string name, ShaderExpressionType type, std::optional<std::size_t> locationIndex)
|
||||||
{
|
{
|
||||||
auto& outputEntry = m_outputs.emplace_back();
|
auto& outputEntry = m_outputs.emplace_back();
|
||||||
outputEntry.name = std::move(name);
|
outputEntry.name = std::move(name);
|
||||||
|
|
@ -39,7 +39,7 @@ namespace Nz
|
||||||
structEntry.members = std::move(members);
|
structEntry.members = std::move(members);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShaderAst::AddUniform(std::string name, Type type, std::optional<std::size_t> bindingIndex, std::optional<ShaderNodes::MemoryLayout> memoryLayout)
|
void ShaderAst::AddUniform(std::string name, ShaderExpressionType type, std::optional<std::size_t> bindingIndex, std::optional<ShaderNodes::MemoryLayout> memoryLayout)
|
||||||
{
|
{
|
||||||
auto& uniformEntry = m_uniforms.emplace_back();
|
auto& uniformEntry = m_uniforms.emplace_back();
|
||||||
uniformEntry.bindingIndex = std::move(bindingIndex);
|
uniformEntry.bindingIndex = std::move(bindingIndex);
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ namespace Nz::ShaderNodes
|
||||||
return ExpressionCategory::LValue;
|
return ExpressionCategory::LValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ExpressionType Identifier::GetExpressionType() const
|
BasicType Identifier::GetExpressionType() const
|
||||||
{
|
{
|
||||||
assert(var);
|
assert(var);
|
||||||
return var->type;
|
return var->type;
|
||||||
|
|
@ -59,7 +59,7 @@ namespace Nz::ShaderNodes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ExpressionType AssignOp::GetExpressionType() const
|
BasicType AssignOp::GetExpressionType() const
|
||||||
{
|
{
|
||||||
return left->GetExpressionType();
|
return left->GetExpressionType();
|
||||||
}
|
}
|
||||||
|
|
@ -70,9 +70,9 @@ namespace Nz::ShaderNodes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ExpressionType BinaryOp::GetExpressionType() const
|
BasicType BinaryOp::GetExpressionType() const
|
||||||
{
|
{
|
||||||
ShaderNodes::ExpressionType exprType = ShaderNodes::ExpressionType::Void;
|
ShaderNodes::BasicType exprType = ShaderNodes::BasicType::Void;
|
||||||
|
|
||||||
switch (op)
|
switch (op)
|
||||||
{
|
{
|
||||||
|
|
@ -84,15 +84,15 @@ namespace Nz::ShaderNodes
|
||||||
case ShaderNodes::BinaryType::Divide:
|
case ShaderNodes::BinaryType::Divide:
|
||||||
case ShaderNodes::BinaryType::Multiply:
|
case ShaderNodes::BinaryType::Multiply:
|
||||||
//FIXME
|
//FIXME
|
||||||
exprType = static_cast<ExpressionType>(std::max(UnderlyingCast(left->GetExpressionType()), UnderlyingCast(right->GetExpressionType())));
|
exprType = static_cast<BasicType>(std::max(UnderlyingCast(left->GetExpressionType()), UnderlyingCast(right->GetExpressionType())));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ShaderNodes::BinaryType::Equality:
|
case ShaderNodes::BinaryType::Equality:
|
||||||
exprType = ExpressionType::Boolean;
|
exprType = BasicType::Boolean;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
NazaraAssert(exprType != ShaderNodes::ExpressionType::Void, "Unhandled builtin");
|
NazaraAssert(exprType != ShaderNodes::BasicType::Void, "Unhandled builtin");
|
||||||
|
|
||||||
return exprType;
|
return exprType;
|
||||||
}
|
}
|
||||||
|
|
@ -109,7 +109,7 @@ namespace Nz::ShaderNodes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ExpressionType Constant::GetExpressionType() const
|
BasicType Constant::GetExpressionType() const
|
||||||
{
|
{
|
||||||
return exprType;
|
return exprType;
|
||||||
}
|
}
|
||||||
|
|
@ -119,7 +119,7 @@ namespace Nz::ShaderNodes
|
||||||
visitor.Visit(*this);
|
visitor.Visit(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
ExpressionType Cast::GetExpressionType() const
|
BasicType Cast::GetExpressionType() const
|
||||||
{
|
{
|
||||||
return exprType;
|
return exprType;
|
||||||
}
|
}
|
||||||
|
|
@ -135,9 +135,9 @@ namespace Nz::ShaderNodes
|
||||||
return ExpressionCategory::LValue;
|
return ExpressionCategory::LValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ExpressionType SwizzleOp::GetExpressionType() const
|
BasicType SwizzleOp::GetExpressionType() const
|
||||||
{
|
{
|
||||||
return static_cast<ExpressionType>(UnderlyingCast(GetComponentType(expression->GetExpressionType())) + componentCount - 1);
|
return static_cast<BasicType>(UnderlyingCast(GetComponentType(expression->GetExpressionType())) + componentCount - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SwizzleOp::Visit(ShaderVisitor& visitor)
|
void SwizzleOp::Visit(ShaderVisitor& visitor)
|
||||||
|
|
@ -146,9 +146,9 @@ namespace Nz::ShaderNodes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ExpressionType Sample2D::GetExpressionType() const
|
BasicType Sample2D::GetExpressionType() const
|
||||||
{
|
{
|
||||||
return ExpressionType::Float4;
|
return BasicType::Float4;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sample2D::Visit(ShaderVisitor& visitor)
|
void Sample2D::Visit(ShaderVisitor& visitor)
|
||||||
|
|
@ -157,7 +157,7 @@ namespace Nz::ShaderNodes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ExpressionType IntrinsicCall::GetExpressionType() const
|
BasicType IntrinsicCall::GetExpressionType() const
|
||||||
{
|
{
|
||||||
switch (intrinsic)
|
switch (intrinsic)
|
||||||
{
|
{
|
||||||
|
|
@ -165,11 +165,11 @@ namespace Nz::ShaderNodes
|
||||||
return parameters.front()->GetExpressionType();
|
return parameters.front()->GetExpressionType();
|
||||||
|
|
||||||
case IntrinsicType::DotProduct:
|
case IntrinsicType::DotProduct:
|
||||||
return ExpressionType::Float1;
|
return BasicType::Float1;
|
||||||
}
|
}
|
||||||
|
|
||||||
NazaraAssert(false, "Unhandled builtin");
|
NazaraAssert(false, "Unhandled builtin");
|
||||||
return ExpressionType::Void;
|
return BasicType::Void;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IntrinsicCall::Visit(ShaderVisitor& visitor)
|
void IntrinsicCall::Visit(ShaderVisitor& visitor)
|
||||||
|
|
|
||||||
|
|
@ -170,23 +170,23 @@ namespace Nz
|
||||||
|
|
||||||
switch (node.exprType)
|
switch (node.exprType)
|
||||||
{
|
{
|
||||||
case ShaderNodes::ExpressionType::Boolean:
|
case ShaderNodes::BasicType::Boolean:
|
||||||
Value(node.values.bool1);
|
Value(node.values.bool1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ShaderNodes::ExpressionType::Float1:
|
case ShaderNodes::BasicType::Float1:
|
||||||
Value(node.values.vec1);
|
Value(node.values.vec1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ShaderNodes::ExpressionType::Float2:
|
case ShaderNodes::BasicType::Float2:
|
||||||
Value(node.values.vec2);
|
Value(node.values.vec2);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ShaderNodes::ExpressionType::Float3:
|
case ShaderNodes::BasicType::Float3:
|
||||||
Value(node.values.vec3);
|
Value(node.values.vec3);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ShaderNodes::ExpressionType::Float4:
|
case ShaderNodes::BasicType::Float4:
|
||||||
Value(node.values.vec4);
|
Value(node.values.vec4);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -249,12 +249,12 @@ namespace Nz
|
||||||
{
|
{
|
||||||
m_stream << s_magicNumber << s_currentVersion;
|
m_stream << s_magicNumber << s_currentVersion;
|
||||||
|
|
||||||
auto SerializeType = [&](const ShaderAst::Type& type)
|
auto SerializeType = [&](const ShaderExpressionType& type)
|
||||||
{
|
{
|
||||||
std::visit([&](auto&& arg)
|
std::visit([&](auto&& arg)
|
||||||
{
|
{
|
||||||
using T = std::decay_t<decltype(arg)>;
|
using T = std::decay_t<decltype(arg)>;
|
||||||
if constexpr (std::is_same_v<T, ShaderNodes::ExpressionType>)
|
if constexpr (std::is_same_v<T, ShaderNodes::BasicType>)
|
||||||
{
|
{
|
||||||
m_stream << UInt8(0);
|
m_stream << UInt8(0);
|
||||||
m_stream << UInt32(arg);
|
m_stream << UInt32(arg);
|
||||||
|
|
@ -448,7 +448,7 @@ namespace Nz
|
||||||
for (UInt32 i = 0; i < inputCount; ++i)
|
for (UInt32 i = 0; i < inputCount; ++i)
|
||||||
{
|
{
|
||||||
std::string inputName;
|
std::string inputName;
|
||||||
ShaderAst::Type inputType;
|
ShaderExpressionType inputType;
|
||||||
std::optional<std::size_t> location;
|
std::optional<std::size_t> location;
|
||||||
|
|
||||||
Value(inputName);
|
Value(inputName);
|
||||||
|
|
@ -463,7 +463,7 @@ namespace Nz
|
||||||
for (UInt32 i = 0; i < outputCount; ++i)
|
for (UInt32 i = 0; i < outputCount; ++i)
|
||||||
{
|
{
|
||||||
std::string outputName;
|
std::string outputName;
|
||||||
ShaderAst::Type outputType;
|
ShaderExpressionType outputType;
|
||||||
std::optional<std::size_t> location;
|
std::optional<std::size_t> location;
|
||||||
|
|
||||||
Value(outputName);
|
Value(outputName);
|
||||||
|
|
@ -478,7 +478,7 @@ namespace Nz
|
||||||
for (UInt32 i = 0; i < uniformCount; ++i)
|
for (UInt32 i = 0; i < uniformCount; ++i)
|
||||||
{
|
{
|
||||||
std::string name;
|
std::string name;
|
||||||
ShaderAst::Type type;
|
ShaderExpressionType type;
|
||||||
std::optional<std::size_t> binding;
|
std::optional<std::size_t> binding;
|
||||||
std::optional<ShaderNodes::MemoryLayout> memLayout;
|
std::optional<ShaderNodes::MemoryLayout> memLayout;
|
||||||
|
|
||||||
|
|
@ -495,7 +495,7 @@ namespace Nz
|
||||||
for (UInt32 i = 0; i < funcCount; ++i)
|
for (UInt32 i = 0; i < funcCount; ++i)
|
||||||
{
|
{
|
||||||
std::string name;
|
std::string name;
|
||||||
ShaderNodes::ExpressionType retType;
|
ShaderNodes::BasicType retType;
|
||||||
std::vector<ShaderAst::FunctionParameter> parameters;
|
std::vector<ShaderAst::FunctionParameter> parameters;
|
||||||
|
|
||||||
Value(name);
|
Value(name);
|
||||||
|
|
@ -560,7 +560,7 @@ namespace Nz
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShaderUnserializer::Type(ShaderAst::Type& type)
|
void ShaderUnserializer::Type(ShaderExpressionType& type)
|
||||||
{
|
{
|
||||||
UInt8 typeIndex;
|
UInt8 typeIndex;
|
||||||
Value(typeIndex);
|
Value(typeIndex);
|
||||||
|
|
@ -569,7 +569,7 @@ namespace Nz
|
||||||
{
|
{
|
||||||
case 0: //< Primitive
|
case 0: //< Primitive
|
||||||
{
|
{
|
||||||
ShaderNodes::ExpressionType exprType;
|
ShaderNodes::BasicType exprType;
|
||||||
Enum(exprType);
|
Enum(exprType);
|
||||||
|
|
||||||
type = exprType;
|
type = exprType;
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ namespace Nz
|
||||||
struct Local
|
struct Local
|
||||||
{
|
{
|
||||||
std::string name;
|
std::string name;
|
||||||
ShaderNodes::ExpressionType type;
|
ShaderNodes::BasicType type;
|
||||||
};
|
};
|
||||||
|
|
||||||
const ShaderAst::Function* currentFunction;
|
const ShaderAst::Function* currentFunction;
|
||||||
|
|
@ -77,7 +77,7 @@ namespace Nz
|
||||||
return TypeMustMatch(left->GetExpressionType(), right->GetExpressionType());
|
return TypeMustMatch(left->GetExpressionType(), right->GetExpressionType());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShaderValidator::TypeMustMatch(const ShaderAst::Type& left, const ShaderAst::Type& right)
|
void ShaderValidator::TypeMustMatch(const ShaderExpressionType& left, const ShaderExpressionType& right)
|
||||||
{
|
{
|
||||||
if (left != right)
|
if (left != right)
|
||||||
throw AstError{ "Left expression type must match right expression type" };
|
throw AstError{ "Left expression type must match right expression type" };
|
||||||
|
|
@ -101,8 +101,8 @@ namespace Nz
|
||||||
MandatoryNode(node.left);
|
MandatoryNode(node.left);
|
||||||
MandatoryNode(node.right);
|
MandatoryNode(node.right);
|
||||||
|
|
||||||
ShaderNodes::ExpressionType leftType = node.left->GetExpressionType();
|
ShaderNodes::BasicType leftType = node.left->GetExpressionType();
|
||||||
ShaderNodes::ExpressionType rightType = node.right->GetExpressionType();
|
ShaderNodes::BasicType rightType = node.right->GetExpressionType();
|
||||||
|
|
||||||
switch (node.op)
|
switch (node.op)
|
||||||
{
|
{
|
||||||
|
|
@ -117,31 +117,31 @@ namespace Nz
|
||||||
{
|
{
|
||||||
switch (leftType)
|
switch (leftType)
|
||||||
{
|
{
|
||||||
case ShaderNodes::ExpressionType::Float1:
|
case ShaderNodes::BasicType::Float1:
|
||||||
{
|
{
|
||||||
if (ShaderNodes::Node::GetComponentType(rightType) != ShaderNodes::ExpressionType::Float1)
|
if (ShaderNodes::Node::GetComponentType(rightType) != ShaderNodes::BasicType::Float1)
|
||||||
throw AstError{ "Left expression type is not compatible with right expression type" };
|
throw AstError{ "Left expression type is not compatible with right expression type" };
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case ShaderNodes::ExpressionType::Float2:
|
case ShaderNodes::BasicType::Float2:
|
||||||
case ShaderNodes::ExpressionType::Float3:
|
case ShaderNodes::BasicType::Float3:
|
||||||
case ShaderNodes::ExpressionType::Float4:
|
case ShaderNodes::BasicType::Float4:
|
||||||
{
|
{
|
||||||
if (leftType != rightType && rightType != ShaderNodes::ExpressionType::Float1)
|
if (leftType != rightType && rightType != ShaderNodes::BasicType::Float1)
|
||||||
throw AstError{ "Left expression type is not compatible with right expression type" };
|
throw AstError{ "Left expression type is not compatible with right expression type" };
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case ShaderNodes::ExpressionType::Mat4x4:
|
case ShaderNodes::BasicType::Mat4x4:
|
||||||
{
|
{
|
||||||
switch (rightType)
|
switch (rightType)
|
||||||
{
|
{
|
||||||
case ShaderNodes::ExpressionType::Float1:
|
case ShaderNodes::BasicType::Float1:
|
||||||
case ShaderNodes::ExpressionType::Float4:
|
case ShaderNodes::BasicType::Float4:
|
||||||
case ShaderNodes::ExpressionType::Mat4x4:
|
case ShaderNodes::BasicType::Mat4x4:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
@ -318,7 +318,7 @@ namespace Nz
|
||||||
for (auto& param : node.parameters)
|
for (auto& param : node.parameters)
|
||||||
MandatoryNode(param);
|
MandatoryNode(param);
|
||||||
|
|
||||||
ShaderNodes::ExpressionType type = node.parameters.front()->GetExpressionType();
|
ShaderNodes::BasicType type = node.parameters.front()->GetExpressionType();
|
||||||
for (std::size_t i = 1; i < node.parameters.size(); ++i)
|
for (std::size_t i = 1; i < node.parameters.size(); ++i)
|
||||||
{
|
{
|
||||||
if (type != node.parameters[i]->GetExpressionType())
|
if (type != node.parameters[i]->GetExpressionType())
|
||||||
|
|
@ -333,7 +333,7 @@ namespace Nz
|
||||||
{
|
{
|
||||||
case ShaderNodes::IntrinsicType::CrossProduct:
|
case ShaderNodes::IntrinsicType::CrossProduct:
|
||||||
{
|
{
|
||||||
if (node.parameters[0]->GetExpressionType() != ShaderNodes::ExpressionType::Float3)
|
if (node.parameters[0]->GetExpressionType() != ShaderNodes::BasicType::Float3)
|
||||||
throw AstError{ "CrossProduct only works with Float3 expressions" };
|
throw AstError{ "CrossProduct only works with Float3 expressions" };
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
@ -349,10 +349,10 @@ namespace Nz
|
||||||
|
|
||||||
void ShaderValidator::Visit(const ShaderNodes::Sample2D& node)
|
void ShaderValidator::Visit(const ShaderNodes::Sample2D& node)
|
||||||
{
|
{
|
||||||
if (MandatoryExpr(node.sampler)->GetExpressionType() != ShaderNodes::ExpressionType::Sampler2D)
|
if (MandatoryExpr(node.sampler)->GetExpressionType() != ShaderNodes::BasicType::Sampler2D)
|
||||||
throw AstError{ "Sampler must be a Sampler2D" };
|
throw AstError{ "Sampler must be a Sampler2D" };
|
||||||
|
|
||||||
if (MandatoryExpr(node.coordinates)->GetExpressionType() != ShaderNodes::ExpressionType::Float2)
|
if (MandatoryExpr(node.coordinates)->GetExpressionType() != ShaderNodes::BasicType::Float2)
|
||||||
throw AstError{ "Coordinates must be a Float2" };
|
throw AstError{ "Coordinates must be a Float2" };
|
||||||
|
|
||||||
Visit(node.sampler);
|
Visit(node.sampler);
|
||||||
|
|
@ -380,10 +380,10 @@ namespace Nz
|
||||||
|
|
||||||
switch (MandatoryExpr(node.expression)->GetExpressionType())
|
switch (MandatoryExpr(node.expression)->GetExpressionType())
|
||||||
{
|
{
|
||||||
case ShaderNodes::ExpressionType::Float1:
|
case ShaderNodes::BasicType::Float1:
|
||||||
case ShaderNodes::ExpressionType::Float2:
|
case ShaderNodes::BasicType::Float2:
|
||||||
case ShaderNodes::ExpressionType::Float3:
|
case ShaderNodes::BasicType::Float3:
|
||||||
case ShaderNodes::ExpressionType::Float4:
|
case ShaderNodes::BasicType::Float4:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
|
|
@ -116,15 +116,15 @@ Nz::ShaderNodes::ExpressionPtr InputValue::GetExpression(Nz::ShaderNodes::Expres
|
||||||
|
|
||||||
const auto& inputEntry = GetGraph().GetInput(*m_currentInputIndex);
|
const auto& inputEntry = GetGraph().GetInput(*m_currentInputIndex);
|
||||||
|
|
||||||
Nz::ShaderNodes::ExpressionType expression = [&]
|
Nz::ShaderNodes::BasicType expression = [&]
|
||||||
{
|
{
|
||||||
switch (inputEntry.type)
|
switch (inputEntry.type)
|
||||||
{
|
{
|
||||||
case PrimitiveType::Bool: return Nz::ShaderNodes::ExpressionType::Boolean;
|
case PrimitiveType::Bool: return Nz::ShaderNodes::BasicType::Boolean;
|
||||||
case PrimitiveType::Float1: return Nz::ShaderNodes::ExpressionType::Float1;
|
case PrimitiveType::Float1: return Nz::ShaderNodes::BasicType::Float1;
|
||||||
case PrimitiveType::Float2: return Nz::ShaderNodes::ExpressionType::Float2;
|
case PrimitiveType::Float2: return Nz::ShaderNodes::BasicType::Float2;
|
||||||
case PrimitiveType::Float3: return Nz::ShaderNodes::ExpressionType::Float3;
|
case PrimitiveType::Float3: return Nz::ShaderNodes::BasicType::Float3;
|
||||||
case PrimitiveType::Float4: return Nz::ShaderNodes::ExpressionType::Float4;
|
case PrimitiveType::Float4: return Nz::ShaderNodes::BasicType::Float4;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(false);
|
assert(false);
|
||||||
|
|
@ -145,7 +145,7 @@ auto InputValue::dataType(QtNodes::PortType portType, QtNodes::PortIndex portInd
|
||||||
const auto& inputEntry = GetGraph().GetInput(*m_currentInputIndex);
|
const auto& inputEntry = GetGraph().GetInput(*m_currentInputIndex);
|
||||||
switch (inputEntry.type)
|
switch (inputEntry.type)
|
||||||
{
|
{
|
||||||
//case InputType::Bool: return Nz::ShaderNodes::ExpressionType::Boolean;
|
//case InputType::Bool: return Nz::ShaderNodes::BasicType::Boolean;
|
||||||
case PrimitiveType::Float1:
|
case PrimitiveType::Float1:
|
||||||
return FloatData::Type();
|
return FloatData::Type();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -63,15 +63,15 @@ Nz::ShaderNodes::ExpressionPtr OutputValue::GetExpression(Nz::ShaderNodes::Expre
|
||||||
|
|
||||||
const auto& outputEntry = GetGraph().GetOutput(*m_currentOutputIndex);
|
const auto& outputEntry = GetGraph().GetOutput(*m_currentOutputIndex);
|
||||||
|
|
||||||
Nz::ShaderNodes::ExpressionType expression = [&]
|
Nz::ShaderNodes::BasicType expression = [&]
|
||||||
{
|
{
|
||||||
switch (outputEntry.type)
|
switch (outputEntry.type)
|
||||||
{
|
{
|
||||||
case PrimitiveType::Bool: return Nz::ShaderNodes::ExpressionType::Boolean;
|
case PrimitiveType::Bool: return Nz::ShaderNodes::BasicType::Boolean;
|
||||||
case PrimitiveType::Float1: return Nz::ShaderNodes::ExpressionType::Float1;
|
case PrimitiveType::Float1: return Nz::ShaderNodes::BasicType::Float1;
|
||||||
case PrimitiveType::Float2: return Nz::ShaderNodes::ExpressionType::Float2;
|
case PrimitiveType::Float2: return Nz::ShaderNodes::BasicType::Float2;
|
||||||
case PrimitiveType::Float3: return Nz::ShaderNodes::ExpressionType::Float3;
|
case PrimitiveType::Float3: return Nz::ShaderNodes::BasicType::Float3;
|
||||||
case PrimitiveType::Float4: return Nz::ShaderNodes::ExpressionType::Float4;
|
case PrimitiveType::Float4: return Nz::ShaderNodes::BasicType::Float4;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(false);
|
assert(false);
|
||||||
|
|
@ -94,8 +94,8 @@ QtNodes::NodeDataType OutputValue::dataType(QtNodes::PortType portType, QtNodes:
|
||||||
const auto& outputEntry = GetGraph().GetOutput(*m_currentOutputIndex);
|
const auto& outputEntry = GetGraph().GetOutput(*m_currentOutputIndex);
|
||||||
switch (outputEntry.type)
|
switch (outputEntry.type)
|
||||||
{
|
{
|
||||||
//case InOutType::Bool: return Nz::ShaderNodes::ExpressionType::Boolean;
|
//case InOutType::Bool: return Nz::ShaderNodes::BasicType::Boolean;
|
||||||
//case InOutType::Float1: return Nz::ShaderNodes::ExpressionType::Float1;
|
//case InOutType::Float1: return Nz::ShaderNodes::BasicType::Float1;
|
||||||
case PrimitiveType::Float2:
|
case PrimitiveType::Float2:
|
||||||
case PrimitiveType::Float3:
|
case PrimitiveType::Float3:
|
||||||
case PrimitiveType::Float4:
|
case PrimitiveType::Float4:
|
||||||
|
|
|
||||||
|
|
@ -119,11 +119,11 @@ Nz::ShaderNodes::ExpressionPtr TextureValue::GetExpression(Nz::ShaderNodes::Expr
|
||||||
|
|
||||||
const auto& textureEntry = GetGraph().GetTexture(*m_currentTextureIndex);
|
const auto& textureEntry = GetGraph().GetTexture(*m_currentTextureIndex);
|
||||||
|
|
||||||
Nz::ShaderNodes::ExpressionType expression = [&]
|
Nz::ShaderNodes::BasicType expression = [&]
|
||||||
{
|
{
|
||||||
switch (textureEntry.type)
|
switch (textureEntry.type)
|
||||||
{
|
{
|
||||||
case TextureType::Sampler2D: return Nz::ShaderNodes::ExpressionType::Sampler2D;
|
case TextureType::Sampler2D: return Nz::ShaderNodes::BasicType::Sampler2D;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(false);
|
assert(false);
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,13 @@
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
Nz::ShaderNodes::ExpressionType VecData::GetExpressionType() const
|
Nz::ShaderNodes::BasicType VecData::GetExpressionType() const
|
||||||
{
|
{
|
||||||
switch (componentCount)
|
switch (componentCount)
|
||||||
{
|
{
|
||||||
case 2: return Nz::ShaderNodes::ExpressionType::Float2;
|
case 2: return Nz::ShaderNodes::BasicType::Float2;
|
||||||
case 3: return Nz::ShaderNodes::ExpressionType::Float3;
|
case 3: return Nz::ShaderNodes::BasicType::Float3;
|
||||||
case 4: return Nz::ShaderNodes::ExpressionType::Float4;
|
case 4: return Nz::ShaderNodes::BasicType::Float4;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ struct VecData : public QtNodes::NodeData
|
||||||
|
|
||||||
inline QtNodes::NodeDataType type() const override;
|
inline QtNodes::NodeDataType type() const override;
|
||||||
|
|
||||||
Nz::ShaderNodes::ExpressionType GetExpressionType() const;
|
Nz::ShaderNodes::BasicType GetExpressionType() const;
|
||||||
|
|
||||||
static inline QtNodes::NodeDataType Type();
|
static inline QtNodes::NodeDataType Type();
|
||||||
|
|
||||||
|
|
@ -27,28 +27,28 @@ struct VecExpressionTypeHelper;
|
||||||
template<>
|
template<>
|
||||||
struct VecExpressionTypeHelper<1>
|
struct VecExpressionTypeHelper<1>
|
||||||
{
|
{
|
||||||
static constexpr Nz::ShaderNodes::ExpressionType ExpressionType = Nz::ShaderNodes::ExpressionType::Float1;
|
static constexpr Nz::ShaderNodes::BasicType ExpressionType = Nz::ShaderNodes::BasicType::Float1;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct VecExpressionTypeHelper<2>
|
struct VecExpressionTypeHelper<2>
|
||||||
{
|
{
|
||||||
static constexpr Nz::ShaderNodes::ExpressionType ExpressionType = Nz::ShaderNodes::ExpressionType::Float2;
|
static constexpr Nz::ShaderNodes::BasicType ExpressionType = Nz::ShaderNodes::BasicType::Float2;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct VecExpressionTypeHelper<3>
|
struct VecExpressionTypeHelper<3>
|
||||||
{
|
{
|
||||||
static constexpr Nz::ShaderNodes::ExpressionType ExpressionType = Nz::ShaderNodes::ExpressionType::Float3;
|
static constexpr Nz::ShaderNodes::BasicType ExpressionType = Nz::ShaderNodes::BasicType::Float3;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct VecExpressionTypeHelper<4>
|
struct VecExpressionTypeHelper<4>
|
||||||
{
|
{
|
||||||
static constexpr Nz::ShaderNodes::ExpressionType ExpressionType = Nz::ShaderNodes::ExpressionType::Float4;
|
static constexpr Nz::ShaderNodes::BasicType ExpressionType = Nz::ShaderNodes::BasicType::Float4;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<std::size_t N> constexpr Nz::ShaderNodes::ExpressionType VecExpressionType = VecExpressionTypeHelper<N>::template ExpressionType;
|
template<std::size_t N> constexpr Nz::ShaderNodes::BasicType VecExpressionType = VecExpressionTypeHelper<N>::template ExpressionType;
|
||||||
|
|
||||||
|
|
||||||
struct VecTypeDummy {};
|
struct VecTypeDummy {};
|
||||||
|
|
|
||||||
|
|
@ -217,11 +217,11 @@ Nz::ShaderAst MainWindow::ToShader()
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case PrimitiveType::Bool: return Nz::ShaderNodes::ExpressionType::Boolean;
|
case PrimitiveType::Bool: return Nz::ShaderNodes::BasicType::Boolean;
|
||||||
case PrimitiveType::Float1: return Nz::ShaderNodes::ExpressionType::Float1;
|
case PrimitiveType::Float1: return Nz::ShaderNodes::BasicType::Float1;
|
||||||
case PrimitiveType::Float2: return Nz::ShaderNodes::ExpressionType::Float2;
|
case PrimitiveType::Float2: return Nz::ShaderNodes::BasicType::Float2;
|
||||||
case PrimitiveType::Float3: return Nz::ShaderNodes::ExpressionType::Float3;
|
case PrimitiveType::Float3: return Nz::ShaderNodes::BasicType::Float3;
|
||||||
case PrimitiveType::Float4: return Nz::ShaderNodes::ExpressionType::Float4;
|
case PrimitiveType::Float4: return Nz::ShaderNodes::BasicType::Float4;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(false);
|
assert(false);
|
||||||
|
|
@ -232,7 +232,7 @@ Nz::ShaderAst MainWindow::ToShader()
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case TextureType::Sampler2D: return Nz::ShaderNodes::ExpressionType::Sampler2D;
|
case TextureType::Sampler2D: return Nz::ShaderNodes::BasicType::Sampler2D;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(false);
|
assert(false);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue