Application refactor #2

Merged
Dynamitos merged 4 commits from coding-agent/Seele:application-refactor into master 2026-11-09 20:07:56 +01:00
7 changed files with 20 additions and 27 deletions
Showing only changes of commit 1f7e7e0541 - Show all commits

No files matched your search

+6 -6
View File
@@ -141,12 +141,6 @@ int main(int argc, char** argv) {
StaticMeshVertexData* vd = StaticMeshVertexData::getInstance(); StaticMeshVertexData* vd = StaticMeshVertexData::getInstance();
vd->init(graphics); 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); AssetRegistry::init(sourcePath / "Assets", graphics);
AssetImporter::init(graphics); AssetImporter::init(graphics);
AssetImporter::importFont(FontImportArgs{ AssetImporter::importFont(FontImportArgs{
@@ -174,6 +168,12 @@ int main(int argc, char** argv) {
}); });
getThreadPool().waitIdle(); 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(); vd->commitMeshes();
WindowCreateInfo mainWindowInfo = { WindowCreateInfo mainWindowInfo = {
.width = 1920, .width = 1920,
+3 -11
View File
@@ -8,7 +8,7 @@
using namespace Seele; 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"}); elementBuffer = graphics->createShaderBuffer(ShaderBufferCreateInfo{.name = "RenderStyleElements"});
uiDescriptorLayout = graphics->createDescriptorLayout("pParams"); uiDescriptorLayout = graphics->createDescriptorLayout("pParams");
@@ -119,8 +119,8 @@ void UIPass::publishOutputs() {}
void UIPass::createRenderPass() { void UIPass::createRenderPass() {
TextureCreateInfo depthBufferInfo = { TextureCreateInfo depthBufferInfo = {
.format = Gfx::SE_FORMAT_D32_SFLOAT, .format = Gfx::SE_FORMAT_D32_SFLOAT,
.width = viewport->getWidth(), .width = viewport->getOwner()->getFramebufferWidth(),
.height = viewport->getHeight(), .height = viewport->getOwner()->getFramebufferHeight(),
.usage = Gfx::SE_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, .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); Gfx::SE_ATTACHMENT_LOAD_OP_CLEAR, Gfx::SE_ATTACHMENT_STORE_OP_STORE);
colorAttachment.clear.color = {{1.0f, 1.0f, 1.0f, 1.0f}}; 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{ Gfx::RenderTargetLayout layout = Gfx::RenderTargetLayout{
.colorAttachments = {colorAttachment}, .colorAttachments = {colorAttachment},
.depthAttachment = depthAttachment, .depthAttachment = depthAttachment,
-1
View File
@@ -70,7 +70,6 @@ class UIPass : public RenderPass {
Gfx::PGraphicsPipeline uiPipeline; Gfx::PGraphicsPipeline uiPipeline;
UI::PSystem system; UI::PSystem system;
UVector2 passSize; // last viewport size the render pass was created at; recreate on resize
Array<UI::UIRender> renderElements; Array<UI::UIRender> renderElements;
Array<RenderElementStyle> elements; Array<RenderElementStyle> elements;
Gfx::OShaderBuffer elementBuffer; Gfx::OShaderBuffer elementBuffer;
+1 -4
View File
@@ -68,10 +68,7 @@ Framebuffer::Framebuffer(PGraphics graphics, PRenderPass renderPass, Gfx::Render
.layers = 1, .layers = 1,
}; };
VK_CHECK(vkCreateFramebuffer(graphics->getDevice(), &createInfo, nullptr, &handle)); VK_CHECK(vkCreateFramebuffer(graphics->getDevice(), &createInfo, nullptr, &handle));
renderArea = VkRect2D{ renderArea = renderPass->getRenderArea();
.offset = {0, 0},
.extent = {width, height},
};
hash = CRC::Calculate(&description, sizeof(FramebufferDescription), CRC::CRC_32()); hash = CRC::Calculate(&description, sizeof(FramebufferDescription), CRC::CRC_32());
} }
+2 -3
View File
@@ -234,10 +234,9 @@ Gfx::OViewport Graphics::createViewport(Gfx::PWindow owner, const ViewportCreate
return new Viewport(owner, viewportInfo); return new Viewport(owner, viewportInfo);
} }
Gfx::ORenderPass Graphics::createRenderPass(Gfx::RenderTargetLayout layout, Array<Gfx::SubPassDependency> dependencies, URect, Gfx::ORenderPass Graphics::createRenderPass(Gfx::RenderTargetLayout layout, Array<Gfx::SubPassDependency> dependencies, URect renderArea,
std::string name, Array<uint32> viewMasks, Array<uint32> correlationMasks) { std::string name, Array<uint32> viewMasks, Array<uint32> correlationMasks) {
// todo: re-introduce render area to renderpass return new RenderPass(this, std::move(layout), std::move(dependencies), renderArea, name, std::move(viewMasks), std::move(correlationMasks));
return new RenderPass(this, std::move(layout), std::move(dependencies), name, std::move(viewMasks), std::move(correlationMasks));
} }
void Graphics::beginRenderPass(Gfx::PRenderPass renderPass) { void Graphics::beginRenderPass(Gfx::PRenderPass renderPass) {
PRenderPass rp = renderPass.cast<RenderPass>(); PRenderPass rp = renderPass.cast<RenderPass>();
+5 -1
View File
@@ -9,9 +9,13 @@
using namespace Seele; using namespace Seele;
using namespace Seele::Vulkan; using namespace Seele::Vulkan;
RenderPass::RenderPass(PGraphics graphics, Gfx::RenderTargetLayout _layout, Array<Gfx::SubPassDependency> _dependencies, std::string name, RenderPass::RenderPass(PGraphics graphics, Gfx::RenderTargetLayout _layout, Array<Gfx::SubPassDependency> _dependencies, URect _renderArea, std::string name,
Array<uint32> viewMasks, Array<uint32> correlationMasks) Array<uint32> viewMasks, Array<uint32> correlationMasks)
: Gfx::RenderPass(std::move(_layout), std::move(_dependencies)), graphics(graphics), name(name) { : 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; subpassContents = VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS;
Array<VkAttachmentDescription2> attachments; Array<VkAttachmentDescription2> attachments;
Array<VkAttachmentReference2> inputRefs; Array<VkAttachmentReference2> inputRefs;
+3 -1
View File
@@ -2,13 +2,14 @@
#include "Graphics.h" #include "Graphics.h"
#include "Resources.h" #include "Resources.h"
#include "Graphics/RenderTarget.h" #include "Graphics/RenderTarget.h"
#include <vulkan/vulkan_core.h>
namespace Seele { namespace Seele {
namespace Vulkan { namespace Vulkan {
class RenderPass : public Gfx::RenderPass { class RenderPass : public Gfx::RenderPass {
public: public:
RenderPass(PGraphics graphics, Gfx::RenderTargetLayout layout, Array<Gfx::SubPassDependency> dependencies, std::string name, RenderPass(PGraphics graphics, Gfx::RenderTargetLayout layout, Array<Gfx::SubPassDependency> dependencies, URect renderArea, std::string name,
Array<uint32> viewMasks = {}, Array<uint32> correlationMasks = {}); Array<uint32> viewMasks = {}, Array<uint32> correlationMasks = {});
virtual ~RenderPass(); virtual ~RenderPass();
uint32 getFramebufferHash(); uint32 getFramebufferHash();
@@ -17,6 +18,7 @@ class RenderPass : public Gfx::RenderPass {
constexpr size_t getClearValueCount() const { return clearValues.size(); } constexpr size_t getClearValueCount() const { return clearValues.size(); }
constexpr VkClearValue* getClearValues() const { return clearValues.data(); } constexpr VkClearValue* getClearValues() const { return clearValues.data(); }
constexpr VkSubpassContents getSubpassContents() const { return subpassContents; } constexpr VkSubpassContents getSubpassContents() const { return subpassContents; }
constexpr VkRect2D getRenderArea() const { return renderArea; }
constexpr const std::string& getName() const { return name; } constexpr const std::string& getName() const { return name; }
constexpr PRenderPassHandle getCommandHandle() const { return renderPass; } constexpr PRenderPassHandle getCommandHandle() const { return renderPass; }