From ed650f2b468ab951c7606d232f0a34e97c51eb77 Mon Sep 17 00:00:00 2001 From: RSDuck Date: Thu, 21 Dec 2023 21:43:57 +0100 Subject: [PATCH 1/2] call Reset on 3D renderer object --- src/GPU3D.cpp | 9 +++++++++ src/GPU3D.h | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/GPU3D.cpp b/src/GPU3D.cpp index ac29a1e4..47877021 100644 --- a/src/GPU3D.cpp +++ b/src/GPU3D.cpp @@ -146,6 +146,12 @@ GPU3D::GPU3D(melonDS::NDS& nds, std::unique_ptr&& renderer) noexcept { } +void GPU3D::SetCurrentRenderer(std::unique_ptr&& renderer) noexcept +{ + CurrentRenderer = std::move(renderer); + CurrentRenderer->Reset(NDS.GPU); +} + void GPU3D::ResetRenderingState() noexcept { RenderNumPolygons = 0; @@ -282,6 +288,9 @@ void GPU3D::Reset() noexcept FlushAttributes = 0; RenderXPos = 0; + + if (CurrentRenderer) + CurrentRenderer->Reset(NDS.GPU); } void GPU3D::DoSavestate(Savestate* file) noexcept diff --git a/src/GPU3D.h b/src/GPU3D.h index 0c900c6c..7c42eeb5 100644 --- a/src/GPU3D.h +++ b/src/GPU3D.h @@ -117,7 +117,7 @@ public: [[nodiscard]] bool IsRendererAccelerated() const noexcept; [[nodiscard]] Renderer3D& GetCurrentRenderer() noexcept { return *CurrentRenderer; } [[nodiscard]] const Renderer3D& GetCurrentRenderer() const noexcept { return *CurrentRenderer; } - void SetCurrentRenderer(std::unique_ptr&& renderer) noexcept { CurrentRenderer = std::move(renderer); } + void SetCurrentRenderer(std::unique_ptr&& renderer) noexcept; u8 Read8(u32 addr) noexcept; u16 Read16(u32 addr) noexcept; From 084747abc52b22ace7ae02b895b343a789af7c67 Mon Sep 17 00:00:00 2001 From: RSDuck Date: Thu, 21 Dec 2023 22:15:12 +0100 Subject: [PATCH 2/2] Reset DS object directly after creation --- src/frontend/qt_sdl/main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/frontend/qt_sdl/main.cpp b/src/frontend/qt_sdl/main.cpp index 9ada19b4..0d775a58 100644 --- a/src/frontend/qt_sdl/main.cpp +++ b/src/frontend/qt_sdl/main.cpp @@ -335,6 +335,7 @@ bool EmuThread::UpdateConsole(UpdateConsoleNDSArgs&& ndsargs, UpdateConsoleGBAAr NDS::Current = nullptr; NDS = CreateConsole(std::move(nextndscart), std::move(nextgbacart)); + NDS->Reset(); NDS::Current = NDS.get(); return NDS != nullptr;