From 8491191e9116c399e3ae6a365338db1a0ed74eda Mon Sep 17 00:00:00 2001 From: Malkierian Date: Sun, 12 Oct 2025 15:33:44 -0700 Subject: [PATCH 1/3] Add `RunGuiOnly` to `interpreter` to run ImGui interface without game commands. --- include/fast/Fast3dWindow.h | 1 + include/fast/interpreter.h | 1 + src/fast/Fast3dWindow.cpp | 4 ++++ src/fast/interpreter.cpp | 40 +++++++++++++++++++++++++++++++++++++ 4 files changed, 46 insertions(+) diff --git a/include/fast/Fast3dWindow.h b/include/fast/Fast3dWindow.h index c9cb9c20c..ccd9284ee 100644 --- a/include/fast/Fast3dWindow.h +++ b/include/fast/Fast3dWindow.h @@ -18,6 +18,7 @@ class Fast3dWindow : public Ship::Window { void Init() override; void Close() override; + void RunGuiOnly(); void StartFrame() override; void EndFrame() override; bool IsFrameReady() override; diff --git a/include/fast/interpreter.h b/include/fast/interpreter.h index 2df3e4f21..b95accde9 100644 --- a/include/fast/interpreter.h +++ b/include/fast/interpreter.h @@ -363,6 +363,7 @@ class Interpreter { void GetDimensions(uint32_t* width, uint32_t* height, int32_t* posX, int32_t* posY); GfxRenderingAPI* GetCurrentRenderingAPI(); void StartFrame(); + void RunGuiOnly(); void Run(Gfx* commands, const std::unordered_map& mtx_replacements); void EndFrame(); void HandleWindowEvents(); diff --git a/src/fast/Fast3dWindow.cpp b/src/fast/Fast3dWindow.cpp index 6267090d1..124c1d7a1 100644 --- a/src/fast/Fast3dWindow.cpp +++ b/src/fast/Fast3dWindow.cpp @@ -166,6 +166,10 @@ void Fast3dWindow::Close() { mWindowManagerApi->Close(); } +void Fast3dWindow::RunGuiOnly() { + mInterpreter->RunGuiOnly(); +} + void Fast3dWindow::StartFrame() { mInterpreter->StartFrame(); } diff --git a/src/fast/interpreter.cpp b/src/fast/interpreter.cpp index e13ccea3b..171cfb108 100644 --- a/src/fast/interpreter.cpp +++ b/src/fast/interpreter.cpp @@ -4293,6 +4293,46 @@ void Interpreter::StartFrame() { GfxExecStack g_exec_stack = {}; +void Interpreter::RunGuiOnly() { + SpReset(); + + mGetPixelDepthPending.clear(); + mGetPixelDepthCached.clear(); + + mRapi->UpdateFramebufferParameters(0, mGfxCurrentWindowDimensions.width, mGfxCurrentWindowDimensions.height, 1, + false, true, true, !mRendersToFb); + mRapi->StartFrame(); + mRapi->StartDrawToFramebuffer(mRendersToFb ? mGameFb : 0, (float)mCurDimensions.height / mNativeDimensions.height); + mRapi->ClearFramebuffer(false, true); + mRdp->viewport_or_scissor_changed = true; + mRenderingState.viewport = {}; + mRenderingState.scissor = {}; + + Flush(); + mGfxFrameBuffer = 0; + + if (mRendersToFb) { + mRapi->StartDrawToFramebuffer(0, 1); + mRapi->ClearFramebuffer(true, true); + if (mMsaaLevel > 1) { + if (!ViewportMatchesRendererResolution()) { + mRapi->ResolveMSAAColorBuffer(mGameFbMsaaResolved, mGameFb); + mGfxFrameBuffer = (uintptr_t)mRapi->GetFramebufferTextureId(mGameFbMsaaResolved); + } else { + mRapi->ResolveMSAAColorBuffer(0, mGameFb); + } + } else { + mGfxFrameBuffer = (uintptr_t)mRapi->GetFramebufferTextureId(mGameFb); + } + } else if (mFbActive) { + // Failsafe reset to main framebuffer to prevent softlocking the renderer + mFbActive = 0; + mRapi->StartDrawToFramebuffer(0, 1); + + assert(0 && "active framebuffer was never reset back to original"); + } +} + void Interpreter::Run(Gfx* commands, const std::unordered_map& mtx_replacements) { SpReset(); From 123c57b69fb6eba7eae9e3d72c657e89ba18f649 Mon Sep 17 00:00:00 2001 From: Malkierian Date: Sun, 26 Oct 2025 23:13:30 -0700 Subject: [PATCH 2/3] clang --- src/fast/interpreter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fast/interpreter.cpp b/src/fast/interpreter.cpp index 1f0ad689f..d703b384b 100644 --- a/src/fast/interpreter.cpp +++ b/src/fast/interpreter.cpp @@ -4308,7 +4308,7 @@ void Interpreter::RunGuiOnly() { mGetPixelDepthCached.clear(); mRapi->UpdateFramebufferParameters(0, mGfxCurrentWindowDimensions.width, mGfxCurrentWindowDimensions.height, 1, - false, true, true, !mRendersToFb); + false, true, true, !mRendersToFb); mRapi->StartFrame(); mRapi->StartDrawToFramebuffer(mRendersToFb ? mGameFb : 0, (float)mCurDimensions.height / mNativeDimensions.height); mRapi->ClearFramebuffer(false, true); From 9c6bc2a213064ce3b1d935a483124b46cb9b6afa Mon Sep 17 00:00:00 2001 From: Malkierian Date: Sun, 2 Nov 2025 13:30:21 -0700 Subject: [PATCH 3/3] Add `RunGuiOnly` to `Window.h` and override with `Fast3dWindow`. --- include/fast/Fast3dWindow.h | 2 +- include/ship/window/Window.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/include/fast/Fast3dWindow.h b/include/fast/Fast3dWindow.h index 25c20d076..6b2f603f3 100644 --- a/include/fast/Fast3dWindow.h +++ b/include/fast/Fast3dWindow.h @@ -16,7 +16,7 @@ class Fast3dWindow : public Ship::Window { void Init() override; void Close() override; - void RunGuiOnly(); + void RunGuiOnly() override; void StartFrame() override; void EndFrame() override; bool IsFrameReady() override; diff --git a/include/ship/window/Window.h b/include/ship/window/Window.h index 389e38cd3..b7dca53e5 100644 --- a/include/ship/window/Window.h +++ b/include/ship/window/Window.h @@ -35,6 +35,7 @@ class Window { virtual void Init() = 0; virtual void Close() = 0; + virtual void RunGuiOnly() = 0; virtual void StartFrame() = 0; virtual void EndFrame() = 0; virtual bool IsFrameReady() = 0;