Do not re-use the old game window if the renderer changed

This commit is contained in:
Megamouse 2025-01-04 18:35:03 +01:00
parent 2ac171a30f
commit c443326fb1
4 changed files with 12 additions and 3 deletions

View File

@ -1147,7 +1147,7 @@ game_boot_result Emulator::Load(const std::string& title_id, bool is_disc_patch,
bool resolve_path_as_vfs_path = false;
const bool from_dev_flash = IsPathInsideDir(m_path, g_cfg_vfs.get_dev_flash());
const bool from_dev_flash = IsPathInsideDir(m_path, g_cfg_vfs.get_dev_flash());
std::string savestate_build_version;
std::string savestate_creation_date;

View File

@ -73,6 +73,7 @@ gs_frame::gs_frame(QScreen* screen, const QRect& geometry, const QIcon& appIcon,
, m_initial_geometry(geometry)
, m_gui_settings(std::move(gui_settings))
, m_start_games_fullscreen(force_fullscreen)
, m_renderer(g_cfg.video.renderer)
{
load_gui_settings();

View File

@ -15,6 +15,7 @@
#include <vector>
class gui_settings;
enum class video_renderer;
class gs_frame : public QWindow, public GSFrameBase
{
@ -53,6 +54,8 @@ public:
explicit gs_frame(QScreen* screen, const QRect& geometry, const QIcon& appIcon, std::shared_ptr<gui_settings> gui_settings, bool force_fullscreen);
~gs_frame();
video_renderer renderer() const { return m_renderer; };
void ignore_stop_events() { m_ignore_stop_events = true; }
draw_context_t make_context() override;
@ -79,6 +82,8 @@ public:
void take_screenshot(std::vector<u8> data, u32 sshot_width, u32 sshot_height, bool is_bgra) override;
protected:
video_renderer m_renderer;
void paintEvent(QPaintEvent *event) override;
void showEvent(QShowEvent *event) override;

View File

@ -356,7 +356,10 @@ std::unique_ptr<gs_frame> gui_application::get_gs_frame()
// Check if the continuous mode is enabled. We reset the mode after each use in order to ensure that it is only used when explicitly needed.
const bool continuous_mode_enabled = Emu.ContinuousModeEnabled(true);
if (Emu.IsChildProcess() || continuous_mode_enabled)
// Make sure we run the same config
const bool is_same_renderer = m_game_window->renderer() == g_cfg.video.renderer;
if (is_same_renderer && (Emu.IsChildProcess() || continuous_mode_enabled))
{
gui_log.notice("gui_application: Re-using old game window (IsChildProcess=%d, ContinuousModeEnabled=%d)", Emu.IsChildProcess(), continuous_mode_enabled);
@ -367,7 +370,7 @@ std::unique_ptr<gs_frame> gui_application::get_gs_frame()
return std::unique_ptr<gs_frame>(m_game_window);
}
// Clean-up old game window. This should only happen if there was an unexpected error during boot.
// Clean-up old game window. This should only happen if the renderer changed or there was an unexpected error during boot.
Emu.GetCallbacks().close_gs_frame();
}