Split engine to packages NazaraUtils and NZSL (#375)

* Move code to NazaraUtils and NZSL packages

* Reorder includes

* Tests: Remove glslang and spirv-tools deps

* Tests: Remove glslang init

* Remove NazaraUtils tests and fix Vector4Test

* Fix Linux compilation

* Update msys2-build.yml

* Fix assimp package

* Update xmake.lua

* Update xmake.lua

* Fix shader compilation on MinGW

* Final fixes

* The final fix 2: the fix strikes back!

* Disable cache on CI

* The return of the fix™️
This commit is contained in:
Jérôme Leclercq
2022-05-25 19:36:10 +02:00
committed by GitHub
parent 3f8f1c4653
commit 03e2801dbe
483 changed files with 1139 additions and 59112 deletions

View File

@@ -10,10 +10,13 @@
#include <Nazara/Prerequisites.hpp>
#include <Nazara/Graphics/MaterialPass.hpp>
namespace Nz
namespace nzsl
{
class FieldOffsets;
}
namespace Nz
{
class NAZARA_GRAPHICS_API BasicMaterial
{
friend class MaterialPipeline;
@@ -94,7 +97,7 @@ namespace Nz
static MaterialSettings::Builder Build(BasicBuildOptions& options);
static std::vector<std::shared_ptr<UberShader>> BuildShaders();
static std::pair<BasicUniformOffsets, FieldOffsets> BuildUniformOffsets();
static std::pair<BasicUniformOffsets, nzsl::FieldOffsets> BuildUniformOffsets();
std::size_t m_uniformBlockIndex;
BasicOptionIndexes m_basicOptionIndexes;

View File

@@ -62,7 +62,7 @@ namespace Nz
{
NazaraAssert(HasAlphaTest(), "Material has no alpha test option");
const auto& optionOpt = m_material.GetOptionValue(m_basicOptionIndexes.alphaTest);
if (std::holds_alternative<ShaderAst::NoValue>(optionOpt))
if (std::holds_alternative<nzsl::Ast::NoValue>(optionOpt))
return false;
return std::get<bool>(optionOpt);

View File

@@ -8,7 +8,7 @@
#define NAZARA_GRAPHICS_ENUMS_HPP
#include <Nazara/Core/Algorithm.hpp>
#include <Nazara/Core/Flags.hpp>
#include <Nazara/Utils/Flags.hpp>
namespace Nz
{

View File

@@ -8,7 +8,6 @@
#define NAZARA_GRAPHICS_FORWARDFRAMEPIPELINE_HPP
#include <Nazara/Prerequisites.hpp>
#include <Nazara/Core/MemoryPool.hpp>
#include <Nazara/Graphics/BakedFrameGraph.hpp>
#include <Nazara/Graphics/Config.hpp>
#include <Nazara/Graphics/DepthPipelinePass.hpp>
@@ -22,6 +21,7 @@
#include <Nazara/Graphics/RenderQueue.hpp>
#include <Nazara/Graphics/RenderQueueRegistry.hpp>
#include <Nazara/Renderer/ShaderBinding.hpp>
#include <Nazara/Utils/MemoryPool.hpp>
#include <memory>
#include <optional>
#include <unordered_map>

View File

@@ -15,7 +15,7 @@
#include <Nazara/Renderer/RenderPassCache.hpp>
#include <Nazara/Renderer/RenderPipelineLayout.hpp>
#include <Nazara/Renderer/Renderer.hpp>
#include <Nazara/Shader/FilesystemModuleResolver.hpp>
#include <NZSL/FilesystemModuleResolver.hpp>
#include <optional>
namespace Nz
@@ -46,7 +46,7 @@ namespace Nz
inline const std::shared_ptr<RenderDevice>& GetRenderDevice() const;
inline const RenderPassCache& GetRenderPassCache() const;
inline TextureSamplerCache& GetSamplerCache();
inline const std::shared_ptr<FilesystemModuleResolver>& GetShaderModuleResolver() const;
inline const std::shared_ptr<nzsl::FilesystemModuleResolver>& GetShaderModuleResolver() const;
struct Config
{
@@ -70,7 +70,7 @@ namespace Nz
std::optional<RenderPassCache> m_renderPassCache;
std::optional<TextureSamplerCache> m_samplerCache;
std::shared_ptr<FilesystemModuleResolver> m_shaderModuleResolver;
std::shared_ptr<nzsl::FilesystemModuleResolver> m_shaderModuleResolver;
std::shared_ptr<RenderBuffer> m_fullscreenVertexBuffer;
std::shared_ptr<RenderDevice> m_renderDevice;
std::shared_ptr<RenderPipeline> m_blitPipeline;

View File

@@ -63,7 +63,7 @@ namespace Nz
return *m_samplerCache;
}
inline const std::shared_ptr<FilesystemModuleResolver>& Graphics::GetShaderModuleResolver() const
inline const std::shared_ptr<nzsl::FilesystemModuleResolver>& Graphics::GetShaderModuleResolver() const
{
return m_shaderModuleResolver;
}

View File

@@ -8,9 +8,9 @@
#define NAZARA_GRAPHICS_INSTANCEDRENDERABLE_HPP
#include <Nazara/Prerequisites.hpp>
#include <Nazara/Core/Signal.hpp>
#include <Nazara/Graphics/Config.hpp>
#include <Nazara/Math/Box.hpp>
#include <Nazara/Utils/Signal.hpp>
#include <memory>
namespace Nz

View File

@@ -8,11 +8,11 @@
#define NAZARA_GRAPHICS_LIGHT_HPP
#include <Nazara/Prerequisites.hpp>
#include <Nazara/Core/Signal.hpp>
#include <Nazara/Graphics/Config.hpp>
#include <Nazara/Math/BoundingVolume.hpp>
#include <Nazara/Math/Quaternion.hpp>
#include <Nazara/Math/Vector3.hpp>
#include <Nazara/Utils/Signal.hpp>
#include <memory>
namespace Nz

View File

@@ -14,14 +14,14 @@
#include <Nazara/Core/ResourceLoader.hpp>
#include <Nazara/Core/ResourceManager.hpp>
#include <Nazara/Core/ResourceParameters.hpp>
#include <Nazara/Core/Signal.hpp>
#include <Nazara/Graphics/Config.hpp>
#include <Nazara/Graphics/Enums.hpp>
#include <Nazara/Graphics/MaterialPipeline.hpp>
#include <Nazara/Renderer/Texture.hpp>
#include <Nazara/Renderer/TextureSampler.hpp>
#include <Nazara/Shader/Ast/ConstantValue.hpp>
#include <Nazara/Utility/UniformBuffer.hpp>
#include <Nazara/Utils/Signal.hpp>
#include <NZSL/Ast/ConstantValue.hpp>
#include <array>
#include <string>
#include <vector>
@@ -67,13 +67,13 @@ namespace Nz
inline FaceFilling GetFaceFilling() const;
inline MaterialPassFlags GetFlags() const;
inline float GetLineWidth() const;
inline const ShaderAst::ConstantValue& GetOptionValue(std::size_t optionIndex) const;
inline const nzsl::Ast::ConstantValue& GetOptionValue(std::size_t optionIndex) const;
inline const std::shared_ptr<MaterialPipeline>& GetPipeline() const;
inline const MaterialPipelineInfo& GetPipelineInfo() const;
inline float GetPointSize() const;
inline PrimitiveMode GetPrimitiveMode() const;
inline const std::shared_ptr<const MaterialSettings>& GetSettings() const;
inline const std::shared_ptr<UberShader>& GetShader(ShaderStageType shaderStage) const;
inline const std::shared_ptr<UberShader>& GetShader(nzsl::ShaderStageType shaderStage) const;
inline const std::shared_ptr<Texture>& GetTexture(std::size_t textureIndex) const;
inline const TextureSamplerInfo& GetTextureSampler(std::size_t textureIndex) const;
inline const std::shared_ptr<RenderBuffer>& GetUniformBuffer(std::size_t bufferIndex) const;
@@ -98,7 +98,7 @@ namespace Nz
inline void SetFaceCulling(FaceSide faceSide);
inline void SetFaceFilling(FaceFilling filling);
inline void SetLineWidth(float lineWidth);
inline void SetOptionValue(std::size_t optionIndex, ShaderAst::ConstantValue value);
inline void SetOptionValue(std::size_t optionIndex, nzsl::Ast::ConstantValue value);
inline void SetPointSize(float pointSize);
inline void SetPrimitiveMode(PrimitiveMode mode);
inline void SetTexture(std::size_t textureIndex, std::shared_ptr<Texture> texture);
@@ -142,7 +142,7 @@ namespace Nz
bool dataInvalidated = true;
};
std::array<ShaderAst::ConstantValue, 64> m_optionValues;
std::array<nzsl::Ast::ConstantValue, 64> m_optionValues;
std::shared_ptr<const MaterialSettings> m_settings;
std::vector<MaterialTexture> m_textures;
std::vector<ShaderEntry> m_shaders;

View File

@@ -319,7 +319,7 @@ namespace Nz
return m_pipelineInfo.lineWidth;
}
inline const ShaderAst::ConstantValue& MaterialPass::GetOptionValue(std::size_t optionIndex) const
inline const nzsl::Ast::ConstantValue& MaterialPass::GetOptionValue(std::size_t optionIndex) const
{
assert(optionIndex < m_optionValues.size());
return m_optionValues[optionIndex];
@@ -368,7 +368,7 @@ namespace Nz
* \brief Gets the über-shader used by this material
* \return Constant pointer to the über-shader used
*/
inline const std::shared_ptr<UberShader>& MaterialPass::GetShader(ShaderStageType shaderStage) const
inline const std::shared_ptr<UberShader>& MaterialPass::GetShader(nzsl::ShaderStageType shaderStage) const
{
return m_pipelineInfo.shaders[UnderlyingCast(shaderStage)].uberShader;
}
@@ -566,7 +566,7 @@ namespace Nz
InvalidatePipeline();
}
inline void MaterialPass::SetOptionValue(std::size_t optionIndex, ShaderAst::ConstantValue value)
inline void MaterialPass::SetOptionValue(std::size_t optionIndex, nzsl::Ast::ConstantValue value)
{
assert(optionIndex < m_optionValues.size());
if (m_optionValues[optionIndex] != value)

View File

@@ -12,7 +12,7 @@
#include <Nazara/Graphics/Enums.hpp>
#include <Nazara/Graphics/MaterialSettings.hpp>
#include <Nazara/Renderer/RenderPipeline.hpp>
#include <Nazara/Shader/Ast/ConstantValue.hpp>
#include <NZSL/Ast/ConstantValue.hpp>
#include <array>
#include <memory>
@@ -25,7 +25,7 @@ namespace Nz
struct Option
{
UInt32 hash;
ShaderAst::ConstantValue value;
nzsl::Ast::ConstantValue value;
};
struct Shader

View File

@@ -41,7 +41,7 @@ namespace Nz
inline std::size_t GetOptionIndex(const std::string_view& name) const;
inline std::size_t GetPredefinedBinding(PredefinedShaderBinding shaderBinding) const;
inline const std::shared_ptr<RenderPipelineLayout>& GetRenderPipelineLayout() const;
inline const std::shared_ptr<UberShader>& GetShader(ShaderStageType stage) const;
inline const std::shared_ptr<UberShader>& GetShader(nzsl::ShaderStageType stage) const;
inline const std::vector<std::shared_ptr<UberShader>>& GetShaders() const;
inline const std::vector<SharedUniformBlock>& GetSharedUniformBlocks() const;
inline std::size_t GetSharedUniformBlockIndex(const std::string_view& name) const;
@@ -88,7 +88,7 @@ namespace Nz
UInt32 bindingIndex;
std::string name;
std::vector<UniformVariable> uniforms;
ShaderStageTypeFlags shaderStages = ShaderStageType_All;
nzsl::ShaderStageTypeFlags shaderStages = nzsl::ShaderStageType_All;
};
struct Texture
@@ -96,7 +96,7 @@ namespace Nz
UInt32 bindingIndex;
std::string name;
ImageType type;
ShaderStageTypeFlags shaderStages = ShaderStageType_All;
nzsl::ShaderStageTypeFlags shaderStages = nzsl::ShaderStageType_All;
};
struct UniformBlock
@@ -106,7 +106,7 @@ namespace Nz
std::size_t blockSize;
std::vector<UniformVariable> uniforms;
std::vector<UInt8> defaultValues;
ShaderStageTypeFlags shaderStages = ShaderStageType_All;
nzsl::ShaderStageTypeFlags shaderStages = nzsl::ShaderStageType_All;
};
private:

View File

@@ -84,7 +84,7 @@ namespace Nz
return m_pipelineLayout;
}
inline const std::shared_ptr<UberShader>& MaterialSettings::GetShader(ShaderStageType stage) const
inline const std::shared_ptr<UberShader>& MaterialSettings::GetShader(nzsl::ShaderStageType stage) const
{
return m_data.shaders[UnderlyingCast(stage)];
}

View File

@@ -92,7 +92,7 @@ namespace Nz
static MaterialSettings::Builder Build(PhongBuildOptions& options);
static std::vector<std::shared_ptr<UberShader>> BuildShaders();
static std::pair<PhongUniformOffsets, FieldOffsets> BuildUniformOffsets();
static std::pair<PhongUniformOffsets, nzsl::FieldOffsets> BuildUniformOffsets();
private:
static bool Initialize();

View File

@@ -35,7 +35,7 @@ namespace Nz
static constexpr std::size_t MaxLightCount = 3;
static PredefinedLightData GetOffsets();
static MaterialSettings::SharedUniformBlock GetUniformBlock(UInt32 bindingIndex, ShaderStageTypeFlags shaderStages);
static MaterialSettings::SharedUniformBlock GetUniformBlock(UInt32 bindingIndex, nzsl::ShaderStageTypeFlags shaderStages);
};
struct NAZARA_GRAPHICS_API PredefinedInstanceData
@@ -45,7 +45,7 @@ namespace Nz
std::size_t worldMatrixOffset;
static PredefinedInstanceData GetOffsets();
static MaterialSettings::SharedUniformBlock GetUniformBlock(UInt32 bindingIndex, ShaderStageTypeFlags shaderStages);
static MaterialSettings::SharedUniformBlock GetUniformBlock(UInt32 bindingIndex, nzsl::ShaderStageTypeFlags shaderStages);
};
struct NAZARA_GRAPHICS_API PredefinedViewerData
@@ -62,7 +62,7 @@ namespace Nz
std::size_t viewProjMatrixOffset;
static PredefinedViewerData GetOffsets();
static MaterialSettings::SharedUniformBlock GetUniformBlock(UInt32 bindingIndex, ShaderStageTypeFlags shaderStages);
static MaterialSettings::SharedUniformBlock GetUniformBlock(UInt32 bindingIndex, nzsl::ShaderStageTypeFlags shaderStages);
};
}

View File

@@ -8,11 +8,11 @@
#define NAZARA_GRAPHICS_SYSTEMS_RENDERSYSTEM_HPP
#include <Nazara/Prerequisites.hpp>
#include <Nazara/Core/MemoryPool.hpp>
#include <Nazara/Graphics/Graphics.hpp>
#include <Nazara/Graphics/Components/GraphicsComponent.hpp>
#include <Nazara/Graphics/Components/LightComponent.hpp>
#include <Nazara/Utility/Node.hpp>
#include <Nazara/Utils/MemoryPool.hpp>
#include <entt/entt.hpp>
#include <array>
#include <memory>

View File

@@ -9,12 +9,11 @@
#include <Nazara/Prerequisites.hpp>
#include <Nazara/Core/Algorithm.hpp>
#include <Nazara/Core/Bitset.hpp>
#include <Nazara/Core/Signal.hpp>
#include <Nazara/Graphics/Config.hpp>
#include <Nazara/Renderer/RenderPipeline.hpp>
#include <Nazara/Shader/ShaderModuleResolver.hpp>
#include <Nazara/Shader/Ast/Module.hpp>
#include <Nazara/Utils/Signal.hpp>
#include <NZSL/ShaderModuleResolver.hpp>
#include <NZSL/Ast/Module.hpp>
#include <unordered_map>
namespace Nz
@@ -28,12 +27,12 @@ namespace Nz
struct Option;
using ConfigCallback = std::function<void(Config& config, const std::vector<RenderPipelineInfo::VertexBufferData>& vertexBuffers)>;
UberShader(ShaderStageTypeFlags shaderStages, std::string moduleName);
UberShader(ShaderStageTypeFlags shaderStages, ShaderModuleResolver& moduleResolver, std::string moduleName);
UberShader(ShaderStageTypeFlags shaderStages, ShaderAst::ModulePtr shaderModule);
UberShader(nzsl::ShaderStageTypeFlags shaderStages, std::string moduleName);
UberShader(nzsl::ShaderStageTypeFlags shaderStages, nzsl::ShaderModuleResolver& moduleResolver, std::string moduleName);
UberShader(nzsl::ShaderStageTypeFlags shaderStages, nzsl::Ast::ModulePtr shaderModule);
~UberShader() = default;
inline ShaderStageTypeFlags GetSupportedStages() const;
inline nzsl::ShaderStageTypeFlags GetSupportedStages() const;
const std::shared_ptr<ShaderModule>& Get(const Config& config);
@@ -44,7 +43,7 @@ namespace Nz
struct Config
{
std::unordered_map<UInt32, ShaderAst::ConstantValue> optionValues;
std::unordered_map<UInt32, nzsl::Ast::ConstantValue> optionValues;
};
struct ConfigEqual
@@ -65,15 +64,15 @@ namespace Nz
NazaraSignal(OnShaderUpdated, UberShader* /*uberShader*/);
private:
ShaderAst::ModulePtr Validate(const ShaderAst::Module& module, std::unordered_map<std::string, Option>* options);
nzsl::Ast::ModulePtr Validate(const nzsl::Ast::Module& module, std::unordered_map<std::string, Option>* options);
NazaraSlot(ShaderModuleResolver, OnModuleUpdated, m_onShaderModuleUpdated);
NazaraSlot(nzsl::ShaderModuleResolver, OnModuleUpdated, m_onShaderModuleUpdated);
std::unordered_map<Config, std::shared_ptr<ShaderModule>, ConfigHasher, ConfigEqual> m_combinations;
std::unordered_map<std::string, Option> m_optionIndexByName;
ShaderAst::ModulePtr m_shaderModule;
nzsl::Ast::ModulePtr m_shaderModule;
ConfigCallback m_configCallback;
ShaderStageTypeFlags m_shaderStages;
nzsl::ShaderStageTypeFlags m_shaderStages;
};
}

View File

@@ -7,7 +7,7 @@
namespace Nz
{
inline ShaderStageTypeFlags UberShader::GetSupportedStages() const
inline nzsl::ShaderStageTypeFlags UberShader::GetSupportedStages() const
{
return m_shaderStages;
}