early-access version 2139

This commit is contained in:
pineappleEA 2021-10-16 02:35:29 +02:00
parent 7a26c1dff6
commit 2545e9f3e9
26 changed files with 358 additions and 359 deletions

View file

@ -1,7 +1,7 @@
yuzu emulator early access yuzu emulator early access
============= =============
This is the source code for early-access 2134. This is the source code for early-access 2139.
## Legal Notice ## Legal Notice

View file

@ -180,20 +180,20 @@ std::wstring UTF8ToUTF16W(const std::string& input) {
#endif #endif
std::string StringFromFixedZeroTerminatedBuffer(const char* buffer, std::size_t max_len) { std::string StringFromFixedZeroTerminatedBuffer(std::string_view buffer, std::size_t max_len) {
std::size_t len = 0; std::size_t len = 0;
while (len < max_len && buffer[len] != '\0') while (len < buffer.length() && len < max_len && buffer[len] != '\0') {
++len; ++len;
}
return std::string(buffer, len); return std::string(buffer.begin(), buffer.begin() + len);
} }
std::u16string UTF16StringFromFixedZeroTerminatedBuffer(std::u16string_view buffer, std::u16string UTF16StringFromFixedZeroTerminatedBuffer(std::u16string_view buffer,
std::size_t max_len) { std::size_t max_len) {
std::size_t len = 0; std::size_t len = 0;
while (len < max_len && buffer[len] != '\0') while (len < buffer.length() && len < max_len && buffer[len] != '\0') {
++len; ++len;
}
return std::u16string(buffer.begin(), buffer.begin() + len); return std::u16string(buffer.begin(), buffer.begin() + len);
} }

View file

@ -63,7 +63,7 @@ template <typename InIt>
* Creates a std::string from a fixed-size NUL-terminated char buffer. If the buffer isn't * Creates a std::string from a fixed-size NUL-terminated char buffer. If the buffer isn't
* NUL-terminated then the string ends at max_len characters. * NUL-terminated then the string ends at max_len characters.
*/ */
[[nodiscard]] std::string StringFromFixedZeroTerminatedBuffer(const char* buffer, [[nodiscard]] std::string StringFromFixedZeroTerminatedBuffer(std::string_view buffer,
std::size_t max_len); std::size_t max_len);
/** /**

View file

@ -139,9 +139,9 @@ struct System::Impl {
: kernel{system}, fs_controller{system}, memory{system}, : kernel{system}, fs_controller{system}, memory{system},
cpu_manager{system}, reporter{system}, applet_manager{system}, time_manager{system} {} cpu_manager{system}, reporter{system}, applet_manager{system}, time_manager{system} {}
ResultStatus Run() { SystemResultStatus Run() {
std::unique_lock<std::mutex> lk(suspend_guard); std::unique_lock<std::mutex> lk(suspend_guard);
status = ResultStatus::Success; status = SystemResultStatus::Success;
kernel.Suspend(false); kernel.Suspend(false);
core_timing.SyncPause(false); core_timing.SyncPause(false);
@ -151,9 +151,9 @@ struct System::Impl {
return status; return status;
} }
ResultStatus Pause() { SystemResultStatus Pause() {
std::unique_lock<std::mutex> lk(suspend_guard); std::unique_lock<std::mutex> lk(suspend_guard);
status = ResultStatus::Success; status = SystemResultStatus::Success;
core_timing.SyncPause(true); core_timing.SyncPause(true);
kernel.Suspend(true); kernel.Suspend(true);
@ -163,23 +163,23 @@ struct System::Impl {
return status; return status;
} }
void stallForGPU(bool pause) { std::unique_lock<std::mutex> StallCPU() {
if (pause) { std::unique_lock<std::mutex> lk(suspend_guard);
suspend_guard.lock(); kernel.Suspend(true);
kernel.Suspend(pause); core_timing.SyncPause(true);
core_timing.SyncPause(pause); cpu_manager.Pause(true);
cpu_manager.Pause(pause); return lk;
} else {
if (!is_paused) {
core_timing.SyncPause(pause);
kernel.Suspend(pause);
cpu_manager.Pause(pause);
} }
suspend_guard.unlock();
void UnstallCPU() {
if (!is_paused) {
core_timing.SyncPause(false);
kernel.Suspend(false);
cpu_manager.Pause(false);
} }
} }
ResultStatus Init(System& system, Frontend::EmuWindow& emu_window) { SystemResultStatus Init(System& system, Frontend::EmuWindow& emu_window) {
LOG_DEBUG(Core, "initialized OK"); LOG_DEBUG(Core, "initialized OK");
device_memory = std::make_unique<Core::DeviceMemory>(); device_memory = std::make_unique<Core::DeviceMemory>();
@ -217,7 +217,7 @@ struct System::Impl {
gpu_core = VideoCore::CreateGPU(emu_window, system); gpu_core = VideoCore::CreateGPU(emu_window, system);
if (!gpu_core) { if (!gpu_core) {
return ResultStatus::ErrorVideoCore; return SystemResultStatus::ErrorVideoCore;
} }
service_manager = std::make_shared<Service::SM::ServiceManager>(kernel); service_manager = std::make_shared<Service::SM::ServiceManager>(kernel);
@ -237,21 +237,22 @@ struct System::Impl {
LOG_DEBUG(Core, "Initialized OK"); LOG_DEBUG(Core, "Initialized OK");
return ResultStatus::Success; return SystemResultStatus::Success;
} }
ResultStatus Load(System& system, Frontend::EmuWindow& emu_window, const std::string& filepath, SystemResultStatus Load(System& system, Frontend::EmuWindow& emu_window,
u64 program_id, std::size_t program_index) { const std::string& filepath, u64 program_id,
std::size_t program_index) {
app_loader = Loader::GetLoader(system, GetGameFileFromPath(virtual_filesystem, filepath), app_loader = Loader::GetLoader(system, GetGameFileFromPath(virtual_filesystem, filepath),
program_id, program_index); program_id, program_index);
if (!app_loader) { if (!app_loader) {
LOG_CRITICAL(Core, "Failed to obtain loader for {}!", filepath); LOG_CRITICAL(Core, "Failed to obtain loader for {}!", filepath);
return ResultStatus::ErrorGetLoader; return SystemResultStatus::ErrorGetLoader;
} }
ResultStatus init_result{Init(system, emu_window)}; SystemResultStatus init_result{Init(system, emu_window)};
if (init_result != ResultStatus::Success) { if (init_result != SystemResultStatus::Success) {
LOG_CRITICAL(Core, "Failed to initialize system (Error {})!", LOG_CRITICAL(Core, "Failed to initialize system (Error {})!",
static_cast<int>(init_result)); static_cast<int>(init_result));
Shutdown(); Shutdown();
@ -269,8 +270,8 @@ struct System::Impl {
LOG_CRITICAL(Core, "Failed to load ROM (Error {})!", load_result); LOG_CRITICAL(Core, "Failed to load ROM (Error {})!", load_result);
Shutdown(); Shutdown();
return static_cast<ResultStatus>(static_cast<u32>(ResultStatus::ErrorLoader) + return static_cast<SystemResultStatus>(
static_cast<u32>(load_result)); static_cast<u32>(SystemResultStatus::ErrorLoader) + static_cast<u32>(load_result));
} }
AddGlueRegistrationForProcess(*app_loader, *main_process); AddGlueRegistrationForProcess(*app_loader, *main_process);
kernel.MakeCurrentProcess(main_process.get()); kernel.MakeCurrentProcess(main_process.get());
@ -302,7 +303,7 @@ struct System::Impl {
GetAndResetPerfStats(); GetAndResetPerfStats();
perf_stats->BeginSystemFrame(); perf_stats->BeginSystemFrame();
status = ResultStatus::Success; status = SystemResultStatus::Success;
return status; return status;
} }
@ -375,7 +376,7 @@ struct System::Impl {
arp_manager.Register(launch.title_id, launch, std::move(nacp_data)); arp_manager.Register(launch.title_id, launch, std::move(nacp_data));
} }
void SetStatus(ResultStatus new_status, const char* details = nullptr) { void SetStatus(SystemResultStatus new_status, const char* details = nullptr) {
status = new_status; status = new_status;
if (details) { if (details) {
status_details = details; status_details = details;
@ -434,7 +435,7 @@ struct System::Impl {
/// Network instance /// Network instance
Network::NetworkInstance network_instance; Network::NetworkInstance network_instance;
ResultStatus status = ResultStatus::Success; SystemResultStatus status = SystemResultStatus::Success;
std::string status_details = ""; std::string status_details = "";
std::unique_ptr<Core::PerfStats> perf_stats; std::unique_ptr<Core::PerfStats> perf_stats;
@ -451,22 +452,9 @@ struct System::Impl {
}; };
System::System() : impl{std::make_unique<Impl>(*this)} {} System::System() : impl{std::make_unique<Impl>(*this)} {}
System::~System() = default; System::~System() = default;
System& System::GetInstance() {
if (!s_instance) {
throw std::runtime_error("Using System instance before its initialization");
}
return *s_instance;
}
void System::InitializeGlobalInstance() {
if (s_instance) {
throw std::runtime_error("Reinitializing Global System instance.");
}
s_instance = std::unique_ptr<System>(new System);
}
CpuManager& System::GetCpuManager() { CpuManager& System::GetCpuManager() {
return impl->cpu_manager; return impl->cpu_manager;
} }
@ -475,16 +463,16 @@ const CpuManager& System::GetCpuManager() const {
return impl->cpu_manager; return impl->cpu_manager;
} }
System::ResultStatus System::Run() { SystemResultStatus System::Run() {
return impl->Run(); return impl->Run();
} }
System::ResultStatus System::Pause() { SystemResultStatus System::Pause() {
return impl->Pause(); return impl->Pause();
} }
System::ResultStatus System::SingleStep() { SystemResultStatus System::SingleStep() {
return ResultStatus::Success; return SystemResultStatus::Success;
} }
void System::InvalidateCpuInstructionCaches() { void System::InvalidateCpuInstructionCaches() {
@ -499,11 +487,15 @@ void System::Shutdown() {
impl->Shutdown(); impl->Shutdown();
} }
void System::stallForGPU(bool pause) { std::unique_lock<std::mutex> System::StallCPU() {
impl->stallForGPU(pause); return impl->StallCPU();
} }
System::ResultStatus System::Load(Frontend::EmuWindow& emu_window, const std::string& filepath, void System::UnstallCPU() {
impl->UnstallCPU();
}
SystemResultStatus System::Load(Frontend::EmuWindow& emu_window, const std::string& filepath,
u64 program_id, std::size_t program_index) { u64 program_id, std::size_t program_index) {
return impl->Load(*this, emu_window, filepath, program_id, program_index); return impl->Load(*this, emu_window, filepath, program_id, program_index);
} }
@ -664,7 +656,7 @@ Loader::ResultStatus System::GetGameName(std::string& out) const {
return impl->GetGameName(out); return impl->GetGameName(out);
} }
void System::SetStatus(ResultStatus new_status, const char* details) { void System::SetStatus(SystemResultStatus new_status, const char* details) {
impl->SetStatus(new_status, details); impl->SetStatus(new_status, details);
} }

View file

@ -7,6 +7,7 @@
#include <cstddef> #include <cstddef>
#include <functional> #include <functional>
#include <memory> #include <memory>
#include <mutex>
#include <string> #include <string>
#include <vector> #include <vector>
@ -104,28 +105,8 @@ struct PerfStatsResults;
FileSys::VirtualFile GetGameFileFromPath(const FileSys::VirtualFilesystem& vfs, FileSys::VirtualFile GetGameFileFromPath(const FileSys::VirtualFilesystem& vfs,
const std::string& path); const std::string& path);
class System { /// Enumeration representing the return values of the System Initialize and Load process.
public: enum class SystemResultStatus : u32 {
using CurrentBuildProcessID = std::array<u8, 0x20>;
System(const System&) = delete;
System& operator=(const System&) = delete;
System(System&&) = delete;
System& operator=(System&&) = delete;
~System();
/**
* Gets the instance of the System singleton class.
* @returns Reference to the instance of the System singleton class.
*/
[[deprecated("Use of the global system instance is deprecated")]] static System& GetInstance();
static void InitializeGlobalInstance();
/// Enumeration representing the return values of the System Initialize and Load process.
enum class ResultStatus : u32 {
Success, ///< Succeeded Success, ///< Succeeded
ErrorNotInitialized, ///< Error trying to use core prior to initialization ErrorNotInitialized, ///< Error trying to use core prior to initialization
ErrorGetLoader, ///< Error finding the correct application loader ErrorGetLoader, ///< Error finding the correct application loader
@ -134,25 +115,39 @@ public:
ErrorVideoCore, ///< Error in the video core ErrorVideoCore, ///< Error in the video core
ErrorUnknown, ///< Any other error ErrorUnknown, ///< Any other error
ErrorLoader, ///< The base for loader errors (too many to repeat) ErrorLoader, ///< The base for loader errors (too many to repeat)
}; };
class System {
public:
using CurrentBuildProcessID = std::array<u8, 0x20>;
explicit System();
~System();
System(const System&) = delete;
System& operator=(const System&) = delete;
System(System&&) = delete;
System& operator=(System&&) = delete;
/** /**
* Run the OS and Application * Run the OS and Application
* This function will start emulation and run the relevant devices * This function will start emulation and run the relevant devices
*/ */
[[nodiscard]] ResultStatus Run(); [[nodiscard]] SystemResultStatus Run();
/** /**
* Pause the OS and Application * Pause the OS and Application
* This function will pause emulation and stop the relevant devices * This function will pause emulation and stop the relevant devices
*/ */
[[nodiscard]] ResultStatus Pause(); [[nodiscard]] SystemResultStatus Pause();
/** /**
* Step the CPU one instruction * Step the CPU one instruction
* @return Result status, indicating whether or not the operation succeeded. * @return Result status, indicating whether or not the operation succeeded.
*/ */
[[nodiscard]] ResultStatus SingleStep(); [[nodiscard]] SystemResultStatus SingleStep();
/** /**
* Invalidate the CPU instruction caches * Invalidate the CPU instruction caches
@ -166,7 +161,8 @@ public:
/// Shutdown the emulated system. /// Shutdown the emulated system.
void Shutdown(); void Shutdown();
void stallForGPU(bool pause); std::unique_lock<std::mutex> StallCPU();
void UnstallCPU();
/** /**
* Load an executable application. * Load an executable application.
@ -174,10 +170,11 @@ public:
* input. * input.
* @param filepath String path to the executable application to load on the host file system. * @param filepath String path to the executable application to load on the host file system.
* @param program_index Specifies the index within the container of the program to launch. * @param program_index Specifies the index within the container of the program to launch.
* @returns ResultStatus code, indicating if the operation succeeded. * @returns SystemResultStatus code, indicating if the operation succeeded.
*/ */
[[nodiscard]] ResultStatus Load(Frontend::EmuWindow& emu_window, const std::string& filepath, [[nodiscard]] SystemResultStatus Load(Frontend::EmuWindow& emu_window,
u64 program_id = 0, std::size_t program_index = 0); const std::string& filepath, u64 program_id = 0,
std::size_t program_index = 0);
/** /**
* Indicates if the emulated system is powered on (all subsystems initialized and able to run an * Indicates if the emulated system is powered on (all subsystems initialized and able to run an
@ -303,7 +300,7 @@ public:
/// Gets the name of the current game /// Gets the name of the current game
[[nodiscard]] Loader::ResultStatus GetGameName(std::string& out) const; [[nodiscard]] Loader::ResultStatus GetGameName(std::string& out) const;
void SetStatus(ResultStatus new_status, const char* details); void SetStatus(SystemResultStatus new_status, const char* details);
[[nodiscard]] const std::string& GetStatusDetails() const; [[nodiscard]] const std::string& GetStatusDetails() const;
@ -405,12 +402,8 @@ public:
void ApplySettings(); void ApplySettings();
private: private:
System();
struct Impl; struct Impl;
std::unique_ptr<Impl> impl; std::unique_ptr<Impl> impl;
inline static std::unique_ptr<System> s_instance{};
}; };
} // namespace Core } // namespace Core

View file

@ -150,9 +150,11 @@ NvResult nvhost_ctrl::IocCtrlEventWait(const std::vector<u8>& input, std::vector
params.value |= event_id; params.value |= event_id;
event.event->GetWritableEvent().Clear(); event.event->GetWritableEvent().Clear();
if (events_interface.failed[event_id]) { if (events_interface.failed[event_id]) {
system.stallForGPU(true); {
auto lk = system.StallCPU();
gpu.WaitFence(params.syncpt_id, target_value); gpu.WaitFence(params.syncpt_id, target_value);
system.stallForGPU(false); system.UnstallCPU();
}
std::memcpy(output.data(), &params, sizeof(params)); std::memcpy(output.data(), &params, sizeof(params));
events_interface.failed[event_id] = false; events_interface.failed[event_id] = false;
return NvResult::Success; return NvResult::Success;

View file

@ -8,7 +8,8 @@
#include "ui_aboutdialog.h" #include "ui_aboutdialog.h"
#include "yuzu/about_dialog.h" #include "yuzu/about_dialog.h"
AboutDialog::AboutDialog(QWidget* parent) : QDialog(parent), ui(new Ui::AboutDialog) { AboutDialog::AboutDialog(QWidget* parent)
: QDialog(parent), ui{std::make_unique<Ui::AboutDialog>()} {
const auto branch_name = std::string(Common::g_scm_branch); const auto branch_name = std::string(Common::g_scm_branch);
const auto description = std::string(Common::g_scm_desc); const auto description = std::string(Common::g_scm_desc);
const auto build_id = std::string(Common::g_build_id); const auto build_id = std::string(Common::g_build_id);

View file

@ -3,6 +3,7 @@
// Refer to the license.txt file included. // Refer to the license.txt file included.
#ifdef YUZU_USE_QT_WEB_ENGINE #ifdef YUZU_USE_QT_WEB_ENGINE
#include <QApplication>
#include <QKeyEvent> #include <QKeyEvent>
#include <QWebEngineProfile> #include <QWebEngineProfile>

View file

@ -86,15 +86,15 @@ void EmuThread::run() {
} }
running_guard = true; running_guard = true;
Core::System::ResultStatus result = system.Run(); Core::SystemResultStatus result = system.Run();
if (result != Core::System::ResultStatus::Success) { if (result != Core::SystemResultStatus::Success) {
running_guard = false; running_guard = false;
this->SetRunning(false); this->SetRunning(false);
emit ErrorThrown(result, system.GetStatusDetails()); emit ErrorThrown(result, system.GetStatusDetails());
} }
running_wait.Wait(); running_wait.Wait();
result = system.Pause(); result = system.Pause();
if (result != Core::System::ResultStatus::Success) { if (result != Core::SystemResultStatus::Success) {
running_guard = false; running_guard = false;
this->SetRunning(false); this->SetRunning(false);
emit ErrorThrown(result, system.GetStatusDetails()); emit ErrorThrown(result, system.GetStatusDetails());

View file

@ -16,7 +16,6 @@
#include <QWindow> #include <QWindow>
#include "common/thread.h" #include "common/thread.h"
#include "core/core.h"
#include "core/frontend/emu_window.h" #include "core/frontend/emu_window.h"
class GRenderWindow; class GRenderWindow;
@ -24,6 +23,11 @@ class GMainWindow;
class QKeyEvent; class QKeyEvent;
class QStringList; class QStringList;
namespace Core {
enum class SystemResultStatus : u32;
class System;
} // namespace Core
namespace InputCommon { namespace InputCommon {
class InputSubsystem; class InputSubsystem;
} }
@ -123,7 +127,7 @@ signals:
*/ */
void DebugModeLeft(); void DebugModeLeft();
void ErrorThrown(Core::System::ResultStatus, std::string); void ErrorThrown(Core::SystemResultStatus, std::string);
void LoadProgress(VideoCore::LoadCallbackStage stage, std::size_t value, std::size_t total); void LoadProgress(VideoCore::LoadCallbackStage stage, std::size_t value, std::size_t total);
}; };

View file

@ -14,7 +14,7 @@
#include "yuzu/configuration/configure_cpu.h" #include "yuzu/configuration/configure_cpu.h"
ConfigureCpu::ConfigureCpu(const Core::System& system_, QWidget* parent) ConfigureCpu::ConfigureCpu(const Core::System& system_, QWidget* parent)
: QWidget(parent), ui(new Ui::ConfigureCpu), system{system_} { : QWidget(parent), ui{std::make_unique<Ui::ConfigureCpu>()}, system{system_} {
ui->setupUi(this); ui->setupUi(this);
SetupPerGameUI(); SetupPerGameUI();

View file

@ -12,7 +12,7 @@
#include "yuzu/configuration/configure_cpu_debug.h" #include "yuzu/configuration/configure_cpu_debug.h"
ConfigureCpuDebug::ConfigureCpuDebug(const Core::System& system_, QWidget* parent) ConfigureCpuDebug::ConfigureCpuDebug(const Core::System& system_, QWidget* parent)
: QWidget(parent), ui(new Ui::ConfigureCpuDebug), system{system_} { : QWidget(parent), ui{std::make_unique<Ui::ConfigureCpuDebug>()}, system{system_} {
ui->setupUi(this); ui->setupUi(this);
SetConfiguration(); SetConfiguration();

View file

@ -15,7 +15,7 @@
#include "yuzu/uisettings.h" #include "yuzu/uisettings.h"
ConfigureDebug::ConfigureDebug(const Core::System& system_, QWidget* parent) ConfigureDebug::ConfigureDebug(const Core::System& system_, QWidget* parent)
: QWidget(parent), ui(new Ui::ConfigureDebug), system{system_} { : QWidget(parent), ui{std::make_unique<Ui::ConfigureDebug>()}, system{system_} {
ui->setupUi(this); ui->setupUi(this);
SetConfiguration(); SetConfiguration();

View file

@ -9,8 +9,8 @@
#include "yuzu/configuration/configure_debug_tab.h" #include "yuzu/configuration/configure_debug_tab.h"
ConfigureDebugTab::ConfigureDebugTab(const Core::System& system_, QWidget* parent) ConfigureDebugTab::ConfigureDebugTab(const Core::System& system_, QWidget* parent)
: QWidget(parent), : QWidget(parent), ui{std::make_unique<Ui::ConfigureDebugTab>()},
ui(new Ui::ConfigureDebugTab), debug_tab{std::make_unique<ConfigureDebug>(system_, this)}, debug_tab{std::make_unique<ConfigureDebug>(system_, this)},
cpu_debug_tab{std::make_unique<ConfigureCpuDebug>(system_, this)} { cpu_debug_tab{std::make_unique<ConfigureCpuDebug>(system_, this)} {
ui->setupUi(this); ui->setupUi(this);

View file

@ -36,7 +36,7 @@
ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry, ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry,
InputCommon::InputSubsystem* input_subsystem, InputCommon::InputSubsystem* input_subsystem,
Core::System& system_) Core::System& system_)
: QDialog(parent), ui(new Ui::ConfigureDialog), : QDialog(parent), ui{std::make_unique<Ui::ConfigureDialog>()},
registry(registry), system{system_}, audio_tab{std::make_unique<ConfigureAudio>(system_, registry(registry), system{system_}, audio_tab{std::make_unique<ConfigureAudio>(system_,
this)}, this)},
cpu_tab{std::make_unique<ConfigureCpu>(system_, this)}, cpu_tab{std::make_unique<ConfigureCpu>(system_, this)},

View file

@ -16,7 +16,7 @@
#include "yuzu/uisettings.h" #include "yuzu/uisettings.h"
ConfigureGeneral::ConfigureGeneral(const Core::System& system_, QWidget* parent) ConfigureGeneral::ConfigureGeneral(const Core::System& system_, QWidget* parent)
: QWidget(parent), ui(new Ui::ConfigureGeneral), system{system_} { : QWidget(parent), ui{std::make_unique<Ui::ConfigureGeneral>()}, system{system_} {
ui->setupUi(this); ui->setupUi(this);
SetupPerGameUI(); SetupPerGameUI();

View file

@ -20,7 +20,7 @@
#include "yuzu/configuration/configure_graphics.h" #include "yuzu/configuration/configure_graphics.h"
ConfigureGraphics::ConfigureGraphics(const Core::System& system_, QWidget* parent) ConfigureGraphics::ConfigureGraphics(const Core::System& system_, QWidget* parent)
: QWidget(parent), ui(new Ui::ConfigureGraphics), system{system_} { : QWidget(parent), ui{std::make_unique<Ui::ConfigureGraphics>()}, system{system_} {
vulkan_device = Settings::values.vulkan_device.GetValue(); vulkan_device = Settings::values.vulkan_device.GetValue();
RetrieveVulkanDevices(); RetrieveVulkanDevices();

View file

@ -9,7 +9,7 @@
#include "yuzu/configuration/configure_graphics_advanced.h" #include "yuzu/configuration/configure_graphics_advanced.h"
ConfigureGraphicsAdvanced::ConfigureGraphicsAdvanced(const Core::System& system_, QWidget* parent) ConfigureGraphicsAdvanced::ConfigureGraphicsAdvanced(const Core::System& system_, QWidget* parent)
: QWidget(parent), ui(new Ui::ConfigureGraphicsAdvanced), system{system_} { : QWidget(parent), ui{std::make_unique<Ui::ConfigureGraphicsAdvanced>()}, system{system_} {
ui->setupUi(this); ui->setupUi(this);

View file

@ -27,7 +27,7 @@
#include "yuzu/util/util.h" #include "yuzu/util/util.h"
ConfigurePerGameAddons::ConfigurePerGameAddons(Core::System& system_, QWidget* parent) ConfigurePerGameAddons::ConfigurePerGameAddons(Core::System& system_, QWidget* parent)
: QWidget(parent), ui(new Ui::ConfigurePerGameAddons), system{system_} { : QWidget(parent), ui{std::make_unique<Ui::ConfigurePerGameAddons>()}, system{system_} {
ui->setupUi(this); ui->setupUi(this);
layout = new QVBoxLayout; layout = new QVBoxLayout;

View file

@ -77,7 +77,7 @@ QString GetProfileUsernameFromUser(QWidget* parent, const QString& description_t
} // Anonymous namespace } // Anonymous namespace
ConfigureProfileManager::ConfigureProfileManager(const Core::System& system_, QWidget* parent) ConfigureProfileManager::ConfigureProfileManager(const Core::System& system_, QWidget* parent)
: QWidget(parent), ui(new Ui::ConfigureProfileManager), : QWidget(parent), ui{std::make_unique<Ui::ConfigureProfileManager>()},
profile_manager(std::make_unique<Service::Account::ProfileManager>()), system{system_} { profile_manager(std::make_unique<Service::Account::ProfileManager>()), system{system_} {
ui->setupUi(this); ui->setupUi(this);

View file

@ -18,7 +18,7 @@
#include "yuzu/configuration/configure_system.h" #include "yuzu/configuration/configure_system.h"
ConfigureSystem::ConfigureSystem(Core::System& system_, QWidget* parent) ConfigureSystem::ConfigureSystem(Core::System& system_, QWidget* parent)
: QWidget(parent), ui(new Ui::ConfigureSystem), system{system_} { : QWidget(parent), ui{std::make_unique<Ui::ConfigureSystem>()}, system{system_} {
ui->setupUi(this); ui->setupUi(this);
connect(ui->button_regenerate_console_id, &QPushButton::clicked, this, connect(ui->button_regenerate_console_id, &QPushButton::clicked, this,
&ConfigureSystem::RefreshConsoleID); &ConfigureSystem::RefreshConsoleID);

View file

@ -55,7 +55,7 @@ QString GetTranslatedRowTextName(size_t index) {
} // Anonymous namespace } // Anonymous namespace
ConfigureUi::ConfigureUi(Core::System& system_, QWidget* parent) ConfigureUi::ConfigureUi(Core::System& system_, QWidget* parent)
: QWidget(parent), ui(new Ui::ConfigureUi), system{system_} { : QWidget(parent), ui{std::make_unique<Ui::ConfigureUi>()}, system{system_} {
ui->setupUi(this); ui->setupUi(this);
InitializeLanguageComboBox(); InitializeLanguageComboBox();

File diff suppressed because it is too large Load diff

View file

@ -13,9 +13,7 @@
#include <QTranslator> #include <QTranslator>
#include "common/common_types.h" #include "common/common_types.h"
#include "core/core.h"
#include "core/hle/service/acc/profile_manager.h" #include "core/hle/service/acc/profile_manager.h"
#include "ui_main.h"
#include "yuzu/compatibility_list.h" #include "yuzu/compatibility_list.h"
#include "yuzu/hotkeys.h" #include "yuzu/hotkeys.h"
@ -45,6 +43,11 @@ enum class StartGameType {
Global, // Only uses global configuration Global, // Only uses global configuration
}; };
namespace Core {
enum class SystemResultStatus : u32;
class System;
} // namespace Core
namespace Core::Frontend { namespace Core::Frontend {
struct ControllerParameters; struct ControllerParameters;
struct InlineAppearParameters; struct InlineAppearParameters;
@ -73,6 +76,10 @@ enum class SwkbdReplyType : u32;
enum class WebExitReason : u32; enum class WebExitReason : u32;
} // namespace Service::AM::Applets } // namespace Service::AM::Applets
namespace Ui {
class MainWindow;
}
enum class EmulatedDirectoryTarget { enum class EmulatedDirectoryTarget {
NAND, NAND,
SDMC, SDMC,
@ -107,7 +114,7 @@ class GMainWindow : public QMainWindow {
public: public:
void filterBarSetChecked(bool state); void filterBarSetChecked(bool state);
void UpdateUITheme(); void UpdateUITheme();
GMainWindow(Core::System& system_); explicit GMainWindow();
~GMainWindow() override; ~GMainWindow() override;
bool DropAction(QDropEvent* event); bool DropAction(QDropEvent* event);
@ -277,7 +284,7 @@ private slots:
void ResetWindowSize900(); void ResetWindowSize900();
void ResetWindowSize1080(); void ResetWindowSize1080();
void OnCaptureScreenshot(); void OnCaptureScreenshot();
void OnCoreError(Core::System::ResultStatus, std::string); void OnCoreError(Core::SystemResultStatus, std::string);
void OnReinitializeKeys(ReinitializeKeyBehavior behavior); void OnReinitializeKeys(ReinitializeKeyBehavior behavior);
void OnLanguageChanged(const QString& locale); void OnLanguageChanged(const QString& locale);
void OnMouseActivity(); void OnMouseActivity();
@ -306,13 +313,12 @@ private:
void OpenPerGameConfiguration(u64 title_id, const std::string& file_name); void OpenPerGameConfiguration(u64 title_id, const std::string& file_name);
QString GetTasStateDescription() const; QString GetTasStateDescription() const;
Ui::MainWindow ui; std::unique_ptr<Ui::MainWindow> ui;
std::unique_ptr<Core::System> system;
std::unique_ptr<DiscordRPC::DiscordInterface> discord_rpc; std::unique_ptr<DiscordRPC::DiscordInterface> discord_rpc;
std::shared_ptr<InputCommon::InputSubsystem> input_subsystem; std::shared_ptr<InputCommon::InputSubsystem> input_subsystem;
Core::System& system;
GRenderWindow* render_window; GRenderWindow* render_window;
GameList* game_list; GameList* game_list;
LoadingScreen* loading_screen; LoadingScreen* loading_screen;

View file

@ -60,7 +60,7 @@ struct Values {
Settings::BasicSetting<bool> confirm_before_closing{true, "confirmClose"}; Settings::BasicSetting<bool> confirm_before_closing{true, "confirmClose"};
Settings::BasicSetting<bool> first_start{true, "firstStart"}; Settings::BasicSetting<bool> first_start{true, "firstStart"};
Settings::BasicSetting<bool> pause_when_in_background{false, "pauseWhenInBackground"}; Settings::BasicSetting<bool> pause_when_in_background{false, "pauseWhenInBackground"};
Settings::BasicSetting<bool> hide_mouse{false, "hideInactiveMouse"}; Settings::BasicSetting<bool> hide_mouse{true, "hideInactiveMouse"};
Settings::BasicSetting<bool> select_user_on_boot{false, "select_user_on_boot"}; Settings::BasicSetting<bool> select_user_on_boot{false, "select_user_on_boot"};

View file

@ -146,9 +146,8 @@ int main(int argc, char** argv) {
return -1; return -1;
} }
Core::System::InitializeGlobalInstance(); Core::System system{};
auto& system{Core::System::GetInstance()}; InputCommon::InputSubsystem input_subsystem{};
InputCommon::InputSubsystem input_subsystem;
// Apply the command line arguments // Apply the command line arguments
system.ApplySettings(); system.ApplySettings();
@ -167,27 +166,27 @@ int main(int argc, char** argv) {
system.SetFilesystem(std::make_shared<FileSys::RealVfsFilesystem>()); system.SetFilesystem(std::make_shared<FileSys::RealVfsFilesystem>());
system.GetFileSystemController().CreateFactories(*system.GetFilesystem()); system.GetFileSystemController().CreateFactories(*system.GetFilesystem());
const Core::System::ResultStatus load_result{system.Load(*emu_window, filepath)}; const Core::SystemResultStatus load_result{system.Load(*emu_window, filepath)};
switch (load_result) { switch (load_result) {
case Core::System::ResultStatus::ErrorGetLoader: case Core::SystemResultStatus::ErrorGetLoader:
LOG_CRITICAL(Frontend, "Failed to obtain loader for {}!", filepath); LOG_CRITICAL(Frontend, "Failed to obtain loader for {}!", filepath);
return -1; return -1;
case Core::System::ResultStatus::ErrorLoader: case Core::SystemResultStatus::ErrorLoader:
LOG_CRITICAL(Frontend, "Failed to load ROM!"); LOG_CRITICAL(Frontend, "Failed to load ROM!");
return -1; return -1;
case Core::System::ResultStatus::ErrorNotInitialized: case Core::SystemResultStatus::ErrorNotInitialized:
LOG_CRITICAL(Frontend, "CPUCore not initialized"); LOG_CRITICAL(Frontend, "CPUCore not initialized");
return -1; return -1;
case Core::System::ResultStatus::ErrorVideoCore: case Core::SystemResultStatus::ErrorVideoCore:
LOG_CRITICAL(Frontend, "Failed to initialize VideoCore!"); LOG_CRITICAL(Frontend, "Failed to initialize VideoCore!");
return -1; return -1;
case Core::System::ResultStatus::Success: case Core::SystemResultStatus::Success:
break; // Expected case break; // Expected case
default: default:
if (static_cast<u32>(load_result) > if (static_cast<u32>(load_result) >
static_cast<u32>(Core::System::ResultStatus::ErrorLoader)) { static_cast<u32>(Core::SystemResultStatus::ErrorLoader)) {
const u16 loader_id = static_cast<u16>(Core::System::ResultStatus::ErrorLoader); const u16 loader_id = static_cast<u16>(Core::SystemResultStatus::ErrorLoader);
const u16 error_id = static_cast<u16>(load_result) - loader_id; const u16 error_id = static_cast<u16>(load_result) - loader_id;
LOG_CRITICAL(Frontend, LOG_CRITICAL(Frontend,
"While attempting to load the ROM requested, an error occurred. Please " "While attempting to load the ROM requested, an error occurred. Please "