From 6c34adb1de2965a9c5800970703bb1288764026f Mon Sep 17 00:00:00 2001 From: Liam Date: Thu, 8 Jun 2023 01:15:51 -0400 Subject: nvnflinger: allow locking framerate during video playback --- src/core/core.cpp | 18 ++++++++++++++++++ src/core/core.h | 3 +++ src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp | 4 ++-- src/core/hle/service/nvnflinger/nvnflinger.cpp | 4 ++++ 4 files changed, 27 insertions(+), 2 deletions(-) (limited to 'src/core') 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 { } } + void SetNVDECActive(bool is_nvdec_active) { + nvdec_active = is_nvdec_active; + } + + bool GetNVDECActive() { + return nvdec_active; + } + void InitializeDebugger(System& system, u16 port) { debugger = std::make_unique(system, port); } @@ -485,6 +493,8 @@ struct System::Impl { std::atomic_bool is_powered_on{}; bool exit_lock = false; + bool nvdec_active{}; + Reporter reporter; std::unique_ptr cheat_engine; std::unique_ptr memory_freezer; @@ -594,6 +604,14 @@ void System::UnstallApplication() { impl->UnstallApplication(); } +void System::SetNVDECActive(bool is_nvdec_active) { + impl->SetNVDECActive(is_nvdec_active); +} + +bool System::GetNVDECActive() { + return impl->GetNVDECActive(); +} + void System::InitializeDebugger() { impl->InitializeDebugger(*this, Settings::values.gdbstub_port.GetValue()); } 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: std::unique_lock StallApplication(); void UnstallApplication(); + void SetNVDECActive(bool is_nvdec_active); + [[nodiscard]] bool GetNVDECActive(); + /** * Initialize the debugger. */ 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 in void nvhost_nvdec::OnOpen(DeviceFD fd) { LOG_INFO(Service_NVDRV, "NVDEC video stream started"); - system.AudioCore().SetNVDECActive(true); + system.SetNVDECActive(true); } void nvhost_nvdec::OnClose(DeviceFD fd) { @@ -79,7 +79,7 @@ void nvhost_nvdec::OnClose(DeviceFD fd) { if (iter != host1x_file.fd_to_id.end()) { system.GPU().ClearCdmaInstance(iter->second); } - system.AudioCore().SetNVDECActive(false); + system.SetNVDECActive(false); } } // 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 { speed_scale = 0.01f; } } + if (system.GetNVDECActive() && settings.use_video_framerate.GetValue()) { + // Run at intended presentation rate during video playback. + speed_scale = 1.f; + } // As an extension, treat nonpositive swap interval as framerate multiplier. const f32 effective_fps = swap_interval <= 0 ? 120.f * static_cast(1 - swap_interval) -- cgit v1.2.3