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:
@@ -6,20 +6,20 @@
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Graphics/Graphics.hpp>
|
||||
#include <Nazara/Renderer/RenderDevice.hpp>
|
||||
#include <Nazara/Shader/Ast/AstReflect.hpp>
|
||||
#include <Nazara/Shader/Ast/SanitizeVisitor.hpp>
|
||||
#include <NZSL/Ast/ReflectVisitor.hpp>
|
||||
#include <NZSL/Ast/SanitizeVisitor.hpp>
|
||||
#include <limits>
|
||||
#include <stdexcept>
|
||||
#include <Nazara/Graphics/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
UberShader::UberShader(ShaderStageTypeFlags shaderStages, std::string moduleName) :
|
||||
UberShader::UberShader(nzsl::ShaderStageTypeFlags shaderStages, std::string moduleName) :
|
||||
UberShader(shaderStages, *Graphics::Instance()->GetShaderModuleResolver(), std::move(moduleName))
|
||||
{
|
||||
}
|
||||
|
||||
UberShader::UberShader(ShaderStageTypeFlags shaderStages, ShaderModuleResolver& moduleResolver, std::string moduleName) :
|
||||
UberShader::UberShader(nzsl::ShaderStageTypeFlags shaderStages, nzsl::ShaderModuleResolver& moduleResolver, std::string moduleName) :
|
||||
m_shaderStages(shaderStages)
|
||||
{
|
||||
m_shaderModule = moduleResolver.Resolve(moduleName);
|
||||
@@ -27,12 +27,12 @@ namespace Nz
|
||||
|
||||
m_shaderModule = Validate(*m_shaderModule, &m_optionIndexByName);
|
||||
|
||||
m_onShaderModuleUpdated.Connect(moduleResolver.OnModuleUpdated, [this, name = std::move(moduleName)](ShaderModuleResolver* resolver, const std::string& updatedModuleName)
|
||||
m_onShaderModuleUpdated.Connect(moduleResolver.OnModuleUpdated, [this, name = std::move(moduleName)](nzsl::ShaderModuleResolver* resolver, const std::string& updatedModuleName)
|
||||
{
|
||||
if (updatedModuleName != name)
|
||||
return;
|
||||
|
||||
ShaderAst::ModulePtr newShaderModule = resolver->Resolve(name);
|
||||
nzsl::Ast::ModulePtr newShaderModule = resolver->Resolve(name);
|
||||
if (!newShaderModule)
|
||||
{
|
||||
NazaraError("failed to retrieve updated shader module " + name);
|
||||
@@ -56,7 +56,7 @@ namespace Nz
|
||||
});
|
||||
}
|
||||
|
||||
UberShader::UberShader(ShaderStageTypeFlags shaderStages, ShaderAst::ModulePtr shaderModule) :
|
||||
UberShader::UberShader(nzsl::ShaderStageTypeFlags shaderStages, nzsl::Ast::ModulePtr shaderModule) :
|
||||
m_shaderModule(std::move(shaderModule)),
|
||||
m_shaderStages(shaderStages)
|
||||
{
|
||||
@@ -70,7 +70,7 @@ namespace Nz
|
||||
auto it = m_combinations.find(config);
|
||||
if (it == m_combinations.end())
|
||||
{
|
||||
ShaderWriter::States states;
|
||||
nzsl::ShaderWriter::States states;
|
||||
states.optionValues = config.optionValues;
|
||||
states.shaderModuleResolver = Graphics::Instance()->GetShaderModuleResolver();
|
||||
|
||||
@@ -82,28 +82,28 @@ namespace Nz
|
||||
return it->second;
|
||||
}
|
||||
|
||||
ShaderAst::ModulePtr UberShader::Validate(const ShaderAst::Module& module, std::unordered_map<std::string, Option>* options)
|
||||
nzsl::Ast::ModulePtr UberShader::Validate(const nzsl::Ast::Module& module, std::unordered_map<std::string, Option>* options)
|
||||
{
|
||||
NazaraAssert(m_shaderStages != 0, "there must be at least one shader stage");
|
||||
assert(options);
|
||||
|
||||
// Try to partially sanitize shader
|
||||
|
||||
ShaderAst::SanitizeVisitor::Options sanitizeOptions;
|
||||
nzsl::Ast::SanitizeVisitor::Options sanitizeOptions;
|
||||
sanitizeOptions.allowPartialSanitization = true;
|
||||
|
||||
ShaderAst::ModulePtr sanitizedModule = ShaderAst::Sanitize(module, sanitizeOptions);
|
||||
nzsl::Ast::ModulePtr sanitizedModule = nzsl::Ast::Sanitize(module, sanitizeOptions);
|
||||
|
||||
ShaderStageTypeFlags supportedStageType;
|
||||
nzsl::ShaderStageTypeFlags supportedStageType;
|
||||
|
||||
ShaderAst::AstReflect::Callbacks callbacks;
|
||||
callbacks.onEntryPointDeclaration = [&](ShaderStageType stageType, const std::string& /*name*/)
|
||||
nzsl::Ast::ReflectVisitor::Callbacks callbacks;
|
||||
callbacks.onEntryPointDeclaration = [&](nzsl::ShaderStageType stageType, const std::string& /*name*/)
|
||||
{
|
||||
supportedStageType |= stageType;
|
||||
};
|
||||
|
||||
std::unordered_map<std::string, Option> optionByName;
|
||||
callbacks.onOptionDeclaration = [&](const ShaderAst::DeclareOptionStatement& option)
|
||||
callbacks.onOptionDeclaration = [&](const nzsl::Ast::DeclareOptionStatement& option)
|
||||
{
|
||||
//TODO: Check optionType
|
||||
|
||||
@@ -112,7 +112,7 @@ namespace Nz
|
||||
};
|
||||
};
|
||||
|
||||
ShaderAst::AstReflect reflect;
|
||||
nzsl::Ast::ReflectVisitor reflect;
|
||||
reflect.Reflect(*sanitizedModule->rootNode, callbacks);
|
||||
|
||||
if ((m_shaderStages & supportedStageType) != m_shaderStages)
|
||||
|
||||
Reference in New Issue
Block a user