Fix a lot of small errors/warnings
This commit is contained in:
@@ -70,9 +70,9 @@ namespace Nz
|
||||
glslVersion = 320;
|
||||
else if (m_environment.glMajorVersion >= 3 && m_environment.glMinorVersion >= 1)
|
||||
glslVersion = 310;
|
||||
else if (m_environment.glMajorVersion >= 3 && m_environment.glMinorVersion >= 0)
|
||||
else if (m_environment.glMajorVersion >= 3)
|
||||
glslVersion = 300;
|
||||
else if (m_environment.glMajorVersion >= 2 && m_environment.glMinorVersion >= 0)
|
||||
else if (m_environment.glMajorVersion >= 2)
|
||||
glslVersion = 100;
|
||||
else
|
||||
throw std::runtime_error("This version of OpenGL ES does not support shaders");
|
||||
@@ -85,11 +85,11 @@ namespace Nz
|
||||
glslVersion = 150;
|
||||
else if (m_environment.glMajorVersion >= 3 && m_environment.glMinorVersion >= 1)
|
||||
glslVersion = 140;
|
||||
else if (m_environment.glMajorVersion >= 3 && m_environment.glMinorVersion >= 0)
|
||||
else if (m_environment.glMajorVersion >= 3)
|
||||
glslVersion = 130;
|
||||
else if (m_environment.glMajorVersion >= 2 && m_environment.glMinorVersion >= 1)
|
||||
glslVersion = 120;
|
||||
else if (m_environment.glMajorVersion >= 2 && m_environment.glMinorVersion >= 0)
|
||||
else if (m_environment.glMajorVersion >= 2)
|
||||
glslVersion = 110;
|
||||
else
|
||||
throw std::runtime_error("This version of OpenGL does not support shaders");
|
||||
|
||||
@@ -8,67 +8,67 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
void ShaderAstVisitorExcept::Visit(ShaderNodes::AccessMember& node)
|
||||
void ShaderAstVisitorExcept::Visit(ShaderNodes::AccessMember& /*node*/)
|
||||
{
|
||||
throw std::runtime_error("unhandled AccessMember node");
|
||||
}
|
||||
|
||||
void ShaderAstVisitorExcept::Visit(ShaderNodes::AssignOp& node)
|
||||
void ShaderAstVisitorExcept::Visit(ShaderNodes::AssignOp& /*node*/)
|
||||
{
|
||||
throw std::runtime_error("unhandled AssignOp node");
|
||||
}
|
||||
|
||||
void ShaderAstVisitorExcept::Visit(ShaderNodes::BinaryOp& node)
|
||||
void ShaderAstVisitorExcept::Visit(ShaderNodes::BinaryOp& /*node*/)
|
||||
{
|
||||
throw std::runtime_error("unhandled AccessMember node");
|
||||
}
|
||||
|
||||
void ShaderAstVisitorExcept::Visit(ShaderNodes::Branch& node)
|
||||
void ShaderAstVisitorExcept::Visit(ShaderNodes::Branch& /*node*/)
|
||||
{
|
||||
throw std::runtime_error("unhandled Branch node");
|
||||
}
|
||||
|
||||
void ShaderAstVisitorExcept::Visit(ShaderNodes::Cast& node)
|
||||
void ShaderAstVisitorExcept::Visit(ShaderNodes::Cast& /*node*/)
|
||||
{
|
||||
throw std::runtime_error("unhandled Cast node");
|
||||
}
|
||||
|
||||
void ShaderAstVisitorExcept::Visit(ShaderNodes::Constant& node)
|
||||
void ShaderAstVisitorExcept::Visit(ShaderNodes::Constant& /*node*/)
|
||||
{
|
||||
throw std::runtime_error("unhandled Constant node");
|
||||
}
|
||||
|
||||
void ShaderAstVisitorExcept::Visit(ShaderNodes::DeclareVariable& node)
|
||||
void ShaderAstVisitorExcept::Visit(ShaderNodes::DeclareVariable& /*node*/)
|
||||
{
|
||||
throw std::runtime_error("unhandled DeclareVariable node");
|
||||
}
|
||||
|
||||
void ShaderAstVisitorExcept::Visit(ShaderNodes::ExpressionStatement& node)
|
||||
void ShaderAstVisitorExcept::Visit(ShaderNodes::ExpressionStatement& /*node*/)
|
||||
{
|
||||
throw std::runtime_error("unhandled ExpressionStatement node");
|
||||
}
|
||||
|
||||
void ShaderAstVisitorExcept::Visit(ShaderNodes::Identifier& node)
|
||||
void ShaderAstVisitorExcept::Visit(ShaderNodes::Identifier& /*node*/)
|
||||
{
|
||||
throw std::runtime_error("unhandled Identifier node");
|
||||
}
|
||||
|
||||
void ShaderAstVisitorExcept::Visit(ShaderNodes::IntrinsicCall& node)
|
||||
void ShaderAstVisitorExcept::Visit(ShaderNodes::IntrinsicCall& /*node*/)
|
||||
{
|
||||
throw std::runtime_error("unhandled IntrinsicCall node");
|
||||
}
|
||||
|
||||
void ShaderAstVisitorExcept::Visit(ShaderNodes::Sample2D& node)
|
||||
void ShaderAstVisitorExcept::Visit(ShaderNodes::Sample2D& /*node*/)
|
||||
{
|
||||
throw std::runtime_error("unhandled Sample2D node");
|
||||
}
|
||||
|
||||
void ShaderAstVisitorExcept::Visit(ShaderNodes::StatementBlock& node)
|
||||
void ShaderAstVisitorExcept::Visit(ShaderNodes::StatementBlock& /*node*/)
|
||||
{
|
||||
throw std::runtime_error("unhandled StatementBlock node");
|
||||
}
|
||||
|
||||
void ShaderAstVisitorExcept::Visit(ShaderNodes::SwizzleOp& node)
|
||||
void ShaderAstVisitorExcept::Visit(ShaderNodes::SwizzleOp& /*node*/)
|
||||
{
|
||||
throw std::runtime_error("unhandled SwizzleOp node");
|
||||
}
|
||||
|
||||
@@ -8,32 +8,32 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
void ShaderVarVisitorExcept::Visit(ShaderNodes::BuiltinVariable& var)
|
||||
void ShaderVarVisitorExcept::Visit(ShaderNodes::BuiltinVariable& /*var*/)
|
||||
{
|
||||
throw std::runtime_error("unhandled BuiltinVariable");
|
||||
}
|
||||
|
||||
void ShaderVarVisitorExcept::Visit(ShaderNodes::InputVariable& var)
|
||||
void ShaderVarVisitorExcept::Visit(ShaderNodes::InputVariable& /*var*/)
|
||||
{
|
||||
throw std::runtime_error("unhandled InputVariable");
|
||||
}
|
||||
|
||||
void ShaderVarVisitorExcept::Visit(ShaderNodes::LocalVariable& var)
|
||||
void ShaderVarVisitorExcept::Visit(ShaderNodes::LocalVariable& /*var*/)
|
||||
{
|
||||
throw std::runtime_error("unhandled LocalVariable");
|
||||
}
|
||||
|
||||
void ShaderVarVisitorExcept::Visit(ShaderNodes::OutputVariable& var)
|
||||
void ShaderVarVisitorExcept::Visit(ShaderNodes::OutputVariable& /*var*/)
|
||||
{
|
||||
throw std::runtime_error("unhandled OutputVariable");
|
||||
}
|
||||
|
||||
void ShaderVarVisitorExcept::Visit(ShaderNodes::ParameterVariable& var)
|
||||
void ShaderVarVisitorExcept::Visit(ShaderNodes::ParameterVariable& /*var*/)
|
||||
{
|
||||
throw std::runtime_error("unhandled ParameterVariable");
|
||||
}
|
||||
|
||||
void ShaderVarVisitorExcept::Visit(ShaderNodes::UniformVariable& var)
|
||||
void ShaderVarVisitorExcept::Visit(ShaderNodes::UniformVariable& /*var*/)
|
||||
{
|
||||
throw std::runtime_error("unhandled UniformVariable");
|
||||
}
|
||||
|
||||
@@ -88,6 +88,8 @@ namespace Nz
|
||||
case ShaderNodes::BasicType::Void:
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case ShaderNodes::BinaryType::Substract:
|
||||
@@ -116,6 +118,8 @@ namespace Nz
|
||||
case ShaderNodes::BasicType::Void:
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case ShaderNodes::BinaryType::Divide:
|
||||
@@ -146,6 +150,8 @@ namespace Nz
|
||||
case ShaderNodes::BasicType::Void:
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case ShaderNodes::BinaryType::Equality:
|
||||
@@ -176,6 +182,8 @@ namespace Nz
|
||||
case ShaderNodes::BasicType::Void:
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case ShaderNodes::BinaryType::Multiply:
|
||||
@@ -258,6 +266,7 @@ namespace Nz
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -483,7 +483,7 @@ namespace Nz
|
||||
|
||||
void SpirvConstantCache::Write(SpirvSection& annotations, SpirvSection& constants, SpirvSection& debugInfos)
|
||||
{
|
||||
for (auto&& [type, id] : m_internal->ids)
|
||||
for (auto&& [object, id] : m_internal->ids)
|
||||
{
|
||||
UInt32 resultId = id;
|
||||
|
||||
@@ -491,7 +491,7 @@ namespace Nz
|
||||
{
|
||||
[&](const AnyConstant& constant) { Write(constant, resultId, constants); },
|
||||
[&](const AnyType& type) { Write(type, resultId, annotations, constants, debugInfos); },
|
||||
}, type);
|
||||
}, object);
|
||||
}
|
||||
|
||||
for (auto&& [variable, id] : m_internal->variableIds)
|
||||
@@ -677,51 +677,51 @@ namespace Nz
|
||||
|
||||
void SpirvConstantCache::Write(const AnyConstant& constant, UInt32 resultId, SpirvSection& constants)
|
||||
{
|
||||
std::visit([&](auto&& arg)
|
||||
std::visit([&](auto&& constant)
|
||||
{
|
||||
using T = std::decay_t<decltype(arg)>;
|
||||
using ConstantType = std::decay_t<decltype(constant)>;
|
||||
|
||||
if constexpr (std::is_same_v<T, ConstantBool>)
|
||||
constants.Append((arg.value) ? SpirvOp::OpConstantTrue : SpirvOp::OpConstantFalse, resultId);
|
||||
else if constexpr (std::is_same_v<T, ConstantComposite>)
|
||||
if constexpr (std::is_same_v<ConstantType, ConstantBool>)
|
||||
constants.Append((constant.value) ? SpirvOp::OpConstantTrue : SpirvOp::OpConstantFalse, resultId);
|
||||
else if constexpr (std::is_same_v<ConstantType, ConstantComposite>)
|
||||
{
|
||||
constants.AppendVariadic(SpirvOp::OpConstantComposite, [&](const auto& appender)
|
||||
{
|
||||
appender(GetId(arg.type->type));
|
||||
appender(GetId(constant.type->type));
|
||||
appender(resultId);
|
||||
|
||||
for (const auto& value : arg.values)
|
||||
for (const auto& value : constant.values)
|
||||
appender(GetId(value->constant));
|
||||
});
|
||||
}
|
||||
else if constexpr (std::is_same_v<T, ConstantScalar>)
|
||||
else if constexpr (std::is_same_v<ConstantType, ConstantScalar>)
|
||||
{
|
||||
std::visit([&](auto&& arg)
|
||||
std::visit([&](auto&& value)
|
||||
{
|
||||
using T = std::decay_t<decltype(arg)>;
|
||||
using ValueType = std::decay_t<decltype(value)>;
|
||||
|
||||
UInt32 typeId;
|
||||
if constexpr (std::is_same_v<T, double>)
|
||||
if constexpr (std::is_same_v<ValueType, double>)
|
||||
typeId = GetId({ Float{ 64 } });
|
||||
else if constexpr (std::is_same_v<T, float>)
|
||||
else if constexpr (std::is_same_v<ValueType, float>)
|
||||
typeId = GetId({ Float{ 32 } });
|
||||
else if constexpr (std::is_same_v<T, Int32>)
|
||||
else if constexpr (std::is_same_v<ValueType, Int32>)
|
||||
typeId = GetId({ Integer{ 32, 1 } });
|
||||
else if constexpr (std::is_same_v<T, Int64>)
|
||||
else if constexpr (std::is_same_v<ValueType, Int64>)
|
||||
typeId = GetId({ Integer{ 64, 1 } });
|
||||
else if constexpr (std::is_same_v<T, UInt32>)
|
||||
else if constexpr (std::is_same_v<ValueType, UInt32>)
|
||||
typeId = GetId({ Integer{ 32, 0 } });
|
||||
else if constexpr (std::is_same_v<T, UInt64>)
|
||||
else if constexpr (std::is_same_v<ValueType, UInt64>)
|
||||
typeId = GetId({ Integer{ 64, 0 } });
|
||||
else
|
||||
static_assert(AlwaysFalse<T>::value, "non-exhaustive visitor");
|
||||
static_assert(AlwaysFalse<ValueType>::value, "non-exhaustive visitor");
|
||||
|
||||
constants.Append(SpirvOp::OpConstant, typeId, resultId, SpirvSection::Raw{ &arg, sizeof(arg) });
|
||||
constants.Append(SpirvOp::OpConstant, typeId, resultId, SpirvSection::Raw{ &value, sizeof(value) });
|
||||
|
||||
}, arg.value);
|
||||
}, constant.value);
|
||||
}
|
||||
else
|
||||
static_assert(AlwaysFalse<T>::value, "non-exhaustive visitor");
|
||||
static_assert(AlwaysFalse<ConstantType>::value, "non-exhaustive visitor");
|
||||
}, constant);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user