diff --git a/.gitignore b/.gitignore index 434b503..d638f85 100644 --- a/.gitignore +++ b/.gitignore @@ -343,4 +343,5 @@ ASALocalRun/ .localhistory/ # BeatPulse healthcheck temp database -healthchecksdb \ No newline at end of file +healthchecksdb +.DS_Store diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 91f60e2..77007ca 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -12,10 +12,24 @@ ], "windowsSdkVersion": "10.0.20348.0", "compilerPath": "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.32.31326/bin/Hostx64/x64/cl.exe", - "cStandard": "c17", - "cppStandard": "c++17", + "cppStandard": "c++20", "intelliSenseMode": "windows-msvc-x64", "configurationProvider": "ms-vscode.cmake-tools" + }, + { + "name": "Mac", + "includePath": [ + "${workspaceFolder}/src/**" + ], + "defines": [ + "_DEBUG", + "UNICODE", + "_UNICODE" + ], + "compilerPath": "/usr/bin/clang", + "cppStandard": "c++20", + "intelliSenseMode": "clang-arm64", + "configurationProvider": "ms-vscode.cmake-tools" } ], "version": 4 diff --git a/.vscode/settings.json b/.vscode/settings.json index f4252d0..e630e8c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -124,7 +124,19 @@ "ranges": "cpp", "source_location": "cpp", "syncstream": "cpp", - "stdfloat": "cpp" + "stdfloat": "cpp", + "__bit_reference": "cpp", + "__config": "cpp", + "__debug": "cpp", + "__errc": "cpp", + "__hash_table": "cpp", + "__locale": "cpp", + "__mutex_base": "cpp", + "__node_handle": "cpp", + "__split_buffer": "cpp", + "__threading_support": "cpp", + "__tree": "cpp", + "__verbose_abort": "cpp" }, "cmake.skipConfigureIfCachePresent": false, "cmake.configureArgs": [ diff --git a/CMakeLists.txt b/CMakeLists.txt index 93fb8de..aaa2108 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,8 @@ set(CMAKE_INSTALL_MESSAGE LAZY) set(BUILD_SHARED_LIBS OFF) set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) +set(VCPKG_INSTALL_OPTIONS "--allow-unsupported") + set(ENGINE_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/src/Engine) set(EXTERNAL_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/external) @@ -45,6 +47,7 @@ find_package(glfw3 CONFIG REQUIRED) find_package(glm CONFIG REQUIRED) find_package(Ktx CONFIG REQUIRED) find_package(nlohmann_json CONFIG REQUIRED) +find_package(fmt CONFIG REQUIRED) if(UNIX) find_package(Threads REQUIRED) @@ -67,7 +70,8 @@ target_link_libraries(Engine PUBLIC assimp::assimp) target_link_libraries(Engine PUBLIC KTX::ktx) target_link_libraries(Engine PUBLIC nlohmann_json::nlohmann_json) target_link_libraries(Engine PUBLIC crcpp) -target_link_libraries(Engine PUBLIC shader-slang) +target_link_libraries(Engine PUBLIC slang) +target_link_libraries(Engine PUBLIC fmt::fmt) if(UNIX) target_link_libraries(Engine PUBLIC Threads::Threads) target_link_libraries(Engine PUBLIC dl) @@ -82,22 +86,6 @@ target_compile_definitions(Editor PRIVATE EDITOR=1) add_executable(AssetViewer "") target_link_libraries(AssetViewer PRIVATE Engine) target_include_directories(AssetViewer PRIVATE src/AssetViewer) - -target_precompile_headers(Engine - PUBLIC - - - - - - - - - - - - - ) if(MSVC) set(_CRT_SECURE_NO_WARNINGS) diff --git a/cmake/SuperBuild.cmake b/cmake/SuperBuild.cmake index 828e431..2f79ec5 100644 --- a/cmake/SuperBuild.cmake +++ b/cmake/SuperBuild.cmake @@ -81,8 +81,8 @@ if(WIN32) install(FILES ${SLANG_ROOT}/lib/slang.lib DESTINATION ${CMAKE_INSTALL_PREFIX}/lib) -else() - +elseif(APPLE) + endif() target_include_directories(shader-slang INTERFACE $ diff --git a/external/vcpkg b/external/vcpkg index 50bffcc..53bef89 160000 --- a/external/vcpkg +++ b/external/vcpkg @@ -1 +1 @@ -Subproject commit 50bffcc62d7f6571eb32bc1a0b1807e77af1166c +Subproject commit 53bef8994c541b6561884a8395ea35715ece75db diff --git a/src/AssetViewer/main.cpp b/src/AssetViewer/main.cpp index 5063e56..b7ddebe 100644 --- a/src/AssetViewer/main.cpp +++ b/src/AssetViewer/main.cpp @@ -5,6 +5,8 @@ #include "Asset/MaterialAsset.h" #include "Asset/MaterialInstanceAsset.h" #include "Asset/AssetRegistry.h" +#include +#include using namespace Seele; @@ -16,7 +18,7 @@ int main(int, char**) //{ // return -1; //} - std::filesystem::path path = "C:\\Users\\Dynamitos\\TrackClear\\Assets\\Dirt.asset"; + std::filesystem::path path = std::filesystem::path("C:\\Users\\Dynamitos\\TrackClear\\Assets\\Dirt.asset"); std::ifstream stream = std::ifstream(path, std::ios::binary); ArchiveBuffer buffer; diff --git a/src/Editor/Asset/FontLoader.cpp b/src/Editor/Asset/FontLoader.cpp index 84c9fa7..358e774 100644 --- a/src/Editor/Asset/FontLoader.cpp +++ b/src/Editor/Asset/FontLoader.cpp @@ -6,6 +6,8 @@ #include "Graphics/Texture.h" #include #include FT_FREETYPE_H +#include +#include using namespace Seele; diff --git a/src/Editor/Asset/MaterialLoader.cpp b/src/Editor/Asset/MaterialLoader.cpp index dd32bd7..30cd3fd 100644 --- a/src/Editor/Asset/MaterialLoader.cpp +++ b/src/Editor/Asset/MaterialLoader.cpp @@ -8,7 +8,9 @@ #include "Material/ShaderExpression.h" #include "Asset/TextureAsset.h" #include -#include +#include +#include +#include using namespace Seele; using json = nlohmann::json; @@ -131,14 +133,14 @@ void MaterialLoader::import(MaterialImportArgs args, PMaterialAsset asset) { std::string str = obj.get(); OConstantExpression c = new ConstantExpression(str, ExpressionType::UNKNOWN); - std::string name = std::format("const_{0}", auxKey++); + std::string name = fmt::format("const_{0}", auxKey++); c->key = name; expressions.add(std::move(c)); return name; } else { - return std::format("{0}", obj.get()); + return fmt::format("{0}", obj.get()); } }; MaterialNode mat; @@ -150,7 +152,7 @@ void MaterialLoader::import(MaterialImportArgs args, PMaterialAsset asset) if (exp.compare("Const") == 0) { OConstantExpression p = new ConstantExpression(); - std::string name = std::format("{0}", key++); + std::string name = fmt::format("{0}", key++); p->key = name; p->expr = obj["value"]; expressions.add(std::move(p)); @@ -158,7 +160,7 @@ void MaterialLoader::import(MaterialImportArgs args, PMaterialAsset asset) if(exp.compare("Add") == 0) { OAddExpression p = new AddExpression(); - std::string name = std::format("{0}", key++); + std::string name = fmt::format("{0}", key++); p->key = name; p->inputs["lhs"].source = referenceExpression(obj["lhs"]); p->inputs["rhs"].source = referenceExpression(obj["rhs"]); @@ -167,7 +169,7 @@ void MaterialLoader::import(MaterialImportArgs args, PMaterialAsset asset) if(exp.compare("Sub") == 0) { OSubExpression p = new SubExpression(); - std::string name = std::format("{0}", key++); + std::string name = fmt::format("{0}", key++); p->key = name; p->inputs["lhs"].source = referenceExpression(obj["lhs"]); p->inputs["rhs"].source = referenceExpression(obj["rhs"]); @@ -176,7 +178,7 @@ void MaterialLoader::import(MaterialImportArgs args, PMaterialAsset asset) if(exp.compare("Mul") == 0) { OMulExpression p = new MulExpression(); - std::string name = std::format("{0}", key++); + std::string name = fmt::format("{0}", key++); p->key = name; p->inputs["lhs"].source = referenceExpression(obj["lhs"]); p->inputs["rhs"].source = referenceExpression(obj["rhs"]); @@ -185,7 +187,7 @@ void MaterialLoader::import(MaterialImportArgs args, PMaterialAsset asset) if(exp.compare("Swizzle") == 0) { OSwizzleExpression p = new SwizzleExpression(); - std::string name = std::format("{0}", key++); + std::string name = fmt::format("{0}", key++); p->key = name; p->inputs["target"].source = referenceExpression(obj["target"]); int32 i = 0; @@ -198,7 +200,7 @@ void MaterialLoader::import(MaterialImportArgs args, PMaterialAsset asset) if(exp.compare("Sample") == 0) { OSampleExpression p = new SampleExpression(); - std::string name = std::format("{0}", key++); + std::string name = fmt::format("{0}", key++); p->key = name; p->inputs["texture"].source = referenceExpression(obj["texture"]); p->inputs["sampler"].source = referenceExpression(obj["sampler"]); diff --git a/src/Editor/Asset/MeshLoader.cpp b/src/Editor/Asset/MeshLoader.cpp index a0605d5..d533995 100644 --- a/src/Editor/Asset/MeshLoader.cpp +++ b/src/Editor/Asset/MeshLoader.cpp @@ -6,7 +6,7 @@ #include "Asset/AssetImporter.h" #include "Asset/MaterialAsset.h" #include -#include +#include #include #include #include @@ -48,7 +48,7 @@ void MeshLoader::loadMaterials(const aiScene* scene, const std::string& baseName { aiMaterial* material = scene->mMaterials[i]; json matCode; - std::string materialName = std::format("{0}{1}{2}", baseName, material->GetName().C_Str(), i); + std::string materialName = fmt::format("{0}{1}{2}", baseName, material->GetName().C_Str(), i); materialName.erase(std::remove(materialName.begin(), materialName.end(), '.'), materialName.end()); // dots break adding the .asset extension later matCode["name"] = materialName; matCode["profile"] = "CelShading"; @@ -196,7 +196,7 @@ void MeshLoader::loadMaterials(const aiScene* scene, const std::string& baseName }); PMaterialAsset baseMat = AssetRegistry::findMaterial(matCode["name"].get()); globalMaterials[i] = baseMat->instantiate(InstantiationParameter{ - .name = std::format("{0}_Inst_0", baseMat->getName()), + .name = fmt::format("{0}_Inst_0", baseMat->getName()), .folderPath = baseMat->getFolderPath(), }); } diff --git a/src/Editor/Asset/TextureLoader.cpp b/src/Editor/Asset/TextureLoader.cpp index 5a2e600..9e43d5f 100644 --- a/src/Editor/Asset/TextureLoader.cpp +++ b/src/Editor/Asset/TextureLoader.cpp @@ -13,6 +13,7 @@ #include #pragma GCC diagnostic pop #include "ktx.h" +#include using namespace Seele; diff --git a/src/Editor/Window/ViewportControl.cpp b/src/Editor/Window/ViewportControl.cpp index 16e7b07..e672d13 100644 --- a/src/Editor/Window/ViewportControl.cpp +++ b/src/Editor/Window/ViewportControl.cpp @@ -1,5 +1,6 @@ #include "ViewportControl.h" #include "Component/Camera.h" +#include using namespace Seele; using namespace Seele::Editor; diff --git a/src/Editor/main.cpp b/src/Editor/main.cpp index f09658b..5693722 100644 --- a/src/Editor/main.cpp +++ b/src/Editor/main.cpp @@ -12,7 +12,7 @@ #include "Asset/FontLoader.h" #include "Asset/AssetImporter.h" #include "Graphics/StaticMeshVertexData.h" -#include +#include using namespace Seele; using namespace Seele::Editor; @@ -254,9 +254,9 @@ int main() if (false) { std::filesystem::create_directories(outputPath); - std::system(std::format("cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DGAME_TITLE=\"{}\" -DGAME_DESTINATION=\"{}\" -DGAME_BINARY=\"{}\" -P ./cmake/ExportProject.cmake", gameName, outputPath.generic_string(), binaryPath.generic_string()).c_str()); - std::system(std::format("cmake -S {} -B {}", cmakePath.generic_string(), cmakePath.generic_string()).c_str()); - std::system(std::format("cmake --build {}", cmakePath.generic_string()).c_str()); + std::system(fmt::format("cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DGAME_TITLE=\"{}\" -DGAME_DESTINATION=\"{}\" -DGAME_BINARY=\"{}\" -P ./cmake/ExportProject.cmake", gameName, outputPath.generic_string(), binaryPath.generic_string()).c_str()); + std::system(fmt::format("cmake -S {} -B {}", cmakePath.generic_string(), cmakePath.generic_string()).c_str()); + std::system(fmt::format("cmake --build {}", cmakePath.generic_string()).c_str()); std::filesystem::copy(sourcePath / "Assets", outputPath / "Assets", std::filesystem::copy_options::recursive); std::filesystem::copy("shaders", outputPath / "shaders", std::filesystem::copy_options::recursive); std::filesystem::copy("textures", outputPath / "textures", std::filesystem::copy_options::recursive); diff --git a/src/Engine/Asset/AssetRegistry.h b/src/Engine/Asset/AssetRegistry.h index 54986ef..79e7b33 100644 --- a/src/Engine/Asset/AssetRegistry.h +++ b/src/Engine/Asset/AssetRegistry.h @@ -3,6 +3,7 @@ #include "Asset.h" #include "Containers/Map.h" #include +#include namespace Seele { diff --git a/src/Engine/Asset/FontAsset.cpp b/src/Engine/Asset/FontAsset.cpp index 4e4a0f1..443f162 100644 --- a/src/Engine/Asset/FontAsset.cpp +++ b/src/Engine/Asset/FontAsset.cpp @@ -50,7 +50,7 @@ void FontAsset::save(ArchiveBuffer& buffer) const { // technically, downloading cant be const, because we have to allocate temporary buffers and change layouts // but practically the texture stays the same - usedTextures[x]->download(0, depth, face, textureData); + const_cast(*(usedTextures[x]))->download(0, depth, face, textureData); ktxTexture_SetImageFromMemory(ktxTexture(kTexture), 0, depth, face, textureData.data(), textureData.size()); } } diff --git a/src/Engine/Component/Camera.cpp b/src/Engine/Component/Camera.cpp index 9323e13..6989aad 100644 --- a/src/Engine/Component/Camera.cpp +++ b/src/Engine/Component/Camera.cpp @@ -9,8 +9,8 @@ using namespace Seele::Math; Camera::Camera() : viewMatrix(Matrix4()) - , bNeedsViewBuild(false) , cameraPos(Vector()) + , bNeedsViewBuild(false) { yaw = -3.1415f/2; pitch = 0; diff --git a/src/Engine/Component/Component.h b/src/Engine/Component/Component.h index 8383928..d85dd50 100644 --- a/src/Engine/Component/Component.h +++ b/src/Engine/Component/Component.h @@ -11,7 +11,7 @@ struct Dependencies<> { int x; template - Dependencies operator|(const Dependencies& other) + Dependencies operator|(const Dependencies&) { return Dependencies(); } @@ -20,7 +20,7 @@ template struct Dependencies : public Dependencies { template - Dependencies operator|(const Dependencies& other) + Dependencies operator|(const Dependencies&) { return Dependencies(); } @@ -38,8 +38,8 @@ concept has_dependencies = requires(Comp) { Comp::dependencies; }; #define REQUIRE_COMPONENT(x) \ private: \ - x& get##x() { return getComponent<##x>(); } \ - const x& get##x() const { return getComponent<##x>(); } \ + x& get##x() { return getComponent(); } \ + const x& get##x() const { return getComponent(); } \ public: \ constexpr static Dependencies dependencies = {}; diff --git a/src/Engine/Containers/Array.h b/src/Engine/Containers/Array.h index ef966c2..644d9ba 100644 --- a/src/Engine/Containers/Array.h +++ b/src/Engine/Containers/Array.h @@ -38,14 +38,14 @@ public: { return p; } - constexpr bool operator!=(const IteratorBase &other) const - { - return p != other.p; - } constexpr bool operator==(const IteratorBase &other) const { return p == other.p; } + constexpr std::strong_ordering operator<=>(const IteratorBase &other) const + { + return p <=> other.p; + } constexpr IteratorBase operator+(size_t other) const { IteratorBase tmp(*this); @@ -61,10 +61,6 @@ public: p+=other; return *this; } - constexpr bool operator<(const IteratorBase& other) const - { - return p < other.p; - } constexpr IteratorBase operator-(difference_type diff) const { return IteratorBase(p - diff); @@ -537,7 +533,7 @@ public: assert(index < arraySize); return _data[index]; } - constexpr const reference operator[](size_type index) const + constexpr const_reference operator[](size_type index) const { assert(index < arraySize); return _data[index]; @@ -674,7 +670,7 @@ constexpr bool operator==(const Array &lhs, const Array constexpr auto operator<=>(const Array& lhs, const Array& rhs) { - return std::lexicographical_compare_three_way(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()); + return std::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()); } template diff --git a/src/Engine/Containers/List.h b/src/Engine/Containers/List.h index dc56f38..1d2a6dd 100644 --- a/src/Engine/Containers/List.h +++ b/src/Engine/Containers/List.h @@ -1,5 +1,6 @@ #pragma once #include +#include namespace Seele { @@ -9,6 +10,16 @@ class List private: struct Node { + Node(Node* prev, Node* next, const T& data) + : prev(prev) + , next(next) + , data(std::move(data)) + {} + Node(Node* prev, Node* next, T&& data) + : prev(prev) + , next(next) + , data(std::move(data)) + {} Node *prev; Node *next; T data; @@ -57,39 +68,43 @@ public: } return *this; } - reference operator*() const + constexpr reference operator*() const { return node->data; } - pointer operator->() const + constexpr pointer operator->() const { return &node->data; } - inline bool operator!=(const IteratorBase &other) + constexpr bool operator!=(const IteratorBase &other) { return node != other.node; } - inline bool operator==(const IteratorBase &other) + constexpr bool operator==(const IteratorBase &other) { return node == other.node; } - IteratorBase &operator--() + constexpr std::strong_ordering operator<=>(const IteratorBase& other) + { + return node <=> other.node; + } + constexpr IteratorBase &operator--() { node = node->prev; return *this; } - IteratorBase operator--(int) + constexpr IteratorBase operator--(int) { IteratorBase tmp(*this); --*this; return tmp; } - IteratorBase &operator++() + constexpr IteratorBase &operator++() { node = node->next; return *this; } - IteratorBase operator++(int) + constexpr IteratorBase operator++(int) { IteratorBase tmp(*this); ++*this; @@ -187,7 +202,7 @@ public: , beginIt(std::move(other.beginIt)) , endIt(std::move(other.endIt)) , _size(std::move(other._size)) - , allocator(allocator) + , allocator(alloc) { other._size = 0; } diff --git a/src/Engine/Containers/Tree.h b/src/Engine/Containers/Tree.h index 0abace7..280dc74 100644 --- a/src/Engine/Containers/Tree.h +++ b/src/Engine/Containers/Tree.h @@ -15,6 +15,16 @@ struct Tree protected: struct Node { + Node(Node* left, Node* right, const NodeData& nodeData) + : leftChild(left) + , rightChild(right) + , data(nodeData) + {} + Node(Node* left, Node* right, NodeData&& nodeData) + : leftChild(left) + , rightChild(right) + , data(std::move(nodeData)) + {} Node* leftChild; Node* rightChild; NodeData data; @@ -71,12 +81,16 @@ public: } constexpr bool operator!=(const IteratorBase& other) { - return node != other.node; + return node == other.node; } constexpr bool operator==(const IteratorBase& other) { return node == other.node; } + constexpr std::strong_ordering operator<=>(const IteratorBase& other) + { + return node == other.node; + } constexpr IteratorBase& operator++() { node = node->rightChild; @@ -433,8 +447,8 @@ private: _size++; return Pair(newNode, true); } - template - Node* _remove(Node* r, KeyType&& key) + template + Node* _remove(Node* r, K&& key) { markIteratorsDirty(); Node* temp; @@ -463,8 +477,8 @@ private: _size--; return r; } - template - Node* _splay(Node* r, KeyType&& key) + template + Node* _splay(Node* r, K&& key) { markIteratorsDirty(); if (r == nullptr || equal(r->data, key)) @@ -516,8 +530,8 @@ private: return (r->rightChild == nullptr) ? r : rotateLeft(r); } } - template - bool equal(const NodeData& a, KeyType&& b) const + template + bool equal(const NodeData& a, K&& b) const { return !comp(keyFun(a), b) && !comp(b, keyFun(a)); } diff --git a/src/Engine/Graphics/RenderPass/DebugPass.cpp b/src/Engine/Graphics/RenderPass/DebugPass.cpp index f50fa65..35b697e 100644 --- a/src/Engine/Graphics/RenderPass/DebugPass.cpp +++ b/src/Engine/Graphics/RenderPass/DebugPass.cpp @@ -1,6 +1,8 @@ #include "DebugPass.h" #include "Graphics/Graphics.h" #include "Graphics/RenderTarget.h" +#include "Graphics/Pipeline.h" +#include "Graphics/Shader.h" using namespace Seele; @@ -74,10 +76,6 @@ void DebugPass::publishOutputs() descriptorLayout = graphics->createDescriptorLayout("DebugDescLayout"); descriptorLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER); descriptorLayout->create(); - - pipelineLayout = graphics->createPipelineLayout(); - pipelineLayout->addDescriptorLayout(0, descriptorLayout); - pipelineLayout->create(); } void DebugPass::createRenderPass() @@ -92,43 +90,29 @@ void DebugPass::createRenderPass() }; renderPass = graphics->createRenderPass(std::move(layout), viewport); + Gfx::OPipelineLayout pipelineLayout = graphics->createPipelineLayout(); + pipelineLayout->addDescriptorLayout(0, descriptorLayout); + pipelineLayout->create(); + ShaderCreateInfo createInfo; createInfo.name = "DebugVertex"; createInfo.mainModule = "Debug"; createInfo.entryPoint = "vertexMain"; createInfo.defines["INDEX_VIEW_PARAMS"] = "0"; - Gfx::PVertexShader vertexShader = graphics->createVertexShader(createInfo); + vertexShader = graphics->createVertexShader(createInfo); createInfo.name = "DebugFragment"; createInfo.entryPoint = "fragmentMain"; - Gfx::PFragmentShader fragmentShader = graphics->createFragmentShader(createInfo); + fragmentShader = graphics->createFragmentShader(createInfo); - Gfx::OVertexDeclaration vertexDecl = graphics->createVertexDeclaration({ - Gfx::VertexElement { - .streamIndex = 0, - .offset = offsetof(DebugVertex, position), - .vertexFormat = Gfx::SE_FORMAT_R32G32B32_SFLOAT, - .attributeIndex = 0, - .stride = sizeof(DebugVertex), - }, - Gfx::VertexElement { - .streamIndex = 0, - .offset = offsetof(DebugVertex, color), - .vertexFormat = Gfx::SE_FORMAT_R32G32B32_SFLOAT, - .attributeIndex = 1, - .stride = sizeof(DebugVertex), - } - }); - - GraphicsPipelineCreateInfo gfxInfo; - gfxInfo.vertexDeclaration = vertexDecl; + Gfx::LegacyPipelineCreateInfo gfxInfo; gfxInfo.vertexShader = vertexShader; gfxInfo.fragmentShader = fragmentShader; gfxInfo.rasterizationState.polygonMode = Gfx::SE_POLYGON_MODE_LINE; gfxInfo.rasterizationState.lineWidth = 5.f; gfxInfo.topology = Gfx::SE_PRIMITIVE_TOPOLOGY_LINE_LIST; - gfxInfo.pipelineLayout = pipelineLayout; + gfxInfo.pipelineLayout = std::move(pipelineLayout); gfxInfo.renderPass = renderPass; - pipeline = graphics->createGraphicsPipeline(gfxInfo); + pipeline = graphics->createGraphicsPipeline(std::move(gfxInfo)); } diff --git a/src/Engine/Graphics/RenderPass/DebugPass.h b/src/Engine/Graphics/RenderPass/DebugPass.h index 2f7218a..834488b 100644 --- a/src/Engine/Graphics/RenderPass/DebugPass.h +++ b/src/Engine/Graphics/RenderPass/DebugPass.h @@ -25,8 +25,9 @@ private: Gfx::OUniformBuffer viewParamsBuffer; Gfx::ODescriptorLayout descriptorLayout; Gfx::PDescriptorSet descriptorSet; - Gfx::OPipelineLayout pipelineLayout; - Gfx::OGraphicsPipeline pipeline; + Gfx::OVertexShader vertexShader; + Gfx::OFragmentShader fragmentShader; + Gfx::PGraphicsPipeline pipeline; }; DEFINE_REF(DebugPass) } // namespace Seele diff --git a/src/Engine/Graphics/RenderPass/RenderGraphResources.cpp b/src/Engine/Graphics/RenderPass/RenderGraphResources.cpp index fa1d5fc..32320c5 100644 --- a/src/Engine/Graphics/RenderPass/RenderGraphResources.cpp +++ b/src/Engine/Graphics/RenderPass/RenderGraphResources.cpp @@ -1,4 +1,5 @@ #include "RenderGraphResources.h" +#include using namespace Seele; diff --git a/src/Engine/Graphics/RenderPass/SkyboxRenderPass.cpp b/src/Engine/Graphics/RenderPass/SkyboxRenderPass.cpp index af8b188..2d6c70c 100644 --- a/src/Engine/Graphics/RenderPass/SkyboxRenderPass.cpp +++ b/src/Engine/Graphics/RenderPass/SkyboxRenderPass.cpp @@ -23,7 +23,6 @@ SkyboxRenderPass::~SkyboxRenderPass() void SkyboxRenderPass::beginFrame(const Component::Camera& cam) { RenderPass::beginFrame(cam); - DataSource uniformUpdate; skyboxDataLayout->reset(); textureLayout->reset(); diff --git a/src/Engine/Graphics/RenderPass/UIPass.cpp b/src/Engine/Graphics/RenderPass/UIPass.cpp index 360bb76..e938f85 100644 --- a/src/Engine/Graphics/RenderPass/UIPass.cpp +++ b/src/Engine/Graphics/RenderPass/UIPass.cpp @@ -83,7 +83,7 @@ void UIPass::publishOutputs() colorBuffer = graphics->createTexture2D(colorBufferInfo); renderTarget = new Gfx::RenderTargetAttachment(colorBuffer, Gfx::SE_ATTACHMENT_LOAD_OP_CLEAR, Gfx::SE_ATTACHMENT_STORE_OP_STORE); - renderTarget->clear.color = { 0.0f, 0.0f, 0.0f, 1.0f }; + renderTarget->clear.color = { {0.0f, 0.0f, 0.0f, 1.0f} }; resources->registerRenderPassOutput("UIPASS_COLOR", renderTarget); } diff --git a/src/Engine/Graphics/Shader.cpp b/src/Engine/Graphics/Shader.cpp index fc592b9..cbe72d0 100644 --- a/src/Engine/Graphics/Shader.cpp +++ b/src/Engine/Graphics/Shader.cpp @@ -2,7 +2,7 @@ #include "Graphics/Initializer.h" #include "Graphics/RenderPass/DepthPrepass.h" #include "Graphics/RenderPass/BasePass.h" -#include +#include using namespace Seele; using namespace Seele::Gfx; @@ -97,7 +97,7 @@ void ShaderCompiler::createShaders(ShaderPermutation permutation) ShaderCollection collection; ShaderCreateInfo createInfo; - createInfo.name = std::format("Material {0}", permutation.materialName); + createInfo.name = fmt::format("Material {0}", permutation.materialName); if (std::strlen(permutation.materialName) > 0) { createInfo.additionalModules.add(permutation.materialName); diff --git a/src/Engine/Graphics/Shader.h b/src/Engine/Graphics/Shader.h index 40de5df..5644205 100644 --- a/src/Engine/Graphics/Shader.h +++ b/src/Engine/Graphics/Shader.h @@ -71,36 +71,36 @@ struct ShaderPermutation { std::memset(taskFile, 0, sizeof(taskFile)); hasTaskShader = 1; - strncpy_s(taskFile, sizeof(taskFile), name.data(), 32); + strncpy(taskFile, name.data(), sizeof(taskFile)); } void setVertexFile(std::string_view name) { std::memset(vertexMeshFile, 0, sizeof(vertexMeshFile)); useMeshShading = 0; - strncpy_s(vertexMeshFile, sizeof(vertexMeshFile), name.data(), 32); + strncpy(vertexMeshFile, name.data(), sizeof(vertexMeshFile)); } void setMeshFile(std::string_view name) { std::memset(vertexMeshFile, 0, sizeof(vertexMeshFile)); useMeshShading = 1; - strncpy_s(vertexMeshFile, sizeof(vertexMeshFile), name.data(), 32); + strncpy(vertexMeshFile, name.data(), sizeof(vertexMeshFile)); } void setFragmentFile(std::string_view name) { std::memset(fragmentFile, 0, sizeof(fragmentFile)); hasFragment = 1; - strncpy_s(fragmentFile, sizeof(fragmentFile), name.data(), 32); + strncpy(fragmentFile, name.data(), sizeof(fragmentFile)); } void setVertexData(std::string_view name) { std::memset(vertexDataName, 0, sizeof(vertexDataName)); - strncpy_s(vertexDataName, sizeof(vertexDataName), name.data(), 32); + strncpy(vertexDataName, name.data(), sizeof(vertexDataName)); } void setMaterial(std::string_view name) { std::memset(materialName, 0, sizeof(materialName)); useMaterial = 1; - strncpy_s(materialName, sizeof(materialName), name.data(), 32); + strncpy(materialName, name.data(), sizeof(materialName)); } }; //Hashed ShaderPermutation for fast lookup diff --git a/src/Engine/Graphics/Vulkan/Allocator.cpp b/src/Engine/Graphics/Vulkan/Allocator.cpp index c278f03..769ea0e 100644 --- a/src/Engine/Graphics/Vulkan/Allocator.cpp +++ b/src/Engine/Graphics/Vulkan/Allocator.cpp @@ -261,8 +261,8 @@ uint32 Allocator::findMemoryType(uint32 typeFilter, VkMemoryPropertyFlags proper StagingBuffer::StagingBuffer(PGraphics graphics, OSubAllocation allocation, VkBuffer buffer, VkDeviceSize size, Gfx::QueueType owner) : owner(owner) - , graphics(graphics) , allocation(std::move(allocation)) + , graphics(graphics) , buffer(buffer) , size(size) { diff --git a/src/Engine/Graphics/Vulkan/Buffer.h b/src/Engine/Graphics/Vulkan/Buffer.h index b65f8d2..e5e5796 100644 --- a/src/Engine/Graphics/Vulkan/Buffer.h +++ b/src/Engine/Graphics/Vulkan/Buffer.h @@ -59,19 +59,19 @@ class UniformBuffer : public Gfx::UniformBuffer, public Buffer public: UniformBuffer(PGraphics graphics, const UniformBufferCreateInfo &sourceData); virtual ~UniformBuffer(); - virtual bool updateContents(const DataSource &sourceData); + virtual bool updateContents(const DataSource &sourceData) override; virtual void* map(bool writeOnly = true) override; virtual void unmap() override; protected: // Inherited via Vulkan::Buffer - virtual VkAccessFlags getSourceAccessMask(); - virtual VkAccessFlags getDestAccessMask(); - virtual void requestOwnershipTransfer(Gfx::QueueType newOwner); + virtual VkAccessFlags getSourceAccessMask() override; + virtual VkAccessFlags getDestAccessMask() override; + virtual void requestOwnershipTransfer(Gfx::QueueType newOwner) override; // Inherited via QueueOwnedResource - virtual void executeOwnershipBarrier(Gfx::QueueType newOwner); + virtual void executeOwnershipBarrier(Gfx::QueueType newOwner) override; virtual void executePipelineBarrier(VkAccessFlags srcAccess, VkPipelineStageFlags srcStage, - VkAccessFlags dstAccess, VkPipelineStageFlags dstStage); + VkAccessFlags dstAccess, VkPipelineStageFlags dstStage) override; private: OStagingBuffer dedicatedStagingBuffer; @@ -83,19 +83,19 @@ class ShaderBuffer : public Gfx::ShaderBuffer, public Buffer public: ShaderBuffer(PGraphics graphics, const ShaderBufferCreateInfo &sourceData); virtual ~ShaderBuffer(); - virtual bool updateContents(const DataSource &sourceData); + virtual bool updateContents(const DataSource &sourceData) override; virtual void* map(bool writeOnly = true) override; virtual void unmap() override; protected: // Inherited via Vulkan::Buffer - virtual VkAccessFlags getSourceAccessMask(); - virtual VkAccessFlags getDestAccessMask(); - virtual void requestOwnershipTransfer(Gfx::QueueType newOwner); + virtual VkAccessFlags getSourceAccessMask() override; + virtual VkAccessFlags getDestAccessMask() override; + virtual void requestOwnershipTransfer(Gfx::QueueType newOwner) override; // Inherited via QueueOwnedResource - virtual void executeOwnershipBarrier(Gfx::QueueType newOwner); + virtual void executeOwnershipBarrier(Gfx::QueueType newOwner) override; virtual void executePipelineBarrier(VkAccessFlags srcAccess, VkPipelineStageFlags srcStage, - VkAccessFlags dstAccess, VkPipelineStageFlags dstStage); + VkAccessFlags dstAccess, VkPipelineStageFlags dstStage) override; private: OStagingBuffer dedicatedStagingBuffer; }; @@ -111,13 +111,13 @@ public: virtual void download(Array& buffer) override; protected: // Inherited via Vulkan::Buffer - virtual VkAccessFlags getSourceAccessMask(); - virtual VkAccessFlags getDestAccessMask(); - virtual void requestOwnershipTransfer(Gfx::QueueType newOwner); + virtual VkAccessFlags getSourceAccessMask() override; + virtual VkAccessFlags getDestAccessMask() override; + virtual void requestOwnershipTransfer(Gfx::QueueType newOwner) override; // Inherited via QueueOwnedResource - virtual void executeOwnershipBarrier(Gfx::QueueType newOwner); + virtual void executeOwnershipBarrier(Gfx::QueueType newOwner) override; virtual void executePipelineBarrier(VkAccessFlags srcAccess, VkPipelineStageFlags srcStage, - VkAccessFlags dstAccess, VkPipelineStageFlags dstStage); + VkAccessFlags dstAccess, VkPipelineStageFlags dstStage) override; }; DEFINE_REF(VertexBuffer) @@ -130,13 +130,13 @@ public: virtual void download(Array& buffer) override; protected: // Inherited via Vulkan::Buffer - virtual VkAccessFlags getSourceAccessMask(); - virtual VkAccessFlags getDestAccessMask(); - virtual void requestOwnershipTransfer(Gfx::QueueType newOwner); + virtual VkAccessFlags getSourceAccessMask() override; + virtual VkAccessFlags getDestAccessMask() override; + virtual void requestOwnershipTransfer(Gfx::QueueType newOwner) override; // Inherited via QueueOwnedResource - virtual void executeOwnershipBarrier(Gfx::QueueType newOwner); + virtual void executeOwnershipBarrier(Gfx::QueueType newOwner) override; virtual void executePipelineBarrier(VkAccessFlags srcAccess, VkPipelineStageFlags srcStage, - VkAccessFlags dstAccess, VkPipelineStageFlags dstStage); + VkAccessFlags dstAccess, VkPipelineStageFlags dstStage) override; }; DEFINE_REF(IndexBuffer) } diff --git a/src/Engine/Graphics/Vulkan/Command.h b/src/Engine/Graphics/Vulkan/Command.h index 36cbc6c..734ca7d 100644 --- a/src/Engine/Graphics/Vulkan/Command.h +++ b/src/Engine/Graphics/Vulkan/Command.h @@ -2,6 +2,7 @@ #include "Queue.h" #include "Graphics/Command.h" #include "Buffer.h" +#include namespace Seele { diff --git a/src/Engine/Graphics/Vulkan/Descriptor.h b/src/Engine/Graphics/Vulkan/Descriptor.h index e09b960..cbe6782 100644 --- a/src/Engine/Graphics/Vulkan/Descriptor.h +++ b/src/Engine/Graphics/Vulkan/Descriptor.h @@ -126,7 +126,7 @@ public: DescriptorPool(PGraphics graphics, DescriptorLayout &layout); virtual ~DescriptorPool(); virtual Gfx::PDescriptorSet allocateDescriptorSet() override; - virtual void reset(); + virtual void reset() override; constexpr VkDescriptorPool getHandle() const { diff --git a/src/Engine/Graphics/Vulkan/Enums.h b/src/Engine/Graphics/Vulkan/Enums.h index 5d4a3e9..3517445 100644 --- a/src/Engine/Graphics/Vulkan/Enums.h +++ b/src/Engine/Graphics/Vulkan/Enums.h @@ -2,6 +2,7 @@ #include "Graphics/Enums.h" #include #include +#include #define VK_CHECK(f) \ { \ diff --git a/src/Engine/Graphics/Vulkan/Graphics.cpp b/src/Engine/Graphics/Vulkan/Graphics.cpp index 778f889..ebd4a58 100644 --- a/src/Engine/Graphics/Vulkan/Graphics.cpp +++ b/src/Engine/Graphics/Vulkan/Graphics.cpp @@ -583,28 +583,28 @@ void Graphics::createDevice(GraphicsInitializer initializer) cmdDrawMeshTasks = (PFN_vkCmdDrawMeshTasksEXT)vkGetDeviceProcAddr(handle, "vkCmdDrawMeshTasksEXT"); - graphicsQueue = new Queue(this, Gfx::QueueType::GRAPHICS, graphicsQueueInfo.familyIndex, 0); + graphicsQueue = new Queue(this, graphicsQueueInfo.familyIndex, 0); if (Gfx::useAsyncCompute && asyncComputeInfo.familyIndex != -1) { if (asyncComputeInfo.familyIndex == graphicsQueueInfo.familyIndex) { // Same family as graphics, but different queue - computeQueue = new Queue(this, Gfx::QueueType::COMPUTE, asyncComputeInfo.familyIndex, 1); + computeQueue = new Queue(this, asyncComputeInfo.familyIndex, 1); } else { // Different family - computeQueue = new Queue(this, Gfx::QueueType::COMPUTE, asyncComputeInfo.familyIndex, 0); + computeQueue = new Queue(this, asyncComputeInfo.familyIndex, 0); } } else { - computeQueue = new Queue(this, Gfx::QueueType::COMPUTE, computeQueueInfo.familyIndex, 0); + computeQueue = new Queue(this, computeQueueInfo.familyIndex, 0); } - transferQueue = new Queue(this, Gfx::QueueType::TRANSFER, transferQueueInfo.familyIndex, 0); + transferQueue = new Queue(this, transferQueueInfo.familyIndex, 0); if (dedicatedTransferQueueInfo.familyIndex != -1) { - dedicatedTransferQueue = new Queue(this, Gfx::QueueType::DEDICATED_TRANSFER, dedicatedTransferQueueInfo.familyIndex, 0); + dedicatedTransferQueue = new Queue(this, dedicatedTransferQueueInfo.familyIndex, 0); } queueMapping.graphicsFamily = graphicsQueue->getFamilyIndex(); queueMapping.computeFamily = computeQueue->getFamilyIndex(); diff --git a/src/Engine/Graphics/Vulkan/PipelineCache.cpp b/src/Engine/Graphics/Vulkan/PipelineCache.cpp index b9ae7ec..61e670f 100644 --- a/src/Engine/Graphics/Vulkan/PipelineCache.cpp +++ b/src/Engine/Graphics/Vulkan/PipelineCache.cpp @@ -36,7 +36,7 @@ PipelineCache::PipelineCache(PGraphics graphics, const std::string& cacheFilePat PipelineCache::~PipelineCache() { - VkDeviceSize cacheSize; + size_t cacheSize; VK_CHECK(vkGetPipelineCacheData(graphics->getDevice(), cache, &cacheSize, nullptr)); Array cacheData(cacheSize); VK_CHECK(vkGetPipelineCacheData(graphics->getDevice(), cache, &cacheSize, cacheData.data())); diff --git a/src/Engine/Graphics/Vulkan/Queue.cpp b/src/Engine/Graphics/Vulkan/Queue.cpp index b10670b..f293016 100644 --- a/src/Engine/Graphics/Vulkan/Queue.cpp +++ b/src/Engine/Graphics/Vulkan/Queue.cpp @@ -6,10 +6,9 @@ using namespace Seele; using namespace Seele::Vulkan; -Queue::Queue(PGraphics graphics, Gfx::QueueType queueType, uint32 familyIndex, uint32 queueIndex) +Queue::Queue(PGraphics graphics, uint32 familyIndex, uint32 queueIndex) : graphics(graphics) , familyIndex(familyIndex) - , queueType(queueType) { vkGetDeviceQueue(graphics->getDevice(), familyIndex, queueIndex, &queue); } diff --git a/src/Engine/Graphics/Vulkan/Queue.h b/src/Engine/Graphics/Vulkan/Queue.h index 0245130..e175de2 100644 --- a/src/Engine/Graphics/Vulkan/Queue.h +++ b/src/Engine/Graphics/Vulkan/Queue.h @@ -10,7 +10,7 @@ DECLARE_REF(Graphics) class Queue { public: - Queue(PGraphics graphics, Gfx::QueueType queueType, uint32 familyIndex, uint32 queueIndex); + Queue(PGraphics graphics, uint32 familyIndex, uint32 queueIndex); virtual ~Queue(); void submitCommandBuffer(PCommand command, const Array& signalSemaphore); constexpr uint32 getFamilyIndex() const @@ -27,7 +27,6 @@ private: PGraphics graphics; VkQueue queue; uint32 familyIndex; - Gfx::QueueType queueType; }; DEFINE_REF(Queue) } // namespace Vulkan diff --git a/src/Engine/Graphics/Vulkan/Texture.h b/src/Engine/Graphics/Vulkan/Texture.h index f8d7ee7..04e59b6 100644 --- a/src/Engine/Graphics/Vulkan/Texture.h +++ b/src/Engine/Graphics/Vulkan/Texture.h @@ -125,9 +125,9 @@ public: protected: // Inherited via QueueOwnedResource - virtual void executeOwnershipBarrier(Gfx::QueueType newOwner); + virtual void executeOwnershipBarrier(Gfx::QueueType newOwner) override; virtual void executePipelineBarrier(VkAccessFlags srcAccess, VkPipelineStageFlags srcStage, - VkAccessFlags dstAccess, VkPipelineStageFlags dstStage); + VkAccessFlags dstAccess, VkPipelineStageFlags dstStage) override; }; DEFINE_REF(Texture2D) @@ -166,9 +166,9 @@ public: protected: // Inherited via QueueOwnedResource - virtual void executeOwnershipBarrier(Gfx::QueueType newOwner); + virtual void executeOwnershipBarrier(Gfx::QueueType newOwner) override; virtual void executePipelineBarrier(VkAccessFlags srcAccess, VkPipelineStageFlags srcStage, - VkAccessFlags dstAccess, VkPipelineStageFlags dstStage); + VkAccessFlags dstAccess, VkPipelineStageFlags dstStage) override; }; DEFINE_REF(Texture3D) @@ -206,9 +206,9 @@ public: virtual void download(uint32 mipLevel, uint32 arrayLayer, uint32 face, Array& buffer) override; protected: // Inherited via QueueOwnedResource - virtual void executeOwnershipBarrier(Gfx::QueueType newOwner); + virtual void executeOwnershipBarrier(Gfx::QueueType newOwner) override; virtual void executePipelineBarrier(VkAccessFlags srcAccess, VkPipelineStageFlags srcStage, - VkAccessFlags dstAccess, VkPipelineStageFlags dstStage); + VkAccessFlags dstAccess, VkPipelineStageFlags dstStage) override; }; DEFINE_REF(TextureCube) } diff --git a/src/Engine/Graphics/Vulkan/Window.h b/src/Engine/Graphics/Vulkan/Window.h index a750770..cb45811 100644 --- a/src/Engine/Graphics/Vulkan/Window.h +++ b/src/Engine/Graphics/Vulkan/Window.h @@ -23,7 +23,7 @@ public: virtual void setMouseButtonCallback(std::function callback) override; virtual void setScrollCallback(std::function callback) override; virtual void setFileCallback(std::function callback) override; - virtual void setCloseCallback(std::function callback); + virtual void setCloseCallback(std::function callback) override; virtual void setResizeCallback(std::function callback) override; void keyPress(KeyCode code, InputAction action, KeyModifier modifier); diff --git a/src/Engine/Material/Material.cpp b/src/Engine/Material/Material.cpp index 481e578..d5877d0 100644 --- a/src/Engine/Material/Material.cpp +++ b/src/Engine/Material/Material.cpp @@ -3,6 +3,7 @@ #include "MaterialInstance.h" #include "Graphics/Graphics.h" #include "Graphics/Shader.h" +#include using namespace Seele; diff --git a/src/Engine/Material/ShaderExpression.cpp b/src/Engine/Material/ShaderExpression.cpp index c4cd6ec..09ed267 100644 --- a/src/Engine/Material/ShaderExpression.cpp +++ b/src/Engine/Material/ShaderExpression.cpp @@ -4,7 +4,8 @@ #include "Asset/AssetRegistry.h" #include "Graphics/Graphics.h" #include "Graphics/Descriptor.h" -#include +#include +#include using namespace Seele; @@ -281,9 +282,9 @@ ConstantExpression::~ConstantExpression() std::string ConstantExpression::evaluate(Map& varState) const { - std::string varName = std::format("const_exp_{}", key); + std::string varName = fmt::format("const_exp_{}", key); varState[key] = varName; - return std::format("let {} = {};\n", varName, expr); + return fmt::format("let {} = {};\n", varName, expr); } void ConstantExpression::save(ArchiveBuffer& buffer) const @@ -310,9 +311,9 @@ AddExpression::~AddExpression() std::string AddExpression::evaluate(Map& varState) const { - std::string varName = std::format("exp_{}", key); + std::string varName = fmt::format("exp_{}", key); varState[key] = varName; - return std::format("let {} = {} + {};\n", varName, varState[inputs.at("lhs").source], varState[inputs.at("rhs").source]); + return fmt::format("let {} = {} + {};\n", varName, varState[inputs.at("lhs").source], varState[inputs.at("rhs").source]); } void AddExpression::save(ArchiveBuffer& buffer) const @@ -327,9 +328,9 @@ void AddExpression::load(ArchiveBuffer& buffer) std::string SubExpression::evaluate(Map& varState) const { - std::string varName = std::format("exp_{}", key); + std::string varName = fmt::format("exp_{}", key); varState[key] = varName; - return std::format("let {} = {} - {};\n", varName, varState[inputs.at("lhs").source], varState[inputs.at("rhs").source]); + return fmt::format("let {} = {} - {};\n", varName, varState[inputs.at("lhs").source], varState[inputs.at("rhs").source]); } void SubExpression::save(ArchiveBuffer& buffer) const @@ -344,9 +345,9 @@ void SubExpression::load(ArchiveBuffer& buffer) std::string MulExpression::evaluate(Map& varState) const { - std::string varName = std::format("exp_{}", key); + std::string varName = fmt::format("exp_{}", key); varState[key] = varName; - return std::format("let {} = {} * {};\n", varName, varState[inputs.at("lhs").source], varState[inputs.at("rhs").source]); + return fmt::format("let {} = {} * {};\n", varName, varState[inputs.at("lhs").source], varState[inputs.at("rhs").source]); } void MulExpression::save(ArchiveBuffer& buffer) const @@ -361,7 +362,7 @@ void MulExpression::load(ArchiveBuffer& buffer) std::string SwizzleExpression::evaluate(Map& varState) const { - std::string varName = std::format("exp_{}", key); + std::string varName = fmt::format("exp_{}", key); std::string swizzle = ""; for(uint32 i = 0; i < 4; ++i) { @@ -388,7 +389,7 @@ std::string SwizzleExpression::evaluate(Map& varState) } } varState[key] = varName; - return std::format("let {} = {}.{};\n", varName, varState[inputs.at("target").source], swizzle); + return fmt::format("let {} = {}.{};\n", varName, varState[inputs.at("target").source], swizzle); } void SwizzleExpression::save(ArchiveBuffer& buffer) const @@ -405,9 +406,9 @@ void SwizzleExpression::load(ArchiveBuffer& buffer) std::string SampleExpression::evaluate(Map& varState) const { - std::string varName = std::format("exp_{}", key); + std::string varName = fmt::format("exp_{}", key); varState[key] = varName; - return std::format("let {} = {}.Sample({}, {});\n", varName, varState[inputs.at("texture").source], varState[inputs.at("sampler").source], varState[inputs.at("coords").source]); + return fmt::format("let {} = {}.Sample({}, {});\n", varName, varState[inputs.at("texture").source], varState[inputs.at("sampler").source], varState[inputs.at("coords").source]); } void SampleExpression::save(ArchiveBuffer& buffer) const diff --git a/src/Engine/Material/ShaderExpression.h b/src/Engine/Material/ShaderExpression.h index 0f4cc9f..6b97fce 100644 --- a/src/Engine/Material/ShaderExpression.h +++ b/src/Engine/Material/ShaderExpression.h @@ -58,10 +58,10 @@ struct ShaderParameter : public ShaderExpression // update a descriptorset, in case of a uniform buffer, copy the data to the dst + byteOffset virtual void updateDescriptorSet(Gfx::PDescriptorSet descriptorSet, uint8* dst) = 0; virtual void generateDeclaration(std::ofstream& stream) const = 0; - virtual uint64 getIdentifier() const = 0; + virtual uint64 getIdentifier() const override = 0; virtual std::string evaluate(Map& varState) const override; - virtual void save(ArchiveBuffer& buffer) const; - virtual void load(ArchiveBuffer& buffer); + virtual void save(ArchiveBuffer& buffer) const override; + virtual void load(ArchiveBuffer& buffer) override; }; DEFINE_REF(ShaderParameter) struct FloatParameter : public ShaderParameter @@ -145,7 +145,7 @@ struct ConstantExpression : public ShaderExpression ConstantExpression(); ConstantExpression(std::string expr, ExpressionType type); virtual ~ConstantExpression(); - virtual uint64 getIdentifier() const { return IDENTIFIER; } + virtual uint64 getIdentifier() const override { return IDENTIFIER; } virtual std::string evaluate(Map& varState) const override; virtual void save(ArchiveBuffer& buffer) const override; virtual void load(ArchiveBuffer& buffer) override; @@ -156,7 +156,7 @@ struct AddExpression : public ShaderExpression static constexpr uint64 IDENTIFIER = 0x12; AddExpression(); virtual ~AddExpression(); - virtual uint64 getIdentifier() const { return IDENTIFIER; } + virtual uint64 getIdentifier() const override { return IDENTIFIER; } virtual std::string evaluate(Map& varState) const override; virtual void save(ArchiveBuffer& buffer) const override; virtual void load(ArchiveBuffer& buffer) override; @@ -167,7 +167,7 @@ struct SubExpression : public ShaderExpression static constexpr uint64 IDENTIFIER = 0x13; SubExpression() {} virtual ~SubExpression() {} - virtual uint64 getIdentifier() const { return IDENTIFIER; } + virtual uint64 getIdentifier() const override { return IDENTIFIER; } virtual std::string evaluate(Map& varState) const override; virtual void save(ArchiveBuffer& buffer) const override; virtual void load(ArchiveBuffer& buffer) override; @@ -178,7 +178,7 @@ struct MulExpression : public ShaderExpression static constexpr uint64 IDENTIFIER = 0x14; MulExpression() {} virtual ~MulExpression() {} - virtual uint64 getIdentifier() const { return IDENTIFIER; } + virtual uint64 getIdentifier() const override { return IDENTIFIER; } virtual std::string evaluate(Map& varState) const override; virtual void save(ArchiveBuffer& buffer) const override; virtual void load(ArchiveBuffer& buffer) override; @@ -190,7 +190,7 @@ struct SwizzleExpression : public ShaderExpression StaticArray comp = {-1, -1, -1, -1}; SwizzleExpression() {} virtual ~SwizzleExpression() {} - virtual uint64 getIdentifier() const { return IDENTIFIER; } + virtual uint64 getIdentifier() const override { return IDENTIFIER; } virtual std::string evaluate(Map& varState) const override; virtual void save(ArchiveBuffer& buffer) const override; virtual void load(ArchiveBuffer& buffer) override; @@ -201,7 +201,7 @@ struct SampleExpression : public ShaderExpression static constexpr uint64 IDENTIFIER = 0x16; SampleExpression() {} virtual ~SampleExpression() {} - virtual uint64 getIdentifier() const { return IDENTIFIER; } + virtual uint64 getIdentifier() const override { return IDENTIFIER; } virtual std::string evaluate(Map& varState) const override; virtual void save(ArchiveBuffer& buffer) const override; virtual void load(ArchiveBuffer& buffer) override; diff --git a/src/Engine/Math/Vector.cpp b/src/Engine/Math/Vector.cpp index d814d2e..fdf1d92 100644 --- a/src/Engine/Math/Vector.cpp +++ b/src/Engine/Math/Vector.cpp @@ -1,6 +1,7 @@ #include "Vector.h" #include -#include +#include +#include #include #include "Serialization/ArchiveBuffer.h" @@ -8,7 +9,7 @@ using namespace Seele; void to_json(nlohmann::json& j, const Vector& vec) { - j = nlohmann::json{std::format("({}, {}, {})", vec.x, vec.y, vec.z)}; + j = nlohmann::json{fmt::format("({}, {}, {})", vec.x, vec.y, vec.z)}; } void from_json(const nlohmann::json& j, Vector& vec) diff --git a/src/Engine/MinimalEngine.h b/src/Engine/MinimalEngine.h index ddb898e..a90fee7 100644 --- a/src/Engine/MinimalEngine.h +++ b/src/Engine/MinimalEngine.h @@ -1,6 +1,9 @@ #pragma once #include "EngineTypes.h" -#include +#include +#include +#include +#include #define DEFINE_REF(x) \ typedef ::Seele::RefPtr P##x; \ diff --git a/src/Engine/Physics/BVH.cpp b/src/Engine/Physics/BVH.cpp index 6c23392..a70302b 100644 --- a/src/Engine/Physics/BVH.cpp +++ b/src/Engine/Physics/BVH.cpp @@ -339,7 +339,16 @@ int32 BVH::splitNode(Array aabbs) { longestAxis = 2; } - std::sort(aabbs.begin(), aabbs.end(), [longestAxis](AABBCenter lhs, AABBCenter rhs){ return lhs.center[longestAxis] < rhs.center[longestAxis];}); + struct + { + bool operator()(const AABBCenter& lhs, const AABBCenter& rhs) + { + return lhs.center[longestAxis] < rhs.center[longestAxis]; + } + int32 longestAxis; + } compare = {longestAxis}; + + std::sort(aabbs.begin(), aabbs.end(), compare); Array left((aabbs.size()+1)/2); Array right(aabbs.size()/2); std::copy(aabbs.begin(), aabbs.begin()+left.size(), left.begin()); diff --git a/src/Engine/Physics/PhysicsSystem.cpp b/src/Engine/Physics/PhysicsSystem.cpp index 7d660ea..9ec4e0b 100644 --- a/src/Engine/Physics/PhysicsSystem.cpp +++ b/src/Engine/Physics/PhysicsSystem.cpp @@ -1,5 +1,6 @@ #include "PhysicsSystem.h" #include +#include using namespace Seele; using namespace Seele::Component; diff --git a/src/Engine/Platform/CMakeLists.txt b/src/Engine/Platform/CMakeLists.txt index e212857..5ca1ef2 100644 --- a/src/Engine/Platform/CMakeLists.txt +++ b/src/Engine/Platform/CMakeLists.txt @@ -1,5 +1,7 @@ if(WIN32) add_subdirectory(Windows/) +elseif(APPLE) + add_subdirectory(Mac/) else() add_subdirectory(Linux/) endif() \ No newline at end of file diff --git a/src/Engine/Platform/Linux/GameInterface.cpp b/src/Engine/Platform/Linux/GameInterface.cpp index ba8b1cb..dc09864 100644 --- a/src/Engine/Platform/Linux/GameInterface.cpp +++ b/src/Engine/Platform/Linux/GameInterface.cpp @@ -18,7 +18,7 @@ Game* GameInterface::getGame() return game; } -void GameInterface::reload(AssetRegistry* registry) +void GameInterface::reload() { if(lib != NULL) { @@ -28,5 +28,5 @@ void GameInterface::reload(AssetRegistry* registry) lib = dlopen(soPath.c_str(), RTLD_NOW); createInstance = (decltype(createInstance))dlsym(lib, "createInstance"); destroyInstance = (decltype(destroyInstance))dlsym(lib, "destroyInstance"); - game = createInstance(registry); + game = createInstance(); } \ No newline at end of file diff --git a/src/Engine/Platform/Linux/GameInterface.h b/src/Engine/Platform/Linux/GameInterface.h index fa3d4c9..b9649c9 100644 --- a/src/Engine/Platform/Linux/GameInterface.h +++ b/src/Engine/Platform/Linux/GameInterface.h @@ -10,12 +10,12 @@ public: GameInterface(std::string soPath); ~GameInterface(); Game* getGame(); - void reload(AssetRegistry* registry); + void reload(); private: void* lib; std::string soPath; Game* game; - Game* (*createInstance)(AssetRegistry*) = nullptr; + Game* (*createInstance)() = nullptr; void (*destroyInstance)(Game*) = nullptr; }; } // namespace Seele \ No newline at end of file diff --git a/src/Engine/Platform/Mac/CMakeLists.txt b/src/Engine/Platform/Mac/CMakeLists.txt new file mode 100644 index 0000000..4613346 --- /dev/null +++ b/src/Engine/Platform/Mac/CMakeLists.txt @@ -0,0 +1,10 @@ +target_sources(Engine + PRIVATE + GameInterface.h + GameInterface.cpp) + + +target_sources(Engine + PUBLIC FILE_SET HEADERS + FILES + GameInterface.h) \ No newline at end of file diff --git a/src/Engine/Platform/Mac/GameInterface.cpp b/src/Engine/Platform/Mac/GameInterface.cpp new file mode 100644 index 0000000..dc09864 --- /dev/null +++ b/src/Engine/Platform/Mac/GameInterface.cpp @@ -0,0 +1,32 @@ +#include "GameInterface.h" + +using namespace Seele; + +GameInterface::GameInterface(std::string soPath) + : lib(NULL) + , soPath(soPath) +{ +} + +GameInterface::~GameInterface() +{ + +} + +Game* GameInterface::getGame() +{ + return game; +} + +void GameInterface::reload() +{ + if(lib != NULL) + { + destroyInstance(game); + dlclose(lib); + } + lib = dlopen(soPath.c_str(), RTLD_NOW); + createInstance = (decltype(createInstance))dlsym(lib, "createInstance"); + destroyInstance = (decltype(destroyInstance))dlsym(lib, "destroyInstance"); + game = createInstance(); +} \ No newline at end of file diff --git a/src/Engine/Platform/Mac/GameInterface.h b/src/Engine/Platform/Mac/GameInterface.h new file mode 100644 index 0000000..b9649c9 --- /dev/null +++ b/src/Engine/Platform/Mac/GameInterface.h @@ -0,0 +1,21 @@ +#pragma once +#include "Game.h" +#include "dlfcn.h" + +namespace Seele +{ +class GameInterface +{ +public: + GameInterface(std::string soPath); + ~GameInterface(); + Game* getGame(); + void reload(); +private: + void* lib; + std::string soPath; + Game* game; + Game* (*createInstance)() = nullptr; + void (*destroyInstance)(Game*) = nullptr; +}; +} // namespace Seele \ No newline at end of file diff --git a/src/Engine/Serialization/ArchiveBuffer.cpp b/src/Engine/Serialization/ArchiveBuffer.cpp index e4f5573..01b3257 100644 --- a/src/Engine/Serialization/ArchiveBuffer.cpp +++ b/src/Engine/Serialization/ArchiveBuffer.cpp @@ -1,5 +1,7 @@ #include "ArchiveBuffer.h" #include "Graphics/Graphics.h" +#include +#include using namespace Seele; diff --git a/src/Engine/System/ComponentSystem.h b/src/Engine/System/ComponentSystem.h index 2d514b5..05c72e8 100644 --- a/src/Engine/System/ComponentSystem.h +++ b/src/Engine/System/ComponentSystem.h @@ -40,7 +40,7 @@ public: SystemBase::run(pool, delta); setupView((getDependencies() | ...), pool); } - virtual void update() {} + virtual void update() override {} virtual void update(Components&... components) = 0; }; } // namespace System diff --git a/src/Engine/Window/View.cpp b/src/Engine/Window/View.cpp index e903090..9c45117 100644 --- a/src/Engine/Window/View.cpp +++ b/src/Engine/Window/View.cpp @@ -6,8 +6,8 @@ using namespace Seele; View::View(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo &viewportInfo, std::string name) : graphics(graphics) - , owner(window) , createInfo(viewportInfo) + , owner(window) , name(name) { viewport = graphics->createViewport(owner->getGfxHandle(), viewportInfo); diff --git a/vcpkg.json b/vcpkg.json index 3790b0f..39093c9 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -9,6 +9,7 @@ "glm", "ktx", "nlohmann-json", + "fmt", "shader-slang", "gtest" ]