diff options
| author | 2023-06-08 01:15:51 -0400 | |
|---|---|---|
| committer | 2023-06-08 01:15:51 -0400 | |
| commit | 6c34adb1de2965a9c5800970703bb1288764026f (patch) | |
| tree | 419d795b517fa790a42ca90ce8f17bda41e85af7 | |
| parent | Merge pull request #10650 from qurious-pixel/android_tv (diff) | |
| download | yuzu-6c34adb1de2965a9c5800970703bb1288764026f.tar.gz yuzu-6c34adb1de2965a9c5800970703bb1288764026f.tar.xz yuzu-6c34adb1de2965a9c5800970703bb1288764026f.zip | |
nvnflinger: allow locking framerate during video playback
| -rw-r--r-- | src/audio_core/audio_core.cpp | 8 | ||||
| -rw-r--r-- | src/audio_core/audio_core.h | 14 | ||||
| -rw-r--r-- | src/common/settings.cpp | 1 | ||||
| -rw-r--r-- | src/common/settings.h | 1 | ||||
| -rw-r--r-- | src/core/core.cpp | 18 | ||||
| -rw-r--r-- | src/core/core.h | 3 | ||||
| -rw-r--r-- | src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/service/nvnflinger/nvnflinger.cpp | 4 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_graphics_advanced.cpp | 8 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_graphics_advanced.h | 1 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_graphics_advanced.ui | 10 |
11 files changed, 48 insertions, 24 deletions
diff --git a/src/audio_core/audio_core.cpp b/src/audio_core/audio_core.cpp index 07a679c32..703ef4494 100644 --- a/src/audio_core/audio_core.cpp +++ b/src/audio_core/audio_core.cpp | |||
| @@ -47,12 +47,4 @@ AudioRenderer::ADSP::ADSP& AudioCore::GetADSP() { | |||
| 47 | return *adsp; | 47 | return *adsp; |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | void AudioCore::SetNVDECActive(bool active) { | ||
| 51 | nvdec_active = active; | ||
| 52 | } | ||
| 53 | |||
| 54 | bool AudioCore::IsNVDECActive() const { | ||
| 55 | return nvdec_active; | ||
| 56 | } | ||
| 57 | |||
| 58 | } // namespace AudioCore | 50 | } // namespace AudioCore |
diff --git a/src/audio_core/audio_core.h b/src/audio_core/audio_core.h index e33e00a3e..ea047773e 100644 --- a/src/audio_core/audio_core.h +++ b/src/audio_core/audio_core.h | |||
| @@ -57,18 +57,6 @@ public: | |||
| 57 | */ | 57 | */ |
| 58 | AudioRenderer::ADSP::ADSP& GetADSP(); | 58 | AudioRenderer::ADSP::ADSP& GetADSP(); |
| 59 | 59 | ||
| 60 | /** | ||
| 61 | * Toggle NVDEC state, used to avoid stall in playback. | ||
| 62 | * | ||
| 63 | * @param active - Set true if nvdec is active, otherwise false. | ||
| 64 | */ | ||
| 65 | void SetNVDECActive(bool active); | ||
| 66 | |||
| 67 | /** | ||
| 68 | * Get NVDEC state. | ||
| 69 | */ | ||
| 70 | bool IsNVDECActive() const; | ||
| 71 | |||
| 72 | private: | 60 | private: |
| 73 | /** | 61 | /** |
| 74 | * Create the sinks on startup. | 62 | * Create the sinks on startup. |
| @@ -83,8 +71,6 @@ private: | |||
| 83 | std::unique_ptr<Sink::Sink> input_sink; | 71 | std::unique_ptr<Sink::Sink> input_sink; |
| 84 | /// The ADSP in the sysmodule | 72 | /// The ADSP in the sysmodule |
| 85 | std::unique_ptr<AudioRenderer::ADSP::ADSP> adsp; | 73 | std::unique_ptr<AudioRenderer::ADSP::ADSP> adsp; |
| 86 | /// Is NVDec currently active? | ||
| 87 | bool nvdec_active{false}; | ||
| 88 | }; | 74 | }; |
| 89 | 75 | ||
| 90 | } // namespace AudioCore | 76 | } // namespace AudioCore |
diff --git a/src/common/settings.cpp b/src/common/settings.cpp index ff53e80bb..9ff3edabb 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp | |||
| @@ -235,6 +235,7 @@ void RestoreGlobalState(bool is_powered_on) { | |||
| 235 | values.bg_green.SetGlobal(true); | 235 | values.bg_green.SetGlobal(true); |
| 236 | values.bg_blue.SetGlobal(true); | 236 | values.bg_blue.SetGlobal(true); |
| 237 | values.enable_compute_pipelines.SetGlobal(true); | 237 | values.enable_compute_pipelines.SetGlobal(true); |
| 238 | values.use_video_framerate.SetGlobal(true); | ||
| 238 | 239 | ||
| 239 | // System | 240 | // System |
| 240 | values.language_index.SetGlobal(true); | 241 | values.language_index.SetGlobal(true); |
diff --git a/src/common/settings.h b/src/common/settings.h index 7f865b2a7..9682281b0 100644 --- a/src/common/settings.h +++ b/src/common/settings.h | |||
| @@ -482,6 +482,7 @@ struct Values { | |||
| 482 | SwitchableSetting<AstcRecompression, true> astc_recompression{ | 482 | SwitchableSetting<AstcRecompression, true> astc_recompression{ |
| 483 | AstcRecompression::Uncompressed, AstcRecompression::Uncompressed, AstcRecompression::Bc3, | 483 | AstcRecompression::Uncompressed, AstcRecompression::Uncompressed, AstcRecompression::Bc3, |
| 484 | "astc_recompression"}; | 484 | "astc_recompression"}; |
| 485 | SwitchableSetting<bool> use_video_framerate{false, "use_video_framerate"}; | ||
| 485 | 486 | ||
| 486 | SwitchableSetting<u8> bg_red{0, "bg_red"}; | 487 | SwitchableSetting<u8> bg_red{0, "bg_red"}; |
| 487 | SwitchableSetting<u8> bg_green{0, "bg_green"}; | 488 | SwitchableSetting<u8> bg_green{0, "bg_green"}; |
diff --git a/src/core/core.cpp b/src/core/core.cpp index 4406ae30e..7ba704f18 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp | |||
| @@ -216,6 +216,14 @@ struct System::Impl { | |||
| 216 | } | 216 | } |
| 217 | } | 217 | } |
| 218 | 218 | ||
| 219 | void SetNVDECActive(bool is_nvdec_active) { | ||
| 220 | nvdec_active = is_nvdec_active; | ||
| 221 | } | ||
| 222 | |||
| 223 | bool GetNVDECActive() { | ||
| 224 | return nvdec_active; | ||
| 225 | } | ||
| 226 | |||
| 219 | void InitializeDebugger(System& system, u16 port) { | 227 | void InitializeDebugger(System& system, u16 port) { |
| 220 | debugger = std::make_unique<Debugger>(system, port); | 228 | debugger = std::make_unique<Debugger>(system, port); |
| 221 | } | 229 | } |
| @@ -485,6 +493,8 @@ struct System::Impl { | |||
| 485 | std::atomic_bool is_powered_on{}; | 493 | std::atomic_bool is_powered_on{}; |
| 486 | bool exit_lock = false; | 494 | bool exit_lock = false; |
| 487 | 495 | ||
| 496 | bool nvdec_active{}; | ||
| 497 | |||
| 488 | Reporter reporter; | 498 | Reporter reporter; |
| 489 | std::unique_ptr<Memory::CheatEngine> cheat_engine; | 499 | std::unique_ptr<Memory::CheatEngine> cheat_engine; |
| 490 | std::unique_ptr<Tools::Freezer> memory_freezer; | 500 | std::unique_ptr<Tools::Freezer> memory_freezer; |
| @@ -594,6 +604,14 @@ void System::UnstallApplication() { | |||
| 594 | impl->UnstallApplication(); | 604 | impl->UnstallApplication(); |
| 595 | } | 605 | } |
| 596 | 606 | ||
| 607 | void System::SetNVDECActive(bool is_nvdec_active) { | ||
| 608 | impl->SetNVDECActive(is_nvdec_active); | ||
| 609 | } | ||
| 610 | |||
| 611 | bool System::GetNVDECActive() { | ||
| 612 | return impl->GetNVDECActive(); | ||
| 613 | } | ||
| 614 | |||
| 597 | void System::InitializeDebugger() { | 615 | void System::InitializeDebugger() { |
| 598 | impl->InitializeDebugger(*this, Settings::values.gdbstub_port.GetValue()); | 616 | impl->InitializeDebugger(*this, Settings::values.gdbstub_port.GetValue()); |
| 599 | } | 617 | } |
diff --git a/src/core/core.h b/src/core/core.h index 4f153154f..ff2e4bd30 100644 --- a/src/core/core.h +++ b/src/core/core.h | |||
| @@ -189,6 +189,9 @@ public: | |||
| 189 | std::unique_lock<std::mutex> StallApplication(); | 189 | std::unique_lock<std::mutex> StallApplication(); |
| 190 | void UnstallApplication(); | 190 | void UnstallApplication(); |
| 191 | 191 | ||
| 192 | void SetNVDECActive(bool is_nvdec_active); | ||
| 193 | [[nodiscard]] bool GetNVDECActive(); | ||
| 194 | |||
| 192 | /** | 195 | /** |
| 193 | * Initialize the debugger. | 196 | * Initialize the debugger. |
| 194 | */ | 197 | */ |
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp b/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp index 0c7aee1b8..dc45169ad 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp | |||
| @@ -69,7 +69,7 @@ NvResult nvhost_nvdec::Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> in | |||
| 69 | 69 | ||
| 70 | void nvhost_nvdec::OnOpen(DeviceFD fd) { | 70 | void nvhost_nvdec::OnOpen(DeviceFD fd) { |
| 71 | LOG_INFO(Service_NVDRV, "NVDEC video stream started"); | 71 | LOG_INFO(Service_NVDRV, "NVDEC video stream started"); |
| 72 | system.AudioCore().SetNVDECActive(true); | 72 | system.SetNVDECActive(true); |
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | void nvhost_nvdec::OnClose(DeviceFD fd) { | 75 | void nvhost_nvdec::OnClose(DeviceFD fd) { |
| @@ -79,7 +79,7 @@ void nvhost_nvdec::OnClose(DeviceFD fd) { | |||
| 79 | if (iter != host1x_file.fd_to_id.end()) { | 79 | if (iter != host1x_file.fd_to_id.end()) { |
| 80 | system.GPU().ClearCdmaInstance(iter->second); | 80 | system.GPU().ClearCdmaInstance(iter->second); |
| 81 | } | 81 | } |
| 82 | system.AudioCore().SetNVDECActive(false); | 82 | system.SetNVDECActive(false); |
| 83 | } | 83 | } |
| 84 | 84 | ||
| 85 | } // namespace Service::Nvidia::Devices | 85 | } // namespace Service::Nvidia::Devices |
diff --git a/src/core/hle/service/nvnflinger/nvnflinger.cpp b/src/core/hle/service/nvnflinger/nvnflinger.cpp index 4988e6e17..da2d5890f 100644 --- a/src/core/hle/service/nvnflinger/nvnflinger.cpp +++ b/src/core/hle/service/nvnflinger/nvnflinger.cpp | |||
| @@ -324,6 +324,10 @@ s64 Nvnflinger::GetNextTicks() const { | |||
| 324 | speed_scale = 0.01f; | 324 | speed_scale = 0.01f; |
| 325 | } | 325 | } |
| 326 | } | 326 | } |
| 327 | if (system.GetNVDECActive() && settings.use_video_framerate.GetValue()) { | ||
| 328 | // Run at intended presentation rate during video playback. | ||
| 329 | speed_scale = 1.f; | ||
| 330 | } | ||
| 327 | 331 | ||
| 328 | // As an extension, treat nonpositive swap interval as framerate multiplier. | 332 | // As an extension, treat nonpositive swap interval as framerate multiplier. |
| 329 | const f32 effective_fps = swap_interval <= 0 ? 120.f * static_cast<f32>(1 - swap_interval) | 333 | const f32 effective_fps = swap_interval <= 0 ? 120.f * static_cast<f32>(1 - swap_interval) |
diff --git a/src/yuzu/configuration/configure_graphics_advanced.cpp b/src/yuzu/configuration/configure_graphics_advanced.cpp index 896863f87..0463ac8b9 100644 --- a/src/yuzu/configuration/configure_graphics_advanced.cpp +++ b/src/yuzu/configuration/configure_graphics_advanced.cpp | |||
| @@ -42,6 +42,7 @@ void ConfigureGraphicsAdvanced::SetConfiguration() { | |||
| 42 | Settings::values.use_vulkan_driver_pipeline_cache.GetValue()); | 42 | Settings::values.use_vulkan_driver_pipeline_cache.GetValue()); |
| 43 | ui->enable_compute_pipelines_checkbox->setChecked( | 43 | ui->enable_compute_pipelines_checkbox->setChecked( |
| 44 | Settings::values.enable_compute_pipelines.GetValue()); | 44 | Settings::values.enable_compute_pipelines.GetValue()); |
| 45 | ui->use_video_framerate_checkbox->setChecked(Settings::values.use_video_framerate.GetValue()); | ||
| 45 | 46 | ||
| 46 | if (Settings::IsConfiguringGlobal()) { | 47 | if (Settings::IsConfiguringGlobal()) { |
| 47 | ui->gpu_accuracy->setCurrentIndex( | 48 | ui->gpu_accuracy->setCurrentIndex( |
| @@ -91,6 +92,8 @@ void ConfigureGraphicsAdvanced::ApplyConfiguration() { | |||
| 91 | ConfigurationShared::ApplyPerGameSetting(&Settings::values.enable_compute_pipelines, | 92 | ConfigurationShared::ApplyPerGameSetting(&Settings::values.enable_compute_pipelines, |
| 92 | ui->enable_compute_pipelines_checkbox, | 93 | ui->enable_compute_pipelines_checkbox, |
| 93 | enable_compute_pipelines); | 94 | enable_compute_pipelines); |
| 95 | ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_video_framerate, | ||
| 96 | ui->use_video_framerate_checkbox, use_video_framerate); | ||
| 94 | } | 97 | } |
| 95 | 98 | ||
| 96 | void ConfigureGraphicsAdvanced::changeEvent(QEvent* event) { | 99 | void ConfigureGraphicsAdvanced::changeEvent(QEvent* event) { |
| @@ -125,6 +128,8 @@ void ConfigureGraphicsAdvanced::SetupPerGameUI() { | |||
| 125 | Settings::values.max_anisotropy.UsingGlobal()); | 128 | Settings::values.max_anisotropy.UsingGlobal()); |
| 126 | ui->enable_compute_pipelines_checkbox->setEnabled( | 129 | ui->enable_compute_pipelines_checkbox->setEnabled( |
| 127 | Settings::values.enable_compute_pipelines.UsingGlobal()); | 130 | Settings::values.enable_compute_pipelines.UsingGlobal()); |
| 131 | ui->use_video_framerate_checkbox->setEnabled( | ||
| 132 | Settings::values.use_video_framerate.UsingGlobal()); | ||
| 128 | 133 | ||
| 129 | return; | 134 | return; |
| 130 | } | 135 | } |
| @@ -149,6 +154,9 @@ void ConfigureGraphicsAdvanced::SetupPerGameUI() { | |||
| 149 | ConfigurationShared::SetColoredTristate(ui->enable_compute_pipelines_checkbox, | 154 | ConfigurationShared::SetColoredTristate(ui->enable_compute_pipelines_checkbox, |
| 150 | Settings::values.enable_compute_pipelines, | 155 | Settings::values.enable_compute_pipelines, |
| 151 | enable_compute_pipelines); | 156 | enable_compute_pipelines); |
| 157 | ConfigurationShared::SetColoredTristate(ui->use_video_framerate_checkbox, | ||
| 158 | Settings::values.use_video_framerate, | ||
| 159 | use_video_framerate); | ||
| 152 | ConfigurationShared::SetColoredComboBox( | 160 | ConfigurationShared::SetColoredComboBox( |
| 153 | ui->gpu_accuracy, ui->label_gpu_accuracy, | 161 | ui->gpu_accuracy, ui->label_gpu_accuracy, |
| 154 | static_cast<int>(Settings::values.gpu_accuracy.GetValue(true))); | 162 | static_cast<int>(Settings::values.gpu_accuracy.GetValue(true))); |
diff --git a/src/yuzu/configuration/configure_graphics_advanced.h b/src/yuzu/configuration/configure_graphics_advanced.h index 1c7b636b9..a4dc8ceb0 100644 --- a/src/yuzu/configuration/configure_graphics_advanced.h +++ b/src/yuzu/configuration/configure_graphics_advanced.h | |||
| @@ -47,6 +47,7 @@ private: | |||
| 47 | ConfigurationShared::CheckState use_fast_gpu_time; | 47 | ConfigurationShared::CheckState use_fast_gpu_time; |
| 48 | ConfigurationShared::CheckState use_vulkan_driver_pipeline_cache; | 48 | ConfigurationShared::CheckState use_vulkan_driver_pipeline_cache; |
| 49 | ConfigurationShared::CheckState enable_compute_pipelines; | 49 | ConfigurationShared::CheckState enable_compute_pipelines; |
| 50 | ConfigurationShared::CheckState use_video_framerate; | ||
| 50 | 51 | ||
| 51 | const Core::System& system; | 52 | const Core::System& system; |
| 52 | }; | 53 | }; |
diff --git a/src/yuzu/configuration/configure_graphics_advanced.ui b/src/yuzu/configuration/configure_graphics_advanced.ui index 37757a918..e7f0ef6be 100644 --- a/src/yuzu/configuration/configure_graphics_advanced.ui +++ b/src/yuzu/configuration/configure_graphics_advanced.ui | |||
| @@ -192,6 +192,16 @@ Compute pipelines are always enabled on all other drivers.</string> | |||
| 192 | </widget> | 192 | </widget> |
| 193 | </item> | 193 | </item> |
| 194 | <item> | 194 | <item> |
| 195 | <widget class="QCheckBox" name="use_video_framerate_checkbox"> | ||
| 196 | <property name="toolTip"> | ||
| 197 | <string>Run the game at normal speed during video playback, even when the framerate is unlocked.</string> | ||
| 198 | </property> | ||
| 199 | <property name="text"> | ||
| 200 | <string>Sync to framerate of video playback</string> | ||
| 201 | </property> | ||
| 202 | </widget> | ||
| 203 | </item> | ||
| 204 | <item> | ||
| 195 | <widget class="QWidget" name="af_layout" native="true"> | 205 | <widget class="QWidget" name="af_layout" native="true"> |
| 196 | <layout class="QHBoxLayout" name="horizontalLayout_1"> | 206 | <layout class="QHBoxLayout" name="horizontalLayout_1"> |
| 197 | <property name="leftMargin"> | 207 | <property name="leftMargin"> |