Move FieldOffsets class to Shader module and remove Utility dependency

This commit is contained in:
SirLynix 2022-04-04 19:22:18 +02:00
parent 998bcde2e2
commit 68d2dfcae6
21 changed files with 117 additions and 93 deletions

View File

@ -2,7 +2,7 @@
#include <Nazara/OpenGLRenderer.hpp> #include <Nazara/OpenGLRenderer.hpp>
#include <Nazara/OpenGLRenderer/Wrapper.hpp> #include <Nazara/OpenGLRenderer/Wrapper.hpp>
#include <Nazara/Renderer.hpp> #include <Nazara/Renderer.hpp>
#include <Nazara/Utility/FieldOffsets.hpp> #include <Nazara/Shader/FieldOffsets.hpp>
#include <iostream> #include <iostream>
#include <numeric> #include <numeric>

View File

@ -70,6 +70,20 @@ namespace Nz
constexpr std::size_t ErrorTypeCount = static_cast<std::size_t>(ErrorType::Max) + 1; constexpr std::size_t ErrorTypeCount = static_cast<std::size_t>(ErrorType::Max) + 1;
enum class ImageType
{
E1D,
E1D_Array,
E2D,
E2D_Array,
E3D,
Cubemap,
Max = Cubemap
};
constexpr std::size_t ImageTypeCount = static_cast<std::size_t>(ImageType::Max) + 1;
enum class HashType enum class HashType
{ {
CRC32, CRC32,

View File

@ -10,6 +10,7 @@
#include <Nazara/Prerequisites.hpp> #include <Nazara/Prerequisites.hpp>
#include <Nazara/OpenGLRenderer/Wrapper/Context.hpp> #include <Nazara/OpenGLRenderer/Wrapper/Context.hpp>
#include <Nazara/Renderer/Enums.hpp> #include <Nazara/Renderer/Enums.hpp>
#include <Nazara/Shader/Enums.hpp>
#include <Nazara/Utility/Enums.hpp> #include <Nazara/Utility/Enums.hpp>
#include <optional> #include <optional>
#include <string> #include <string>

View File

@ -10,7 +10,7 @@
#include <Nazara/Core/MovablePtr.hpp> #include <Nazara/Core/MovablePtr.hpp>
#include <Nazara/Renderer/Enums.hpp> #include <Nazara/Renderer/Enums.hpp>
#include <Nazara/Renderer/ShaderBinding.hpp> #include <Nazara/Renderer/ShaderBinding.hpp>
#include <Nazara/Utility/Enums.hpp> #include <Nazara/Shader/Enums.hpp>
#include <memory> #include <memory>
#include <string> #include <string>
#include <vector> #include <vector>

View File

@ -30,6 +30,8 @@
#define NAZARA_GLOBAL_SHADER_HPP #define NAZARA_GLOBAL_SHADER_HPP
#include <Nazara/Shader/Config.hpp> #include <Nazara/Shader/Config.hpp>
#include <Nazara/Shader/Enums.hpp>
#include <Nazara/Shader/FieldOffsets.hpp>
#include <Nazara/Shader/FilesystemModuleResolver.hpp> #include <Nazara/Shader/FilesystemModuleResolver.hpp>
#include <Nazara/Shader/GlslWriter.hpp> #include <Nazara/Shader/GlslWriter.hpp>
#include <Nazara/Shader/LangWriter.hpp> #include <Nazara/Shader/LangWriter.hpp>

View File

@ -8,10 +8,11 @@
#define NAZARA_SHADER_AST_EXPRESSIONTYPE_HPP #define NAZARA_SHADER_AST_EXPRESSIONTYPE_HPP
#include <Nazara/Prerequisites.hpp> #include <Nazara/Prerequisites.hpp>
#include <Nazara/Core/Enums.hpp>
#include <Nazara/Shader/Enums.hpp>
#include <Nazara/Shader/ShaderLangSourceLocation.hpp> #include <Nazara/Shader/ShaderLangSourceLocation.hpp>
#include <Nazara/Shader/Ast/Enums.hpp> #include <Nazara/Shader/Ast/Enums.hpp>
#include <Nazara/Shader/Ast/ExpressionValue.hpp> #include <Nazara/Shader/Ast/ExpressionValue.hpp>
#include <Nazara/Utility/Enums.hpp>
#include <optional> #include <optional>
#include <string> #include <string>
#include <variant> #include <variant>

View File

@ -0,0 +1,70 @@
// 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
#pragma once
#ifndef NAZARA_SHADER_ENUMS_HPP
#define NAZARA_SHADER_ENUMS_HPP
#include <Nazara/Core/Flags.hpp>
namespace Nz
{
enum class ShaderStageType
{
Fragment,
Vertex,
Max = Vertex
};
constexpr std::size_t ShaderStageTypeCount = static_cast<std::size_t>(ShaderStageType::Max) + 1;
template<>
struct EnumAsFlags<ShaderStageType>
{
static constexpr ShaderStageType max = ShaderStageType::Max;
};
using ShaderStageTypeFlags = Flags<ShaderStageType>;
constexpr ShaderStageTypeFlags ShaderStageType_All = ShaderStageType::Fragment | ShaderStageType::Vertex;
enum class StructFieldType
{
Bool1,
Bool2,
Bool3,
Bool4,
Float1,
Float2,
Float3,
Float4,
Double1,
Double2,
Double3,
Double4,
Int1,
Int2,
Int3,
Int4,
UInt1,
UInt2,
UInt3,
UInt4,
Max = UInt4
};
enum class StructLayout
{
Packed,
Std140,
Max = Std140
};
}
#endif // NAZARA_SHADER_ENUMS_HPP

View File

@ -1,18 +1,20 @@
// Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com) // Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com)
// This file is part of the "Nazara Engine - Utility module" // This file is part of the "Nazara Engine - Shader module"
// For conditions of distribution and use, see copyright notice in Config.hpp // For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once #pragma once
#ifndef NAZARA_UTILITY_FIELDOFFSETS_HPP #ifndef NAZARA_SHADER_FIELDOFFSETS_HPP
#define NAZARA_UTILITY_FIELDOFFSETS_HPP #define NAZARA_SHADER_FIELDOFFSETS_HPP
#include <Nazara/Utility/Config.hpp> #include <Nazara/Prerequisites.hpp>
#include <Nazara/Utility/Enums.hpp> #include <Nazara/Shader/Config.hpp>
#include <Nazara/Shader/Enums.hpp>
#include <cstddef>
namespace Nz namespace Nz
{ {
class NAZARA_UTILITY_API FieldOffsets class NAZARA_SHADER_API FieldOffsets
{ {
public: public:
inline FieldOffsets(StructLayout layout); inline FieldOffsets(StructLayout layout);
@ -47,6 +49,6 @@ namespace Nz
}; };
} }
#include <Nazara/Utility/FieldOffsets.inl> #include <Nazara/Shader/FieldOffsets.inl>
#endif // NAZARA_UTILITY_FIELDOFFSETS_HPP #endif // NAZARA_SHADER_FIELDOFFSETS_HPP

View File

@ -1,12 +1,12 @@
// Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com) // Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com)
// This file is part of the "Nazara Engine - Utility module" // This file is part of the "Nazara Engine - Shader module"
// For conditions of distribution and use, see copyright notice in Config.hpp // For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Utility/FieldOffsets.hpp> #include <Nazara/Shader/FieldOffsets.hpp>
#include <Nazara/Core/Algorithm.hpp> #include <Nazara/Core/Algorithm.hpp>
#include <cassert> #include <cassert>
#include <memory> #include <memory>
#include <Nazara/Utility/Debug.hpp> #include <Nazara/Shader/Debug.hpp>
namespace Nz namespace Nz
{ {
@ -171,4 +171,4 @@ namespace Nz
} }
} }
#include <Nazara/Utility/DebugOff.hpp> #include <Nazara/Shader/DebugOff.hpp>

View File

@ -39,7 +39,6 @@
#include <Nazara/Utility/Config.hpp> #include <Nazara/Utility/Config.hpp>
#include <Nazara/Utility/CubemapParams.hpp> #include <Nazara/Utility/CubemapParams.hpp>
#include <Nazara/Utility/Enums.hpp> #include <Nazara/Utility/Enums.hpp>
#include <Nazara/Utility/FieldOffsets.hpp>
#include <Nazara/Utility/Font.hpp> #include <Nazara/Utility/Font.hpp>
#include <Nazara/Utility/FontData.hpp> #include <Nazara/Utility/FontData.hpp>
#include <Nazara/Utility/FontGlyph.hpp> #include <Nazara/Utility/FontGlyph.hpp>

View File

@ -166,20 +166,6 @@ namespace Nz
Max = CounterClockwise Max = CounterClockwise
}; };
enum class ImageType
{
E1D,
E1D_Array,
E2D,
E2D_Array,
E3D,
Cubemap,
Max = Cubemap
};
constexpr std::size_t ImageTypeCount = static_cast<std::size_t>(ImageType::Max) + 1;
enum class IndexType enum class IndexType
{ {
U8, U8,
@ -351,60 +337,6 @@ namespace Nz
Max = Repeat Max = Repeat
}; };
enum class ShaderStageType
{
Fragment,
Vertex,
Max = Vertex
};
constexpr std::size_t ShaderStageTypeCount = static_cast<std::size_t>(ShaderStageType::Max) + 1;
template<>
struct EnumAsFlags<ShaderStageType>
{
static constexpr ShaderStageType max = ShaderStageType::Max;
};
using ShaderStageTypeFlags = Flags<ShaderStageType>;
constexpr ShaderStageTypeFlags ShaderStageType_All = ShaderStageType::Fragment | ShaderStageType::Vertex;
enum class StructFieldType
{
Bool1,
Bool2,
Bool3,
Bool4,
Float1,
Float2,
Float3,
Float4,
Double1,
Double2,
Double3,
Double4,
Int1,
Int2,
Int3,
Int4,
UInt1,
UInt2,
UInt3,
UInt4,
Max = UInt4
};
enum class StructLayout
{
Packed,
Std140,
Max = Std140
};
enum class StencilOperation enum class StencilOperation
{ {
Decrement, Decrement,

View File

@ -9,6 +9,7 @@
#include <Nazara/Prerequisites.hpp> #include <Nazara/Prerequisites.hpp>
#include <Nazara/Renderer/Enums.hpp> #include <Nazara/Renderer/Enums.hpp>
#include <Nazara/Shader/Enums.hpp>
#include <Nazara/Utility/Enums.hpp> #include <Nazara/Utility/Enums.hpp>
#include <Nazara/VulkanRenderer/Wrapper/Loader.hpp> #include <Nazara/VulkanRenderer/Wrapper/Loader.hpp>
#include <optional> #include <optional>

View File

@ -8,9 +8,9 @@
#include <Nazara/Graphics/PredefinedShaderStructs.hpp> #include <Nazara/Graphics/PredefinedShaderStructs.hpp>
#include <Nazara/Graphics/UberShader.hpp> #include <Nazara/Graphics/UberShader.hpp>
#include <Nazara/Renderer/Renderer.hpp> #include <Nazara/Renderer/Renderer.hpp>
#include <Nazara/Shader/FieldOffsets.hpp>
#include <Nazara/Shader/ShaderLangParser.hpp> #include <Nazara/Shader/ShaderLangParser.hpp>
#include <Nazara/Utility/BufferMapper.hpp> #include <Nazara/Utility/BufferMapper.hpp>
#include <Nazara/Utility/FieldOffsets.hpp>
#include <Nazara/Utility/MaterialData.hpp> #include <Nazara/Utility/MaterialData.hpp>
#include <cassert> #include <cassert>
#include <Nazara/Graphics/Debug.hpp> #include <Nazara/Graphics/Debug.hpp>

View File

@ -3,8 +3,8 @@
// For conditions of distribution and use, see copyright notice in Config.hpp // For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Graphics/DepthMaterial.hpp> #include <Nazara/Graphics/DepthMaterial.hpp>
#include <Nazara/Shader/FieldOffsets.hpp>
#include <Nazara/Shader/ShaderLangParser.hpp> #include <Nazara/Shader/ShaderLangParser.hpp>
#include <Nazara/Utility/FieldOffsets.hpp>
#include <Nazara/Graphics/Debug.hpp> #include <Nazara/Graphics/Debug.hpp>
namespace Nz namespace Nz

View File

@ -7,9 +7,9 @@
#include <Nazara/Core/ErrorFlags.hpp> #include <Nazara/Core/ErrorFlags.hpp>
#include <Nazara/Graphics/PredefinedShaderStructs.hpp> #include <Nazara/Graphics/PredefinedShaderStructs.hpp>
#include <Nazara/Renderer/Renderer.hpp> #include <Nazara/Renderer/Renderer.hpp>
#include <Nazara/Shader/FieldOffsets.hpp>
#include <Nazara/Shader/ShaderLangParser.hpp> #include <Nazara/Shader/ShaderLangParser.hpp>
#include <Nazara/Utility/BufferMapper.hpp> #include <Nazara/Utility/BufferMapper.hpp>
#include <Nazara/Utility/FieldOffsets.hpp>
#include <Nazara/Utility/MaterialData.hpp> #include <Nazara/Utility/MaterialData.hpp>
#include <cassert> #include <cassert>
#include <filesystem> #include <filesystem>

View File

@ -3,7 +3,7 @@
// For conditions of distribution and use, see copyright notice in Config.hpp // For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Graphics/PredefinedShaderStructs.hpp> #include <Nazara/Graphics/PredefinedShaderStructs.hpp>
#include <Nazara/Utility/FieldOffsets.hpp> #include <Nazara/Shader/FieldOffsets.hpp>
#include <Nazara/Graphics/Debug.hpp> #include <Nazara/Graphics/Debug.hpp>
namespace Nz namespace Nz

View File

@ -1,11 +1,11 @@
// Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com) // Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com)
// This file is part of the "Nazara Engine - Utility module" // This file is part of the "Nazara Engine - Shader module"
// For conditions of distribution and use, see copyright notice in Config.hpp // For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Utility/FieldOffsets.hpp> #include <Nazara/Shader/FieldOffsets.hpp>
#include <algorithm> #include <algorithm>
#include <cassert> #include <cassert>
#include <Nazara/Utility/Debug.hpp> #include <Nazara/Shader/Debug.hpp>
namespace Nz namespace Nz
{ {

View File

@ -7,6 +7,7 @@
#include <Nazara/Core/Bitset.hpp> #include <Nazara/Core/Bitset.hpp>
#include <Nazara/Core/CallOnExit.hpp> #include <Nazara/Core/CallOnExit.hpp>
#include <Nazara/Math/Algorithm.hpp> #include <Nazara/Math/Algorithm.hpp>
#include <Nazara/Shader/Enums.hpp>
#include <Nazara/Shader/ShaderBuilder.hpp> #include <Nazara/Shader/ShaderBuilder.hpp>
#include <Nazara/Shader/Ast/AstCloner.hpp> #include <Nazara/Shader/Ast/AstCloner.hpp>
#include <Nazara/Shader/Ast/AstConstantPropagationVisitor.hpp> #include <Nazara/Shader/Ast/AstConstantPropagationVisitor.hpp>

View File

@ -6,6 +6,7 @@
#include <Nazara/Core/Algorithm.hpp> #include <Nazara/Core/Algorithm.hpp>
#include <Nazara/Core/CallOnExit.hpp> #include <Nazara/Core/CallOnExit.hpp>
#include <Nazara/Math/Algorithm.hpp> #include <Nazara/Math/Algorithm.hpp>
#include <Nazara/Shader/Enums.hpp>
#include <Nazara/Shader/ShaderBuilder.hpp> #include <Nazara/Shader/ShaderBuilder.hpp>
#include <Nazara/Shader/Ast/AstCloner.hpp> #include <Nazara/Shader/Ast/AstCloner.hpp>
#include <Nazara/Shader/Ast/AstRecursiveVisitor.hpp> #include <Nazara/Shader/Ast/AstRecursiveVisitor.hpp>

View File

@ -3,9 +3,9 @@
// For conditions of distribution and use, see copyright notice in Config.hpp // For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Shader/SpirvConstantCache.hpp> #include <Nazara/Shader/SpirvConstantCache.hpp>
#include <Nazara/Shader/FieldOffsets.hpp>
#include <Nazara/Shader/SpirvSection.hpp> #include <Nazara/Shader/SpirvSection.hpp>
#include <Nazara/Shader/Ast/Nodes.hpp> #include <Nazara/Shader/Ast/Nodes.hpp>
#include <Nazara/Utility/FieldOffsets.hpp>
#include <tsl/ordered_map.h> #include <tsl/ordered_map.h>
#include <cassert> #include <cassert>
#include <stdexcept> #include <stdexcept>

View File

@ -80,8 +80,8 @@ local modules = {
Deps = {"NazaraPlatform", "NazaraShader"} Deps = {"NazaraPlatform", "NazaraShader"}
}, },
Shader = { Shader = {
Deps = {"NazaraUtility"},
Packages = {"efsw", "fmt"}, Packages = {"efsw", "fmt"},
Deps = {"NazaraCore"},
Custom = function() Custom = function()
-- Set precise floating-points models to ensure shader optimization leads to correct results -- Set precise floating-points models to ensure shader optimization leads to correct results
set_fpmodels("precise") set_fpmodels("precise")