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:
@@ -3,13 +3,13 @@
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/VulkanRenderer/Vulkan.hpp>
|
||||
#include <Nazara/Core/CallOnExit.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Core/ErrorFlags.hpp>
|
||||
#include <Nazara/Core/Log.hpp>
|
||||
#include <Nazara/Utility/Utility.hpp>
|
||||
#include <Nazara/VulkanRenderer/Config.hpp>
|
||||
#include <Nazara/VulkanRenderer/VulkanDevice.hpp>
|
||||
#include <Nazara/Utils/CallOnExit.hpp>
|
||||
#include <array>
|
||||
#include <unordered_set>
|
||||
#include <Nazara/VulkanRenderer/Debug.hpp>
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/VulkanRenderer/VulkanBuffer.hpp>
|
||||
#include <Nazara/Core/CallOnExit.hpp>
|
||||
#include <Nazara/VulkanRenderer/VulkanDevice.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/QueueHandle.hpp>
|
||||
#include <Nazara/Utils/CallOnExit.hpp>
|
||||
#include <vma/vk_mem_alloc.h>
|
||||
#include <Nazara/VulkanRenderer/Debug.hpp>
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/VulkanRenderer/VulkanCommandBufferBuilder.hpp>
|
||||
#include <Nazara/Core/StackArray.hpp>
|
||||
#include <Nazara/Utility/PixelFormat.hpp>
|
||||
#include <Nazara/VulkanRenderer/VulkanBuffer.hpp>
|
||||
#include <Nazara/VulkanRenderer/VulkanRenderPass.hpp>
|
||||
@@ -14,6 +13,7 @@
|
||||
#include <Nazara/VulkanRenderer/VulkanTextureFramebuffer.hpp>
|
||||
#include <Nazara/VulkanRenderer/VulkanUploadPool.hpp>
|
||||
#include <Nazara/VulkanRenderer/VulkanWindowFramebuffer.hpp>
|
||||
#include <Nazara/Utils/StackArray.hpp>
|
||||
#include <Nazara/VulkanRenderer/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/VulkanRenderer/VulkanCommandPool.hpp>
|
||||
#include <Nazara/Core/StackVector.hpp>
|
||||
#include <Nazara/VulkanRenderer/VulkanCommandBuffer.hpp>
|
||||
#include <Nazara/VulkanRenderer/VulkanCommandBufferBuilder.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp>
|
||||
#include <Nazara/Utils/StackVector.hpp>
|
||||
#include <Nazara/VulkanRenderer/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace Nz
|
||||
return pipelineLayout;
|
||||
}
|
||||
|
||||
std::shared_ptr<ShaderModule> VulkanDevice::InstantiateShaderModule(ShaderStageTypeFlags stages, const ShaderAst::Module& shaderModule, const ShaderWriter::States& states)
|
||||
std::shared_ptr<ShaderModule> VulkanDevice::InstantiateShaderModule(nzsl::ShaderStageTypeFlags stages, const nzsl::Ast::Module& shaderModule, const nzsl::ShaderWriter::States& states)
|
||||
{
|
||||
auto stage = std::make_shared<VulkanShaderModule>();
|
||||
if (!stage->Create(*this, stages, shaderModule, states))
|
||||
@@ -70,7 +70,7 @@ namespace Nz
|
||||
return stage;
|
||||
}
|
||||
|
||||
std::shared_ptr<ShaderModule> VulkanDevice::InstantiateShaderModule(ShaderStageTypeFlags stages, ShaderLanguage lang, const void* source, std::size_t sourceSize, const ShaderWriter::States& states)
|
||||
std::shared_ptr<ShaderModule> VulkanDevice::InstantiateShaderModule(nzsl::ShaderStageTypeFlags stages, ShaderLanguage lang, const void* source, std::size_t sourceSize, const nzsl::ShaderWriter::States& states)
|
||||
{
|
||||
auto stage = std::make_shared<VulkanShaderModule>();
|
||||
if (!stage->Create(*this, stages, lang, source, sourceSize, states))
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/VulkanRenderer/VulkanRenderPass.hpp>
|
||||
#include <Nazara/Core/StackVector.hpp>
|
||||
#include <Nazara/VulkanRenderer/Utils.hpp>
|
||||
#include <Nazara/Utils/StackVector.hpp>
|
||||
#include <stdexcept>
|
||||
#include <Nazara/VulkanRenderer/Debug.hpp>
|
||||
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
|
||||
#include <Nazara/VulkanRenderer/VulkanRenderPipelineLayout.hpp>
|
||||
#include <Nazara/Core/ErrorFlags.hpp>
|
||||
#include <Nazara/Core/MemoryHelper.hpp>
|
||||
#include <Nazara/Core/StackArray.hpp>
|
||||
#include <Nazara/Core/StackVector.hpp>
|
||||
#include <Nazara/VulkanRenderer/Utils.hpp>
|
||||
#include <Nazara/VulkanRenderer/VulkanDescriptorSetLayoutCache.hpp>
|
||||
#include <Nazara/Utils/MemoryHelper.hpp>
|
||||
#include <Nazara/Utils/StackArray.hpp>
|
||||
#include <Nazara/Utils/StackVector.hpp>
|
||||
#include <cassert>
|
||||
#include <stdexcept>
|
||||
#include <Nazara/VulkanRenderer/Debug.hpp>
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include <Nazara/VulkanRenderer/VulkanRenderWindow.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Core/ErrorFlags.hpp>
|
||||
#include <Nazara/Core/StackArray.hpp>
|
||||
#include <Nazara/Math/Vector2.hpp>
|
||||
#include <Nazara/Renderer/RenderWindow.hpp>
|
||||
#include <Nazara/Utility/PixelFormat.hpp>
|
||||
@@ -13,6 +12,7 @@
|
||||
#include <Nazara/VulkanRenderer/VulkanCommandPool.hpp>
|
||||
#include <Nazara/VulkanRenderer/VulkanDevice.hpp>
|
||||
#include <Nazara/VulkanRenderer/VulkanSurface.hpp>
|
||||
#include <Nazara/Utils/StackArray.hpp>
|
||||
#include <array>
|
||||
#include <stdexcept>
|
||||
#include <Nazara/VulkanRenderer/Debug.hpp>
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
|
||||
#include <Nazara/VulkanRenderer/VulkanShaderBinding.hpp>
|
||||
#include <Nazara/Core/Algorithm.hpp>
|
||||
#include <Nazara/Core/StackVector.hpp>
|
||||
#include <Nazara/VulkanRenderer/VulkanBuffer.hpp>
|
||||
#include <Nazara/VulkanRenderer/VulkanRenderPipelineLayout.hpp>
|
||||
#include <Nazara/VulkanRenderer/VulkanTexture.hpp>
|
||||
#include <Nazara/VulkanRenderer/VulkanTextureSampler.hpp>
|
||||
#include <Nazara/Utils/StackVector.hpp>
|
||||
#include <Nazara/VulkanRenderer/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
|
||||
@@ -3,41 +3,41 @@
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/VulkanRenderer/VulkanShaderModule.hpp>
|
||||
#include <Nazara/Shader/ShaderLangLexer.hpp>
|
||||
#include <Nazara/Shader/ShaderLangParser.hpp>
|
||||
#include <Nazara/Shader/SpirvDecoder.hpp>
|
||||
#include <Nazara/Shader/SpirvWriter.hpp>
|
||||
#include <Nazara/Shader/Ast/AstSerializer.hpp>
|
||||
#include <NZSL/ShaderLangLexer.hpp>
|
||||
#include <NZSL/ShaderLangParser.hpp>
|
||||
#include <NZSL/SpirvDecoder.hpp>
|
||||
#include <NZSL/SpirvWriter.hpp>
|
||||
#include <NZSL/Ast/AstSerializer.hpp>
|
||||
#include <Nazara/VulkanRenderer/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
namespace
|
||||
{
|
||||
struct SpirvEntryPointExtractor : SpirvDecoder
|
||||
struct SpirvEntryPointExtractor : nzsl::SpirvDecoder
|
||||
{
|
||||
struct EntryPoint
|
||||
{
|
||||
SpirvExecutionModel executionModel;
|
||||
nzsl::SpirvExecutionModel executionModel;
|
||||
std::string name;
|
||||
};
|
||||
|
||||
std::vector<EntryPoint> entryPoints;
|
||||
|
||||
bool HandleOpcode(const SpirvInstruction& instruction, UInt32 /*wordCount*/) override
|
||||
bool HandleOpcode(const nzsl::SpirvInstruction& instruction, UInt32 /*wordCount*/) override
|
||||
{
|
||||
switch (instruction.op)
|
||||
{
|
||||
// All instructions that can appear before OpEntryPoint
|
||||
case SpirvOp::OpCapability:
|
||||
case SpirvOp::OpExtension:
|
||||
case SpirvOp::OpExtInstImport:
|
||||
case SpirvOp::OpMemoryModel:
|
||||
case nzsl::SpirvOp::OpCapability:
|
||||
case nzsl::SpirvOp::OpExtension:
|
||||
case nzsl::SpirvOp::OpExtInstImport:
|
||||
case nzsl::SpirvOp::OpMemoryModel:
|
||||
return true;
|
||||
|
||||
case SpirvOp::OpEntryPoint:
|
||||
case nzsl::SpirvOp::OpEntryPoint:
|
||||
{
|
||||
SpirvExecutionModel executionModel = static_cast<SpirvExecutionModel>(ReadWord());
|
||||
nzsl::SpirvExecutionModel executionModel = static_cast<nzsl::SpirvExecutionModel>(ReadWord());
|
||||
ReadWord(); // func id
|
||||
std::string name = ReadString();
|
||||
|
||||
@@ -57,18 +57,18 @@ namespace Nz
|
||||
};
|
||||
}
|
||||
|
||||
bool VulkanShaderModule::Create(Vk::Device& device, ShaderStageTypeFlags shaderStages, const ShaderAst::Module& shaderModule, const ShaderWriter::States& states)
|
||||
bool VulkanShaderModule::Create(Vk::Device& device, nzsl::ShaderStageTypeFlags shaderStages, const nzsl::Ast::Module& shaderModule, const nzsl::ShaderWriter::States& states)
|
||||
{
|
||||
SpirvWriter::Environment env;
|
||||
nzsl::SpirvWriter::Environment env;
|
||||
|
||||
SpirvWriter writer;
|
||||
nzsl::SpirvWriter writer;
|
||||
writer.SetEnv(env);
|
||||
|
||||
std::vector<UInt32> code = writer.Generate(shaderModule, states);
|
||||
return Create(device, shaderStages, ShaderLanguage::SpirV, code.data(), code.size() * sizeof(UInt32), {});
|
||||
}
|
||||
|
||||
bool VulkanShaderModule::Create(Vk::Device& device, ShaderStageTypeFlags shaderStages, ShaderLanguage lang, const void* source, std::size_t sourceSize, const ShaderWriter::States& states)
|
||||
bool VulkanShaderModule::Create(Vk::Device& device, nzsl::ShaderStageTypeFlags shaderStages, ShaderLanguage lang, const void* source, std::size_t sourceSize, const nzsl::ShaderWriter::States& states)
|
||||
{
|
||||
switch (lang)
|
||||
{
|
||||
@@ -79,16 +79,17 @@ namespace Nz
|
||||
|
||||
case ShaderLanguage::NazaraBinary:
|
||||
{
|
||||
auto shader = ShaderAst::UnserializeShader(source, sourceSize);
|
||||
nzsl::Unserializer unserializer(source, sourceSize);
|
||||
auto shader = nzsl::Ast::UnserializeShader(unserializer);
|
||||
return Create(device, shaderStages, *shader, {});
|
||||
}
|
||||
|
||||
case ShaderLanguage::NazaraShader:
|
||||
{
|
||||
std::vector<ShaderLang::Token> tokens = ShaderLang::Tokenize(std::string_view(static_cast<const char*>(source), sourceSize));
|
||||
std::vector<nzsl::Token> tokens = nzsl::Tokenize(std::string_view(static_cast<const char*>(source), sourceSize));
|
||||
|
||||
ShaderLang::Parser parser;
|
||||
ShaderAst::ModulePtr shaderModule = parser.Parse(tokens);
|
||||
nzsl::Parser parser;
|
||||
nzsl::Ast::ModulePtr shaderModule = parser.Parse(tokens);
|
||||
return Create(device, shaderStages, *shaderModule, states);
|
||||
}
|
||||
|
||||
@@ -97,18 +98,18 @@ namespace Nz
|
||||
SpirvEntryPointExtractor extractor;
|
||||
extractor.Decode(reinterpret_cast<const UInt32*>(source), sourceSize / sizeof(UInt32));
|
||||
|
||||
ShaderStageTypeFlags remainingStages = shaderStages;
|
||||
nzsl::ShaderStageTypeFlags remainingStages = shaderStages;
|
||||
for (auto& entryPoint : extractor.entryPoints)
|
||||
{
|
||||
ShaderStageType stageType;
|
||||
nzsl::ShaderStageType stageType;
|
||||
switch (entryPoint.executionModel)
|
||||
{
|
||||
case SpirvExecutionModel::Fragment:
|
||||
stageType = ShaderStageType::Fragment;
|
||||
case nzsl::SpirvExecutionModel::Fragment:
|
||||
stageType = nzsl::ShaderStageType::Fragment;
|
||||
break;
|
||||
|
||||
case SpirvExecutionModel::Vertex:
|
||||
stageType = ShaderStageType::Vertex;
|
||||
case nzsl::SpirvExecutionModel::Vertex:
|
||||
stageType = nzsl::ShaderStageType::Vertex;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/VulkanRenderer/VulkanTexture.hpp>
|
||||
#include <Nazara/Core/CallOnExit.hpp>
|
||||
#include <Nazara/Utility/PixelFormat.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/QueueHandle.hpp>
|
||||
#include <Nazara/Utils/CallOnExit.hpp>
|
||||
#include <vma/vk_mem_alloc.h>
|
||||
#include <stdexcept>
|
||||
#include <Nazara/VulkanRenderer/Debug.hpp>
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/VulkanRenderer/VulkanTextureFramebuffer.hpp>
|
||||
#include <Nazara/Core/StackArray.hpp>
|
||||
#include <Nazara/VulkanRenderer/VulkanRenderPass.hpp>
|
||||
#include <Nazara/VulkanRenderer/VulkanTexture.hpp>
|
||||
#include <Nazara/Utils/StackArray.hpp>
|
||||
#include <stdexcept>
|
||||
#include <Nazara/VulkanRenderer/Debug.hpp>
|
||||
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/VulkanRenderer/Wrapper/Device.hpp>
|
||||
#include <Nazara/Core/CallOnExit.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Core/ErrorFlags.hpp>
|
||||
#include <Nazara/VulkanRenderer/VulkanDescriptorSetLayoutCache.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/CommandPool.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/QueueHandle.hpp>
|
||||
#include <Nazara/Utils/CallOnExit.hpp>
|
||||
|
||||
#define VMA_IMPLEMENTATION
|
||||
#define VMA_USE_STL_CONTAINERS 1
|
||||
|
||||
Reference in New Issue
Block a user