Split shader generation to a new module

This commit is contained in:
Jérôme Leclercq
2020-08-11 00:00:36 +02:00
parent 0313f2d0a6
commit 837a6585a1
86 changed files with 564 additions and 312 deletions

View File

@@ -1,11 +0,0 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Renderer/ShaderWriter.hpp>
#include <Nazara/Renderer/Debug.hpp>
namespace Nz
{
ShaderWriter::~ShaderWriter() = default;
}

View File

@@ -0,0 +1,31 @@
// Copyright (C) 2020 Jérôme Leclercq
// This file is part of the "Nazara Engine - Shader generator"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Shader/Config.hpp>
#if NAZARA_SHADER_MANAGE_MEMORY
#include <Nazara/Core/MemoryManager.hpp>
#include <new> // Nécessaire ?
void* operator new(std::size_t size)
{
return Nz::MemoryManager::Allocate(size, false);
}
void* operator new[](std::size_t size)
{
return Nz::MemoryManager::Allocate(size, true);
}
void operator delete(void* pointer) noexcept
{
Nz::MemoryManager::Free(pointer, false);
}
void operator delete[](void* pointer) noexcept
{
Nz::MemoryManager::Free(pointer, true);
}
#endif // NAZARA_SHADER_MANAGE_MEMORY

View File

@@ -1,15 +1,15 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// Copyright (C) 2020 Jérôme Leclercq
// This file is part of the "Nazara Engine - Shader generator"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Renderer/GlslWriter.hpp>
#include <Nazara/Shader/GlslWriter.hpp>
#include <Nazara/Core/Algorithm.hpp>
#include <Nazara/Core/CallOnExit.hpp>
#include <Nazara/Renderer/ShaderBuilder.hpp>
#include <Nazara/Renderer/ShaderAstCloner.hpp>
#include <Nazara/Renderer/ShaderAstValidator.hpp>
#include <Nazara/Shader/ShaderBuilder.hpp>
#include <Nazara/Shader/ShaderAstCloner.hpp>
#include <Nazara/Shader/ShaderAstValidator.hpp>
#include <stdexcept>
#include <Nazara/Renderer/Debug.hpp>
#include <Nazara/Shader/Debug.hpp>
namespace Nz
{

View File

@@ -0,0 +1,70 @@
// Copyright (C) 2020 Jérôme Leclercq
// This file is part of the "Nazara Engine - Shader generator"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Shader/Shader.hpp>
#include <Nazara/Core/CallOnExit.hpp>
#include <Nazara/Core/Core.hpp>
#include <Nazara/Core/Error.hpp>
#include <Nazara/Core/Log.hpp>
#include <Nazara/Shader/Config.hpp>
#include <Nazara/Shader/Debug.hpp>
namespace Nz
{
bool Shader::Initialize()
{
if (s_moduleReferenceCounter > 0)
{
s_moduleReferenceCounter++;
return true; // Already initialized
}
// Initialize module dependencies
if (!Core::Initialize())
{
NazaraError("Failed to initialize shader module");
return false;
}
s_moduleReferenceCounter++;
CallOnExit onExit(Shader::Uninitialize);
// Initialize module here
onExit.Reset();
NazaraNotice("Initialized: Shader module");
return true;
}
bool Shader::IsInitialized()
{
return s_moduleReferenceCounter != 0;
}
void Shader::Uninitialize()
{
if (s_moduleReferenceCounter != 1)
{
// Either the module is not initialized, either it was initialized multiple times
if (s_moduleReferenceCounter > 1)
s_moduleReferenceCounter--;
return;
}
s_moduleReferenceCounter = 0;
// Uninitialize module here
NazaraNotice("Uninitialized: Shader module");
// Free module dependencies
Core::Uninitialize();
}
unsigned int Shader::s_moduleReferenceCounter = 0;
}

View File

@@ -1,9 +1,9 @@
// Copyright (C) 2020 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// This file is part of the "Nazara Engine - Shader generator"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Renderer/ShaderAst.hpp>
#include <Nazara/Renderer/Debug.hpp>
#include <Nazara/Shader/ShaderAst.hpp>
#include <Nazara/Shader/Debug.hpp>
namespace Nz
{

View File

@@ -1,10 +1,10 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// Copyright (C) 2020 Jérôme Leclercq
// This file is part of the "Nazara Engine - Shader generator"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Renderer/ShaderAstCloner.hpp>
#include <Nazara/Shader/ShaderAstCloner.hpp>
#include <stdexcept>
#include <Nazara/Renderer/Debug.hpp>
#include <Nazara/Shader/Debug.hpp>
namespace Nz
{

View File

@@ -1,9 +1,9 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// Copyright (C) 2020 Jérôme Leclercq
// This file is part of the "Nazara Engine - Shader generator"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Renderer/ShaderAstRecursiveVisitor.hpp>
#include <Nazara/Renderer/Debug.hpp>
#include <Nazara/Shader/ShaderAstRecursiveVisitor.hpp>
#include <Nazara/Shader/Debug.hpp>
namespace Nz
{

View File

@@ -1,11 +1,11 @@
// Copyright (C) 2020 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// This file is part of the "Nazara Engine - Shader generator"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Renderer/ShaderAstSerializer.hpp>
#include <Nazara/Renderer/ShaderVarVisitor.hpp>
#include <Nazara/Renderer/ShaderAstVisitor.hpp>
#include <Nazara/Renderer/Debug.hpp>
#include <Nazara/Shader/ShaderAstSerializer.hpp>
#include <Nazara/Shader/ShaderVarVisitor.hpp>
#include <Nazara/Shader/ShaderAstVisitor.hpp>
#include <Nazara/Shader/Debug.hpp>
namespace Nz
{

View File

@@ -1,13 +1,13 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// Copyright (C) 2020 Jérôme Leclercq
// This file is part of the "Nazara Engine - Shader generator"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Renderer/ShaderAstValidator.hpp>
#include <Nazara/Shader/ShaderAstValidator.hpp>
#include <Nazara/Core/CallOnExit.hpp>
#include <Nazara/Renderer/ShaderAst.hpp>
#include <Nazara/Renderer/ShaderVariables.hpp>
#include <Nazara/Shader/ShaderAst.hpp>
#include <Nazara/Shader/ShaderVariables.hpp>
#include <vector>
#include <Nazara/Renderer/Debug.hpp>
#include <Nazara/Shader/Debug.hpp>
namespace Nz
{

View File

@@ -1,9 +1,9 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// Copyright (C) 2020 Jérôme Leclercq
// This file is part of the "Nazara Engine - Shader generator"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Renderer/ShaderAstVisitor.hpp>
#include <Nazara/Renderer/Debug.hpp>
#include <Nazara/Shader/ShaderAstVisitor.hpp>
#include <Nazara/Shader/Debug.hpp>
namespace Nz
{

View File

@@ -1,13 +1,13 @@
// Copyright (C) 2020 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// This file is part of the "Nazara Engine - Shader generator"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Renderer/ShaderNodes.hpp>
#include <Nazara/Shader/ShaderNodes.hpp>
#include <Nazara/Core/Algorithm.hpp>
#include <Nazara/Renderer/ShaderAstSerializer.hpp>
#include <Nazara/Renderer/ShaderAstVisitor.hpp>
#include <Nazara/Renderer/ShaderWriter.hpp>
#include <Nazara/Renderer/Debug.hpp>
#include <Nazara/Shader/ShaderAstSerializer.hpp>
#include <Nazara/Shader/ShaderAstVisitor.hpp>
#include <Nazara/Shader/ShaderWriter.hpp>
#include <Nazara/Shader/Debug.hpp>
namespace Nz::ShaderNodes
{
@@ -61,7 +61,7 @@ namespace Nz::ShaderNodes
ExpressionCategory AccessMember::GetExpressionCategory() const
{
return ExpressionCategory::LValue;
return structExpr->GetExpressionCategory();
}
ShaderExpressionType AccessMember::GetExpressionType() const
@@ -200,7 +200,7 @@ namespace Nz::ShaderNodes
ExpressionCategory SwizzleOp::GetExpressionCategory() const
{
return ExpressionCategory::LValue;
return expression->GetExpressionCategory();
}
ShaderExpressionType SwizzleOp::GetExpressionType() const

View File

@@ -1,9 +1,9 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// Copyright (C) 2020 Jérôme Leclercq
// This file is part of the "Nazara Engine - Shader generator"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Renderer/ShaderVarVisitor.hpp>
#include <Nazara/Renderer/Debug.hpp>
#include <Nazara/Shader/ShaderVarVisitor.hpp>
#include <Nazara/Shader/Debug.hpp>
namespace Nz
{

View File

@@ -1,10 +1,10 @@
// Copyright (C) 2020 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// This file is part of the "Nazara Engine - Shader generator"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Renderer/ShaderVariables.hpp>
#include <Nazara/Renderer/ShaderVarVisitor.hpp>
#include <Nazara/Renderer/Debug.hpp>
#include <Nazara/Shader/ShaderVariables.hpp>
#include <Nazara/Shader/ShaderVarVisitor.hpp>
#include <Nazara/Shader/Debug.hpp>
namespace Nz::ShaderNodes
{

View File

@@ -0,0 +1,11 @@
// Copyright (C) 2020 Jérôme Leclercq
// This file is part of the "Nazara Engine - Shader generator"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Shader/ShaderWriter.hpp>
#include <Nazara/Shader/Debug.hpp>
namespace Nz
{
ShaderWriter::~ShaderWriter() = default;
}

View File

@@ -1,13 +1,13 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// Copyright (C) 2020 Jérôme Leclercq
// This file is part of the "Nazara Engine - Shader generator"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Renderer/SpirvWriter.hpp>
#include <Nazara/Shader/SpirvWriter.hpp>
#include <Nazara/Core/CallOnExit.hpp>
#include <Nazara/Core/Endianness.hpp>
#include <Nazara/Core/StackVector.hpp>
#include <Nazara/Renderer/ShaderAstCloner.hpp>
#include <Nazara/Renderer/ShaderAstValidator.hpp>
#include <Nazara/Shader/ShaderAstCloner.hpp>
#include <Nazara/Shader/ShaderAstValidator.hpp>
#include <tsl/ordered_map.h>
#include <tsl/ordered_set.h>
#include <SpirV/spirv.h>
@@ -16,7 +16,7 @@
#include <stdexcept>
#include <type_traits>
#include <vector>
#include <Nazara/Renderer/Debug.hpp>
#include <Nazara/Shader/Debug.hpp>
namespace Nz
{

View File

@@ -5,7 +5,7 @@
#include <ShaderNode/DataTypes/FloatData.hpp>
#include <ShaderNode/DataTypes/Matrix4Data.hpp>
#include <ShaderNode/DataTypes/VecData.hpp>
#include <Nazara/Renderer/ShaderBuilder.hpp>
#include <Nazara/Shader/ShaderBuilder.hpp>
#include <QtWidgets/QComboBox>
#include <QtWidgets/QFormLayout>
#include <iostream>

View File

@@ -1,5 +1,5 @@
#include <ShaderNode/DataModels/Cast.hpp>
#include <Nazara/Renderer/ShaderBuilder.hpp>
#include <Nazara/Shader/ShaderBuilder.hpp>
#include <QtWidgets/QDoubleSpinBox>
#include <QtWidgets/QFormLayout>
#include <stdexcept>

View File

@@ -1,6 +1,6 @@
#include <ShaderNode/DataModels/FloatValue.hpp>
#include <ShaderNode/DataTypes/FloatData.hpp>
#include <Nazara/Renderer/ShaderBuilder.hpp>
#include <Nazara/Shader/ShaderBuilder.hpp>
#include <cassert>
FloatValue::FloatValue(ShaderGraph& graph) :

View File

@@ -4,7 +4,7 @@
#include <ShaderNode/DataTypes/FloatData.hpp>
#include <ShaderNode/DataTypes/Matrix4Data.hpp>
#include <ShaderNode/DataTypes/VecData.hpp>
#include <Nazara/Renderer/ShaderBuilder.hpp>
#include <Nazara/Shader/ShaderBuilder.hpp>
#include <QtWidgets/QFormLayout>
InputValue::InputValue(ShaderGraph& graph) :

View File

@@ -1,5 +1,5 @@
#include <ShaderNode/DataModels/Mat4BinOp.hpp>
#include <Nazara/Renderer/ShaderBuilder.hpp>
#include <Nazara/Shader/ShaderBuilder.hpp>
template<Nz::ShaderNodes::BinaryType BinOp>
Mat4BinOp<BinOp>::Mat4BinOp(ShaderGraph& graph) :

View File

@@ -1,5 +1,5 @@
#include <ShaderNode/DataModels/Mat4VecMul.hpp>
#include <Nazara/Renderer/ShaderNodes.hpp>
#include <Nazara/Shader/ShaderNodes.hpp>
Mat4VecMul::Mat4VecMul(ShaderGraph& graph) :
ShaderNode(graph)

View File

@@ -1,5 +1,5 @@
#include <ShaderNode/DataModels/OutputValue.hpp>
#include <Nazara/Renderer/ShaderBuilder.hpp>
#include <Nazara/Shader/ShaderBuilder.hpp>
#include <ShaderNode/ShaderGraph.hpp>
#include <ShaderNode/DataTypes/BoolData.hpp>
#include <ShaderNode/DataTypes/FloatData.hpp>

View File

@@ -1,5 +1,5 @@
#include <ShaderNode/DataModels/PositionOutputValue.hpp>
#include <Nazara/Renderer/ShaderBuilder.hpp>
#include <Nazara/Shader/ShaderBuilder.hpp>
#include <ShaderNode/ShaderGraph.hpp>
#include <ShaderNode/DataTypes/BoolData.hpp>
#include <ShaderNode/DataTypes/FloatData.hpp>

View File

@@ -1,6 +1,6 @@
#include <ShaderNode/ShaderGraph.hpp>
#include <ShaderNode/DataModels/SampleTexture.hpp>
#include <Nazara/Renderer/ShaderBuilder.hpp>
#include <Nazara/Shader/ShaderBuilder.hpp>
SampleTexture::SampleTexture(ShaderGraph& graph) :
ShaderNode(graph)

View File

@@ -4,7 +4,7 @@
#define NAZARA_SHADERNODES_SHADERNODE_HPP
#include <Nazara/Math/Vector2.hpp>
#include <Nazara/Renderer/ShaderNodes.hpp>
#include <Nazara/Shader/ShaderNodes.hpp>
#include <nodes/NodeDataModel>
#include <QtGui/QPixmap>
#include <optional>

View File

@@ -2,7 +2,7 @@
#include <ShaderNode/ShaderGraph.hpp>
#include <ShaderNode/DataTypes/TextureData.hpp>
#include <ShaderNode/DataTypes/VecData.hpp>
#include <Nazara/Renderer/ShaderBuilder.hpp>
#include <Nazara/Shader/ShaderBuilder.hpp>
#include <QtWidgets/QFormLayout>
TextureValue::TextureValue(ShaderGraph& graph) :

View File

@@ -1,5 +1,5 @@
#include <ShaderNode/DataModels/VecBinOp.hpp>
#include <Nazara/Renderer/ShaderBuilder.hpp>
#include <Nazara/Shader/ShaderBuilder.hpp>
template<Nz::ShaderNodes::BinaryType BinOp>
VecBinOp<BinOp>::VecBinOp(ShaderGraph& graph) :

View File

@@ -1,5 +1,5 @@
#include <ShaderNode/DataModels/VecDot.hpp>
#include <Nazara/Renderer/ShaderNodes.hpp>
#include <Nazara/Shader/ShaderNodes.hpp>
VecDot::VecDot(ShaderGraph& graph) :
ShaderNode(graph)

View File

@@ -1,5 +1,5 @@
#include <ShaderNode/DataModels/VecFloatMul.hpp>
#include <Nazara/Renderer/ShaderNodes.hpp>
#include <Nazara/Shader/ShaderNodes.hpp>
VecFloatMul::VecFloatMul(ShaderGraph& graph) :
ShaderNode(graph)

View File

@@ -1,6 +1,6 @@
#include <ShaderNode/DataModels/VecValue.hpp>
#include <Nazara/Core/Algorithm.hpp>
#include <Nazara/Renderer/ShaderBuilder.hpp>
#include <Nazara/Shader/ShaderBuilder.hpp>
#include <ShaderNode/DataTypes/VecData.hpp>
#include <QtCore/QJsonArray>
#include <array>

View File

@@ -3,7 +3,7 @@
#ifndef NAZARA_SHADERNODES_MATRIXDATA_HPP
#define NAZARA_SHADERNODES_MATRIXDATA_HPP
#include <Nazara/Renderer/ShaderNodes.hpp>
#include <Nazara/Shader/ShaderNodes.hpp>
#include <ShaderNode/Previews/PreviewValues.hpp>
#include <nodes/NodeData>

View File

@@ -4,7 +4,7 @@
#define NAZARA_SHADERNODES_TEXTUREDATA_HPP
#include <ShaderNode/Previews/PreviewValues.hpp>
#include <Nazara/Renderer/ShaderNodes.hpp>
#include <Nazara/Shader/ShaderNodes.hpp>
#include <nodes/NodeData>
struct TextureData : public QtNodes::NodeData

View File

@@ -3,7 +3,7 @@
#ifndef NAZARA_SHADERNODES_VECDATA_HPP
#define NAZARA_SHADERNODES_VECDATA_HPP
#include <Nazara/Renderer/ShaderNodes.hpp>
#include <Nazara/Shader/ShaderNodes.hpp>
#include <ShaderNode/Previews/PreviewValues.hpp>
#include <nodes/NodeData>

View File

@@ -4,8 +4,8 @@
#define NAZARA_SHADERNODES_SHADERGRAPH_HPP
#include <Nazara/Core/Signal.hpp>
#include <Nazara/Renderer/Enums.hpp>
#include <Nazara/Renderer/ShaderNodes.hpp>
#include <Nazara/Utility/Enums.hpp>
#include <Nazara/Shader/ShaderNodes.hpp>
#include <nodes/FlowScene>
#include <ShaderNode/Enums.hpp>
#include <ShaderNode/Previews/PreviewModel.hpp>

View File

@@ -1,7 +1,7 @@
#include <ShaderNode/Widgets/MainWindow.hpp>
#include <Nazara/Core/File.hpp>
#include <Nazara/Renderer/GlslWriter.hpp>
#include <Nazara/Renderer/ShaderAstSerializer.hpp>
#include <Nazara/Shader/GlslWriter.hpp>
#include <Nazara/Shader/ShaderAstSerializer.hpp>
#include <ShaderNode/ShaderGraph.hpp>
#include <ShaderNode/Widgets/BufferEditor.hpp>
#include <ShaderNode/Widgets/InputEditor.hpp>