From 3cee2ae9ab3a694c076a7d9468016483780db1e1 Mon Sep 17 00:00:00 2001 From: Dynamitos Date: Sat, 12 Apr 2025 17:40:14 +0200 Subject: [PATCH] Trying to get metal backend to run --- CMakeLists.txt | 5 ++-- external/vcpkg | 2 +- src/Editor/Asset/EnvironmentLoader.cpp | 12 +++++++--- src/Editor/main.cpp | 11 +++++++-- src/Engine/Graphics/Graphics.h | 2 +- src/Engine/Graphics/Metal/Command.mm | 10 +++----- src/Engine/Graphics/Metal/Descriptor.h | 4 +--- src/Engine/Graphics/Metal/Descriptor.mm | 24 +------------------ src/Engine/Graphics/Metal/Graphics.h | 3 +-- src/Engine/Graphics/Metal/Graphics.mm | 3 +-- src/Engine/Graphics/Metal/RenderPass.h | 4 ++-- src/Engine/Graphics/Metal/RenderPass.mm | 9 ++++--- src/Engine/Graphics/Metal/Texture.mm | 4 +++- src/Engine/Graphics/RenderPass/BasePass.cpp | 2 +- .../Graphics/RenderPass/CachedDepthPass.cpp | 2 +- .../Graphics/RenderPass/DepthCullingPass.cpp | 2 +- .../Graphics/RenderPass/ToneMappingPass.cpp | 2 +- src/Engine/Graphics/RenderPass/UIPass.cpp | 2 +- src/Engine/Graphics/VertexData.cpp | 10 ++++++-- src/Engine/Graphics/Vulkan/Graphics.cpp | 3 ++- src/Engine/Graphics/Vulkan/Graphics.h | 2 +- src/Engine/Material/Material.cpp | 4 +++- src/Engine/Platform/Mac/GameInterface.cpp | 5 +++- src/Engine/Platform/Mac/GameInterface.h | 6 ++--- 24 files changed, 64 insertions(+), 69 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0dbea35..7a657aa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,6 @@ set(BUILD_SHARED_LIBS OFF) set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) set(VCPKG_INSTALL_OPTIONS "--allow-unsupported") -set(VCPKG_BUILD_TYPE release) set(ENGINE_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/src/Engine) set(EXTERNAL_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/external) @@ -25,7 +24,7 @@ set(METAL_ROOT ${EXTERNAL_ROOT}/metal-cpp) if(WIN32) set(VCPKG_BASE_FOLDER ${CMAKE_BINARY_DIR}/vcpkg_installed/x64-windows/) elseif(APPLE) - set(VCPKG_BASE_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}/build/vcpkg_installed/arm64-osx/) + set(VCPKG_BASE_FOLDER ${CMAKE_BINARY_DIR}/vcpkg_installed/arm64-osx/) endif() set(Boost_NO_WARN_NEW_VERSIONS 1) @@ -78,7 +77,7 @@ target_link_libraries(Engine PUBLIC GPUOpen::VulkanMemoryAllocator) if(WIN32) target_link_libraries(Engine PUBLIC ${VCPKG_BASE_FOLDER}/lib/slang.lib) elseif(APPLE) - target_link_libraries(Engine PUBLIC ${VCPKG_BASE_FOLDER}/lib/libslang.dylib) + target_link_libraries(Engine PUBLIC ${VCPKG_BASE_FOLDER}/debug/lib/libslang.dylib) endif() if(APPLE) diff --git a/external/vcpkg b/external/vcpkg index f9a99aa..0bf1354 160000 --- a/external/vcpkg +++ b/external/vcpkg @@ -1 +1 @@ -Subproject commit f9a99aa79c1309001e36572fa42d7d8edebfc451 +Subproject commit 0bf1354d6704ec797acea686d0250afc4036a082 diff --git a/src/Editor/Asset/EnvironmentLoader.cpp b/src/Editor/Asset/EnvironmentLoader.cpp index 4ab351c..b295644 100644 --- a/src/Editor/Asset/EnvironmentLoader.cpp +++ b/src/Editor/Asset/EnvironmentLoader.cpp @@ -133,15 +133,17 @@ void EnvironmentLoader::import(EnvironmentImportArgs args, PEnvironmentMapAsset Gfx::SE_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, Gfx::SE_ATTACHMENT_LOAD_OP_DONT_CARE, Gfx::SE_ATTACHMENT_STORE_OP_STORE)}, }, - { - Gfx::SubPassDependency{ + {Gfx::SubPassDependency{ .srcSubpass = 0, .dstSubpass = ~0U, .srcStage = Gfx::SE_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, .dstStage = Gfx::SE_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, .srcAccess = Gfx::SE_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, .dstAccess = Gfx::SE_ACCESS_SHADER_READ_BIT, - } + }}, + { + .offset = {0, 0}, + .size = {SOURCE_RESOLUTION, SOURCE_RESOLUTION}, }, "EnvironmentRenderPass", {0b111111}, {0b111111}); cubeRenderPipeline = graphics->createGraphicsPipeline(Gfx::LegacyPipelineCreateInfo{ @@ -176,6 +178,10 @@ void EnvironmentLoader::import(EnvironmentImportArgs args, PEnvironmentMapAsset Gfx::SE_ATTACHMENT_LOAD_OP_DONT_CARE, Gfx::SE_ATTACHMENT_STORE_OP_STORE)}, }, {}, + { + .offset = {0, 0}, + .size = {CONVOLUTED_RESOLUTION, CONVOLUTED_RESOLUTION}, + }, "EnvironmentRenderPass", {0b111111}, {0b111111}); convolutionPipeline = graphics->createGraphicsPipeline(Gfx::LegacyPipelineCreateInfo{ .vertexShader = cubeRenderVertex, diff --git a/src/Editor/main.cpp b/src/Editor/main.cpp index db06781..28777cd 100644 --- a/src/Editor/main.cpp +++ b/src/Editor/main.cpp @@ -9,8 +9,8 @@ #ifdef __APPLE__ #include "Graphics/Metal/Graphics.h" #else -#include "Graphics/Vulkan/Graphics.h" #endif +#include "Graphics/Vulkan/Graphics.h" #include "Graphics/StaticMeshVertexData.h" #include "Window/InspectorView.h" #include "Window/PlayView.h" @@ -28,7 +28,14 @@ int main() { std::string gameName = "MinecraftClone"; std::filesystem::path outputPath = fmt::format("../../{0}Game", gameName); std::filesystem::path sourcePath = fmt::format("../../{0}", gameName); - std::filesystem::path binaryPath = sourcePath / "bin" / fmt::format("{0}.dll", gameName); +#ifdef WIN32 + std::string libraryEnding = "dll"; +#elif __APPLE__ + std::string libraryEnding = "dylib"; +#else + std::string libraryEnding = "so"; +#endif + std::filesystem::path binaryPath = sourcePath / "bin" / fmt::format("{}.{}", gameName, libraryEnding); std::filesystem::path cmakePath = outputPath / "cmake"; if (true) { #ifdef __APPLE__ diff --git a/src/Engine/Graphics/Graphics.h b/src/Engine/Graphics/Graphics.h index 37772c9..b673a91 100644 --- a/src/Engine/Graphics/Graphics.h +++ b/src/Engine/Graphics/Graphics.h @@ -55,7 +55,7 @@ class Graphics { virtual OWindow createWindow(const WindowCreateInfo& createInfo) = 0; virtual OViewport createViewport(PWindow owner, const ViewportCreateInfo& createInfo) = 0; - virtual ORenderPass createRenderPass(RenderTargetLayout layout, Array dependencies, + virtual ORenderPass createRenderPass(RenderTargetLayout layout, Array dependencies, URect renderArea, std::string name = "", Array viewMasks = {0}, Array correlationMasks = {}) = 0; virtual void beginRenderPass(PRenderPass renderPass) = 0; virtual void endRenderPass() = 0; diff --git a/src/Engine/Graphics/Metal/Command.mm b/src/Engine/Graphics/Metal/Command.mm index 1dc4f79..1b517f0 100644 --- a/src/Engine/Graphics/Metal/Command.mm +++ b/src/Engine/Graphics/Metal/Command.mm @@ -319,6 +319,7 @@ CommandQueue::CommandQueue(PGraphics graphics) : graphics(graphics) { MTL::CommandBufferDescriptor* descriptor = MTL::CommandBufferDescriptor::alloc()->init(); descriptor->setErrorOptions(MTL::CommandBufferErrorOptionEncoderExecutionStatus); activeCommand = new Command(graphics, queue->commandBuffer(descriptor)); + activeCommand->begin(); descriptor->release(); } @@ -353,7 +354,7 @@ void CommandQueue::executeCommands(Array commands) { } void CommandQueue::submitCommands(PEvent signalSemaphore) { - /*activeCommand->getHandle()->addCompletedHandler(MTL::CommandBufferHandler([&](MTL::CommandBuffer* cmdBuffer) { + activeCommand->getHandle()->addCompletedHandler(MTL::CommandBufferHandler([&](MTL::CommandBuffer* cmdBuffer) { for (auto it = pendingCommands.begin(); it != pendingCommands.end(); it++) { if ((*it)->getHandle() == cmdBuffer) { auto& cmd = *it; @@ -380,12 +381,7 @@ void CommandQueue::submitCommands(PEvent signalSemaphore) { activeCommand->begin(); activeCommand->waitForEvent(prevCmdEvent); descriptor->release(); - }*/ - activeCommand->end(); - activeCommand->waitDeviceIdle(); - activeCommand->reset(); - activeCommand = new Command(graphics, queue->commandBuffer()); - activeCommand->begin(); + } } IOCommandQueue::IOCommandQueue(PGraphics graphics) : graphics(graphics) { diff --git a/src/Engine/Graphics/Metal/Descriptor.h b/src/Engine/Graphics/Metal/Descriptor.h index 947c72f..18c416e 100644 --- a/src/Engine/Graphics/Metal/Descriptor.h +++ b/src/Engine/Graphics/Metal/Descriptor.h @@ -70,9 +70,7 @@ class DescriptorSet : public Gfx::DescriptorSet, public CommandBoundResource { virtual void updateBuffer(const std::string& name, uint32 index, Gfx::PVertexBuffer uniformBuffer) override; virtual void updateBuffer(const std::string& name, uint32 index, Gfx::PIndexBuffer uniformBuffer) override; virtual void updateSampler(const std::string& name, uint32 index, Gfx::PSampler samplerState) override; - virtual void updateTexture(const std::string& name, uint32 index, Gfx::PTexture2D texture) override; - virtual void updateTexture(const std::string& name, uint32 index, Gfx::PTexture3D texture) override; - virtual void updateTexture(const std::string& name, uint32 index, Gfx::PTextureCube texture) override; + virtual void updateTexture(const std::string& name, uint32 index, Gfx::PTexture texture) override; virtual void updateAccelerationStructure(const std::string& name, uint32 index, Gfx::PTopLevelAS as) override; constexpr bool isPlainDescriptor() const { return owner->getLayout()->isPlainDescriptor(); } diff --git a/src/Engine/Graphics/Metal/Descriptor.mm b/src/Engine/Graphics/Metal/Descriptor.mm index 0c33c0b..78972f4 100644 --- a/src/Engine/Graphics/Metal/Descriptor.mm +++ b/src/Engine/Graphics/Metal/Descriptor.mm @@ -152,29 +152,7 @@ void DescriptorSet::updateSampler(const std::string& name, uint32 index, Gfx::PS }); } -void DescriptorSet::updateTexture(const std::string& name, uint32 index, Gfx::PTexture2D texture) { - uint32 flattenedIndex = owner->getLayout()->variableMapping[name].index + index; - PTextureBase tex = texture.cast(); - textureWrites.add(TextureWriteInfo{ - .index = flattenedIndex, - .texture = tex->getHandle(), - .access = owner->getLayout()->variableMapping[name].access, - }); - boundResources.add(tex->getHandle()); -} - -void DescriptorSet::updateTexture(const std::string& name, uint32 index, Gfx::PTexture3D texture) { - uint32 flattenedIndex = owner->getLayout()->variableMapping[name].index + index; - PTextureBase tex = texture.cast(); - textureWrites.add(TextureWriteInfo{ - .index = flattenedIndex, - .texture = tex->getHandle(), - .access = owner->getLayout()->variableMapping[name].access, - }); - boundResources.add(tex->getHandle()); -} - -void DescriptorSet::updateTexture(const std::string& name, uint32 index, Gfx::PTextureCube texture) { +void DescriptorSet::updateTexture(const std::string& name, uint32 index, Gfx::PTexture texture) { uint32 flattenedIndex = owner->getLayout()->variableMapping[name].index + index; PTextureBase tex = texture.cast(); textureWrites.add(TextureWriteInfo{ diff --git a/src/Engine/Graphics/Metal/Graphics.h b/src/Engine/Graphics/Metal/Graphics.h index e4319ef..bb6d7d8 100644 --- a/src/Engine/Graphics/Metal/Graphics.h +++ b/src/Engine/Graphics/Metal/Graphics.h @@ -17,8 +17,7 @@ class Graphics : public Gfx::Graphics { virtual Gfx::OWindow createWindow(const WindowCreateInfo& createInfo) override; virtual Gfx::OViewport createViewport(Gfx::PWindow owner, const ViewportCreateInfo& createInfo) override; - virtual Gfx::ORenderPass createRenderPass(Gfx::RenderTargetLayout layout, Array dependencies, - Gfx::PViewport renderArea, std::string name = "") override; + virtual Gfx::ORenderPass createRenderPass(Gfx::RenderTargetLayout layout, Array dependencies, URect renderArea, std::string name, Array viewMasks, Array correlationMasks) override; virtual void beginRenderPass(Gfx::PRenderPass renderPass) override; virtual void endRenderPass() override; virtual void waitDeviceIdle() override; diff --git a/src/Engine/Graphics/Metal/Graphics.mm b/src/Engine/Graphics/Metal/Graphics.mm index 8d27183..5459b34 100644 --- a/src/Engine/Graphics/Metal/Graphics.mm +++ b/src/Engine/Graphics/Metal/Graphics.mm @@ -38,8 +38,7 @@ Gfx::OViewport Graphics::createViewport(Gfx::PWindow owner, const ViewportCreate return new Viewport(owner, createInfo); } -Gfx::ORenderPass Graphics::createRenderPass(Gfx::RenderTargetLayout layout, Array dependencies, - Gfx::PViewport renderArea, std::string name) { +Gfx::ORenderPass Graphics::createRenderPass(Gfx::RenderTargetLayout layout, Array dependencies, URect renderArea, std::string name, Array viewMask, Array correlationMask) { return new RenderPass(this, layout, dependencies, renderArea, name); } diff --git a/src/Engine/Graphics/Metal/RenderPass.h b/src/Engine/Graphics/Metal/RenderPass.h index 10ecbc0..8a80423 100644 --- a/src/Engine/Graphics/Metal/RenderPass.h +++ b/src/Engine/Graphics/Metal/RenderPass.h @@ -7,7 +7,7 @@ namespace Metal { DECLARE_REF(Graphics) class RenderPass : public Gfx::RenderPass { public: - RenderPass(PGraphics graphics, Gfx::RenderTargetLayout layout, Array dependencies, Gfx::PViewport viewport, + RenderPass(PGraphics graphics, Gfx::RenderTargetLayout layout, Array dependencies, URect viewport, const std::string& name = ""); virtual ~RenderPass(); void updateRenderPass(); @@ -16,7 +16,7 @@ class RenderPass : public Gfx::RenderPass { private: PGraphics graphics; - Gfx::PViewport viewport; + URect renderArea; MTL::RenderPassDescriptor* renderPass; std::string name; }; diff --git a/src/Engine/Graphics/Metal/RenderPass.mm b/src/Engine/Graphics/Metal/RenderPass.mm index 108a8e3..c60f8e9 100644 --- a/src/Engine/Graphics/Metal/RenderPass.mm +++ b/src/Engine/Graphics/Metal/RenderPass.mm @@ -8,13 +8,12 @@ using namespace Seele; using namespace Seele::Metal; RenderPass::RenderPass(PGraphics graphics, Gfx::RenderTargetLayout _layout, Array dependencies, - Gfx::PViewport viewport, const std::string& name) - : Gfx::RenderPass(std::move(_layout), dependencies), graphics(graphics), viewport(viewport), name(name) { + URect renderArea, const std::string& name) + : Gfx::RenderPass(std::move(_layout), dependencies), graphics(graphics), renderArea(renderArea), name(name) { renderPass = MTL::RenderPassDescriptor::renderPassDescriptor(); renderPass->setRenderTargetArrayLength(1); - renderPass->setRenderTargetWidth(viewport->getWidth()); - renderPass->setRenderTargetHeight(viewport->getHeight()); - renderPass->setDefaultRasterSampleCount(viewport->getSamples()); + renderPass->setRenderTargetWidth(renderArea.size.x); + renderPass->setRenderTargetHeight(renderArea.size.y); for (size_t i = 0; i < layout.colorAttachments.size(); ++i) { const auto& color = layout.colorAttachments[i]; diff --git a/src/Engine/Graphics/Metal/Texture.mm b/src/Engine/Graphics/Metal/Texture.mm index 7adc3d9..a7eb3ed 100644 --- a/src/Engine/Graphics/Metal/Texture.mm +++ b/src/Engine/Graphics/Metal/Texture.mm @@ -94,7 +94,9 @@ void TextureHandle::generateMipmaps() {} TextureBase::TextureBase(PGraphics graphics, MTL::TextureType viewType, const TextureCreateInfo& createInfo, MTL::Texture* existingImage) : handle(new TextureHandle(graphics, viewType, createInfo, existingImage)), graphics(graphics) {} -TextureBase::~TextureBase() {} +TextureBase::~TextureBase() { + graphics->getDestructionManager()->queueResourceForDestruction(std::move(handle)); +} void TextureBase::pipelineBarrier(Gfx::SeAccessFlags srcAccess, Gfx::SePipelineStageFlags srcStage, Gfx::SeAccessFlags dstAccess, Gfx::SePipelineStageFlags dstStage) { diff --git a/src/Engine/Graphics/RenderPass/BasePass.cpp b/src/Engine/Graphics/RenderPass/BasePass.cpp index 459ee2b..bdf3ae1 100644 --- a/src/Engine/Graphics/RenderPass/BasePass.cpp +++ b/src/Engine/Graphics/RenderPass/BasePass.cpp @@ -472,7 +472,7 @@ void BasePass::createRenderPass() { Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, }, }; - renderPass = graphics->createRenderPass(std::move(layout), std::move(dependency), "BasePass"); + renderPass = graphics->createRenderPass(std::move(layout), std::move(dependency), viewport->getRenderArea(), "BasePass"); oLightIndexList = resources->requestBuffer("LIGHTCULLING_OLIGHTLIST"); tLightIndexList = resources->requestBuffer("LIGHTCULLING_TLIGHTLIST"); oLightGrid = resources->requestTexture("LIGHTCULLING_OLIGHTGRID"); diff --git a/src/Engine/Graphics/RenderPass/CachedDepthPass.cpp b/src/Engine/Graphics/RenderPass/CachedDepthPass.cpp index dad61b2..b648efd 100644 --- a/src/Engine/Graphics/RenderPass/CachedDepthPass.cpp +++ b/src/Engine/Graphics/RenderPass/CachedDepthPass.cpp @@ -203,5 +203,5 @@ void CachedDepthPass::createRenderPass() { Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, }, }; - renderPass = graphics->createRenderPass(std::move(layout), std::move(dependency), "CachedDepthPass"); + renderPass = graphics->createRenderPass(std::move(layout), std::move(dependency), viewport->getRenderArea(), "CachedDepthPass"); } diff --git a/src/Engine/Graphics/RenderPass/DepthCullingPass.cpp b/src/Engine/Graphics/RenderPass/DepthCullingPass.cpp index 7656601..665a571 100644 --- a/src/Engine/Graphics/RenderPass/DepthCullingPass.cpp +++ b/src/Engine/Graphics/RenderPass/DepthCullingPass.cpp @@ -306,5 +306,5 @@ void DepthCullingPass::createRenderPass() { Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, }, }; - renderPass = graphics->createRenderPass(std::move(layout), std::move(dependency), "DepthCullingPass"); + renderPass = graphics->createRenderPass(std::move(layout), std::move(dependency), viewport->getRenderArea(), "DepthCullingPass"); } diff --git a/src/Engine/Graphics/RenderPass/ToneMappingPass.cpp b/src/Engine/Graphics/RenderPass/ToneMappingPass.cpp index d078b64..9e85745 100644 --- a/src/Engine/Graphics/RenderPass/ToneMappingPass.cpp +++ b/src/Engine/Graphics/RenderPass/ToneMappingPass.cpp @@ -216,7 +216,7 @@ void ToneMappingPass::createRenderPass() { .dstAccess = Gfx::SE_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, }, }; - renderPass = graphics->createRenderPass(targetLayout, dependency, "ToneMappingPass"); + renderPass = graphics->createRenderPass(targetLayout, dependency, viewport->getRenderArea(), "ToneMappingPass"); pipeline = graphics->createGraphicsPipeline(Gfx::LegacyPipelineCreateInfo{ .vertexShader = vert, .fragmentShader = frag, diff --git a/src/Engine/Graphics/RenderPass/UIPass.cpp b/src/Engine/Graphics/RenderPass/UIPass.cpp index 61225ef..8d55e49 100644 --- a/src/Engine/Graphics/RenderPass/UIPass.cpp +++ b/src/Engine/Graphics/RenderPass/UIPass.cpp @@ -170,7 +170,7 @@ void UIPass::createRenderPass() { Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, }, }; - renderPass = graphics->createRenderPass(std::move(layout), dependency, "TextPass"); + renderPass = graphics->createRenderPass(std::move(layout), dependency, viewport->getRenderArea(), "TextPass"); graphics->beginShaderCompilation(ShaderCompilationInfo{ .name = "TextVertex", diff --git a/src/Engine/Graphics/VertexData.cpp b/src/Engine/Graphics/VertexData.cpp index 30ef637..ab39581 100644 --- a/src/Engine/Graphics/VertexData.cpp +++ b/src/Engine/Graphics/VertexData.cpp @@ -140,11 +140,16 @@ void VertexData::createDescriptors() { void VertexData::loadMesh(MeshId id, Array loadedIndices, Array loadedMeshlets) { std::unique_lock l(vertexDataLock); - for (auto&& chunk : loadedMeshlets | std::views::chunk(2048)) { + uint32 numChunks = (loadedMeshlets.size() + 2047) / 2048; + for(uint32 chunkIdx = 0; chunkIdx < numChunks; ++chunkIdx) + { uint32 meshletOffset = (uint32)meshlets.size(); AABB meshAABB; uint32 numMeshlets = 0; - for (auto&& m : chunk) { + uint32 chunkOffset = chunkIdx * 2048; + uint32 numRemaining = loadedMeshlets.size() - chunkOffset; + for (uint32 chunk = 0; chunk < std::min(numRemaining, 2048u); chunk++) { + Meshlet& m = loadedMeshlets[chunkOffset + chunk]; numMeshlets++; //... meshAABB = meshAABB.combine(m.boundingBox); @@ -169,6 +174,7 @@ void VertexData::loadMesh(MeshId id, Array loadedIndices, Array .numMeshlets = numMeshlets, .meshletOffset = meshletOffset, }); + } // todo: in case of a index split for 16 bit, do something here meshData[id][0].firstIndex = (uint32)indices.size(); diff --git a/src/Engine/Graphics/Vulkan/Graphics.cpp b/src/Engine/Graphics/Vulkan/Graphics.cpp index bb1af95..542cb0e 100644 --- a/src/Engine/Graphics/Vulkan/Graphics.cpp +++ b/src/Engine/Graphics/Vulkan/Graphics.cpp @@ -171,8 +171,9 @@ Gfx::OViewport Graphics::createViewport(Gfx::PWindow owner, const ViewportCreate return new Viewport(owner, viewportInfo); } -Gfx::ORenderPass Graphics::createRenderPass(Gfx::RenderTargetLayout layout, Array dependencies, std::string name, +Gfx::ORenderPass Graphics::createRenderPass(Gfx::RenderTargetLayout layout, Array dependencies, URect renderArea, std::string name, Array viewMasks, Array correlationMasks) { + // todo: re-introduce render area to renderpass return new RenderPass(this, std::move(layout), std::move(dependencies), name, std::move(viewMasks), std::move(correlationMasks)); } void Graphics::beginRenderPass(Gfx::PRenderPass renderPass) { diff --git a/src/Engine/Graphics/Vulkan/Graphics.h b/src/Engine/Graphics/Vulkan/Graphics.h index 5b7e7b5..535026e 100644 --- a/src/Engine/Graphics/Vulkan/Graphics.h +++ b/src/Engine/Graphics/Vulkan/Graphics.h @@ -34,7 +34,7 @@ class Graphics : public Gfx::Graphics { virtual Gfx::OWindow createWindow(const WindowCreateInfo& createInfo) override; virtual Gfx::OViewport createViewport(Gfx::PWindow owner, const ViewportCreateInfo& createInfo) override; - virtual Gfx::ORenderPass createRenderPass(Gfx::RenderTargetLayout layout, Array dependencies, std::string name, + virtual Gfx::ORenderPass createRenderPass(Gfx::RenderTargetLayout layout, Array dependencies, URect renderArea, std::string name, Array viewMasks, Array correlationMasks) override; virtual void beginRenderPass(Gfx::PRenderPass renderPass) override; virtual void endRenderPass() override; diff --git a/src/Engine/Material/Material.cpp b/src/Engine/Material/Material.cpp index f9255bd..d0785a4 100644 --- a/src/Engine/Material/Material.cpp +++ b/src/Engine/Material/Material.cpp @@ -170,7 +170,9 @@ void Material::compile() { for (const auto& expr : codeExpressions) { codeStream << "\t\t" << expr->evaluate(varState); } - for (const auto& [name, exp] : brdf.variables) { + //for (const auto& [name, exp] : brdf.variables) { + for(auto it = brdf.variables.begin(); it != brdf.variables.end(); ++it){ + auto [name, exp] = *it; codeStream << "\t\tresult." << name << " = " << varState[exp] << ";" << std::endl; } codeStream << "\t\tresult.transformNormal(input.tangentToWorld);" << std::endl; diff --git a/src/Engine/Platform/Mac/GameInterface.cpp b/src/Engine/Platform/Mac/GameInterface.cpp index bb690a3..161e494 100644 --- a/src/Engine/Platform/Mac/GameInterface.cpp +++ b/src/Engine/Platform/Mac/GameInterface.cpp @@ -1,8 +1,10 @@ #include "GameInterface.h" +#include "dlfcn.h" +#include using namespace Seele; -GameInterface::GameInterface(std::string soPath) : lib(NULL), soPath(soPath) {} +GameInterface::GameInterface(std::filesystem::path soPath) : lib(NULL), soPath(soPath) {} GameInterface::~GameInterface() {} @@ -13,6 +15,7 @@ void GameInterface::reload() { destroyInstance(game); dlclose(lib); } + std::filesystem::copy(soPath.parent_path().parent_path() / "res" / "shaders", "shaders/game", std::filesystem::copy_options::overwrite_existing); lib = dlopen(soPath.c_str(), RTLD_NOW); createInstance = (decltype(createInstance))dlsym(lib, "createInstance"); destroyInstance = (decltype(destroyInstance))dlsym(lib, "destroyInstance"); diff --git a/src/Engine/Platform/Mac/GameInterface.h b/src/Engine/Platform/Mac/GameInterface.h index 7b0a2d9..c8df33b 100644 --- a/src/Engine/Platform/Mac/GameInterface.h +++ b/src/Engine/Platform/Mac/GameInterface.h @@ -1,18 +1,18 @@ #pragma once #include "Game.h" -#include "dlfcn.h" +#include namespace Seele { class GameInterface { public: - GameInterface(std::string soPath); + GameInterface(std::filesystem::path soPath); ~GameInterface(); Game* getGame(); void reload(); private: void* lib; - std::string soPath; + std::filesystem::path soPath; Game* game; Game* (*createInstance)() = nullptr; void (*destroyInstance)(Game*) = nullptr;