From 837a6585a187006ae28167df269cd9fc26a07b78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Tue, 11 Aug 2020 00:00:36 +0200 Subject: [PATCH] Split shader generation to a new module --- build/scripts/modules/renderer.lua | 16 +---- build/scripts/modules/shader.lua | 6 ++ build/scripts/tools/shadernodes.lua | 2 +- examples/VulkanTest/main.cpp | 2 - include/Nazara/OpenGLRenderer/Config.hpp | 2 +- include/Nazara/OpenGLRenderer/ConfigCheck.hpp | 8 +-- include/Nazara/OpenGLRenderer/Debug.hpp | 2 +- include/Nazara/OpenGLRenderer/DebugOff.hpp | 2 +- .../Nazara/OpenGLRenderer/DummySurface.hpp | 2 +- .../Nazara/OpenGLRenderer/OpenGLBuffer.hpp | 2 +- .../Nazara/OpenGLRenderer/OpenGLDevice.hpp | 2 +- .../OpenGLRenderer/OpenGLRenderWindow.hpp | 2 +- .../OpenGLRenderer/OpenGLShaderStage.hpp | 2 +- .../Nazara/OpenGLRenderer/OpenGLVaoCache.hpp | 2 +- include/Nazara/Renderer.hpp | 15 ---- include/Nazara/Renderer/Enums.hpp | 18 ----- .../Nazara/Renderer/RenderPipelineLayout.hpp | 1 + include/Nazara/Renderer/ShaderAstCloner.inl | 12 ---- .../Renderer/ShaderAstRecursiveVisitor.inl | 12 ---- include/Nazara/Shader.hpp | 50 +++++++++++++ include/Nazara/Shader/Config.hpp | 53 ++++++++++++++ include/Nazara/Shader/ConfigCheck.hpp | 22 ++++++ include/Nazara/Shader/Debug.hpp | 8 +++ include/Nazara/Shader/DebugOff.hpp | 9 +++ .../{Renderer => Shader}/GlslWriter.hpp | 14 ++-- .../{Renderer => Shader}/GlslWriter.inl | 8 +-- include/Nazara/Shader/Shader.hpp | 33 +++++++++ .../Nazara/{Renderer => Shader}/ShaderAst.hpp | 10 +-- .../Nazara/{Renderer => Shader}/ShaderAst.inl | 8 +-- .../{Renderer => Shader}/ShaderAstCloner.hpp | 14 ++-- include/Nazara/Shader/ShaderAstCloner.inl | 12 ++++ .../ShaderAstRecursiveVisitor.hpp | 10 +-- .../Shader/ShaderAstRecursiveVisitor.inl | 12 ++++ .../ShaderAstSerializer.hpp | 22 +++--- .../ShaderAstSerializer.inl | 8 +-- .../ShaderAstValidator.hpp | 16 ++--- .../ShaderAstValidator.inl | 8 +-- .../{Renderer => Shader}/ShaderAstVisitor.hpp | 10 +-- .../{Renderer => Shader}/ShaderBuilder.hpp | 6 +- .../{Renderer => Shader}/ShaderBuilder.inl | 8 +-- .../{Renderer => Shader}/ShaderEnums.hpp | 2 +- .../ShaderExpressionType.hpp | 4 +- .../{Renderer => Shader}/ShaderNodes.hpp | 46 ++++++------ .../{Renderer => Shader}/ShaderNodes.inl | 8 +-- .../{Renderer => Shader}/ShaderVarVisitor.hpp | 8 +-- .../{Renderer => Shader}/ShaderVariables.hpp | 24 +++---- .../{Renderer => Shader}/ShaderVariables.inl | 8 +-- .../{Renderer => Shader}/ShaderWriter.hpp | 6 +- .../{Renderer => Shader}/SpirvWriter.hpp | 16 ++--- .../{Renderer => Shader}/SpirvWriter.inl | 8 +-- include/Nazara/Utility/Enums.hpp | 18 +++++ src/Nazara/Renderer/ShaderWriter.cpp | 11 --- src/Nazara/Shader/Debug/NewOverload.cpp | 31 ++++++++ .../{Renderer => Shader}/GlslWriter.cpp | 14 ++-- src/Nazara/Shader/Shader.cpp | 70 +++++++++++++++++++ src/Nazara/{Renderer => Shader}/ShaderAst.cpp | 6 +- .../{Renderer => Shader}/ShaderAstCloner.cpp | 8 +-- .../ShaderAstRecursiveVisitor.cpp | 8 +-- .../ShaderAstSerializer.cpp | 10 +-- .../ShaderAstValidator.cpp | 12 ++-- .../{Renderer => Shader}/ShaderAstVisitor.cpp | 8 +-- .../{Renderer => Shader}/ShaderNodes.cpp | 16 ++--- .../{Renderer => Shader}/ShaderVarVisitor.cpp | 8 +-- .../{Renderer => Shader}/ShaderVariables.cpp | 8 +-- src/Nazara/Shader/ShaderWriter.cpp | 11 +++ .../{Renderer => Shader}/SpirvWriter.cpp | 12 ++-- src/ShaderNode/DataModels/BufferField.cpp | 2 +- src/ShaderNode/DataModels/Cast.inl | 2 +- src/ShaderNode/DataModels/FloatValue.cpp | 2 +- src/ShaderNode/DataModels/InputValue.cpp | 2 +- src/ShaderNode/DataModels/Mat4BinOp.inl | 2 +- src/ShaderNode/DataModels/Mat4VecMul.cpp | 2 +- src/ShaderNode/DataModels/OutputValue.cpp | 2 +- .../DataModels/PositionOutputValue.cpp | 2 +- src/ShaderNode/DataModels/SampleTexture.cpp | 2 +- src/ShaderNode/DataModels/ShaderNode.hpp | 2 +- src/ShaderNode/DataModels/TextureValue.cpp | 2 +- src/ShaderNode/DataModels/VecBinOp.inl | 2 +- src/ShaderNode/DataModels/VecDot.cpp | 2 +- src/ShaderNode/DataModels/VecFloatMul.cpp | 2 +- src/ShaderNode/DataModels/VecValue.inl | 2 +- src/ShaderNode/DataTypes/Matrix4Data.hpp | 2 +- src/ShaderNode/DataTypes/TextureData.hpp | 2 +- src/ShaderNode/DataTypes/VecData.hpp | 2 +- src/ShaderNode/ShaderGraph.hpp | 4 +- src/ShaderNode/Widgets/MainWindow.cpp | 4 +- 86 files changed, 564 insertions(+), 312 deletions(-) create mode 100644 build/scripts/modules/shader.lua delete mode 100644 include/Nazara/Renderer/ShaderAstCloner.inl delete mode 100644 include/Nazara/Renderer/ShaderAstRecursiveVisitor.inl create mode 100644 include/Nazara/Shader.hpp create mode 100644 include/Nazara/Shader/Config.hpp create mode 100644 include/Nazara/Shader/ConfigCheck.hpp create mode 100644 include/Nazara/Shader/Debug.hpp create mode 100644 include/Nazara/Shader/DebugOff.hpp rename include/Nazara/{Renderer => Shader}/GlslWriter.hpp (89%) rename include/Nazara/{Renderer => Shader}/GlslWriter.inl (93%) create mode 100644 include/Nazara/Shader/Shader.hpp rename include/Nazara/{Renderer => Shader}/ShaderAst.hpp (94%) rename include/Nazara/{Renderer => Shader}/ShaderAst.inl (91%) rename include/Nazara/{Renderer => Shader}/ShaderAstCloner.hpp (86%) create mode 100644 include/Nazara/Shader/ShaderAstCloner.inl rename include/Nazara/{Renderer => Shader}/ShaderAstRecursiveVisitor.hpp (80%) create mode 100644 include/Nazara/Shader/ShaderAstRecursiveVisitor.inl rename include/Nazara/{Renderer => Shader}/ShaderAstSerializer.hpp (87%) rename include/Nazara/{Renderer => Shader}/ShaderAstSerializer.inl (92%) rename include/Nazara/{Renderer => Shader}/ShaderAstValidator.hpp (81%) rename include/Nazara/{Renderer => Shader}/ShaderAstValidator.inl (54%) rename include/Nazara/{Renderer => Shader}/ShaderAstVisitor.hpp (86%) rename include/Nazara/{Renderer => Shader}/ShaderBuilder.hpp (94%) rename include/Nazara/{Renderer => Shader}/ShaderBuilder.inl (89%) rename include/Nazara/{Renderer => Shader}/ShaderEnums.hpp (96%) rename include/Nazara/{Renderer => Shader}/ShaderExpressionType.hpp (80%) rename include/Nazara/{Renderer => Shader}/ShaderNodes.hpp (84%) rename include/Nazara/{Renderer => Shader}/ShaderNodes.inl (97%) rename include/Nazara/{Renderer => Shader}/ShaderVarVisitor.hpp (82%) rename include/Nazara/{Renderer => Shader}/ShaderVariables.hpp (78%) rename include/Nazara/{Renderer => Shader}/ShaderVariables.inl (89%) rename include/Nazara/{Renderer => Shader}/ShaderWriter.hpp (79%) rename include/Nazara/{Renderer => Shader}/SpirvWriter.hpp (90%) rename include/Nazara/{Renderer => Shader}/SpirvWriter.inl (93%) delete mode 100644 src/Nazara/Renderer/ShaderWriter.cpp create mode 100644 src/Nazara/Shader/Debug/NewOverload.cpp rename src/Nazara/{Renderer => Shader}/GlslWriter.cpp (97%) create mode 100644 src/Nazara/Shader/Shader.cpp rename src/Nazara/{Renderer => Shader}/ShaderAst.cpp (92%) rename src/Nazara/{Renderer => Shader}/ShaderAstCloner.cpp (97%) rename src/Nazara/{Renderer => Shader}/ShaderAstRecursiveVisitor.cpp (90%) rename src/Nazara/{Renderer => Shader}/ShaderAstSerializer.cpp (98%) rename src/Nazara/{Renderer => Shader}/ShaderAstValidator.cpp (97%) rename src/Nazara/{Renderer => Shader}/ShaderAstVisitor.cpp (73%) rename src/Nazara/{Renderer => Shader}/ShaderNodes.cpp (93%) rename src/Nazara/{Renderer => Shader}/ShaderVarVisitor.cpp (56%) rename src/Nazara/{Renderer => Shader}/ShaderVariables.cpp (86%) create mode 100644 src/Nazara/Shader/ShaderWriter.cpp rename src/Nazara/{Renderer => Shader}/SpirvWriter.cpp (99%) diff --git a/build/scripts/modules/renderer.lua b/build/scripts/modules/renderer.lua index df10e2910..2e3a6619a 100644 --- a/build/scripts/modules/renderer.lua +++ b/build/scripts/modules/renderer.lua @@ -2,12 +2,9 @@ MODULE.Name = "Renderer" MODULE.ClientOnly = true -MODULE.Defines = { - "NAZARA_RENDERER_OPENGL" -} - MODULE.Libraries = { "NazaraCore", + "NazaraShader", "NazaraUtility", "NazaraPlatform" } @@ -22,14 +19,3 @@ MODULE.OsFiles.Posix = { "../src/Nazara/Renderer/GLX/**.cpp" } -MODULE.OsLibraries.Windows = { - "gdi32", - "opengl32", - "winmm" -} - -MODULE.OsLibraries.Posix = { - "GL", - "X11" -} - diff --git a/build/scripts/modules/shader.lua b/build/scripts/modules/shader.lua new file mode 100644 index 000000000..a0a22a663 --- /dev/null +++ b/build/scripts/modules/shader.lua @@ -0,0 +1,6 @@ +MODULE.Name = "Shader" + +MODULE.Libraries = { + "NazaraCore", + "NazaraUtility" +} diff --git a/build/scripts/tools/shadernodes.lua b/build/scripts/tools/shadernodes.lua index 3abeaa658..bcf9a1593 100644 --- a/build/scripts/tools/shadernodes.lua +++ b/build/scripts/tools/shadernodes.lua @@ -28,7 +28,7 @@ TOOL.Files = { TOOL.Libraries = { "NazaraCore", - "NazaraRenderer", + "NazaraShader", "NazaraUtility", "Qt5Cored", "Qt5Guid", diff --git a/examples/VulkanTest/main.cpp b/examples/VulkanTest/main.cpp index cd7132e4a..54c34762c 100644 --- a/examples/VulkanTest/main.cpp +++ b/examples/VulkanTest/main.cpp @@ -1,7 +1,5 @@ #include #include -#include -#include #include #include diff --git a/include/Nazara/OpenGLRenderer/Config.hpp b/include/Nazara/OpenGLRenderer/Config.hpp index 1ffd4999f..3cc4856f1 100644 --- a/include/Nazara/OpenGLRenderer/Config.hpp +++ b/include/Nazara/OpenGLRenderer/Config.hpp @@ -50,4 +50,4 @@ #define NAZARA_OPENGLRENDERER_API #endif -#endif // NAZARA_CONFIG_MODULENAME_HPP +#endif // NAZARA_CONFIG_OPENGLRENDERER_HPP diff --git a/include/Nazara/OpenGLRenderer/ConfigCheck.hpp b/include/Nazara/OpenGLRenderer/ConfigCheck.hpp index 793b04818..9f59a0119 100644 --- a/include/Nazara/OpenGLRenderer/ConfigCheck.hpp +++ b/include/Nazara/OpenGLRenderer/ConfigCheck.hpp @@ -4,8 +4,8 @@ #pragma once -#ifndef NAZARA_CONFIG_CHECK_OPENGLE_HPP -#define NAZARA_CONFIG_CHECK_OPENGLE_HPP +#ifndef NAZARA_CONFIG_CHECK_OPENGLRENDERER_HPP +#define NAZARA_CONFIG_CHECK_OPENGLRENDERER_HPP /// Ce fichier sert à vérifier la valeur des constantes du fichier Config.hpp @@ -15,8 +15,8 @@ // On force la valeur de MANAGE_MEMORY en mode debug #if defined(NAZARA_DEBUG) && !NAZARA_OPENGLRENDERER_MANAGE_MEMORY - #undef NAZARA_MODULENAME_MANAGE_MEMORY - #define NAZARA_MODULENAME_MANAGE_MEMORY 0 + #undef NAZARA_OPENGLRENDERER_MANAGE_MEMORY + #define NAZARA_OPENGLRENDERER_MANAGE_MEMORY 0 #endif #endif // NAZARA_CONFIG_CHECK_OPENGLRENDERER_HPP diff --git a/include/Nazara/OpenGLRenderer/Debug.hpp b/include/Nazara/OpenGLRenderer/Debug.hpp index 36e55c909..181fe26d0 100644 --- a/include/Nazara/OpenGLRenderer/Debug.hpp +++ b/include/Nazara/OpenGLRenderer/Debug.hpp @@ -3,6 +3,6 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#if NAZARA_MODULENAME_MANAGE_MEMORY +#if NAZARA_OPENGLRENDERER_MANAGE_MEMORY #include #endif diff --git a/include/Nazara/OpenGLRenderer/DebugOff.hpp b/include/Nazara/OpenGLRenderer/DebugOff.hpp index c8ee4e470..600f6f117 100644 --- a/include/Nazara/OpenGLRenderer/DebugOff.hpp +++ b/include/Nazara/OpenGLRenderer/DebugOff.hpp @@ -3,7 +3,7 @@ // For conditions of distribution and use, see copyright notice in Config.hpp // On suppose que Debug.hpp a déjà été inclus, tout comme Config.hpp -#if NAZARA_MODULENAME_MANAGE_MEMORY +#if NAZARA_OPENGLRENDERER_MANAGE_MEMORY #undef delete #undef new #endif diff --git a/include/Nazara/OpenGLRenderer/DummySurface.hpp b/include/Nazara/OpenGLRenderer/DummySurface.hpp index 10246a9d1..51a60783f 100644 --- a/include/Nazara/OpenGLRenderer/DummySurface.hpp +++ b/include/Nazara/OpenGLRenderer/DummySurface.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - OpenGL Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/OpenGLRenderer/OpenGLBuffer.hpp b/include/Nazara/OpenGLRenderer/OpenGLBuffer.hpp index c00ad0710..17688b5d9 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLBuffer.hpp +++ b/include/Nazara/OpenGLRenderer/OpenGLBuffer.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - OpenGL Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/OpenGLRenderer/OpenGLDevice.hpp b/include/Nazara/OpenGLRenderer/OpenGLDevice.hpp index 2bbb95c33..9d9b6adef 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLDevice.hpp +++ b/include/Nazara/OpenGLRenderer/OpenGLDevice.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - OpenGL Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/OpenGLRenderer/OpenGLRenderWindow.hpp b/include/Nazara/OpenGLRenderer/OpenGLRenderWindow.hpp index 9fdb69561..ceb7b2489 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLRenderWindow.hpp +++ b/include/Nazara/OpenGLRenderer/OpenGLRenderWindow.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - OpenGL Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/OpenGLRenderer/OpenGLShaderStage.hpp b/include/Nazara/OpenGLRenderer/OpenGLShaderStage.hpp index f72f282ad..8768befb7 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLShaderStage.hpp +++ b/include/Nazara/OpenGLRenderer/OpenGLShaderStage.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - OpenGL Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/OpenGLRenderer/OpenGLVaoCache.hpp b/include/Nazara/OpenGLRenderer/OpenGLVaoCache.hpp index 0a9bc14d1..8f7cca48d 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLVaoCache.hpp +++ b/include/Nazara/OpenGLRenderer/OpenGLVaoCache.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - OpenGL Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer.hpp b/include/Nazara/Renderer.hpp index ff9193d3f..69153a0d4 100644 --- a/include/Nazara/Renderer.hpp +++ b/include/Nazara/Renderer.hpp @@ -36,7 +36,6 @@ #include #include #include -#include #include #include #include @@ -52,22 +51,8 @@ #include #include #include -#include -#include -#include -#include -#include -#include #include -#include -#include -#include -#include #include -#include -#include -#include -#include #include #include #include diff --git a/include/Nazara/Renderer/Enums.hpp b/include/Nazara/Renderer/Enums.hpp index 05daee7a5..0b44ae629 100644 --- a/include/Nazara/Renderer/Enums.hpp +++ b/include/Nazara/Renderer/Enums.hpp @@ -53,24 +53,6 @@ namespace Nz SpirV }; - enum class ShaderStageType - { - Fragment, - Vertex, - - Max = Vertex - }; - - template<> - struct EnumAsFlags - { - static constexpr ShaderStageType max = ShaderStageType::Max; - }; - - using ShaderStageTypeFlags = Flags; - - constexpr ShaderStageTypeFlags ShaderStageType_All = ShaderStageType::Fragment | ShaderStageType::Vertex; - enum class QueueType { Compute, diff --git a/include/Nazara/Renderer/RenderPipelineLayout.hpp b/include/Nazara/Renderer/RenderPipelineLayout.hpp index c15787c35..38c1b6ef3 100644 --- a/include/Nazara/Renderer/RenderPipelineLayout.hpp +++ b/include/Nazara/Renderer/RenderPipelineLayout.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include diff --git a/include/Nazara/Renderer/ShaderAstCloner.inl b/include/Nazara/Renderer/ShaderAstCloner.inl deleted file mode 100644 index 1acdd41ab..000000000 --- a/include/Nazara/Renderer/ShaderAstCloner.inl +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (C) 2020 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 -#include - -namespace Nz -{ -} - -#include diff --git a/include/Nazara/Renderer/ShaderAstRecursiveVisitor.inl b/include/Nazara/Renderer/ShaderAstRecursiveVisitor.inl deleted file mode 100644 index 3b2c6be62..000000000 --- a/include/Nazara/Renderer/ShaderAstRecursiveVisitor.inl +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (C) 2020 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 -#include - -namespace Nz -{ -} - -#include diff --git a/include/Nazara/Shader.hpp b/include/Nazara/Shader.hpp new file mode 100644 index 000000000..cd9e02507 --- /dev/null +++ b/include/Nazara/Shader.hpp @@ -0,0 +1,50 @@ +// This file was automatically generated + +/* + Nazara Engine - Module name + + Copyright (C) 2020 Jérôme "Lynix" Leclercq (lynix680@gmail.com) + + Permission is hereby granted, free of charge, to any person obtaining a copy of + this software and associated documentation files (the "Software"), to deal in + the Software without restriction, including without limitation the rights to + use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + of the Software, and to permit persons to whom the Software is furnished to do + so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +#pragma once + +#ifndef NAZARA_GLOBAL_SHADER_HPP +#define NAZARA_GLOBAL_SHADER_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif // NAZARA_GLOBAL_SHADER_HPP diff --git a/include/Nazara/Shader/Config.hpp b/include/Nazara/Shader/Config.hpp new file mode 100644 index 000000000..e357579aa --- /dev/null +++ b/include/Nazara/Shader/Config.hpp @@ -0,0 +1,53 @@ +/* + Nazara Engine - Shader generator + + Copyright (C) 2020 Jérôme "Lynix" Leclercq (lynix680@gmail.com) + + Permission is hereby granted, free of charge, to any person obtaining a copy of + this software and associated documentation files (the "Software"), to deal in + the Software without restriction, including without limitation the rights to + use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + of the Software, and to permit persons to whom the Software is furnished to do + so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +#pragma once + +#ifndef NAZARA_CONFIG_SHADER_HPP +#define NAZARA_CONFIG_SHADER_HPP + +/// Each modification of a parameter needs a recompilation of the module + +// Use the MemoryManager to manage dynamic allocations (can detect memory leak but allocations/frees are slower) +#define NAZARA_SHADER_MANAGE_MEMORY 0 + +// Activate the security tests based on the code (Advised for development) +#define NAZARA_SHADER_SAFE 1 + +/// Each modification of a parameter following implies a modification (often minor) of the code + +/// Checking the values and types of certain constants +#include + +#if !defined(NAZARA_STATIC) + #ifdef NAZARA_SHADER_BUILD + #define NAZARA_SHADER_API NAZARA_EXPORT + #else + #define NAZARA_SHADER_API NAZARA_IMPORT + #endif +#else + #define NAZARA_SHADER_API +#endif + +#endif // NAZARA_CONFIG_SHADER_HPP diff --git a/include/Nazara/Shader/ConfigCheck.hpp b/include/Nazara/Shader/ConfigCheck.hpp new file mode 100644 index 000000000..48252e452 --- /dev/null +++ b/include/Nazara/Shader/ConfigCheck.hpp @@ -0,0 +1,22 @@ +// Copyright (C) YEAR AUTHORS +// This file is part of the "Nazara Engine - Shader generator" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_CONFIG_CHECK_SHADER_HPP +#define NAZARA_CONFIG_CHECK_SHADER_HPP + +/// This file is used to check the constant values defined in Config.hpp + +#include +#define CheckType(name, type, err) static_assert(std::is_ ##type ::value, #type err) +#define CheckTypeAndVal(name, type, op, val, err) static_assert(std::is_ ##type ::value && name op val, #type err) + +// We force the value of MANAGE_MEMORY in debug +#if defined(NAZARA_DEBUG) && !NAZARA_SHADER_MANAGE_MEMORY + #undef NAZARA_SHADER_MANAGE_MEMORY + #define NAZARA_SHADER_MANAGE_MEMORY 0 +#endif + +#endif // NAZARA_CONFIG_CHECK_SHADER_HPP diff --git a/include/Nazara/Shader/Debug.hpp b/include/Nazara/Shader/Debug.hpp new file mode 100644 index 000000000..32333d44d --- /dev/null +++ b/include/Nazara/Shader/Debug.hpp @@ -0,0 +1,8 @@ +// Copyright (C) YEAR AUTHORS +// This file is part of the "Nazara Engine - Shader generator" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#if NAZARA_SHADER_MANAGE_MEMORY + #include +#endif diff --git a/include/Nazara/Shader/DebugOff.hpp b/include/Nazara/Shader/DebugOff.hpp new file mode 100644 index 000000000..bca09b27c --- /dev/null +++ b/include/Nazara/Shader/DebugOff.hpp @@ -0,0 +1,9 @@ +// Copyright (C) YEAR AUTHORS +// This file is part of the "Nazara Engine - Shader generator" +// For conditions of distribution and use, see copyright notice in Config.hpp + +// We suppose that Debug.hpp is already included, same goes for Config.hpp +#if NAZARA_SHADER_MANAGE_MEMORY + #undef delete + #undef new +#endif diff --git a/include/Nazara/Renderer/GlslWriter.hpp b/include/Nazara/Shader/GlslWriter.hpp similarity index 89% rename from include/Nazara/Renderer/GlslWriter.hpp rename to include/Nazara/Shader/GlslWriter.hpp index d423286db..3212d81cd 100644 --- a/include/Nazara/Renderer/GlslWriter.hpp +++ b/include/Nazara/Shader/GlslWriter.hpp @@ -8,11 +8,11 @@ #define NAZARA_GLSLWRITER_HPP #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include #include @@ -20,7 +20,7 @@ namespace Nz { - class NAZARA_RENDERER_API GlslWriter : public ShaderWriter, public ShaderVarVisitor, public ShaderAstVisitor + class NAZARA_SHADER_API GlslWriter : public ShaderWriter, public ShaderVarVisitor, public ShaderAstVisitor { public: struct Environment; @@ -104,6 +104,6 @@ namespace Nz }; } -#include +#include #endif // NAZARA_GLSLWRITER_HPP diff --git a/include/Nazara/Renderer/GlslWriter.inl b/include/Nazara/Shader/GlslWriter.inl similarity index 93% rename from include/Nazara/Renderer/GlslWriter.inl rename to include/Nazara/Shader/GlslWriter.inl index e543f870f..76972eec1 100644 --- a/include/Nazara/Renderer/GlslWriter.inl +++ b/include/Nazara/Shader/GlslWriter.inl @@ -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 +#include #include -#include +#include namespace Nz { @@ -129,4 +129,4 @@ namespace Nz } } -#include +#include diff --git a/include/Nazara/Shader/Shader.hpp b/include/Nazara/Shader/Shader.hpp new file mode 100644 index 000000000..e40bd1212 --- /dev/null +++ b/include/Nazara/Shader/Shader.hpp @@ -0,0 +1,33 @@ +// Copyright (C) YEAR AUTHORS +// This file is part of the "Nazara Engine - Module name" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_SHADER_HPP +#define NAZARA_SHADER_HPP + +#include +#include +#include + +namespace Nz +{ + class NAZARA_SHADER_API Shader + { + public: + Shader() = delete; + ~Shader() = delete; + + static bool Initialize(); + + static bool IsInitialized(); + + static void Uninitialize(); + + private: + static unsigned int s_moduleReferenceCounter; + }; +} + +#endif // NAZARA_SHADER_HPP diff --git a/include/Nazara/Renderer/ShaderAst.hpp b/include/Nazara/Shader/ShaderAst.hpp similarity index 94% rename from include/Nazara/Renderer/ShaderAst.hpp rename to include/Nazara/Shader/ShaderAst.hpp index 51117c1d7..11b39d5e9 100644 --- a/include/Nazara/Renderer/ShaderAst.hpp +++ b/include/Nazara/Shader/ShaderAst.hpp @@ -8,16 +8,16 @@ #define NAZARA_SHADER_AST_HPP #include -#include -#include -#include +#include +#include +#include #include #include #include namespace Nz { - class NAZARA_RENDERER_API ShaderAst + class NAZARA_SHADER_API ShaderAst { public: struct Function; @@ -110,6 +110,6 @@ namespace Nz }; } -#include +#include #endif // NAZARA_SHADER_AST_HPP diff --git a/include/Nazara/Renderer/ShaderAst.inl b/include/Nazara/Shader/ShaderAst.inl similarity index 91% rename from include/Nazara/Renderer/ShaderAst.inl rename to include/Nazara/Shader/ShaderAst.inl index f0bc1aebb..4c6c42833 100644 --- a/include/Nazara/Renderer/ShaderAst.inl +++ b/include/Nazara/Shader/ShaderAst.inl @@ -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 -#include +#include +#include namespace Nz { @@ -98,4 +98,4 @@ namespace Nz } } -#include +#include diff --git a/include/Nazara/Renderer/ShaderAstCloner.hpp b/include/Nazara/Shader/ShaderAstCloner.hpp similarity index 86% rename from include/Nazara/Renderer/ShaderAstCloner.hpp rename to include/Nazara/Shader/ShaderAstCloner.hpp index c8b61b02c..4c24e689e 100644 --- a/include/Nazara/Renderer/ShaderAstCloner.hpp +++ b/include/Nazara/Shader/ShaderAstCloner.hpp @@ -1,5 +1,5 @@ -// 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 #pragma once @@ -8,14 +8,14 @@ #define NAZARA_SHADERASTCLONER_HPP #include -#include -#include -#include +#include +#include +#include #include namespace Nz { - class NAZARA_RENDERER_API ShaderAstCloner : public ShaderAstVisitor, public ShaderVarVisitor + class NAZARA_SHADER_API ShaderAstCloner : public ShaderAstVisitor, public ShaderVarVisitor { public: ShaderAstCloner() = default; @@ -69,6 +69,6 @@ namespace Nz }; } -#include +#include #endif diff --git a/include/Nazara/Shader/ShaderAstCloner.inl b/include/Nazara/Shader/ShaderAstCloner.inl new file mode 100644 index 000000000..1182f110d --- /dev/null +++ b/include/Nazara/Shader/ShaderAstCloner.inl @@ -0,0 +1,12 @@ +// 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 +#include + +namespace Nz +{ +} + +#include diff --git a/include/Nazara/Renderer/ShaderAstRecursiveVisitor.hpp b/include/Nazara/Shader/ShaderAstRecursiveVisitor.hpp similarity index 80% rename from include/Nazara/Renderer/ShaderAstRecursiveVisitor.hpp rename to include/Nazara/Shader/ShaderAstRecursiveVisitor.hpp index 0482ea009..367f9b4ca 100644 --- a/include/Nazara/Renderer/ShaderAstRecursiveVisitor.hpp +++ b/include/Nazara/Shader/ShaderAstRecursiveVisitor.hpp @@ -1,5 +1,5 @@ // 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 #pragma once @@ -8,12 +8,12 @@ #define NAZARA_SHADER_RECURSIVE_VISITOR_HPP #include -#include -#include +#include +#include namespace Nz { - class NAZARA_RENDERER_API ShaderAstRecursiveVisitor : public ShaderAstVisitor + class NAZARA_SHADER_API ShaderAstRecursiveVisitor : public ShaderAstVisitor { public: ShaderAstRecursiveVisitor() = default; @@ -37,6 +37,6 @@ namespace Nz }; } -#include +#include #endif diff --git a/include/Nazara/Shader/ShaderAstRecursiveVisitor.inl b/include/Nazara/Shader/ShaderAstRecursiveVisitor.inl new file mode 100644 index 000000000..8de7f453c --- /dev/null +++ b/include/Nazara/Shader/ShaderAstRecursiveVisitor.inl @@ -0,0 +1,12 @@ +// 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 +#include + +namespace Nz +{ +} + +#include diff --git a/include/Nazara/Renderer/ShaderAstSerializer.hpp b/include/Nazara/Shader/ShaderAstSerializer.hpp similarity index 87% rename from include/Nazara/Renderer/ShaderAstSerializer.hpp rename to include/Nazara/Shader/ShaderAstSerializer.hpp index 3298d81e6..2e0102e8e 100644 --- a/include/Nazara/Renderer/ShaderAstSerializer.hpp +++ b/include/Nazara/Shader/ShaderAstSerializer.hpp @@ -1,5 +1,5 @@ // 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 #pragma once @@ -10,14 +10,14 @@ #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include namespace Nz { - class NAZARA_RENDERER_API ShaderAstSerializerBase + class NAZARA_SHADER_API ShaderAstSerializerBase { public: ShaderAstSerializerBase() = default; @@ -73,7 +73,7 @@ namespace Nz template void Variable(std::shared_ptr& var); }; - class NAZARA_RENDERER_API ShaderAstSerializer final : public ShaderAstSerializerBase + class NAZARA_SHADER_API ShaderAstSerializer final : public ShaderAstSerializerBase { public: inline ShaderAstSerializer(ByteStream& stream); @@ -104,7 +104,7 @@ namespace Nz ByteStream& m_stream; }; - class NAZARA_RENDERER_API ShaderAstUnserializer final : public ShaderAstSerializerBase + class NAZARA_SHADER_API ShaderAstUnserializer final : public ShaderAstSerializerBase { public: ShaderAstUnserializer(ByteStream& stream); @@ -134,10 +134,10 @@ namespace Nz ByteStream& m_stream; }; - NAZARA_RENDERER_API ByteArray SerializeShader(const ShaderAst& shader); - NAZARA_RENDERER_API ShaderAst UnserializeShader(ByteStream& stream); + NAZARA_SHADER_API ByteArray SerializeShader(const ShaderAst& shader); + NAZARA_SHADER_API ShaderAst UnserializeShader(ByteStream& stream); } -#include +#include #endif diff --git a/include/Nazara/Renderer/ShaderAstSerializer.inl b/include/Nazara/Shader/ShaderAstSerializer.inl similarity index 92% rename from include/Nazara/Renderer/ShaderAstSerializer.inl rename to include/Nazara/Shader/ShaderAstSerializer.inl index dd272e1fa..a335f91c2 100644 --- a/include/Nazara/Renderer/ShaderAstSerializer.inl +++ b/include/Nazara/Shader/ShaderAstSerializer.inl @@ -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 -#include +#include +#include namespace Nz { @@ -124,4 +124,4 @@ namespace Nz } } -#include +#include diff --git a/include/Nazara/Renderer/ShaderAstValidator.hpp b/include/Nazara/Shader/ShaderAstValidator.hpp similarity index 81% rename from include/Nazara/Renderer/ShaderAstValidator.hpp rename to include/Nazara/Shader/ShaderAstValidator.hpp index 90aec52aa..0f9e99347 100644 --- a/include/Nazara/Renderer/ShaderAstValidator.hpp +++ b/include/Nazara/Shader/ShaderAstValidator.hpp @@ -1,5 +1,5 @@ // 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 #pragma once @@ -10,14 +10,14 @@ #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include namespace Nz { - class NAZARA_RENDERER_API ShaderAstValidator : public ShaderAstRecursiveVisitor, public ShaderVarVisitor + class NAZARA_SHADER_API ShaderAstValidator : public ShaderAstRecursiveVisitor, public ShaderVarVisitor { public: inline ShaderAstValidator(const ShaderAst& shader); @@ -62,9 +62,9 @@ namespace Nz Context* m_context; }; - NAZARA_RENDERER_API bool ValidateShader(const ShaderAst& shader, std::string* error = nullptr); + NAZARA_SHADER_API bool ValidateShader(const ShaderAst& shader, std::string* error = nullptr); } -#include +#include #endif diff --git a/include/Nazara/Renderer/ShaderAstValidator.inl b/include/Nazara/Shader/ShaderAstValidator.inl similarity index 54% rename from include/Nazara/Renderer/ShaderAstValidator.inl rename to include/Nazara/Shader/ShaderAstValidator.inl index ee2628ce5..eed116766 100644 --- a/include/Nazara/Renderer/ShaderAstValidator.inl +++ b/include/Nazara/Shader/ShaderAstValidator.inl @@ -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 -#include +#include +#include namespace Nz { @@ -13,4 +13,4 @@ namespace Nz } } -#include +#include diff --git a/include/Nazara/Renderer/ShaderAstVisitor.hpp b/include/Nazara/Shader/ShaderAstVisitor.hpp similarity index 86% rename from include/Nazara/Renderer/ShaderAstVisitor.hpp rename to include/Nazara/Shader/ShaderAstVisitor.hpp index 3ce83f406..a6896cb2c 100644 --- a/include/Nazara/Renderer/ShaderAstVisitor.hpp +++ b/include/Nazara/Shader/ShaderAstVisitor.hpp @@ -1,5 +1,5 @@ -// 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 #pragma once @@ -8,14 +8,14 @@ #define NAZARA_SHADERVISITOR_HPP #include -#include -#include +#include +#include #include #include namespace Nz { - class NAZARA_RENDERER_API ShaderAstVisitor + class NAZARA_SHADER_API ShaderAstVisitor { public: ShaderAstVisitor() = default; diff --git a/include/Nazara/Renderer/ShaderBuilder.hpp b/include/Nazara/Shader/ShaderBuilder.hpp similarity index 94% rename from include/Nazara/Renderer/ShaderBuilder.hpp rename to include/Nazara/Shader/ShaderBuilder.hpp index 8f544e018..074434a44 100644 --- a/include/Nazara/Renderer/ShaderBuilder.hpp +++ b/include/Nazara/Shader/ShaderBuilder.hpp @@ -1,5 +1,5 @@ // 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 #pragma once @@ -8,7 +8,7 @@ #define NAZARA_SHADER_BUILDER_HPP #include -#include +#include #include namespace Nz::ShaderBuilder @@ -71,6 +71,6 @@ namespace Nz::ShaderBuilder template std::shared_ptr Cast(Args&&... args); } -#include +#include #endif // NAZARA_SHADER_BUILDER_HPP diff --git a/include/Nazara/Renderer/ShaderBuilder.inl b/include/Nazara/Shader/ShaderBuilder.inl similarity index 89% rename from include/Nazara/Renderer/ShaderBuilder.inl rename to include/Nazara/Shader/ShaderBuilder.inl index 8ef833536..c3221c84f 100644 --- a/include/Nazara/Renderer/ShaderBuilder.inl +++ b/include/Nazara/Shader/ShaderBuilder.inl @@ -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 -#include +#include +#include namespace Nz::ShaderBuilder { @@ -49,4 +49,4 @@ namespace Nz::ShaderBuilder } } -#include +#include diff --git a/include/Nazara/Renderer/ShaderEnums.hpp b/include/Nazara/Shader/ShaderEnums.hpp similarity index 96% rename from include/Nazara/Renderer/ShaderEnums.hpp rename to include/Nazara/Shader/ShaderEnums.hpp index 46e6a3d74..2ddbb5b97 100644 --- a/include/Nazara/Renderer/ShaderEnums.hpp +++ b/include/Nazara/Shader/ShaderEnums.hpp @@ -1,5 +1,5 @@ // 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 #pragma once diff --git a/include/Nazara/Renderer/ShaderExpressionType.hpp b/include/Nazara/Shader/ShaderExpressionType.hpp similarity index 80% rename from include/Nazara/Renderer/ShaderExpressionType.hpp rename to include/Nazara/Shader/ShaderExpressionType.hpp index 68671b07c..69b53b06a 100644 --- a/include/Nazara/Renderer/ShaderExpressionType.hpp +++ b/include/Nazara/Shader/ShaderExpressionType.hpp @@ -1,5 +1,5 @@ // 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 #pragma once @@ -8,7 +8,7 @@ #define NAZARA_SHADER_EXPRESSIONTYPE_HPP #include -#include +#include #include #include diff --git a/include/Nazara/Renderer/ShaderNodes.hpp b/include/Nazara/Shader/ShaderNodes.hpp similarity index 84% rename from include/Nazara/Renderer/ShaderNodes.hpp rename to include/Nazara/Shader/ShaderNodes.hpp index 985cde039..833af1248 100644 --- a/include/Nazara/Renderer/ShaderNodes.hpp +++ b/include/Nazara/Shader/ShaderNodes.hpp @@ -1,5 +1,5 @@ // 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 #pragma once @@ -11,10 +11,10 @@ #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include #include #include @@ -29,7 +29,7 @@ namespace Nz using NodePtr = std::shared_ptr; - class NAZARA_RENDERER_API Node + class NAZARA_SHADER_API Node { public: virtual ~Node(); @@ -54,7 +54,7 @@ namespace Nz using ExpressionPtr = std::shared_ptr; - class NAZARA_RENDERER_API Expression : public Node + class NAZARA_SHADER_API Expression : public Node { public: inline Expression(NodeType type); @@ -67,13 +67,13 @@ namespace Nz using StatementPtr = std::shared_ptr; - class NAZARA_RENDERER_API Statement : public Node + class NAZARA_SHADER_API Statement : public Node { public: inline Statement(NodeType type); }; - struct NAZARA_RENDERER_API ExpressionStatement : public Statement + struct NAZARA_SHADER_API ExpressionStatement : public Statement { inline ExpressionStatement(); @@ -86,7 +86,7 @@ namespace Nz ////////////////////////////////////////////////////////////////////////// - struct NAZARA_RENDERER_API ConditionalStatement : public Statement + struct NAZARA_SHADER_API ConditionalStatement : public Statement { inline ConditionalStatement(); @@ -98,7 +98,7 @@ namespace Nz static inline std::shared_ptr Build(std::string condition, StatementPtr statementPtr); }; - struct NAZARA_RENDERER_API StatementBlock : public Statement + struct NAZARA_SHADER_API StatementBlock : public Statement { inline StatementBlock(); @@ -110,7 +110,7 @@ namespace Nz template static std::shared_ptr Build(Args&&... args); }; - struct NAZARA_RENDERER_API DeclareVariable : public Statement + struct NAZARA_SHADER_API DeclareVariable : public Statement { inline DeclareVariable(); @@ -122,7 +122,7 @@ namespace Nz static inline std::shared_ptr Build(VariablePtr variable, ExpressionPtr expression = nullptr); }; - struct NAZARA_RENDERER_API Identifier : public Expression + struct NAZARA_SHADER_API Identifier : public Expression { inline Identifier(); @@ -135,7 +135,7 @@ namespace Nz static inline std::shared_ptr Build(VariablePtr variable); }; - struct NAZARA_RENDERER_API AccessMember : public Expression + struct NAZARA_SHADER_API AccessMember : public Expression { inline AccessMember(); @@ -152,7 +152,7 @@ namespace Nz ////////////////////////////////////////////////////////////////////////// - struct NAZARA_RENDERER_API AssignOp : public Expression + struct NAZARA_SHADER_API AssignOp : public Expression { inline AssignOp(); @@ -166,7 +166,7 @@ namespace Nz static inline std::shared_ptr Build(AssignType op, ExpressionPtr left, ExpressionPtr right); }; - struct NAZARA_RENDERER_API BinaryOp : public Expression + struct NAZARA_SHADER_API BinaryOp : public Expression { inline BinaryOp(); @@ -180,7 +180,7 @@ namespace Nz static inline std::shared_ptr Build(BinaryType op, ExpressionPtr left, ExpressionPtr right); }; - struct NAZARA_RENDERER_API Branch : public Statement + struct NAZARA_SHADER_API Branch : public Statement { struct ConditionalStatement; @@ -201,7 +201,7 @@ namespace Nz static inline std::shared_ptr Build(std::vector statements, StatementPtr elseStatement = nullptr); }; - struct NAZARA_RENDERER_API Cast : public Expression + struct NAZARA_SHADER_API Cast : public Expression { inline Cast(); @@ -215,7 +215,7 @@ namespace Nz static inline std::shared_ptr Build(BasicType castTo, ExpressionPtr* expressions, std::size_t expressionCount); }; - struct NAZARA_RENDERER_API Constant : public Expression + struct NAZARA_SHADER_API Constant : public Expression { inline Constant(); @@ -239,7 +239,7 @@ namespace Nz template static std::shared_ptr Build(const T& value); }; - struct NAZARA_RENDERER_API SwizzleOp : public Expression + struct NAZARA_SHADER_API SwizzleOp : public Expression { inline SwizzleOp(); @@ -257,7 +257,7 @@ namespace Nz ////////////////////////////////////////////////////////////////////////// - struct NAZARA_RENDERER_API Sample2D : public Expression + struct NAZARA_SHADER_API Sample2D : public Expression { inline Sample2D(); @@ -272,7 +272,7 @@ namespace Nz ////////////////////////////////////////////////////////////////////////// - struct NAZARA_RENDERER_API IntrinsicCall : public Expression + struct NAZARA_SHADER_API IntrinsicCall : public Expression { inline IntrinsicCall(); @@ -287,6 +287,6 @@ namespace Nz } } -#include +#include #endif diff --git a/include/Nazara/Renderer/ShaderNodes.inl b/include/Nazara/Shader/ShaderNodes.inl similarity index 97% rename from include/Nazara/Renderer/ShaderNodes.inl rename to include/Nazara/Shader/ShaderNodes.inl index e6dbec2ba..9265fe359 100644 --- a/include/Nazara/Renderer/ShaderNodes.inl +++ b/include/Nazara/Shader/ShaderNodes.inl @@ -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 -#include +#include +#include namespace Nz::ShaderNodes { @@ -335,4 +335,4 @@ namespace Nz::ShaderNodes } } -#include +#include diff --git a/include/Nazara/Renderer/ShaderVarVisitor.hpp b/include/Nazara/Shader/ShaderVarVisitor.hpp similarity index 82% rename from include/Nazara/Renderer/ShaderVarVisitor.hpp rename to include/Nazara/Shader/ShaderVarVisitor.hpp index bda5e0b4d..ebee55ab6 100644 --- a/include/Nazara/Renderer/ShaderVarVisitor.hpp +++ b/include/Nazara/Shader/ShaderVarVisitor.hpp @@ -1,5 +1,5 @@ // Copyright (C) 2015 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 #pragma once @@ -8,12 +8,12 @@ #define NAZARA_SHADERVARVISITOR_HPP #include -#include -#include +#include +#include namespace Nz { - class NAZARA_RENDERER_API ShaderVarVisitor + class NAZARA_SHADER_API ShaderVarVisitor { public: ShaderVarVisitor() = default; diff --git a/include/Nazara/Renderer/ShaderVariables.hpp b/include/Nazara/Shader/ShaderVariables.hpp similarity index 78% rename from include/Nazara/Renderer/ShaderVariables.hpp rename to include/Nazara/Shader/ShaderVariables.hpp index 4fac1681f..eb0bc8ede 100644 --- a/include/Nazara/Renderer/ShaderVariables.hpp +++ b/include/Nazara/Shader/ShaderVariables.hpp @@ -1,5 +1,5 @@ // 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 #pragma once @@ -11,8 +11,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include @@ -28,7 +28,7 @@ namespace Nz using VariablePtr = std::shared_ptr; - struct NAZARA_RENDERER_API Variable : std::enable_shared_from_this + struct NAZARA_SHADER_API Variable : std::enable_shared_from_this { virtual ~Variable(); @@ -42,7 +42,7 @@ namespace Nz using BuiltinVariablePtr = std::shared_ptr; - struct NAZARA_RENDERER_API BuiltinVariable : public Variable + struct NAZARA_SHADER_API BuiltinVariable : public Variable { BuiltinEntry entry; @@ -56,7 +56,7 @@ namespace Nz using NamedVariablePtr = std::shared_ptr; - struct NAZARA_RENDERER_API NamedVariable : public Variable + struct NAZARA_SHADER_API NamedVariable : public Variable { std::string name; }; @@ -65,7 +65,7 @@ namespace Nz using InputVariablePtr = std::shared_ptr; - struct NAZARA_RENDERER_API InputVariable : public NamedVariable + struct NAZARA_SHADER_API InputVariable : public NamedVariable { VariableType GetType() const override; void Visit(ShaderVarVisitor& visitor) override; @@ -77,7 +77,7 @@ namespace Nz using LocalVariablePtr = std::shared_ptr; - struct NAZARA_RENDERER_API LocalVariable : public NamedVariable + struct NAZARA_SHADER_API LocalVariable : public NamedVariable { VariableType GetType() const override; void Visit(ShaderVarVisitor& visitor) override; @@ -89,7 +89,7 @@ namespace Nz using OutputVariablePtr = std::shared_ptr; - struct NAZARA_RENDERER_API OutputVariable : public NamedVariable + struct NAZARA_SHADER_API OutputVariable : public NamedVariable { VariableType GetType() const override; void Visit(ShaderVarVisitor& visitor) override; @@ -101,7 +101,7 @@ namespace Nz using ParameterVariablePtr = std::shared_ptr; - struct NAZARA_RENDERER_API ParameterVariable : public NamedVariable + struct NAZARA_SHADER_API ParameterVariable : public NamedVariable { VariableType GetType() const override; void Visit(ShaderVarVisitor& visitor) override; @@ -113,7 +113,7 @@ namespace Nz using UniformVariablePtr = std::shared_ptr; - struct NAZARA_RENDERER_API UniformVariable : public NamedVariable + struct NAZARA_SHADER_API UniformVariable : public NamedVariable { VariableType GetType() const override; void Visit(ShaderVarVisitor& visitor) override; @@ -123,6 +123,6 @@ namespace Nz } } -#include +#include #endif diff --git a/include/Nazara/Renderer/ShaderVariables.inl b/include/Nazara/Shader/ShaderVariables.inl similarity index 89% rename from include/Nazara/Renderer/ShaderVariables.inl rename to include/Nazara/Shader/ShaderVariables.inl index 917459c67..9f2415708 100644 --- a/include/Nazara/Renderer/ShaderVariables.inl +++ b/include/Nazara/Shader/ShaderVariables.inl @@ -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 -#include +#include +#include namespace Nz::ShaderNodes { @@ -62,4 +62,4 @@ namespace Nz::ShaderNodes } } -#include +#include diff --git a/include/Nazara/Renderer/ShaderWriter.hpp b/include/Nazara/Shader/ShaderWriter.hpp similarity index 79% rename from include/Nazara/Renderer/ShaderWriter.hpp rename to include/Nazara/Shader/ShaderWriter.hpp index e4fe2d835..0e896fa40 100644 --- a/include/Nazara/Renderer/ShaderWriter.hpp +++ b/include/Nazara/Shader/ShaderWriter.hpp @@ -1,5 +1,5 @@ // Copyright (C) 2015 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 #pragma once @@ -8,14 +8,14 @@ #define NAZARA_SHADERWRITER_HPP #include -#include +#include #include namespace Nz { class ShaderAst; - class NAZARA_RENDERER_API ShaderWriter + class NAZARA_SHADER_API ShaderWriter { public: ShaderWriter() = default; diff --git a/include/Nazara/Renderer/SpirvWriter.hpp b/include/Nazara/Shader/SpirvWriter.hpp similarity index 90% rename from include/Nazara/Renderer/SpirvWriter.hpp rename to include/Nazara/Shader/SpirvWriter.hpp index b9e48dd12..90f6b0e3e 100644 --- a/include/Nazara/Renderer/SpirvWriter.hpp +++ b/include/Nazara/Shader/SpirvWriter.hpp @@ -1,5 +1,5 @@ // 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 #pragma once @@ -8,11 +8,11 @@ #define NAZARA_SPIRVWRITER_HPP #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include #include @@ -20,7 +20,7 @@ namespace Nz { - class NAZARA_RENDERER_API SpirvWriter : public ShaderAstVisitor, public ShaderVarVisitor + class NAZARA_SHADER_API SpirvWriter : public ShaderAstVisitor, public ShaderVarVisitor { public: struct Environment; @@ -127,6 +127,6 @@ namespace Nz }; } -#include +#include #endif diff --git a/include/Nazara/Renderer/SpirvWriter.inl b/include/Nazara/Shader/SpirvWriter.inl similarity index 93% rename from include/Nazara/Renderer/SpirvWriter.inl rename to include/Nazara/Shader/SpirvWriter.inl index 2e75f1271..4ef96c82b 100644 --- a/include/Nazara/Renderer/SpirvWriter.inl +++ b/include/Nazara/Shader/SpirvWriter.inl @@ -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 +#include #include #include -#include +#include namespace Nz { @@ -108,4 +108,4 @@ namespace Nz } } -#include +#include diff --git a/include/Nazara/Utility/Enums.hpp b/include/Nazara/Utility/Enums.hpp index 0e652448e..99328ecde 100644 --- a/include/Nazara/Utility/Enums.hpp +++ b/include/Nazara/Utility/Enums.hpp @@ -309,6 +309,24 @@ namespace Nz SamplerWrap_Max = SamplerWrap_Repeat }; + enum class ShaderStageType + { + Fragment, + Vertex, + + Max = Vertex + }; + + template<> + struct EnumAsFlags + { + static constexpr ShaderStageType max = ShaderStageType::Max; + }; + + using ShaderStageTypeFlags = Flags; + + constexpr ShaderStageTypeFlags ShaderStageType_All = ShaderStageType::Fragment | ShaderStageType::Vertex; + enum StructFieldType { StructFieldType_Bool1, diff --git a/src/Nazara/Renderer/ShaderWriter.cpp b/src/Nazara/Renderer/ShaderWriter.cpp deleted file mode 100644 index 8ca48da3e..000000000 --- a/src/Nazara/Renderer/ShaderWriter.cpp +++ /dev/null @@ -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 -#include - -namespace Nz -{ - ShaderWriter::~ShaderWriter() = default; -} diff --git a/src/Nazara/Shader/Debug/NewOverload.cpp b/src/Nazara/Shader/Debug/NewOverload.cpp new file mode 100644 index 000000000..d16399d8f --- /dev/null +++ b/src/Nazara/Shader/Debug/NewOverload.cpp @@ -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 +#if NAZARA_SHADER_MANAGE_MEMORY + +#include +#include // 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 diff --git a/src/Nazara/Renderer/GlslWriter.cpp b/src/Nazara/Shader/GlslWriter.cpp similarity index 97% rename from src/Nazara/Renderer/GlslWriter.cpp rename to src/Nazara/Shader/GlslWriter.cpp index f851a3aa0..b17c8d4a3 100644 --- a/src/Nazara/Renderer/GlslWriter.cpp +++ b/src/Nazara/Shader/GlslWriter.cpp @@ -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 +#include #include #include -#include -#include -#include +#include +#include +#include #include -#include +#include namespace Nz { diff --git a/src/Nazara/Shader/Shader.cpp b/src/Nazara/Shader/Shader.cpp new file mode 100644 index 000000000..44d65fbe6 --- /dev/null +++ b/src/Nazara/Shader/Shader.cpp @@ -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 +#include +#include +#include +#include +#include +#include + +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; +} + diff --git a/src/Nazara/Renderer/ShaderAst.cpp b/src/Nazara/Shader/ShaderAst.cpp similarity index 92% rename from src/Nazara/Renderer/ShaderAst.cpp rename to src/Nazara/Shader/ShaderAst.cpp index da009248b..236a5e28f 100644 --- a/src/Nazara/Renderer/ShaderAst.cpp +++ b/src/Nazara/Shader/ShaderAst.cpp @@ -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 -#include +#include +#include namespace Nz { diff --git a/src/Nazara/Renderer/ShaderAstCloner.cpp b/src/Nazara/Shader/ShaderAstCloner.cpp similarity index 97% rename from src/Nazara/Renderer/ShaderAstCloner.cpp rename to src/Nazara/Shader/ShaderAstCloner.cpp index 2b712075c..1e0f04899 100644 --- a/src/Nazara/Renderer/ShaderAstCloner.cpp +++ b/src/Nazara/Shader/ShaderAstCloner.cpp @@ -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 +#include #include -#include +#include namespace Nz { diff --git a/src/Nazara/Renderer/ShaderAstRecursiveVisitor.cpp b/src/Nazara/Shader/ShaderAstRecursiveVisitor.cpp similarity index 90% rename from src/Nazara/Renderer/ShaderAstRecursiveVisitor.cpp rename to src/Nazara/Shader/ShaderAstRecursiveVisitor.cpp index 5a39e68c5..98fdbfee6 100644 --- a/src/Nazara/Renderer/ShaderAstRecursiveVisitor.cpp +++ b/src/Nazara/Shader/ShaderAstRecursiveVisitor.cpp @@ -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 -#include +#include +#include namespace Nz { diff --git a/src/Nazara/Renderer/ShaderAstSerializer.cpp b/src/Nazara/Shader/ShaderAstSerializer.cpp similarity index 98% rename from src/Nazara/Renderer/ShaderAstSerializer.cpp rename to src/Nazara/Shader/ShaderAstSerializer.cpp index f8afa178c..6d45cc711 100644 --- a/src/Nazara/Renderer/ShaderAstSerializer.cpp +++ b/src/Nazara/Shader/ShaderAstSerializer.cpp @@ -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 -#include -#include -#include +#include +#include +#include +#include namespace Nz { diff --git a/src/Nazara/Renderer/ShaderAstValidator.cpp b/src/Nazara/Shader/ShaderAstValidator.cpp similarity index 97% rename from src/Nazara/Renderer/ShaderAstValidator.cpp rename to src/Nazara/Shader/ShaderAstValidator.cpp index 81970e766..2f3177283 100644 --- a/src/Nazara/Renderer/ShaderAstValidator.cpp +++ b/src/Nazara/Shader/ShaderAstValidator.cpp @@ -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 +#include #include -#include -#include +#include +#include #include -#include +#include namespace Nz { diff --git a/src/Nazara/Renderer/ShaderAstVisitor.cpp b/src/Nazara/Shader/ShaderAstVisitor.cpp similarity index 73% rename from src/Nazara/Renderer/ShaderAstVisitor.cpp rename to src/Nazara/Shader/ShaderAstVisitor.cpp index 49760f028..53325c9ca 100644 --- a/src/Nazara/Renderer/ShaderAstVisitor.cpp +++ b/src/Nazara/Shader/ShaderAstVisitor.cpp @@ -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 -#include +#include +#include namespace Nz { diff --git a/src/Nazara/Renderer/ShaderNodes.cpp b/src/Nazara/Shader/ShaderNodes.cpp similarity index 93% rename from src/Nazara/Renderer/ShaderNodes.cpp rename to src/Nazara/Shader/ShaderNodes.cpp index 29ffb8508..2f72a1ea0 100644 --- a/src/Nazara/Renderer/ShaderNodes.cpp +++ b/src/Nazara/Shader/ShaderNodes.cpp @@ -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 +#include #include -#include -#include -#include -#include +#include +#include +#include +#include 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 diff --git a/src/Nazara/Renderer/ShaderVarVisitor.cpp b/src/Nazara/Shader/ShaderVarVisitor.cpp similarity index 56% rename from src/Nazara/Renderer/ShaderVarVisitor.cpp rename to src/Nazara/Shader/ShaderVarVisitor.cpp index 6f3838f26..108d5c69a 100644 --- a/src/Nazara/Renderer/ShaderVarVisitor.cpp +++ b/src/Nazara/Shader/ShaderVarVisitor.cpp @@ -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 -#include +#include +#include namespace Nz { diff --git a/src/Nazara/Renderer/ShaderVariables.cpp b/src/Nazara/Shader/ShaderVariables.cpp similarity index 86% rename from src/Nazara/Renderer/ShaderVariables.cpp rename to src/Nazara/Shader/ShaderVariables.cpp index 93701c4ef..ebe520a0c 100644 --- a/src/Nazara/Renderer/ShaderVariables.cpp +++ b/src/Nazara/Shader/ShaderVariables.cpp @@ -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 -#include -#include +#include +#include +#include namespace Nz::ShaderNodes { diff --git a/src/Nazara/Shader/ShaderWriter.cpp b/src/Nazara/Shader/ShaderWriter.cpp new file mode 100644 index 000000000..6e994f0f0 --- /dev/null +++ b/src/Nazara/Shader/ShaderWriter.cpp @@ -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 +#include + +namespace Nz +{ + ShaderWriter::~ShaderWriter() = default; +} diff --git a/src/Nazara/Renderer/SpirvWriter.cpp b/src/Nazara/Shader/SpirvWriter.cpp similarity index 99% rename from src/Nazara/Renderer/SpirvWriter.cpp rename to src/Nazara/Shader/SpirvWriter.cpp index 1e9218e34..b3b318c63 100644 --- a/src/Nazara/Renderer/SpirvWriter.cpp +++ b/src/Nazara/Shader/SpirvWriter.cpp @@ -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 +#include #include #include #include -#include -#include +#include +#include #include #include #include @@ -16,7 +16,7 @@ #include #include #include -#include +#include namespace Nz { diff --git a/src/ShaderNode/DataModels/BufferField.cpp b/src/ShaderNode/DataModels/BufferField.cpp index 844f56bd8..2d9cde16d 100644 --- a/src/ShaderNode/DataModels/BufferField.cpp +++ b/src/ShaderNode/DataModels/BufferField.cpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/ShaderNode/DataModels/Cast.inl b/src/ShaderNode/DataModels/Cast.inl index fb088b3a0..cd96d6ccc 100644 --- a/src/ShaderNode/DataModels/Cast.inl +++ b/src/ShaderNode/DataModels/Cast.inl @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/src/ShaderNode/DataModels/FloatValue.cpp b/src/ShaderNode/DataModels/FloatValue.cpp index c30ea8874..23a4c766f 100644 --- a/src/ShaderNode/DataModels/FloatValue.cpp +++ b/src/ShaderNode/DataModels/FloatValue.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include FloatValue::FloatValue(ShaderGraph& graph) : diff --git a/src/ShaderNode/DataModels/InputValue.cpp b/src/ShaderNode/DataModels/InputValue.cpp index c2c6f6b01..e4710e6f5 100644 --- a/src/ShaderNode/DataModels/InputValue.cpp +++ b/src/ShaderNode/DataModels/InputValue.cpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include InputValue::InputValue(ShaderGraph& graph) : diff --git a/src/ShaderNode/DataModels/Mat4BinOp.inl b/src/ShaderNode/DataModels/Mat4BinOp.inl index 684a6ec79..05cdb0479 100644 --- a/src/ShaderNode/DataModels/Mat4BinOp.inl +++ b/src/ShaderNode/DataModels/Mat4BinOp.inl @@ -1,5 +1,5 @@ #include -#include +#include template Mat4BinOp::Mat4BinOp(ShaderGraph& graph) : diff --git a/src/ShaderNode/DataModels/Mat4VecMul.cpp b/src/ShaderNode/DataModels/Mat4VecMul.cpp index 2e530e496..983545973 100644 --- a/src/ShaderNode/DataModels/Mat4VecMul.cpp +++ b/src/ShaderNode/DataModels/Mat4VecMul.cpp @@ -1,5 +1,5 @@ #include -#include +#include Mat4VecMul::Mat4VecMul(ShaderGraph& graph) : ShaderNode(graph) diff --git a/src/ShaderNode/DataModels/OutputValue.cpp b/src/ShaderNode/DataModels/OutputValue.cpp index 6f30a9b66..63a481588 100644 --- a/src/ShaderNode/DataModels/OutputValue.cpp +++ b/src/ShaderNode/DataModels/OutputValue.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/src/ShaderNode/DataModels/PositionOutputValue.cpp b/src/ShaderNode/DataModels/PositionOutputValue.cpp index ee1be66a2..c3d252f54 100644 --- a/src/ShaderNode/DataModels/PositionOutputValue.cpp +++ b/src/ShaderNode/DataModels/PositionOutputValue.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/src/ShaderNode/DataModels/SampleTexture.cpp b/src/ShaderNode/DataModels/SampleTexture.cpp index 131a8b161..c784b83af 100644 --- a/src/ShaderNode/DataModels/SampleTexture.cpp +++ b/src/ShaderNode/DataModels/SampleTexture.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include SampleTexture::SampleTexture(ShaderGraph& graph) : ShaderNode(graph) diff --git a/src/ShaderNode/DataModels/ShaderNode.hpp b/src/ShaderNode/DataModels/ShaderNode.hpp index 1becb5a3d..6d3dd5cc1 100644 --- a/src/ShaderNode/DataModels/ShaderNode.hpp +++ b/src/ShaderNode/DataModels/ShaderNode.hpp @@ -4,7 +4,7 @@ #define NAZARA_SHADERNODES_SHADERNODE_HPP #include -#include +#include #include #include #include diff --git a/src/ShaderNode/DataModels/TextureValue.cpp b/src/ShaderNode/DataModels/TextureValue.cpp index 79df6de5c..c400d0469 100644 --- a/src/ShaderNode/DataModels/TextureValue.cpp +++ b/src/ShaderNode/DataModels/TextureValue.cpp @@ -2,7 +2,7 @@ #include #include #include -#include +#include #include TextureValue::TextureValue(ShaderGraph& graph) : diff --git a/src/ShaderNode/DataModels/VecBinOp.inl b/src/ShaderNode/DataModels/VecBinOp.inl index d159545be..d16347799 100644 --- a/src/ShaderNode/DataModels/VecBinOp.inl +++ b/src/ShaderNode/DataModels/VecBinOp.inl @@ -1,5 +1,5 @@ #include -#include +#include template VecBinOp::VecBinOp(ShaderGraph& graph) : diff --git a/src/ShaderNode/DataModels/VecDot.cpp b/src/ShaderNode/DataModels/VecDot.cpp index 818a68a2a..b083623d0 100644 --- a/src/ShaderNode/DataModels/VecDot.cpp +++ b/src/ShaderNode/DataModels/VecDot.cpp @@ -1,5 +1,5 @@ #include -#include +#include VecDot::VecDot(ShaderGraph& graph) : ShaderNode(graph) diff --git a/src/ShaderNode/DataModels/VecFloatMul.cpp b/src/ShaderNode/DataModels/VecFloatMul.cpp index c1ecf50d2..9dd3b02c3 100644 --- a/src/ShaderNode/DataModels/VecFloatMul.cpp +++ b/src/ShaderNode/DataModels/VecFloatMul.cpp @@ -1,5 +1,5 @@ #include -#include +#include VecFloatMul::VecFloatMul(ShaderGraph& graph) : ShaderNode(graph) diff --git a/src/ShaderNode/DataModels/VecValue.inl b/src/ShaderNode/DataModels/VecValue.inl index 8b72d1186..b07c46a9b 100644 --- a/src/ShaderNode/DataModels/VecValue.inl +++ b/src/ShaderNode/DataModels/VecValue.inl @@ -1,6 +1,6 @@ #include #include -#include +#include #include #include #include diff --git a/src/ShaderNode/DataTypes/Matrix4Data.hpp b/src/ShaderNode/DataTypes/Matrix4Data.hpp index fdfbf1897..4eb63f136 100644 --- a/src/ShaderNode/DataTypes/Matrix4Data.hpp +++ b/src/ShaderNode/DataTypes/Matrix4Data.hpp @@ -3,7 +3,7 @@ #ifndef NAZARA_SHADERNODES_MATRIXDATA_HPP #define NAZARA_SHADERNODES_MATRIXDATA_HPP -#include +#include #include #include diff --git a/src/ShaderNode/DataTypes/TextureData.hpp b/src/ShaderNode/DataTypes/TextureData.hpp index b6f7b4433..28b2b73d0 100644 --- a/src/ShaderNode/DataTypes/TextureData.hpp +++ b/src/ShaderNode/DataTypes/TextureData.hpp @@ -4,7 +4,7 @@ #define NAZARA_SHADERNODES_TEXTUREDATA_HPP #include -#include +#include #include struct TextureData : public QtNodes::NodeData diff --git a/src/ShaderNode/DataTypes/VecData.hpp b/src/ShaderNode/DataTypes/VecData.hpp index 7c515a12a..d80bff106 100644 --- a/src/ShaderNode/DataTypes/VecData.hpp +++ b/src/ShaderNode/DataTypes/VecData.hpp @@ -3,7 +3,7 @@ #ifndef NAZARA_SHADERNODES_VECDATA_HPP #define NAZARA_SHADERNODES_VECDATA_HPP -#include +#include #include #include diff --git a/src/ShaderNode/ShaderGraph.hpp b/src/ShaderNode/ShaderGraph.hpp index be7aeba4c..1df336ce6 100644 --- a/src/ShaderNode/ShaderGraph.hpp +++ b/src/ShaderNode/ShaderGraph.hpp @@ -4,8 +4,8 @@ #define NAZARA_SHADERNODES_SHADERGRAPH_HPP #include -#include -#include +#include +#include #include #include #include diff --git a/src/ShaderNode/Widgets/MainWindow.cpp b/src/ShaderNode/Widgets/MainWindow.cpp index 31665bb8d..b88bef25f 100644 --- a/src/ShaderNode/Widgets/MainWindow.cpp +++ b/src/ShaderNode/Widgets/MainWindow.cpp @@ -1,7 +1,7 @@ #include #include -#include -#include +#include +#include #include #include #include