From e0c396b533ab40090d8412df196dbbeb488e9d3e Mon Sep 17 00:00:00 2001 From: Dynamitos Date: Mon, 9 Nov 2026 20:06:47 +0100 Subject: [PATCH] Engine is up and running --- src/Editor/main.cpp | 12 ++++++------ src/Engine/Graphics/RenderPass/UIPass.cpp | 14 +++----------- src/Engine/Graphics/RenderPass/UIPass.h | 1 - src/Engine/Graphics/Vulkan/Framebuffer.cpp | 5 +---- src/Engine/Graphics/Vulkan/Graphics.cpp | 5 ++--- src/Engine/Graphics/Vulkan/RenderPass.cpp | 6 +++++- src/Engine/Graphics/Vulkan/RenderPass.h | 4 +++- 7 files changed, 20 insertions(+), 27 deletions(-) diff --git a/src/Editor/main.cpp b/src/Editor/main.cpp index db0e1e9..c242826 100644 --- a/src/Editor/main.cpp +++ b/src/Editor/main.cpp @@ -141,12 +141,6 @@ int main(int argc, char** argv) { StaticMeshVertexData* vd = StaticMeshVertexData::getInstance(); vd->init(graphics); - // The world (Scene + SystemGraph) and the game binary are owned by the - // Application from here on. `loadGame` dlopen's the .so, lets the game - // populate the scene+graph, and appends the editor's own systems. Views - // below only render the non-owning application->scene() handle. - OApplication application = new Application(); - application->loadGame(graphics, sourcePath, gameName); AssetRegistry::init(sourcePath / "Assets", graphics); AssetImporter::init(graphics); AssetImporter::importFont(FontImportArgs{ @@ -174,6 +168,12 @@ int main(int argc, char** argv) { }); getThreadPool().waitIdle(); + // The world (Scene + SystemGraph) and the game binary are owned by the + // Application from here on. `loadGame` dlopen's the .so, lets the game + // populate the scene+graph, and appends the editor's own systems. Views + // below only render the non-owning application->scene() handle. + OApplication application = new Application(); + application->loadGame(graphics, sourcePath, gameName); vd->commitMeshes(); WindowCreateInfo mainWindowInfo = { .width = 1920, diff --git a/src/Engine/Graphics/RenderPass/UIPass.cpp b/src/Engine/Graphics/RenderPass/UIPass.cpp index 4cde135..6139b96 100644 --- a/src/Engine/Graphics/RenderPass/UIPass.cpp +++ b/src/Engine/Graphics/RenderPass/UIPass.cpp @@ -8,7 +8,7 @@ using namespace Seele; -UIPass::UIPass(Gfx::PGraphics graphics, UI::PSystem system) : RenderPass(graphics), system(system), passSize(0, 0) { +UIPass::UIPass(Gfx::PGraphics graphics, UI::PSystem system) : RenderPass(graphics), system(system) { elementBuffer = graphics->createShaderBuffer(ShaderBufferCreateInfo{.name = "RenderStyleElements"}); uiDescriptorLayout = graphics->createDescriptorLayout("pParams"); @@ -119,8 +119,8 @@ void UIPass::publishOutputs() {} void UIPass::createRenderPass() { TextureCreateInfo depthBufferInfo = { .format = Gfx::SE_FORMAT_D32_SFLOAT, - .width = viewport->getWidth(), - .height = viewport->getHeight(), + .width = viewport->getOwner()->getFramebufferWidth(), + .height = viewport->getOwner()->getFramebufferHeight(), .usage = Gfx::SE_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, }; @@ -134,14 +134,6 @@ void UIPass::createRenderPass() { Gfx::SE_ATTACHMENT_LOAD_OP_CLEAR, Gfx::SE_ATTACHMENT_STORE_OP_STORE); colorAttachment.clear.color = {{1.0f, 1.0f, 1.0f, 1.0f}}; - // the render pass encodes the viewport size, and Vulkan requires a fresh pass object when - // that changes. Re-run createRenderPass() from beginFrame on a viewport resize; the - // pipeline is recreated here from scratch (it embeds renderPass and is size-independent - // otherwise). - if (passSize.x != viewport->getWidth() || passSize.y != viewport->getHeight()) { - passSize = UVector2(viewport->getWidth(), viewport->getHeight()); - createRenderPass(); - } Gfx::RenderTargetLayout layout = Gfx::RenderTargetLayout{ .colorAttachments = {colorAttachment}, .depthAttachment = depthAttachment, diff --git a/src/Engine/Graphics/RenderPass/UIPass.h b/src/Engine/Graphics/RenderPass/UIPass.h index 21cc074..fc5425f 100644 --- a/src/Engine/Graphics/RenderPass/UIPass.h +++ b/src/Engine/Graphics/RenderPass/UIPass.h @@ -70,7 +70,6 @@ class UIPass : public RenderPass { Gfx::PGraphicsPipeline uiPipeline; UI::PSystem system; - UVector2 passSize; // last viewport size the render pass was created at; recreate on resize Array renderElements; Array elements; Gfx::OShaderBuffer elementBuffer; diff --git a/src/Engine/Graphics/Vulkan/Framebuffer.cpp b/src/Engine/Graphics/Vulkan/Framebuffer.cpp index 670c653..576b295 100644 --- a/src/Engine/Graphics/Vulkan/Framebuffer.cpp +++ b/src/Engine/Graphics/Vulkan/Framebuffer.cpp @@ -68,10 +68,7 @@ Framebuffer::Framebuffer(PGraphics graphics, PRenderPass renderPass, Gfx::Render .layers = 1, }; VK_CHECK(vkCreateFramebuffer(graphics->getDevice(), &createInfo, nullptr, &handle)); - renderArea = VkRect2D{ - .offset = {0, 0}, - .extent = {width, height}, - }; + renderArea = renderPass->getRenderArea(); hash = CRC::Calculate(&description, sizeof(FramebufferDescription), CRC::CRC_32()); } diff --git a/src/Engine/Graphics/Vulkan/Graphics.cpp b/src/Engine/Graphics/Vulkan/Graphics.cpp index 74c16e3..47852d6 100644 --- a/src/Engine/Graphics/Vulkan/Graphics.cpp +++ b/src/Engine/Graphics/Vulkan/Graphics.cpp @@ -234,10 +234,9 @@ Gfx::OViewport Graphics::createViewport(Gfx::PWindow owner, const ViewportCreate return new Viewport(owner, viewportInfo); } -Gfx::ORenderPass Graphics::createRenderPass(Gfx::RenderTargetLayout layout, Array dependencies, URect, +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)); + return new RenderPass(this, std::move(layout), std::move(dependencies), renderArea, name, std::move(viewMasks), std::move(correlationMasks)); } void Graphics::beginRenderPass(Gfx::PRenderPass renderPass) { PRenderPass rp = renderPass.cast(); diff --git a/src/Engine/Graphics/Vulkan/RenderPass.cpp b/src/Engine/Graphics/Vulkan/RenderPass.cpp index 5d64728..15b0eb2 100644 --- a/src/Engine/Graphics/Vulkan/RenderPass.cpp +++ b/src/Engine/Graphics/Vulkan/RenderPass.cpp @@ -9,9 +9,13 @@ using namespace Seele; using namespace Seele::Vulkan; -RenderPass::RenderPass(PGraphics graphics, Gfx::RenderTargetLayout _layout, Array _dependencies, std::string name, +RenderPass::RenderPass(PGraphics graphics, Gfx::RenderTargetLayout _layout, Array _dependencies, URect _renderArea, std::string name, Array viewMasks, Array correlationMasks) : Gfx::RenderPass(std::move(_layout), std::move(_dependencies)), graphics(graphics), name(name) { + renderArea = { + .offset = { (int32)_renderArea.offset.x, (int32)_renderArea.offset.y }, + .extent = { _renderArea.size.x, _renderArea.size.y }, + }; subpassContents = VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS; Array attachments; Array inputRefs; diff --git a/src/Engine/Graphics/Vulkan/RenderPass.h b/src/Engine/Graphics/Vulkan/RenderPass.h index 3e057fe..65ebb67 100644 --- a/src/Engine/Graphics/Vulkan/RenderPass.h +++ b/src/Engine/Graphics/Vulkan/RenderPass.h @@ -2,13 +2,14 @@ #include "Graphics.h" #include "Resources.h" #include "Graphics/RenderTarget.h" +#include namespace Seele { namespace Vulkan { class RenderPass : public Gfx::RenderPass { public: - RenderPass(PGraphics graphics, Gfx::RenderTargetLayout layout, Array dependencies, std::string name, + RenderPass(PGraphics graphics, Gfx::RenderTargetLayout layout, Array dependencies, URect renderArea, std::string name, Array viewMasks = {}, Array correlationMasks = {}); virtual ~RenderPass(); uint32 getFramebufferHash(); @@ -17,6 +18,7 @@ class RenderPass : public Gfx::RenderPass { constexpr size_t getClearValueCount() const { return clearValues.size(); } constexpr VkClearValue* getClearValues() const { return clearValues.data(); } constexpr VkSubpassContents getSubpassContents() const { return subpassContents; } + constexpr VkRect2D getRenderArea() const { return renderArea; } constexpr const std::string& getName() const { return name; } constexpr PRenderPassHandle getCommandHandle() const { return renderPass; }