VERY experimental Nintendo Switch 2 emulator
C++
emu_window: Remove global system instance
lat9nqd15ff8a89b2f
diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp b/src/yuzu_cmd/emu_window/emu_window_sdl2.cppindex ea3e0ada4b..f643a4b0b0 100644--- a/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp+++ b/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp@@ -16,8 +16,8 @@#include "yuzu_cmd/emu_window/emu_window_sdl2.h"#include "yuzu_cmd/yuzu_icon.h"-EmuWindow_SDL2::EmuWindow_SDL2(InputCommon::InputSubsystem* input_subsystem_)- : input_subsystem{input_subsystem_} {+EmuWindow_SDL2::EmuWindow_SDL2(InputCommon::InputSubsystem* input_subsystem_, Core::System& system_)+ : input_subsystem{input_subsystem_}, system{system_} {if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0) {LOG_CRITICAL(Frontend, "Failed to initialize SDL2! Exiting...");exit(1);@@ -218,7 +218,7 @@ void EmuWindow_SDL2::WaitEvent() {const u32 current_time = SDL_GetTicks();if (current_time > last_time + 2000) {- const auto results = Core::System::GetInstance().GetAndResetPerfStats();+ const auto results = system.GetAndResetPerfStats();const auto title =fmt::format("yuzu {} | {}-{} | FPS: {:.0f} ({:.0f}%)", Common::g_build_fullname,Common::g_scm_branch, Common::g_scm_desc, results.average_game_fps,diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2.h b/src/yuzu_cmd/emu_window/emu_window_sdl2.hindex 1b9ab5b934..aa0d52ae42 100644--- a/src/yuzu_cmd/emu_window/emu_window_sdl2.h+++ b/src/yuzu_cmd/emu_window/emu_window_sdl2.h@@ -24,7 +24,7 @@ enum class MouseButton;class EmuWindow_SDL2 : public Core::Frontend::EmuWindow {public:- explicit EmuWindow_SDL2(InputCommon::InputSubsystem* input_subsystem);+ explicit EmuWindow_SDL2(InputCommon::InputSubsystem* input_subsystem, Core::System& system_);~EmuWindow_SDL2();/// Whether the window is still open, and a close request hasn't yet been sent@@ -87,4 +87,7 @@ protected:/// Input subsystem to use with this window.InputCommon::InputSubsystem* input_subsystem;++ /// yuzu core instance+ Core::System& system;};diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2_gl.cpp b/src/yuzu_cmd/emu_window/emu_window_sdl2_gl.cppindex eadb41790e..5b98c255ba 100644--- a/src/yuzu_cmd/emu_window/emu_window_sdl2_gl.cpp+++ b/src/yuzu_cmd/emu_window/emu_window_sdl2_gl.cpp@@ -76,8 +76,9 @@ bool EmuWindow_SDL2_GL::SupportsRequiredGLExtensions() {return unsupported_ext.empty();}-EmuWindow_SDL2_GL::EmuWindow_SDL2_GL(InputCommon::InputSubsystem* input_subsystem, bool fullscreen)- : EmuWindow_SDL2{input_subsystem} {+EmuWindow_SDL2_GL::EmuWindow_SDL2_GL(InputCommon::InputSubsystem* input_subsystem,+ Core::System& system_, bool fullscreen)+ : EmuWindow_SDL2{input_subsystem, system_} {SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4);SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 6);SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY);diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2_gl.h b/src/yuzu_cmd/emu_window/emu_window_sdl2_gl.hindex 9e694d9855..d7f2c83d8d 100644--- a/src/yuzu_cmd/emu_window/emu_window_sdl2_gl.h+++ b/src/yuzu_cmd/emu_window/emu_window_sdl2_gl.h@@ -8,13 +8,18 @@#include "core/frontend/emu_window.h"#include "yuzu_cmd/emu_window/emu_window_sdl2.h"+namespace Core {+class System;+}+namespace InputCommon {class InputSubsystem;}class EmuWindow_SDL2_GL final : public EmuWindow_SDL2 {public:- explicit EmuWindow_SDL2_GL(InputCommon::InputSubsystem* input_subsystem, bool fullscreen);+ explicit EmuWindow_SDL2_GL(InputCommon::InputSubsystem* input_subsystem, Core::System& system_,+ bool fullscreen);~EmuWindow_SDL2_GL();std::unique_ptr<Core::Frontend::GraphicsContext> CreateSharedContext() const override;diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.cpp b/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.cppindex d1473dbab4..cdda375d8d 100644--- a/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.cpp+++ b/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.cpp@@ -24,8 +24,9 @@#include <SDL.h>#include <SDL_syswm.h>-EmuWindow_SDL2_VK::EmuWindow_SDL2_VK(InputCommon::InputSubsystem* input_subsystem, bool fullscreen)- : EmuWindow_SDL2{input_subsystem} {+EmuWindow_SDL2_VK::EmuWindow_SDL2_VK(InputCommon::InputSubsystem* input_subsystem,+ Core::System& system_, bool fullscreen)+ : EmuWindow_SDL2{input_subsystem, system_} {const std::string window_title = fmt::format("yuzu {} | {}-{} (Vulkan)", Common::g_build_name,Common::g_scm_branch, Common::g_scm_desc);render_window =diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.h b/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.hindex de53844f05..3ea521b2a4 100644--- a/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.h+++ b/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.h@@ -19,7 +19,8 @@ class InputSubsystem;class EmuWindow_SDL2_VK final : public EmuWindow_SDL2 {public:- explicit EmuWindow_SDL2_VK(InputCommon::InputSubsystem* input_subsystem, bool fullscreen);+ explicit EmuWindow_SDL2_VK(InputCommon::InputSubsystem* input_subsystem, Core::System& system,+ bool fullscreen);~EmuWindow_SDL2_VK() override;std::unique_ptr<Core::Frontend::GraphicsContext> CreateSharedContext() const override;diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cppindex 35ce23696a..c10093820a 100644--- a/src/yuzu_cmd/yuzu.cpp+++ b/src/yuzu_cmd/yuzu.cpp@@ -172,10 +172,10 @@ int main(int argc, char** argv) {std::unique_ptr<EmuWindow_SDL2> emu_window;switch (Settings::values.renderer_backend.GetValue()) {case Settings::RendererBackend::OpenGL:- emu_window = std::make_unique<EmuWindow_SDL2_GL>(&input_subsystem, fullscreen);+ emu_window = std::make_unique<EmuWindow_SDL2_GL>(&input_subsystem, system, fullscreen);break;case Settings::RendererBackend::Vulkan:- emu_window = std::make_unique<EmuWindow_SDL2_VK>(&input_subsystem, fullscreen);+ emu_window = std::make_unique<EmuWindow_SDL2_VK>(&input_subsystem, system, fullscreen);break;}