diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index 76c272c49c..fc44b8cabb 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -475,7 +475,6 @@ void Emulator::Init() g_cfg.name.clear(); // Not all renderers are known at compile time, so set a provided default if possible - // TODO: Also initialize render_creator in headless mode ensure(m_supported_renderers.contains(m_default_renderer)); ensure(!(m_default_renderer == video_renderer::vulkan && m_default_graphics_adapter.empty())); g_cfg.video.renderer.set(m_default_renderer); diff --git a/rpcs3/main_application.cpp b/rpcs3/main_application.cpp index 0936089f6f..8d5c44c5e3 100644 --- a/rpcs3/main_application.cpp +++ b/rpcs3/main_application.cpp @@ -45,6 +45,7 @@ #include LOG_CHANNEL(sys_log, "SYS"); +LOG_CHANNEL(cfg_log, "CFG"); namespace audio { @@ -60,6 +61,36 @@ namespace rsx::overlays extern void qt_events_aware_op(int repeat_duration_ms, std::function wrapped_op); +main_application::main_application() + : m_render_creator(std::make_shared()) +{ + std::set supported_renderers; + supported_renderers.insert(video_renderer::null); + + if (m_render_creator->OpenGL.supported) + { + supported_renderers.insert(video_renderer::opengl); + } + + // Make Vulkan default setting if it is supported + if (m_render_creator->Vulkan.supported && !m_render_creator->Vulkan.adapters.empty()) + { + const std::string adapter = ::at32(m_render_creator->Vulkan.adapters, 0).toStdString(); + cfg_log.notice("Setting the default renderer to Vulkan. Default GPU: '%s'", adapter); + Emu.SetDefaultRenderer(video_renderer::vulkan); + Emu.SetDefaultGraphicsAdapter(adapter); + + supported_renderers.insert(video_renderer::vulkan); + } + else if (m_render_creator->OpenGL.supported) + { + cfg_log.notice("Setting the default renderer to OpenGl"); + Emu.SetDefaultRenderer(video_renderer::opengl); + } + + Emu.SetSupportedRenderers(supported_renderers); +} + /** Emu.Init() wrapper for user management */ void main_application::InitializeEmulator(const std::string& user, bool show_gui, bool headless) { diff --git a/rpcs3/main_application.h b/rpcs3/main_application.h index f10adda17a..ee7666e4a9 100644 --- a/rpcs3/main_application.h +++ b/rpcs3/main_application.h @@ -1,5 +1,7 @@ #pragma once +#include "rpcs3qt/render_creator.h" + #include #include @@ -9,6 +11,8 @@ class gs_frame; class main_application { public: + main_application(); + virtual bool Init() = 0; static void InitializeEmulator(const std::string& user, bool show_gui, bool headless); @@ -25,6 +29,7 @@ protected: EmuCallbacks CreateCallbacks(); + std::shared_ptr m_render_creator; std::string m_active_user; gs_frame* m_game_window = nullptr; }; diff --git a/rpcs3/rpcs3.vcxproj b/rpcs3/rpcs3.vcxproj index d1ea74eb05..0aeb999181 100644 --- a/rpcs3/rpcs3.vcxproj +++ b/rpcs3/rpcs3.vcxproj @@ -425,9 +425,6 @@ true - - true - true @@ -737,9 +734,6 @@ true - - true - true @@ -1471,16 +1465,7 @@ - - Moc%27ing %(Identity)... - .\QTGeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp - "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\QTGeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -D_WINDOWS -DUNICODE -DWIN32 -DWIN64 -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_CONCURRENT_LIB -D%(PreprocessorDefinitions) "-I.\..\3rdparty\wolfssl\wolfssl" "-I.\..\3rdparty\curl\curl\include" "-I.\..\3rdparty\libusb\libusb\libusb" "-I$(VULKAN_SDK)\Include" "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtCore" "-I.\debug" "-I.\QTGeneratedFiles\$(ConfigurationName)" "-I.\QTGeneratedFiles" "-I$(QTDIR)\include\QtConcurrent" - Moc%27ing %(Identity)... - .\QTGeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp - "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\QTGeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -D_WINDOWS -DUNICODE -DWIN32 -DWIN64 -DWITH_DISCORD_RPC -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DNDEBUG -DQT_CONCURRENT_LIB -D%(PreprocessorDefinitions) "-I.\..\3rdparty\wolfssl\wolfssl" "-I.\..\3rdparty\curl\curl\include" "-I.\..\3rdparty\libusb\libusb\libusb" "-I$(VULKAN_SDK)\Include" "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtCore" "-I.\release" "-I.\QTGeneratedFiles\$(ConfigurationName)" "-I.\QTGeneratedFiles" "-I$(QTDIR)\include\QtConcurrent" - $(QTDIR)\bin\moc.exe;%(FullPath) - $(QTDIR)\bin\moc.exe;%(FullPath) - + Moc%27ing %(Identity)... diff --git a/rpcs3/rpcs3.vcxproj.filters b/rpcs3/rpcs3.vcxproj.filters index e083e83187..5358f6e372 100644 --- a/rpcs3/rpcs3.vcxproj.filters +++ b/rpcs3/rpcs3.vcxproj.filters @@ -858,12 +858,6 @@ Gui\settings - - Generated Files\Debug - - - Generated Files\Release - Gui\settings diff --git a/rpcs3/rpcs3qt/emu_settings.cpp b/rpcs3/rpcs3qt/emu_settings.cpp index 734aa3504d..21a20f965c 100644 --- a/rpcs3/rpcs3qt/emu_settings.cpp +++ b/rpcs3/rpcs3qt/emu_settings.cpp @@ -91,44 +91,12 @@ namespace } } -emu_settings::emu_settings() +emu_settings::emu_settings(std::shared_ptr r_creator) : QObject() + , m_render_creator(ensure(r_creator)) { } -bool emu_settings::Init() -{ - m_render_creator = new render_creator(this); - - std::set supported_renderers; - supported_renderers.insert(video_renderer::null); - - if (m_render_creator->OpenGL.supported) - { - supported_renderers.insert(video_renderer::opengl); - } - - // Make Vulkan default setting if it is supported - if (!m_render_creator->abort_requested && m_render_creator->Vulkan.supported && !m_render_creator->Vulkan.adapters.empty()) - { - const std::string adapter = ::at32(m_render_creator->Vulkan.adapters, 0).toStdString(); - cfg_log.notice("Setting the default renderer to Vulkan. Default GPU: '%s'", adapter); - Emu.SetDefaultRenderer(video_renderer::vulkan); - Emu.SetDefaultGraphicsAdapter(adapter); - - supported_renderers.insert(video_renderer::vulkan); - } - else if (m_render_creator->OpenGL.supported) - { - cfg_log.notice("Setting the default renderer to OpenGl"); - Emu.SetDefaultRenderer(video_renderer::opengl); - } - - Emu.SetSupportedRenderers(supported_renderers); - - return !m_render_creator->abort_requested; -} - void emu_settings::LoadSettings(const std::string& title_id, bool create_config_from_global, const std::string& db_config) { m_title_id = title_id; diff --git a/rpcs3/rpcs3qt/emu_settings.h b/rpcs3/rpcs3qt/emu_settings.h index 4a7f8ee40d..539102729a 100644 --- a/rpcs3/rpcs3qt/emu_settings.h +++ b/rpcs3/rpcs3qt/emu_settings.h @@ -35,9 +35,7 @@ public: /** Creates a settings object which reads in the config.yml file at rpcs3/bin/%path%/config.yml * Settings are only written when SaveSettings is called. */ - emu_settings(); - - bool Init(); + emu_settings(std::shared_ptr r_creator); /** Connects a combo box with the target settings type*/ void EnhanceComboBox(QComboBox* combobox, emu_settings_type type, bool is_ranged = false, bool use_max = false, int max = 0, bool sorted = false, bool strict = true); @@ -94,7 +92,7 @@ public: emu_settings_type FindSettingsType(const cfg::_base* node) const; /** Gets all the renderer info for gpu settings.*/ - render_creator* m_render_creator = nullptr; + std::shared_ptr m_render_creator; /** Gets a list of all the microphones available.*/ microphone_creator m_microphone_creator; diff --git a/rpcs3/rpcs3qt/gui_application.cpp b/rpcs3/rpcs3qt/gui_application.cpp index 026e98cedd..e24696eb90 100644 --- a/rpcs3/rpcs3qt/gui_application.cpp +++ b/rpcs3/rpcs3qt/gui_application.cpp @@ -126,15 +126,35 @@ bool gui_application::Init() } } - m_emu_settings = std::make_shared(); + if (m_render_creator->vulkan_timed_out) + { + gui_log.error("Vulkan device enumeration timed out"); + const auto button = QMessageBox::critical(nullptr, tr("Vulkan Check Timeout"), + tr("Querying for Vulkan-compatible devices is taking too long. This is usually caused by malfunctioning " + "graphics drivers, reinstalling them could fix the issue.\n\n" + "Selecting ignore starts the emulator without Vulkan support."), + QMessageBox::Ignore | QMessageBox::Abort, QMessageBox::Abort); + + if (button != QMessageBox::Ignore) + { + return false; + } + } + +#ifdef __APPLE__ + if (!m_render_creator->Vulkan.supported) + { + QMessageBox::warning(nullptr, + tr("Warning"), + tr("Vulkan is not supported on this Mac.\n" + "No graphics will be rendered.")); + } +#endif + + m_emu_settings = std::make_shared(m_render_creator); m_gui_settings = std::make_shared(); m_persistent_settings = std::make_shared(); - if (!m_emu_settings->Init()) - { - return false; - } - if (m_gui_settings->GetValue(gui::m_attachCommandLine).toBool()) { utils::attach_console(utils::console_stream::std_err, true); diff --git a/rpcs3/rpcs3qt/render_creator.cpp b/rpcs3/rpcs3qt/render_creator.cpp index 57cd71ecbf..ba074bda2a 100644 --- a/rpcs3/rpcs3qt/render_creator.cpp +++ b/rpcs3/rpcs3qt/render_creator.cpp @@ -1,7 +1,5 @@ #include "render_creator.h" -#include - #include "Utilities/Thread.h" #if defined(HAVE_VULKAN) @@ -15,7 +13,7 @@ LOG_CHANNEL(cfg_log, "CFG"); -render_creator::render_creator(QObject *parent) : QObject(parent) +render_creator::render_creator() { #if defined(HAVE_VULKAN) // Some drivers can get stuck when checking for vulkan-compatible gpus, f.ex. if they're waiting for one to get @@ -73,21 +71,8 @@ render_creator::render_creator(QObject *parent) : QObject(parent) }()) { enum_thread.release(); // Detach thread (destructor is not called) - - cfg_log.error("Vulkan device enumeration timed out"); - const auto button = QMessageBox::critical(nullptr, tr("Vulkan Check Timeout"), - tr("Querying for Vulkan-compatible devices is taking too long. This is usually caused by malfunctioning " - "graphics drivers, reinstalling them could fix the issue.\n\n" - "Selecting ignore starts the emulator without Vulkan support."), - QMessageBox::Ignore | QMessageBox::Abort, QMessageBox::Abort); - - if (button != QMessageBox::Ignore) - { - abort_requested = true; - return; - } - supports_vulkan = false; + vulkan_timed_out = true; } else { @@ -103,14 +88,6 @@ render_creator::render_creator(QObject *parent) : QObject(parent) #ifdef __APPLE__ OpenGL.supported = false; - - if (!Vulkan.supported) - { - QMessageBox::warning(nullptr, - tr("Warning"), - tr("Vulkan is not supported on this Mac.\n" - "No graphics will be rendered.")); - } #endif renderers = { &Vulkan, &OpenGL, &NullRender }; diff --git a/rpcs3/rpcs3qt/render_creator.h b/rpcs3/rpcs3qt/render_creator.h index c433c77353..af672cb2b0 100644 --- a/rpcs3/rpcs3qt/render_creator.h +++ b/rpcs3/rpcs3qt/render_creator.h @@ -2,16 +2,13 @@ #include "emu_settings_type.h" -#include #include #include -class render_creator : public QObject +class render_creator { - Q_OBJECT - public: - render_creator(QObject* parent); + render_creator(); void update_names(const QStringList& names); @@ -33,7 +30,7 @@ public: , supported(supported) {} }; - bool abort_requested = false; + bool vulkan_timed_out = false; bool supports_vulkan = false; QStringList vulkan_adapters; render_info Vulkan; diff --git a/rpcs3/rpcs3qt/settings_dialog.cpp b/rpcs3/rpcs3qt/settings_dialog.cpp index 8dcd0040b0..036d7c41e7 100644 --- a/rpcs3/rpcs3qt/settings_dialog.cpp +++ b/rpcs3/rpcs3qt/settings_dialog.cpp @@ -370,7 +370,7 @@ settings_dialog::settings_dialog(std::shared_ptr gui_settings, std // | |__| | | | |__| | | | (_| | |_) | // \_____|_| \____/ |_|\__,_|_.__/ - render_creator* r_creator = m_emu_settings->m_render_creator; + std::shared_ptr r_creator = m_emu_settings->m_render_creator; if (!r_creator) {