From 9543adf072a7d116e49b2d54359cd7e5b374e594 Mon Sep 17 00:00:00 2001 From: Charles Lombardo Date: Fri, 3 Nov 2023 23:57:57 -0400 Subject: [PATCH] android: Always update FPS counter --- .../org/yuzu/yuzu_emu/fragments/EmulationFragment.kt | 6 +++--- src/android/app/src/main/jni/native.cpp | 9 ++------- src/android/app/src/main/jni/native.h | 3 +-- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt index c456c05921..77f2cdf65f 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt @@ -414,12 +414,12 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { val FRAMETIME = 2 val SPEED = 3 perfStatsUpdater = { - if (emulationViewModel.emulationStarted.value == true) { + if (emulationViewModel.emulationStarted.value) { val perfStats = NativeLibrary.getPerfStats() - if (perfStats[FPS] > 0 && _binding != null) { + if (_binding != null) { binding.showFpsText.text = String.format("FPS: %.1f", perfStats[FPS]) } - perfStatsUpdateHandler.postDelayed(perfStatsUpdater!!, 100) + perfStatsUpdateHandler.postDelayed(perfStatsUpdater!!, 800) } } perfStatsUpdateHandler.post(perfStatsUpdater!!) diff --git a/src/android/app/src/main/jni/native.cpp b/src/android/app/src/main/jni/native.cpp index 294e41045c..2b1c6374d9 100644 --- a/src/android/app/src/main/jni/native.cpp +++ b/src/android/app/src/main/jni/native.cpp @@ -199,8 +199,8 @@ bool EmulationSession::IsPaused() const { return m_is_running && m_is_paused; } -const Core::PerfStatsResults& EmulationSession::PerfStats() const { - std::scoped_lock m_perf_stats_lock(m_perf_stats_mutex); +const Core::PerfStatsResults& EmulationSession::PerfStats() { + m_perf_stats = m_system.GetAndResetPerfStats(); return m_perf_stats; } @@ -381,11 +381,6 @@ void EmulationSession::RunEmulation() { break; } } - { - // Refresh performance stats. - std::scoped_lock m_perf_stats_lock(m_perf_stats_mutex); - m_perf_stats = m_system.GetAndResetPerfStats(); - } } } diff --git a/src/android/app/src/main/jni/native.h b/src/android/app/src/main/jni/native.h index 0aa2b085b5..9f915b160e 100644 --- a/src/android/app/src/main/jni/native.h +++ b/src/android/app/src/main/jni/native.h @@ -41,7 +41,7 @@ public: void RunEmulation(); void ShutdownEmulation(); - const Core::PerfStatsResults& PerfStats() const; + const Core::PerfStatsResults& PerfStats(); void ConfigureFilesystemProvider(const std::string& filepath); void InitializeSystem(); Core::SystemResultStatus InitializeEmulation(const std::string& filepath); @@ -80,6 +80,5 @@ private: // Synchronization std::condition_variable_any m_cv; - mutable std::mutex m_perf_stats_mutex; mutable std::mutex m_mutex; };