Merge pull request #6775 from lat9nq/cmd-remove-global-core
emu_window: Remove global system instance
This commit is contained in:
commit
2c7fdee7a7
7 changed files with 23 additions and 12 deletions
|
@ -16,8 +16,8 @@
|
||||||
#include "yuzu_cmd/emu_window/emu_window_sdl2.h"
|
#include "yuzu_cmd/emu_window/emu_window_sdl2.h"
|
||||||
#include "yuzu_cmd/yuzu_icon.h"
|
#include "yuzu_cmd/yuzu_icon.h"
|
||||||
|
|
||||||
EmuWindow_SDL2::EmuWindow_SDL2(InputCommon::InputSubsystem* input_subsystem_)
|
EmuWindow_SDL2::EmuWindow_SDL2(InputCommon::InputSubsystem* input_subsystem_, Core::System& system_)
|
||||||
: input_subsystem{input_subsystem_} {
|
: input_subsystem{input_subsystem_}, system{system_} {
|
||||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0) {
|
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0) {
|
||||||
LOG_CRITICAL(Frontend, "Failed to initialize SDL2! Exiting...");
|
LOG_CRITICAL(Frontend, "Failed to initialize SDL2! Exiting...");
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -218,7 +218,7 @@ void EmuWindow_SDL2::WaitEvent() {
|
||||||
|
|
||||||
const u32 current_time = SDL_GetTicks();
|
const u32 current_time = SDL_GetTicks();
|
||||||
if (current_time > last_time + 2000) {
|
if (current_time > last_time + 2000) {
|
||||||
const auto results = Core::System::GetInstance().GetAndResetPerfStats();
|
const auto results = system.GetAndResetPerfStats();
|
||||||
const auto title =
|
const auto title =
|
||||||
fmt::format("yuzu {} | {}-{} | FPS: {:.0f} ({:.0f}%)", Common::g_build_fullname,
|
fmt::format("yuzu {} | {}-{} | FPS: {:.0f} ({:.0f}%)", Common::g_build_fullname,
|
||||||
Common::g_scm_branch, Common::g_scm_desc, results.average_game_fps,
|
Common::g_scm_branch, Common::g_scm_desc, results.average_game_fps,
|
||||||
|
|
|
@ -24,7 +24,7 @@ enum class MouseButton;
|
||||||
|
|
||||||
class EmuWindow_SDL2 : public Core::Frontend::EmuWindow {
|
class EmuWindow_SDL2 : public Core::Frontend::EmuWindow {
|
||||||
public:
|
public:
|
||||||
explicit EmuWindow_SDL2(InputCommon::InputSubsystem* input_subsystem);
|
explicit EmuWindow_SDL2(InputCommon::InputSubsystem* input_subsystem, Core::System& system_);
|
||||||
~EmuWindow_SDL2();
|
~EmuWindow_SDL2();
|
||||||
|
|
||||||
/// Whether the window is still open, and a close request hasn't yet been sent
|
/// 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.
|
/// Input subsystem to use with this window.
|
||||||
InputCommon::InputSubsystem* input_subsystem;
|
InputCommon::InputSubsystem* input_subsystem;
|
||||||
|
|
||||||
|
/// yuzu core instance
|
||||||
|
Core::System& system;
|
||||||
};
|
};
|
||||||
|
|
|
@ -76,8 +76,9 @@ bool EmuWindow_SDL2_GL::SupportsRequiredGLExtensions() {
|
||||||
return unsupported_ext.empty();
|
return unsupported_ext.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
EmuWindow_SDL2_GL::EmuWindow_SDL2_GL(InputCommon::InputSubsystem* input_subsystem, bool fullscreen)
|
EmuWindow_SDL2_GL::EmuWindow_SDL2_GL(InputCommon::InputSubsystem* input_subsystem,
|
||||||
: EmuWindow_SDL2{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_MAJOR_VERSION, 4);
|
||||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 6);
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 6);
|
||||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY);
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY);
|
||||||
|
|
|
@ -8,13 +8,18 @@
|
||||||
#include "core/frontend/emu_window.h"
|
#include "core/frontend/emu_window.h"
|
||||||
#include "yuzu_cmd/emu_window/emu_window_sdl2.h"
|
#include "yuzu_cmd/emu_window/emu_window_sdl2.h"
|
||||||
|
|
||||||
|
namespace Core {
|
||||||
|
class System;
|
||||||
|
}
|
||||||
|
|
||||||
namespace InputCommon {
|
namespace InputCommon {
|
||||||
class InputSubsystem;
|
class InputSubsystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
class EmuWindow_SDL2_GL final : public EmuWindow_SDL2 {
|
class EmuWindow_SDL2_GL final : public EmuWindow_SDL2 {
|
||||||
public:
|
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();
|
~EmuWindow_SDL2_GL();
|
||||||
|
|
||||||
std::unique_ptr<Core::Frontend::GraphicsContext> CreateSharedContext() const override;
|
std::unique_ptr<Core::Frontend::GraphicsContext> CreateSharedContext() const override;
|
||||||
|
|
|
@ -24,8 +24,9 @@
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include <SDL_syswm.h>
|
#include <SDL_syswm.h>
|
||||||
|
|
||||||
EmuWindow_SDL2_VK::EmuWindow_SDL2_VK(InputCommon::InputSubsystem* input_subsystem, bool fullscreen)
|
EmuWindow_SDL2_VK::EmuWindow_SDL2_VK(InputCommon::InputSubsystem* input_subsystem,
|
||||||
: EmuWindow_SDL2{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,
|
const std::string window_title = fmt::format("yuzu {} | {}-{} (Vulkan)", Common::g_build_name,
|
||||||
Common::g_scm_branch, Common::g_scm_desc);
|
Common::g_scm_branch, Common::g_scm_desc);
|
||||||
render_window =
|
render_window =
|
||||||
|
|
|
@ -19,7 +19,8 @@ class InputSubsystem;
|
||||||
|
|
||||||
class EmuWindow_SDL2_VK final : public EmuWindow_SDL2 {
|
class EmuWindow_SDL2_VK final : public EmuWindow_SDL2 {
|
||||||
public:
|
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;
|
~EmuWindow_SDL2_VK() override;
|
||||||
|
|
||||||
std::unique_ptr<Core::Frontend::GraphicsContext> CreateSharedContext() const override;
|
std::unique_ptr<Core::Frontend::GraphicsContext> CreateSharedContext() const override;
|
||||||
|
|
|
@ -172,10 +172,10 @@ int main(int argc, char** argv) {
|
||||||
std::unique_ptr<EmuWindow_SDL2> emu_window;
|
std::unique_ptr<EmuWindow_SDL2> emu_window;
|
||||||
switch (Settings::values.renderer_backend.GetValue()) {
|
switch (Settings::values.renderer_backend.GetValue()) {
|
||||||
case Settings::RendererBackend::OpenGL:
|
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;
|
break;
|
||||||
case Settings::RendererBackend::Vulkan:
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue