// Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com) // This file is part of the "Nazara Engine - Shader module" // For conditions of distribution and use, see copyright notice in Config.hpp #include #include namespace Nz::ShaderAst { ExpressionType GetExpressionType(const ConstantValue& constant) { return std::visit([&](auto&& arg) -> ShaderAst::ExpressionType { using T = std::decay_t; if constexpr (std::is_same_v) return NoType{}; else if constexpr (std::is_same_v) return PrimitiveType::Boolean; else if constexpr (std::is_same_v) return PrimitiveType::Float32; else if constexpr (std::is_same_v) return PrimitiveType::Int32; else if constexpr (std::is_same_v) return PrimitiveType::UInt32; else if constexpr (std::is_same_v) return VectorType{ 2, PrimitiveType::Float32 }; else if constexpr (std::is_same_v) return VectorType{ 3, PrimitiveType::Float32 }; else if constexpr (std::is_same_v) return VectorType{ 4, PrimitiveType::Float32 }; else if constexpr (std::is_same_v) return VectorType{ 2, PrimitiveType::Int32 }; else if constexpr (std::is_same_v) return VectorType{ 3, PrimitiveType::Int32 }; else if constexpr (std::is_same_v) return VectorType{ 4, PrimitiveType::Int32 }; else static_assert(AlwaysFalse::value, "non-exhaustive visitor"); }, constant); } }