From 77e9938f0fbca403d7c3e284c3be779af82d9eba Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sun, 4 Dec 2022 15:09:22 +1000 Subject: [PATCH] GS: Manually throttle fullscreen UI rendering Fixes rendering at thousands of FPS when pausing if FSUI is active. Avoids flickering when recreating swap chain in vulkan on menu open, because we're no longer doing it. --- pcsx2-gsrunner/Main.cpp | 9 ++------- pcsx2-qt/MainWindow.cpp | 2 +- pcsx2-qt/QtHost.cpp | 20 -------------------- pcsx2/Frontend/CommonHost.cpp | 3 --- pcsx2/Frontend/CommonHotkeys.cpp | 1 - pcsx2/Frontend/D3D11HostDisplay.cpp | 4 ++-- pcsx2/Frontend/D3D11HostDisplay.h | 2 +- pcsx2/Frontend/D3D12HostDisplay.cpp | 4 ++-- pcsx2/Frontend/D3D12HostDisplay.h | 2 +- pcsx2/Frontend/FullscreenUI.cpp | 19 ------------------- pcsx2/Frontend/FullscreenUI.h | 2 -- pcsx2/Frontend/MetalHostDisplay.h | 2 +- pcsx2/Frontend/MetalHostDisplay.mm | 4 ++-- pcsx2/Frontend/OpenGLHostDisplay.cpp | 7 ++++--- pcsx2/Frontend/OpenGLHostDisplay.h | 2 +- pcsx2/Frontend/VulkanHostDisplay.cpp | 3 +-- pcsx2/Frontend/VulkanHostDisplay.h | 2 +- pcsx2/GS.cpp | 4 ++++ pcsx2/GS/GS.cpp | 28 ++++++++++++++++++++++++++++ pcsx2/GS/GS.h | 1 + pcsx2/Host.h | 2 ++ pcsx2/HostDisplay.cpp | 23 ++++++++++++++++++++++- pcsx2/HostDisplay.h | 3 ++- pcsx2/MTGS.cpp | 8 +++----- pcsx2/PAD/Gamepad.h | 7 ++++++- pcsx2/VMManager.cpp | 2 -- pcsx2/gui/AppHost.cpp | 13 ++----------- 27 files changed, 89 insertions(+), 90 deletions(-) diff --git a/pcsx2-gsrunner/Main.cpp b/pcsx2-gsrunner/Main.cpp index 3317927ef4..80a4996a43 100644 --- a/pcsx2-gsrunner/Main.cpp +++ b/pcsx2-gsrunner/Main.cpp @@ -265,7 +265,8 @@ bool Host::AcquireHostDisplay(RenderAPI api, bool clear_state_on_fail) if (!g_host_display) return false; - if (!g_host_display->CreateDevice(wi.value()) || !g_host_display->MakeCurrent() || !g_host_display->SetupDevice() || !ImGuiManager::Initialize()) + if (!g_host_display->CreateDevice(wi.value(), Host::GetEffectiveVSyncMode()) || + !g_host_display->MakeCurrent() || !g_host_display->SetupDevice() || !ImGuiManager::Initialize()) { ReleaseHostDisplay(clear_state_on_fail); return false; @@ -283,12 +284,6 @@ void Host::ReleaseHostDisplay(bool clear_state) g_host_display.reset(); } -VsyncMode Host::GetEffectiveVSyncMode() -{ - // Never vsync! We want to finish as quickly as possible. - return VsyncMode::Off; -} - bool Host::BeginPresentFrame(bool frame_skip) { if (g_host_display->BeginPresent(frame_skip)) diff --git a/pcsx2-qt/MainWindow.cpp b/pcsx2-qt/MainWindow.cpp index 034a546de4..55a6fb18e6 100644 --- a/pcsx2-qt/MainWindow.cpp +++ b/pcsx2-qt/MainWindow.cpp @@ -2012,7 +2012,7 @@ DisplayWidget* MainWindow::createDisplay(bool fullscreen, bool render_to_main) g_emu_thread->connectDisplaySignals(m_display_widget); - if (!g_host_display->CreateDevice(wi.value())) + if (!g_host_display->CreateDevice(wi.value(), Host::GetEffectiveVSyncMode())) { QMessageBox::critical(this, tr("Error"), tr("Failed to create host display device context.")); destroyDisplayWidget(true); diff --git a/pcsx2-qt/QtHost.cpp b/pcsx2-qt/QtHost.cpp index 194d717662..84154e9a85 100644 --- a/pcsx2-qt/QtHost.cpp +++ b/pcsx2-qt/QtHost.cpp @@ -931,26 +931,6 @@ void Host::ReleaseHostDisplay(bool clear_state) g_emu_thread->releaseHostDisplay(clear_state); } -VsyncMode Host::GetEffectiveVSyncMode() -{ - // Force vsync on when running big picture UI, and paused or no VM. - // We check the "running FSUI" flag here, because that way we set the initial vsync - // state when initalizing to on, avoiding an unnecessary switch. - if (FullscreenUI::HasActiveWindow() || (!FullscreenUI::IsInitialized() && g_emu_thread->isRunningFullscreenUI())) - { - const VMState state = VMManager::GetState(); - if (state == VMState::Shutdown || state == VMState::Paused) - return VsyncMode::On; - } - - // Force vsync off when not running at 100% speed. - if (EmuConfig.GS.LimitScalar != 1.0f) - return VsyncMode::Off; - - // Otherwise use the config setting. - return EmuConfig.GS.VsyncEnable; -} - bool Host::BeginPresentFrame(bool frame_skip) { if (!g_host_display->BeginPresent(frame_skip)) diff --git a/pcsx2/Frontend/CommonHost.cpp b/pcsx2/Frontend/CommonHost.cpp index 7b76a473bb..6dba55ceb8 100644 --- a/pcsx2/Frontend/CommonHost.cpp +++ b/pcsx2/Frontend/CommonHost.cpp @@ -346,7 +346,6 @@ void CommonHost::OnVMDestroyed() void CommonHost::OnVMPaused() { InputManager::PauseVibration(); - FullscreenUI::OnVMPaused(); #ifdef ENABLE_ACHIEVEMENTS Achievements::OnPaused(true); @@ -357,8 +356,6 @@ void CommonHost::OnVMPaused() void CommonHost::OnVMResumed() { - FullscreenUI::OnVMResumed(); - #ifdef ENABLE_ACHIEVEMENTS Achievements::OnPaused(false); #endif diff --git a/pcsx2/Frontend/CommonHotkeys.cpp b/pcsx2/Frontend/CommonHotkeys.cpp index ce387af13a..59e33d64a8 100644 --- a/pcsx2/Frontend/CommonHotkeys.cpp +++ b/pcsx2/Frontend/CommonHotkeys.cpp @@ -46,7 +46,6 @@ static void HotkeyAdjustTargetSpeed(double delta) EmuConfig.Framerate.NominalScalar = std::max(min_speed, EmuConfig.GS.LimitScalar + delta); VMManager::SetLimiterMode(LimiterModeType::Nominal); gsUpdateFrequency(EmuConfig); - GetMTGS().UpdateVSyncMode(); Host::AddIconOSDMessage("SpeedChanged", ICON_FA_CLOCK, fmt::format("Target speed set to {:.0f}%.", std::round(EmuConfig.Framerate.NominalScalar * 100.0)), Host::OSD_QUICK_DURATION); } diff --git a/pcsx2/Frontend/D3D11HostDisplay.cpp b/pcsx2/Frontend/D3D11HostDisplay.cpp index 865fae31f7..e57caf9988 100644 --- a/pcsx2/Frontend/D3D11HostDisplay.cpp +++ b/pcsx2/Frontend/D3D11HostDisplay.cpp @@ -210,7 +210,7 @@ void D3D11HostDisplay::SetVSync(VsyncMode mode) m_vsync_mode = mode; } -bool D3D11HostDisplay::CreateDevice(const WindowInfo& wi) +bool D3D11HostDisplay::CreateDevice(const WindowInfo& wi, VsyncMode vsync) { UINT create_flags = 0; if (EmuConfig.GS.UseDebugDevice) @@ -314,7 +314,7 @@ bool D3D11HostDisplay::CreateDevice(const WindowInfo& wi) } m_window_info = wi; - m_vsync_mode = Host::GetEffectiveVSyncMode(); + m_vsync_mode = vsync; if (m_window_info.type != WindowInfo::Type::Surfaceless && !CreateSwapChain(nullptr)) return false; diff --git a/pcsx2/Frontend/D3D11HostDisplay.h b/pcsx2/Frontend/D3D11HostDisplay.h index 6eccfd8afe..57ff3dd143 100644 --- a/pcsx2/Frontend/D3D11HostDisplay.h +++ b/pcsx2/Frontend/D3D11HostDisplay.h @@ -43,7 +43,7 @@ public: bool HasDevice() const override; bool HasSurface() const override; - bool CreateDevice(const WindowInfo& wi) override; + bool CreateDevice(const WindowInfo& wi, VsyncMode vsync) override; bool SetupDevice() override; bool MakeCurrent() override; diff --git a/pcsx2/Frontend/D3D12HostDisplay.cpp b/pcsx2/Frontend/D3D12HostDisplay.cpp index eec5aa02f1..cdb4c07ad3 100644 --- a/pcsx2/Frontend/D3D12HostDisplay.cpp +++ b/pcsx2/Frontend/D3D12HostDisplay.cpp @@ -136,7 +136,7 @@ void D3D12HostDisplay::SetVSync(VsyncMode mode) m_vsync_mode = mode; } -bool D3D12HostDisplay::CreateDevice(const WindowInfo& wi) +bool D3D12HostDisplay::CreateDevice(const WindowInfo& wi, VsyncMode vsync) { ComPtr temp_dxgi_factory; HRESULT hr = CreateDXGIFactory(IID_PPV_ARGS(temp_dxgi_factory.put())); @@ -190,7 +190,7 @@ bool D3D12HostDisplay::CreateDevice(const WindowInfo& wi) } m_window_info = wi; - m_vsync_mode = Host::GetEffectiveVSyncMode(); + m_vsync_mode = vsync; if (m_window_info.type != WindowInfo::Type::Surfaceless && !CreateSwapChain(nullptr)) return false; diff --git a/pcsx2/Frontend/D3D12HostDisplay.h b/pcsx2/Frontend/D3D12HostDisplay.h index 2377cf4fe8..696cece5c6 100644 --- a/pcsx2/Frontend/D3D12HostDisplay.h +++ b/pcsx2/Frontend/D3D12HostDisplay.h @@ -49,7 +49,7 @@ public: bool HasDevice() const override; bool HasSurface() const override; - bool CreateDevice(const WindowInfo& wi) override; + bool CreateDevice(const WindowInfo& wi, VsyncMode vsync) override; bool SetupDevice() override; bool MakeCurrent() override; diff --git a/pcsx2/Frontend/FullscreenUI.cpp b/pcsx2/Frontend/FullscreenUI.cpp index 58a1369a70..cf537590b6 100644 --- a/pcsx2/Frontend/FullscreenUI.cpp +++ b/pcsx2/Frontend/FullscreenUI.cpp @@ -623,24 +623,6 @@ void FullscreenUI::OnVMStarted() }); } -void FullscreenUI::OnVMPaused() -{ - if (!IsInitialized()) - return; - - // Force vsync on. - GetMTGS().UpdateVSyncMode(); -} - -void FullscreenUI::OnVMResumed() -{ - if (!IsInitialized()) - return; - - // Restore game vsync. - GetMTGS().UpdateVSyncMode(); -} - void FullscreenUI::OnVMDestroyed() { if (!IsInitialized()) @@ -652,7 +634,6 @@ void FullscreenUI::OnVMDestroyed() s_pause_menu_was_open = false; SwitchToLanding(); - GetMTGS().UpdateVSyncMode(); }); } diff --git a/pcsx2/Frontend/FullscreenUI.h b/pcsx2/Frontend/FullscreenUI.h index 6ac421e21e..4dd708a4b9 100644 --- a/pcsx2/Frontend/FullscreenUI.h +++ b/pcsx2/Frontend/FullscreenUI.h @@ -30,8 +30,6 @@ namespace FullscreenUI bool HasActiveWindow(); void CheckForConfigChanges(const Pcsx2Config& old_config); void OnVMStarted(); - void OnVMPaused(); - void OnVMResumed(); void OnVMDestroyed(); void OnRunningGameChanged(std::string path, std::string serial, std::string title, u32 crc); void OpenPauseMenu(); diff --git a/pcsx2/Frontend/MetalHostDisplay.h b/pcsx2/Frontend/MetalHostDisplay.h index aed0b5f5c2..436ca9a157 100644 --- a/pcsx2/Frontend/MetalHostDisplay.h +++ b/pcsx2/Frontend/MetalHostDisplay.h @@ -64,7 +64,7 @@ public: bool HasDevice() const override; bool HasSurface() const override; - bool CreateDevice(const WindowInfo& wi) override; + bool CreateDevice(const WindowInfo& wi, VsyncMode vsync) override; bool SetupDevice() override; bool MakeCurrent() override; bool DoneCurrent() override; diff --git a/pcsx2/Frontend/MetalHostDisplay.mm b/pcsx2/Frontend/MetalHostDisplay.mm index e51b567756..8e372cab9d 100644 --- a/pcsx2/Frontend/MetalHostDisplay.mm +++ b/pcsx2/Frontend/MetalHostDisplay.mm @@ -103,7 +103,7 @@ void MetalHostDisplay::DetachSurfaceOnMainThread() m_layer = nullptr; } -bool MetalHostDisplay::CreateDevice(const WindowInfo& wi) +bool MetalHostDisplay::CreateDevice(const WindowInfo& wi, VsyncMode vsync) { @autoreleasepool { m_window_info = wi; pxAssertRel(!m_dev.dev, "Device already created!"); @@ -152,7 +152,7 @@ bool MetalHostDisplay::CreateDevice(const WindowInfo& wi) { AttachSurfaceOnMainThread(); }); - SetVSync(Host::GetEffectiveVSyncMode()); + SetVSync(vsync); return true; } else diff --git a/pcsx2/Frontend/OpenGLHostDisplay.cpp b/pcsx2/Frontend/OpenGLHostDisplay.cpp index b6a332460d..31884ec531 100644 --- a/pcsx2/Frontend/OpenGLHostDisplay.cpp +++ b/pcsx2/Frontend/OpenGLHostDisplay.cpp @@ -143,7 +143,7 @@ void OpenGLHostDisplay::UpdateTexture(HostDisplayTexture* texture, u32 x, u32 y, void OpenGLHostDisplay::SetVSync(VsyncMode mode) { - if (m_gl_context->GetWindowInfo().type == WindowInfo::Type::Surfaceless) + if (m_vsync_mode == mode || m_gl_context->GetWindowInfo().type == WindowInfo::Type::Surfaceless) return; // Window framebuffer has to be bound to call SetSwapInterval. @@ -155,6 +155,7 @@ void OpenGLHostDisplay::SetVSync(VsyncMode mode) m_gl_context->SetSwapInterval(static_cast(mode != VsyncMode::Off)); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, current_fbo); + m_vsync_mode = mode; } const char* OpenGLHostDisplay::GetGLSLVersionString() const @@ -198,7 +199,7 @@ bool OpenGLHostDisplay::HasSurface() const return m_window_info.type != WindowInfo::Type::Surfaceless; } -bool OpenGLHostDisplay::CreateDevice(const WindowInfo& wi) +bool OpenGLHostDisplay::CreateDevice(const WindowInfo& wi, VsyncMode vsync) { m_gl_context = GL::Context::Create(wi); if (!m_gl_context) @@ -209,7 +210,7 @@ bool OpenGLHostDisplay::CreateDevice(const WindowInfo& wi) } m_window_info = m_gl_context->GetWindowInfo(); - m_vsync_mode = Host::GetEffectiveVSyncMode(); + m_vsync_mode = vsync; return true; } diff --git a/pcsx2/Frontend/OpenGLHostDisplay.h b/pcsx2/Frontend/OpenGLHostDisplay.h index 345592e251..20469fe3e9 100644 --- a/pcsx2/Frontend/OpenGLHostDisplay.h +++ b/pcsx2/Frontend/OpenGLHostDisplay.h @@ -38,7 +38,7 @@ public: bool HasDevice() const override; bool HasSurface() const override; - bool CreateDevice(const WindowInfo& wi) override; + bool CreateDevice(const WindowInfo& wi, VsyncMode vsync) override; bool SetupDevice() override; bool MakeCurrent() override; diff --git a/pcsx2/Frontend/VulkanHostDisplay.cpp b/pcsx2/Frontend/VulkanHostDisplay.cpp index f19de05657..52cec047cc 100644 --- a/pcsx2/Frontend/VulkanHostDisplay.cpp +++ b/pcsx2/Frontend/VulkanHostDisplay.cpp @@ -274,10 +274,9 @@ void VulkanHostDisplay::SetVSync(VsyncMode mode) m_vsync_mode = mode; } -bool VulkanHostDisplay::CreateDevice(const WindowInfo& wi) +bool VulkanHostDisplay::CreateDevice(const WindowInfo& wi, VsyncMode vsync) { WindowInfo local_wi(wi); - const VsyncMode vsync = Host::GetEffectiveVSyncMode(); const bool debug_device = EmuConfig.GS.UseDebugDevice; if (!Vulkan::Context::Create(EmuConfig.GS.Adapter, &local_wi, &m_swap_chain, GetPreferredPresentModeForVsyncMode(vsync), EmuConfig.GS.ThreadedPresentation, debug_device, debug_device)) diff --git a/pcsx2/Frontend/VulkanHostDisplay.h b/pcsx2/Frontend/VulkanHostDisplay.h index f308cc1cbc..91d29c984b 100644 --- a/pcsx2/Frontend/VulkanHostDisplay.h +++ b/pcsx2/Frontend/VulkanHostDisplay.h @@ -27,7 +27,7 @@ public: bool HasDevice() const override; bool HasSurface() const override; - bool CreateDevice(const WindowInfo& wi) override; + bool CreateDevice(const WindowInfo& wi, VsyncMode vsync) override; bool SetupDevice() override; bool MakeCurrent() override; diff --git a/pcsx2/GS.cpp b/pcsx2/GS.cpp index 5d5ee06ea7..7754b147d0 100644 --- a/pcsx2/GS.cpp +++ b/pcsx2/GS.cpp @@ -74,6 +74,10 @@ void gsUpdateFrequency(Pcsx2Config& config) config.GS.LimitScalar = 0.0f; } +#ifdef PCSX2_CORE + GetMTGS().UpdateVSyncMode(); +#endif + UpdateVSyncRate(); } diff --git a/pcsx2/GS/GS.cpp b/pcsx2/GS/GS.cpp index ed2e6331ae..d52a18079d 100644 --- a/pcsx2/GS/GS.cpp +++ b/pcsx2/GS/GS.cpp @@ -77,6 +77,7 @@ static HRESULT s_hr = E_FAIL; Pcsx2Config::GSOptions GSConfig; static RenderAPI s_render_api; +static u64 s_next_manual_present_time; int GSinit() { @@ -554,6 +555,33 @@ void GSPresentCurrentFrame() g_gs_renderer->PresentCurrentFrame(); } +void GSThrottlePresentation() +{ + if (g_host_display->GetVsyncMode() != VsyncMode::Off) + { + // Let vsync take care of throttling. + return; + } + + // Manually throttle presentation when vsync isn't enabled, so we don't try to render the + // fullscreen UI at thousands of FPS and make the gpu go brrrrrrrr. + const float surface_refresh_rate = g_host_display->GetWindowInfo().surface_refresh_rate; + const float throttle_rate = (surface_refresh_rate > 0.0f) ? surface_refresh_rate : 60.0f; + + const u64 sleep_period = static_cast(static_cast(GetTickFrequency()) / static_cast(throttle_rate)); + const u64 current_ts = GetCPUTicks(); + + // Allow it to fall behind/run ahead up to 2*period. Sleep isn't that precise, plus we need to + // allow time for the actual rendering. + const u64 max_variance = sleep_period * 2; + if (static_cast(std::abs(static_cast(current_ts - s_next_manual_present_time))) > max_variance) + s_next_manual_present_time = current_ts + sleep_period; + else + s_next_manual_present_time += sleep_period; + + Threading::SleepUntil(s_next_manual_present_time); +} + #ifndef PCSX2_CORE void GSkeyEvent(const HostKeyEvent& e) diff --git a/pcsx2/GS/GS.h b/pcsx2/GS/GS.h index e17e39c1d4..338143a8ae 100644 --- a/pcsx2/GS/GS.h +++ b/pcsx2/GS/GS.h @@ -72,6 +72,7 @@ int GSfreeze(FreezeAction mode, freezeData* data); void GSQueueSnapshot(const std::string& path, u32 gsdump_frames = 0); void GSStopGSDump(); void GSPresentCurrentFrame(); +void GSThrottlePresentation(); #ifndef PCSX2_CORE void GSkeyEvent(const HostKeyEvent& e); void GSconfigure(); diff --git a/pcsx2/Host.h b/pcsx2/Host.h index 0bd9df14bb..21cc8d05bd 100644 --- a/pcsx2/Host.h +++ b/pcsx2/Host.h @@ -24,6 +24,7 @@ #include #include +#ifndef PCSX2_CORE struct HostKeyEvent { enum class Type @@ -43,6 +44,7 @@ struct HostKeyEvent Type type; u32 key; }; +#endif namespace Host { diff --git a/pcsx2/HostDisplay.cpp b/pcsx2/HostDisplay.cpp index cdcb38e817..e208cac3fb 100644 --- a/pcsx2/HostDisplay.cpp +++ b/pcsx2/HostDisplay.cpp @@ -16,9 +16,15 @@ #include "PrecompiledHeader.h" #include "HostDisplay.h" + +#ifdef PCSX2_CORE +#include "VMManager.h" +#endif + #include "common/Assertions.h" #include "common/Console.h" #include "common/StringUtil.h" + #include #include #include @@ -128,6 +134,22 @@ std::string HostDisplay::GetFullscreenModeString(u32 width, u32 height, float re return StringUtil::StdStringFromFormat("%u x %u @ %f hz", width, height, refresh_rate); } +VsyncMode Host::GetEffectiveVSyncMode() +{ +#ifdef PCSX2_CORE + const bool has_vm = VMManager::GetState() != VMState::Shutdown; +#else + const bool has_vm = false; +#endif + + // Force vsync off when not running at 100% speed. + if (has_vm && EmuConfig.GS.LimitScalar != 1.0f) + return VsyncMode::Off; + + // Otherwise use the config setting. + return EmuConfig.GS.VsyncEnable; +} + #ifdef ENABLE_OPENGL #include "Frontend/OpenGLHostDisplay.h" #endif @@ -173,4 +195,3 @@ std::unique_ptr HostDisplay::CreateForAPI(RenderAPI api) return {}; } } - diff --git a/pcsx2/HostDisplay.h b/pcsx2/HostDisplay.h index eb10a24cd4..a3c6af85d1 100644 --- a/pcsx2/HostDisplay.h +++ b/pcsx2/HostDisplay.h @@ -84,6 +84,7 @@ public: __fi s32 GetWindowWidth() const { return static_cast(m_window_info.surface_width); } __fi s32 GetWindowHeight() const { return static_cast(m_window_info.surface_height); } __fi float GetWindowScale() const { return m_window_info.surface_scale; } + __fi VsyncMode GetVsyncMode() const { return m_vsync_mode; } /// Changes the alignment for this display (screen positioning). __fi Alignment GetDisplayAlignment() const { return m_display_alignment; } @@ -98,7 +99,7 @@ public: virtual bool HasSurface() const = 0; /// Creates the rendering/GPU device. This should be called on the thread which owns the window. - virtual bool CreateDevice(const WindowInfo& wi) = 0; + virtual bool CreateDevice(const WindowInfo& wi, VsyncMode vsync) = 0; /// Fully initializes the rendering device. This should be called on the GS thread. virtual bool SetupDevice() = 0; diff --git a/pcsx2/MTGS.cpp b/pcsx2/MTGS.cpp index 2587773aa9..3ed792d4b1 100644 --- a/pcsx2/MTGS.cpp +++ b/pcsx2/MTGS.cpp @@ -298,16 +298,14 @@ void SysMtgsThread::MainLoop() while (true) { - - // Performance note: Both of these perform cancellation tests, but pthread_testcancel - // is very optimized (only 1 instruction test in most cases), so no point in trying - // to avoid it. - #ifdef PCSX2_CORE if (m_run_idle_flag.load(std::memory_order_acquire) && VMManager::GetState() != VMState::Running) { if (!m_sem_event.CheckForWork()) + { GSPresentCurrentFrame(); + GSThrottlePresentation(); + } } else { diff --git a/pcsx2/PAD/Gamepad.h b/pcsx2/PAD/Gamepad.h index 9842794081..9e76575c6d 100644 --- a/pcsx2/PAD/Gamepad.h +++ b/pcsx2/PAD/Gamepad.h @@ -27,11 +27,16 @@ void PADclose(); u8 PADstartPoll(int port, int slot); u8 PADpoll(u8 value); bool PADcomplete(); -HostKeyEvent* PADkeyEvent(); void PADconfigure(); s32 PADfreeze(FreezeAction mode, freezeData* data); s32 PADsetSlot(u8 port, u8 slot); +#ifndef PCSX2_CORE + +HostKeyEvent* PADkeyEvent(); + #if defined(__unix__) || defined(__APPLE__) void PADWriteEvent(HostKeyEvent& evt); #endif + +#endif \ No newline at end of file diff --git a/pcsx2/VMManager.cpp b/pcsx2/VMManager.cpp index 1200072aa1..3b1f55497d 100644 --- a/pcsx2/VMManager.cpp +++ b/pcsx2/VMManager.cpp @@ -1393,7 +1393,6 @@ void VMManager::SetLimiterMode(LimiterModeType type) EmuConfig.LimiterMode = type; gsUpdateFrequency(EmuConfig); - GetMTGS().UpdateVSyncMode(); } void VMManager::FrameAdvance(u32 num_frames /*= 1*/) @@ -1635,7 +1634,6 @@ void VMManager::CheckForFramerateConfigChanges(const Pcsx2Config& old_config) gsUpdateFrequency(EmuConfig); UpdateVSyncRate(); frameLimitReset(); - GetMTGS().UpdateVSyncMode(); } void VMManager::CheckForPatchConfigChanges(const Pcsx2Config& old_config) diff --git a/pcsx2/gui/AppHost.cpp b/pcsx2/gui/AppHost.cpp index 467a56a6dc..f82f0f4522 100644 --- a/pcsx2/gui/AppHost.cpp +++ b/pcsx2/gui/AppHost.cpp @@ -129,7 +129,8 @@ bool Host::AcquireHostDisplay(RenderAPI api, bool clear_state_on_fail) if (!g_host_display) return false; - if (!g_host_display->CreateDevice(g_gs_window_info) || !g_host_display->SetupDevice() || !ImGuiManager::Initialize()) + if (!g_host_display->CreateDevice(g_gs_window_info, Host::GetEffectiveVSyncMode()) || + !g_host_display->SetupDevice() || !ImGuiManager::Initialize()) { g_host_display.reset(); return false; @@ -151,16 +152,6 @@ void Host::ReleaseHostDisplay(bool clear_state_on_fail) sApp.CloseGsPanel(); } -VsyncMode Host::GetEffectiveVSyncMode() -{ - // Force vsync off when not running at 100% speed. - if (EmuConfig.GS.LimitScalar != 1.0f) - return VsyncMode::Off; - - // Otherwise use the config setting. - return EmuConfig.GS.VsyncEnable; -} - bool Host::BeginPresentFrame(bool frame_skip) { CheckForGSWindowResize();