summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar bunnei2022-07-17 13:59:52 -0700
committerGravatar GitHub2022-07-17 13:59:52 -0700
commitba8ea956242537d862b4f9b5d27b95a5a6928ea7 (patch)
treef776066179ea4c1e2671ff3dc3811ed7301261a9
parentMerge pull request #8544 from german77/14dot0 (diff)
parenthle: service: nvflinger: Fix implicit conversion. (diff)
downloadyuzu-ba8ea956242537d862b4f9b5d27b95a5a6928ea7.tar.gz
yuzu-ba8ea956242537d862b4f9b5d27b95a5a6928ea7.tar.xz
yuzu-ba8ea956242537d862b4f9b5d27b95a5a6928ea7.zip
Merge pull request #8508 from yuzu-emu/mc-speed-limit
hle: service: nvflinger: Factor speed limit into frame time calculation.
Diffstat (limited to '')
-rw-r--r--src/common/settings.cpp1
-rw-r--r--src/common/settings.h2
-rw-r--r--src/core/hle/service/nvflinger/nvflinger.cpp18
-rw-r--r--src/video_core/renderer_vulkan/vk_swapchain.cpp6
-rw-r--r--src/yuzu/configuration/config.cpp2
-rw-r--r--src/yuzu/configuration/configure_general.cpp24
-rw-r--r--src/yuzu/configuration/configure_general.ui81
-rw-r--r--src/yuzu/main.cpp7
-rw-r--r--src/yuzu_cmd/config.cpp2
-rw-r--r--src/yuzu_cmd/default_ini.h7
10 files changed, 20 insertions, 130 deletions
diff --git a/src/common/settings.cpp b/src/common/settings.cpp
index 751549583..d4c52989a 100644
--- a/src/common/settings.cpp
+++ b/src/common/settings.cpp
@@ -185,7 +185,6 @@ void RestoreGlobalState(bool is_powered_on) {
185 values.max_anisotropy.SetGlobal(true); 185 values.max_anisotropy.SetGlobal(true);
186 values.use_speed_limit.SetGlobal(true); 186 values.use_speed_limit.SetGlobal(true);
187 values.speed_limit.SetGlobal(true); 187 values.speed_limit.SetGlobal(true);
188 values.fps_cap.SetGlobal(true);
189 values.use_disk_shader_cache.SetGlobal(true); 188 values.use_disk_shader_cache.SetGlobal(true);
190 values.gpu_accuracy.SetGlobal(true); 189 values.gpu_accuracy.SetGlobal(true);
191 values.use_asynchronous_gpu_emulation.SetGlobal(true); 190 values.use_asynchronous_gpu_emulation.SetGlobal(true);
diff --git a/src/common/settings.h b/src/common/settings.h
index 368046e87..2bccb8642 100644
--- a/src/common/settings.h
+++ b/src/common/settings.h
@@ -440,8 +440,6 @@ struct Values {
440 SwitchableSetting<NvdecEmulation> nvdec_emulation{NvdecEmulation::GPU, "nvdec_emulation"}; 440 SwitchableSetting<NvdecEmulation> nvdec_emulation{NvdecEmulation::GPU, "nvdec_emulation"};
441 SwitchableSetting<bool> accelerate_astc{true, "accelerate_astc"}; 441 SwitchableSetting<bool> accelerate_astc{true, "accelerate_astc"};
442 SwitchableSetting<bool> use_vsync{true, "use_vsync"}; 442 SwitchableSetting<bool> use_vsync{true, "use_vsync"};
443 SwitchableSetting<u16, true> fps_cap{1000, 1, 1000, "fps_cap"};
444 Setting<bool> disable_fps_limit{false, "disable_fps_limit"};
445 SwitchableSetting<ShaderBackend, true> shader_backend{ShaderBackend::GLASM, ShaderBackend::GLSL, 443 SwitchableSetting<ShaderBackend, true> shader_backend{ShaderBackend::GLASM, ShaderBackend::GLSL,
446 ShaderBackend::SPIRV, "shader_backend"}; 444 ShaderBackend::SPIRV, "shader_backend"};
447 SwitchableSetting<bool> use_asynchronous_shaders{false, "use_asynchronous_shaders"}; 445 SwitchableSetting<bool> use_asynchronous_shaders{false, "use_asynchronous_shaders"};
diff --git a/src/core/hle/service/nvflinger/nvflinger.cpp b/src/core/hle/service/nvflinger/nvflinger.cpp
index 5f69c8c2c..5574269eb 100644
--- a/src/core/hle/service/nvflinger/nvflinger.cpp
+++ b/src/core/hle/service/nvflinger/nvflinger.cpp
@@ -287,9 +287,21 @@ s64 NVFlinger::GetNextTicks() const {
287 static constexpr s64 max_hertz = 120LL; 287 static constexpr s64 max_hertz = 120LL;
288 288
289 const auto& settings = Settings::values; 289 const auto& settings = Settings::values;
290 const bool unlocked_fps = settings.disable_fps_limit.GetValue(); 290 auto speed_scale = 1.f;
291 const s64 fps_cap = unlocked_fps ? static_cast<s64>(settings.fps_cap.GetValue()) : 1; 291 if (settings.use_multi_core.GetValue()) {
292 return (1000000000 * (1LL << swap_interval)) / (max_hertz * fps_cap); 292 if (settings.use_speed_limit.GetValue()) {
293 // Scales the speed based on speed_limit setting on MC. SC is handled by
294 // SpeedLimiter::DoSpeedLimiting.
295 speed_scale = 100.f / settings.speed_limit.GetValue();
296 } else {
297 // Run at unlocked framerate.
298 speed_scale = 0.01f;
299 }
300 }
301
302 const auto next_ticks = ((1000000000 * (1LL << swap_interval)) / max_hertz);
303
304 return static_cast<s64>(speed_scale * static_cast<float>(next_ticks));
293} 305}
294 306
295} // namespace Service::NVFlinger 307} // namespace Service::NVFlinger
diff --git a/src/video_core/renderer_vulkan/vk_swapchain.cpp b/src/video_core/renderer_vulkan/vk_swapchain.cpp
index a0c26a72a..fa8efd22e 100644
--- a/src/video_core/renderer_vulkan/vk_swapchain.cpp
+++ b/src/video_core/renderer_vulkan/vk_swapchain.cpp
@@ -38,7 +38,7 @@ VkPresentModeKHR ChooseSwapPresentMode(vk::Span<VkPresentModeKHR> modes) {
38 if (found_mailbox != modes.end()) { 38 if (found_mailbox != modes.end()) {
39 return VK_PRESENT_MODE_MAILBOX_KHR; 39 return VK_PRESENT_MODE_MAILBOX_KHR;
40 } 40 }
41 if (Settings::values.disable_fps_limit.GetValue()) { 41 if (!Settings::values.use_speed_limit.GetValue()) {
42 // FIFO present mode locks the framerate to the monitor's refresh rate, 42 // FIFO present mode locks the framerate to the monitor's refresh rate,
43 // Find an alternative to surpass this limitation if FPS is unlocked. 43 // Find an alternative to surpass this limitation if FPS is unlocked.
44 const auto found_imm = std::find(modes.begin(), modes.end(), VK_PRESENT_MODE_IMMEDIATE_KHR); 44 const auto found_imm = std::find(modes.begin(), modes.end(), VK_PRESENT_MODE_IMMEDIATE_KHR);
@@ -205,7 +205,7 @@ void Swapchain::CreateSwapchain(const VkSurfaceCapabilitiesKHR& capabilities, u3
205 205
206 extent = swapchain_ci.imageExtent; 206 extent = swapchain_ci.imageExtent;
207 current_srgb = srgb; 207 current_srgb = srgb;
208 current_fps_unlocked = Settings::values.disable_fps_limit.GetValue(); 208 current_fps_unlocked = !Settings::values.use_speed_limit.GetValue();
209 209
210 images = swapchain.GetImages(); 210 images = swapchain.GetImages();
211 image_count = static_cast<u32>(images.size()); 211 image_count = static_cast<u32>(images.size());
@@ -259,7 +259,7 @@ void Swapchain::Destroy() {
259} 259}
260 260
261bool Swapchain::HasFpsUnlockChanged() const { 261bool Swapchain::HasFpsUnlockChanged() const {
262 return current_fps_unlocked != Settings::values.disable_fps_limit.GetValue(); 262 return current_fps_unlocked != !Settings::values.use_speed_limit.GetValue();
263} 263}
264 264
265bool Swapchain::NeedsPresentModeUpdate() const { 265bool Swapchain::NeedsPresentModeUpdate() const {
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp
index a57b2e019..0a61839da 100644
--- a/src/yuzu/configuration/config.cpp
+++ b/src/yuzu/configuration/config.cpp
@@ -668,7 +668,6 @@ void Config::ReadRendererValues() {
668 ReadGlobalSetting(Settings::values.max_anisotropy); 668 ReadGlobalSetting(Settings::values.max_anisotropy);
669 ReadGlobalSetting(Settings::values.use_speed_limit); 669 ReadGlobalSetting(Settings::values.use_speed_limit);
670 ReadGlobalSetting(Settings::values.speed_limit); 670 ReadGlobalSetting(Settings::values.speed_limit);
671 ReadGlobalSetting(Settings::values.fps_cap);
672 ReadGlobalSetting(Settings::values.use_disk_shader_cache); 671 ReadGlobalSetting(Settings::values.use_disk_shader_cache);
673 ReadGlobalSetting(Settings::values.gpu_accuracy); 672 ReadGlobalSetting(Settings::values.gpu_accuracy);
674 ReadGlobalSetting(Settings::values.use_asynchronous_gpu_emulation); 673 ReadGlobalSetting(Settings::values.use_asynchronous_gpu_emulation);
@@ -1237,7 +1236,6 @@ void Config::SaveRendererValues() {
1237 WriteGlobalSetting(Settings::values.max_anisotropy); 1236 WriteGlobalSetting(Settings::values.max_anisotropy);
1238 WriteGlobalSetting(Settings::values.use_speed_limit); 1237 WriteGlobalSetting(Settings::values.use_speed_limit);
1239 WriteGlobalSetting(Settings::values.speed_limit); 1238 WriteGlobalSetting(Settings::values.speed_limit);
1240 WriteGlobalSetting(Settings::values.fps_cap);
1241 WriteGlobalSetting(Settings::values.use_disk_shader_cache); 1239 WriteGlobalSetting(Settings::values.use_disk_shader_cache);
1242 WriteSetting(QString::fromStdString(Settings::values.gpu_accuracy.GetLabel()), 1240 WriteSetting(QString::fromStdString(Settings::values.gpu_accuracy.GetLabel()),
1243 static_cast<u32>(Settings::values.gpu_accuracy.GetValue(global)), 1241 static_cast<u32>(Settings::values.gpu_accuracy.GetValue(global)),
diff --git a/src/yuzu/configuration/configure_general.cpp b/src/yuzu/configuration/configure_general.cpp
index a31fabd3f..2a446205b 100644
--- a/src/yuzu/configuration/configure_general.cpp
+++ b/src/yuzu/configuration/configure_general.cpp
@@ -27,9 +27,6 @@ ConfigureGeneral::ConfigureGeneral(const Core::System& system_, QWidget* parent)
27 27
28 connect(ui->button_reset_defaults, &QPushButton::clicked, this, 28 connect(ui->button_reset_defaults, &QPushButton::clicked, this,
29 &ConfigureGeneral::ResetDefaults); 29 &ConfigureGeneral::ResetDefaults);
30
31 ui->fps_cap_label->setVisible(Settings::IsConfiguringGlobal());
32 ui->fps_cap_combobox->setVisible(!Settings::IsConfiguringGlobal());
33} 30}
34 31
35ConfigureGeneral::~ConfigureGeneral() = default; 32ConfigureGeneral::~ConfigureGeneral() = default;
@@ -52,8 +49,6 @@ void ConfigureGeneral::SetConfiguration() {
52 ui->toggle_speed_limit->setChecked(Settings::values.use_speed_limit.GetValue()); 49 ui->toggle_speed_limit->setChecked(Settings::values.use_speed_limit.GetValue());
53 ui->speed_limit->setValue(Settings::values.speed_limit.GetValue()); 50 ui->speed_limit->setValue(Settings::values.speed_limit.GetValue());
54 51
55 ui->fps_cap->setValue(Settings::values.fps_cap.GetValue());
56
57 ui->button_reset_defaults->setEnabled(runtime_lock); 52 ui->button_reset_defaults->setEnabled(runtime_lock);
58 53
59 if (Settings::IsConfiguringGlobal()) { 54 if (Settings::IsConfiguringGlobal()) {
@@ -61,11 +56,6 @@ void ConfigureGeneral::SetConfiguration() {
61 } else { 56 } else {
62 ui->speed_limit->setEnabled(Settings::values.use_speed_limit.GetValue() && 57 ui->speed_limit->setEnabled(Settings::values.use_speed_limit.GetValue() &&
63 use_speed_limit != ConfigurationShared::CheckState::Global); 58 use_speed_limit != ConfigurationShared::CheckState::Global);
64
65 ui->fps_cap_combobox->setCurrentIndex(Settings::values.fps_cap.UsingGlobal() ? 0 : 1);
66 ui->fps_cap->setEnabled(!Settings::values.fps_cap.UsingGlobal());
67 ConfigurationShared::SetHighlight(ui->fps_cap_layout,
68 !Settings::values.fps_cap.UsingGlobal());
69 } 59 }
70} 60}
71 61
@@ -102,8 +92,6 @@ void ConfigureGeneral::ApplyConfiguration() {
102 UISettings::values.mute_when_in_background = ui->toggle_background_mute->isChecked(); 92 UISettings::values.mute_when_in_background = ui->toggle_background_mute->isChecked();
103 UISettings::values.hide_mouse = ui->toggle_hide_mouse->isChecked(); 93 UISettings::values.hide_mouse = ui->toggle_hide_mouse->isChecked();
104 94
105 Settings::values.fps_cap.SetValue(ui->fps_cap->value());
106
107 // Guard if during game and set to game-specific value 95 // Guard if during game and set to game-specific value
108 if (Settings::values.use_speed_limit.UsingGlobal()) { 96 if (Settings::values.use_speed_limit.UsingGlobal()) {
109 Settings::values.use_speed_limit.SetValue(ui->toggle_speed_limit->checkState() == 97 Settings::values.use_speed_limit.SetValue(ui->toggle_speed_limit->checkState() ==
@@ -119,13 +107,6 @@ void ConfigureGeneral::ApplyConfiguration() {
119 Qt::Checked); 107 Qt::Checked);
120 Settings::values.speed_limit.SetValue(ui->speed_limit->value()); 108 Settings::values.speed_limit.SetValue(ui->speed_limit->value());
121 } 109 }
122
123 if (ui->fps_cap_combobox->currentIndex() == ConfigurationShared::USE_GLOBAL_INDEX) {
124 Settings::values.fps_cap.SetGlobal(true);
125 } else {
126 Settings::values.fps_cap.SetGlobal(false);
127 Settings::values.fps_cap.SetValue(ui->fps_cap->value());
128 }
129 } 110 }
130} 111}
131 112
@@ -171,9 +152,4 @@ void ConfigureGeneral::SetupPerGameUI() {
171 ui->speed_limit->setEnabled(ui->toggle_speed_limit->isChecked() && 152 ui->speed_limit->setEnabled(ui->toggle_speed_limit->isChecked() &&
172 (use_speed_limit != ConfigurationShared::CheckState::Global)); 153 (use_speed_limit != ConfigurationShared::CheckState::Global));
173 }); 154 });
174
175 connect(ui->fps_cap_combobox, qOverload<int>(&QComboBox::activated), this, [this](int index) {
176 ui->fps_cap->setEnabled(index == 1);
177 ConfigurationShared::SetHighlight(ui->fps_cap_layout, index == 1);
178 });
179} 155}
diff --git a/src/yuzu/configuration/configure_general.ui b/src/yuzu/configuration/configure_general.ui
index c6ef2ab70..5b90b1109 100644
--- a/src/yuzu/configuration/configure_general.ui
+++ b/src/yuzu/configuration/configure_general.ui
@@ -28,87 +28,6 @@
28 <item> 28 <item>
29 <layout class="QVBoxLayout" name="GeneralVerticalLayout"> 29 <layout class="QVBoxLayout" name="GeneralVerticalLayout">
30 <item> 30 <item>
31 <widget class="QWidget" name="fps_cap_layout" native="true">
32 <layout class="QHBoxLayout" name="horizontalLayout" stretch="1,1">
33 <property name="leftMargin">
34 <number>0</number>
35 </property>
36 <property name="topMargin">
37 <number>0</number>
38 </property>
39 <property name="rightMargin">
40 <number>0</number>
41 </property>
42 <property name="bottomMargin">
43 <number>0</number>
44 </property>
45 <item>
46 <layout class="QHBoxLayout" name="horizontalLayout_4">
47 <item>
48 <widget class="QComboBox" name="fps_cap_combobox">
49 <property name="currentText">
50 <string>Use global framerate cap</string>
51 </property>
52 <property name="currentIndex">
53 <number>0</number>
54 </property>
55 <item>
56 <property name="text">
57 <string>Use global framerate cap</string>
58 </property>
59 </item>
60 <item>
61 <property name="text">
62 <string>Set framerate cap:</string>
63 </property>
64 </item>
65 </widget>
66 </item>
67 <item>
68 <widget class="QLabel" name="fps_cap_label">
69 <property name="toolTip">
70 <string>Requires the use of the FPS Limiter Toggle hotkey to take effect.</string>
71 </property>
72 <property name="text">
73 <string>Framerate Cap</string>
74 </property>
75 </widget>
76 </item>
77 <item>
78 <spacer name="horizontalSpacer">
79 <property name="orientation">
80 <enum>Qt::Horizontal</enum>
81 </property>
82 <property name="sizeHint" stdset="0">
83 <size>
84 <width>40</width>
85 <height>20</height>
86 </size>
87 </property>
88 </spacer>
89 </item>
90 </layout>
91 </item>
92 <item>
93 <widget class="QSpinBox" name="fps_cap">
94 <property name="suffix">
95 <string>x</string>
96 </property>
97 <property name="minimum">
98 <number>1</number>
99 </property>
100 <property name="maximum">
101 <number>1000</number>
102 </property>
103 <property name="value">
104 <number>500</number>
105 </property>
106 </widget>
107 </item>
108 </layout>
109 </widget>
110 </item>
111 <item>
112 <layout class="QHBoxLayout" name="horizontalLayout_2"> 31 <layout class="QHBoxLayout" name="horizontalLayout_2">
113 <item> 32 <item>
114 <widget class="QCheckBox" name="toggle_speed_limit"> 33 <widget class="QCheckBox" name="toggle_speed_limit">
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index b460020b1..ed802d329 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -1059,7 +1059,7 @@ void GMainWindow::InitializeHotkeys() {
1059 Settings::values.volume.SetValue(static_cast<u8>(new_volume)); 1059 Settings::values.volume.SetValue(static_cast<u8>(new_volume));
1060 }); 1060 });
1061 connect_shortcut(QStringLiteral("Toggle Framerate Limit"), [] { 1061 connect_shortcut(QStringLiteral("Toggle Framerate Limit"), [] {
1062 Settings::values.disable_fps_limit.SetValue(!Settings::values.disable_fps_limit.GetValue()); 1062 Settings::values.use_speed_limit.SetValue(!Settings::values.use_speed_limit.GetValue());
1063 }); 1063 });
1064 connect_shortcut(QStringLiteral("Toggle Mouse Panning"), [&] { 1064 connect_shortcut(QStringLiteral("Toggle Mouse Panning"), [&] {
1065 Settings::values.mouse_panning = !Settings::values.mouse_panning; 1065 Settings::values.mouse_panning = !Settings::values.mouse_panning;
@@ -1483,9 +1483,6 @@ void GMainWindow::BootGame(const QString& filename, u64 program_id, std::size_t
1483 Config per_game_config(*system, config_file_name, Config::ConfigType::PerGameConfig); 1483 Config per_game_config(*system, config_file_name, Config::ConfigType::PerGameConfig);
1484 } 1484 }
1485 1485
1486 // Disable fps limit toggle when booting a new title
1487 Settings::values.disable_fps_limit.SetValue(false);
1488
1489 // Save configurations 1486 // Save configurations
1490 UpdateUISettings(); 1487 UpdateUISettings();
1491 game_list->SaveInterfaceLayout(); 1488 game_list->SaveInterfaceLayout();
@@ -3277,7 +3274,7 @@ void GMainWindow::UpdateStatusBar() {
3277 } else { 3274 } else {
3278 emu_speed_label->setText(tr("Speed: %1%").arg(results.emulation_speed * 100.0, 0, 'f', 0)); 3275 emu_speed_label->setText(tr("Speed: %1%").arg(results.emulation_speed * 100.0, 0, 'f', 0));
3279 } 3276 }
3280 if (Settings::values.disable_fps_limit) { 3277 if (!Settings::values.use_speed_limit) {
3281 game_fps_label->setText( 3278 game_fps_label->setText(
3282 tr("Game: %1 FPS (Unlocked)").arg(results.average_game_fps, 0, 'f', 0)); 3279 tr("Game: %1 FPS (Unlocked)").arg(results.average_game_fps, 0, 'f', 0));
3283 } else { 3280 } else {
diff --git a/src/yuzu_cmd/config.cpp b/src/yuzu_cmd/config.cpp
index 9db7115a2..5576fb795 100644
--- a/src/yuzu_cmd/config.cpp
+++ b/src/yuzu_cmd/config.cpp
@@ -310,8 +310,6 @@ void Config::ReadValues() {
310 ReadSetting("Renderer", Settings::values.gpu_accuracy); 310 ReadSetting("Renderer", Settings::values.gpu_accuracy);
311 ReadSetting("Renderer", Settings::values.use_asynchronous_gpu_emulation); 311 ReadSetting("Renderer", Settings::values.use_asynchronous_gpu_emulation);
312 ReadSetting("Renderer", Settings::values.use_vsync); 312 ReadSetting("Renderer", Settings::values.use_vsync);
313 ReadSetting("Renderer", Settings::values.fps_cap);
314 ReadSetting("Renderer", Settings::values.disable_fps_limit);
315 ReadSetting("Renderer", Settings::values.shader_backend); 313 ReadSetting("Renderer", Settings::values.shader_backend);
316 ReadSetting("Renderer", Settings::values.use_asynchronous_shaders); 314 ReadSetting("Renderer", Settings::values.use_asynchronous_shaders);
317 ReadSetting("Renderer", Settings::values.nvdec_emulation); 315 ReadSetting("Renderer", Settings::values.nvdec_emulation);
diff --git a/src/yuzu_cmd/default_ini.h b/src/yuzu_cmd/default_ini.h
index a3b8432f5..d9a2a460c 100644
--- a/src/yuzu_cmd/default_ini.h
+++ b/src/yuzu_cmd/default_ini.h
@@ -330,10 +330,6 @@ bg_red =
330bg_blue = 330bg_blue =
331bg_green = 331bg_green =
332 332
333# Caps the unlocked framerate to a multiple of the title's target FPS.
334# 1 - 1000: Target FPS multiple cap. 1000 (default)
335fps_cap =
336
337[Audio] 333[Audio]
338# Which audio output engine to use. 334# Which audio output engine to use.
339# auto (default): Auto-select 335# auto (default): Auto-select
@@ -434,9 +430,6 @@ use_debug_asserts =
434use_auto_stub = 430use_auto_stub =
435# Enables/Disables the macro JIT compiler 431# Enables/Disables the macro JIT compiler
436disable_macro_jit=false 432disable_macro_jit=false
437# Presents guest frames as they become available. Experimental.
438# false: Disabled (default), true: Enabled
439disable_fps_limit=false
440# Determines whether to enable the GDB stub and wait for the debugger to attach before running. 433# Determines whether to enable the GDB stub and wait for the debugger to attach before running.
441# false: Disabled (default), true: Enabled 434# false: Disabled (default), true: Enabled
442use_gdbstub=false 435use_gdbstub=false