From 55d96f86f0348543dfe29a42934966f1abf4cce7 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sun, 26 May 2024 22:30:34 +1000 Subject: [PATCH] System: Add "Disable Mailbox Presentation" option Partial backport of https://github.com/PCSX2/pcsx2/pull/11296 --- src/core/fullscreen_ui.cpp | 10 ++++- src/core/fullscreen_ui.h | 1 + src/core/settings.cpp | 2 + src/core/settings.h | 1 + src/core/system.cpp | 11 ++++- src/duckstation-qt/graphicssettingswidget.cpp | 9 +++- src/duckstation-qt/graphicssettingswidget.ui | 41 +++++++++++-------- 7 files changed, 53 insertions(+), 22 deletions(-) diff --git a/src/core/fullscreen_ui.cpp b/src/core/fullscreen_ui.cpp index de7a9b2a2..dc0217f08 100644 --- a/src/core/fullscreen_ui.cpp +++ b/src/core/fullscreen_ui.cpp @@ -4283,6 +4283,12 @@ void FullscreenUI::DrawDisplaySettingsPage() break; } + DrawToggleSetting( + bsi, FSUI_CSTR("Disable Mailbox Presentation"), + FSUI_CSTR("Forces the use of FIFO over Mailbox presentation, i.e. double buffering instead of triple buffering. " + "Usually results in worse frame pacing."), + "Display", "DisableMailboxPresentation", false); + if (renderer != GPURenderer::Software) { DrawToggleSetting( @@ -7296,13 +7302,13 @@ TRANSLATE_NOOP("FullscreenUI", "Determines which algorithm is used to convert in TRANSLATE_NOOP("FullscreenUI", "Device Settings"); TRANSLATE_NOOP("FullscreenUI", "Disable All Enhancements"); TRANSLATE_NOOP("FullscreenUI", "Disable Interlacing"); +TRANSLATE_NOOP("FullscreenUI", "Disable Mailbox Presentation"); TRANSLATE_NOOP("FullscreenUI", "Disable Subdirectory Scanning"); TRANSLATE_NOOP("FullscreenUI", "Disabled"); TRANSLATE_NOOP("FullscreenUI", "Disables dithering and uses the full 8 bits per channel of color information."); TRANSLATE_NOOP("FullscreenUI", "Disables interlaced rendering and display in the GPU. Some games can render in 480p this way, but others will break."); TRANSLATE_NOOP("FullscreenUI", "Disc {} | {}"); TRANSLATE_NOOP("FullscreenUI", "Discord Server"); -TRANSLATE_NOOP("FullscreenUI", "Display FPS Limit"); TRANSLATE_NOOP("FullscreenUI", "Display Settings"); TRANSLATE_NOOP("FullscreenUI", "Displays popup messages on events such as achievement unlocks and leaderboard submissions."); TRANSLATE_NOOP("FullscreenUI", "Displays popup messages when starting, submitting, or failing a leaderboard challenge."); @@ -7371,6 +7377,7 @@ TRANSLATE_NOOP("FullscreenUI", "Force 4:3 For 24-Bit Display"); TRANSLATE_NOOP("FullscreenUI", "Force NTSC Timings"); TRANSLATE_NOOP("FullscreenUI", "Forces PAL games to run at NTSC timings, i.e. 60hz. Some PAL games will run at their \"normal\" speeds, while others will break."); TRANSLATE_NOOP("FullscreenUI", "Forces a full rescan of all games previously identified."); +TRANSLATE_NOOP("FullscreenUI", "Forces the use of FIFO over Mailbox presentation, i.e. double buffering instead of triple buffering. Usually results in worse frame pacing."); TRANSLATE_NOOP("FullscreenUI", "Forcibly mutes both CD-DA and XA audio from the CD-ROM. Can be used to disable background music in some games."); TRANSLATE_NOOP("FullscreenUI", "Frame Time Buffer"); TRANSLATE_NOOP("FullscreenUI", "From File..."); @@ -7429,7 +7436,6 @@ TRANSLATE_NOOP("FullscreenUI", "Launch a game from images scanned from your game TRANSLATE_NOOP("FullscreenUI", "Leaderboard Notifications"); TRANSLATE_NOOP("FullscreenUI", "Leaderboards"); TRANSLATE_NOOP("FullscreenUI", "Leaderboards are not enabled."); -TRANSLATE_NOOP("FullscreenUI", "Limits how many frames are displayed to the screen. These frames are still rendered."); TRANSLATE_NOOP("FullscreenUI", "Line Detection"); TRANSLATE_NOOP("FullscreenUI", "List Settings"); TRANSLATE_NOOP("FullscreenUI", "Load Devices From Save States"); diff --git a/src/core/fullscreen_ui.h b/src/core/fullscreen_ui.h index 5942239f3..f33da4566 100644 --- a/src/core/fullscreen_ui.h +++ b/src/core/fullscreen_ui.h @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin +// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #pragma once diff --git a/src/core/settings.cpp b/src/core/settings.cpp index 31a452dfb..18834dfe2 100644 --- a/src/core/settings.cpp +++ b/src/core/settings.cpp @@ -277,6 +277,7 @@ void Settings::Load(SettingsInterface& si) si.GetFloatValue("Display", "PreFrameSleepBuffer", DEFAULT_DISPLAY_PRE_FRAME_SLEEP_BUFFER); display_skip_presenting_duplicate_frames = si.GetBoolValue("Display", "SkipPresentingDuplicateFrames", false); display_vsync = si.GetBoolValue("Display", "VSync", false); + display_disable_mailbox_presentation = si.GetBoolValue("Display", "DisableMailboxPresentation", false); display_force_4_3_for_24bit = si.GetBoolValue("Display", "Force4_3For24Bit", false); display_active_start_offset = static_cast(si.GetIntValue("Display", "ActiveStartOffset", 0)); display_active_end_offset = static_cast(si.GetIntValue("Display", "ActiveEndOffset", 0)); @@ -529,6 +530,7 @@ void Settings::Save(SettingsInterface& si, bool ignore_base) const si.SetBoolValue("Display", "SkipPresentingDuplicateFrames", display_skip_presenting_duplicate_frames); si.SetFloatValue("Display", "PreFrameSleepBuffer", display_pre_frame_sleep_buffer); si.SetBoolValue("Display", "VSync", display_vsync); + si.SetBoolValue("Display", "DisableMailboxPresentation", display_disable_mailbox_presentation); si.SetStringValue("Display", "ExclusiveFullscreenControl", GetDisplayExclusiveFullscreenControlName(display_exclusive_fullscreen_control)); si.SetStringValue("Display", "ScreenshotMode", GetDisplayScreenshotModeName(display_screenshot_mode)); diff --git a/src/core/settings.h b/src/core/settings.h index 92d4ea011..13f5639a6 100644 --- a/src/core/settings.h +++ b/src/core/settings.h @@ -152,6 +152,7 @@ struct Settings bool display_pre_frame_sleep : 1 = false; bool display_skip_presenting_duplicate_frames : 1 = false; bool display_vsync : 1 = false; + bool display_disable_mailbox_presentation : 1 = true; bool display_force_4_3_for_24bit : 1 = false; bool gpu_24bit_chroma_smoothing : 1 = false; bool display_show_osd_messages : 1 = true; diff --git a/src/core/system.cpp b/src/core/system.cpp index e6f6b4e55..0873fd5c9 100644 --- a/src/core/system.cpp +++ b/src/core/system.cpp @@ -2962,8 +2962,11 @@ GPUVSyncMode System::GetEffectiveVSyncMode() // If there's no VM, or we're using vsync for timing, then we always use double-buffered (blocking). // Try to keep the same present mode whether we're running or not, since it'll avoid flicker. const bool valid_vm = (s_state != State::Shutdown && s_state != State::Stopping); - if (s_can_sync_to_host || (!valid_vm && g_settings.sync_to_host_refresh_rate)) + if (s_can_sync_to_host || (!valid_vm && g_settings.sync_to_host_refresh_rate) || + g_settings.display_disable_mailbox_presentation) + { return GPUVSyncMode::FIFO; + } // For PAL games, we always want to triple buffer, because otherwise we'll be tearing. // Or for when we aren't using sync-to-host-refresh, to avoid dropping frames. @@ -4054,6 +4057,7 @@ void System::CheckForSettingsChanges(const Settings& old_settings) g_settings.display_pre_frame_sleep != old_settings.display_pre_frame_sleep || g_settings.display_pre_frame_sleep_buffer != old_settings.display_pre_frame_sleep_buffer || g_settings.display_vsync != old_settings.display_vsync || + g_settings.display_disable_mailbox_presentation != old_settings.display_disable_mailbox_presentation || g_settings.sync_to_host_refresh_rate != old_settings.sync_to_host_refresh_rate) { UpdateSpeedLimiterState(); @@ -4073,8 +4077,11 @@ void System::CheckForSettingsChanges(const Settings& old_settings) { if (g_gpu_device) { - if (g_settings.display_vsync != old_settings.display_vsync) + if (g_settings.display_vsync != old_settings.display_vsync || + g_settings.display_disable_mailbox_presentation != old_settings.display_disable_mailbox_presentation) + { UpdateDisplayVSync(); + } } } diff --git a/src/duckstation-qt/graphicssettingswidget.cpp b/src/duckstation-qt/graphicssettingswidget.cpp index 564c0171e..850e83acc 100644 --- a/src/duckstation-qt/graphicssettingswidget.cpp +++ b/src/duckstation-qt/graphicssettingswidget.cpp @@ -124,7 +124,10 @@ GraphicsSettingsWidget::GraphicsSettingsWidget(SettingsWindow* dialog, QWidget* &Settings::ParseDisplayAlignment, &Settings::GetDisplayAlignmentName, Settings::DEFAULT_DISPLAY_ALIGNMENT); SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.gpuThread, "GPU", "UseThread", true); - SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.threadedPresentation, "GPU", "ThreadedPresentation", true); + SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.threadedPresentation, "GPU", "ThreadedPresentation", + Settings::DEFAULT_THREADED_PRESENTATION); + SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.disableMailboxPresentation, "Display", + "DisableMailboxPresentation", false); SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.stretchDisplayVertically, "Display", "StretchVertically", false); #ifdef _WIN32 @@ -334,6 +337,10 @@ GraphicsSettingsWidget::GraphicsSettingsWidget(SettingsWindow* dialog, QWidget* dialog->registerWidgetHelp(m_ui.threadedPresentation, tr("Threaded Presentation"), tr("Checked"), tr("Presents frames on a background thread when fast forwarding or vsync is disabled. " "This can measurably improve performance in the Vulkan renderer.")); + dialog->registerWidgetHelp( + m_ui.disableMailboxPresentation, tr("Disable Mailbox Presentation"), tr("Unchecked"), + tr("Forces the use of FIFO over Mailbox presentation, i.e. double buffering instead of triple buffering. " + "Usually results in worse frame pacing.")); dialog->registerWidgetHelp( m_ui.stretchDisplayVertically, tr("Stretch Vertically"), tr("Unchecked"), tr("Prefers stretching the display vertically instead of horizontally, when applying the display aspect ratio.")); diff --git a/src/duckstation-qt/graphicssettingswidget.ui b/src/duckstation-qt/graphicssettingswidget.ui index 441b84962..b38590351 100644 --- a/src/duckstation-qt/graphicssettingswidget.ui +++ b/src/duckstation-qt/graphicssettingswidget.ui @@ -417,20 +417,6 @@ - - - - Use Blit Swap Chain - - - - - - - Stretch Vertically - - - @@ -439,9 +425,23 @@ - + - Threaded Rendering + Use Blit Swap Chain + + + + + + + Stretch Vertically + + + + + + + Disable Mailbox Presentation @@ -482,13 +482,20 @@ - + Software Renderer Readbacks + + + + Threaded Rendering + + +