diff options
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/core.cpp | 3 | ||||
| -rw-r--r-- | src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp | 1 | ||||
| -rw-r--r-- | src/core/perf_stats.cpp | 12 | ||||
| -rw-r--r-- | src/core/perf_stats.h | 9 |
4 files changed, 14 insertions, 11 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp index 434bf3262..47e70c157 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp | |||
| @@ -289,7 +289,8 @@ struct System::Impl { | |||
| 289 | 289 | ||
| 290 | telemetry_session->AddField(performance, "Shutdown_EmulationSpeed", | 290 | telemetry_session->AddField(performance, "Shutdown_EmulationSpeed", |
| 291 | perf_results.emulation_speed * 100.0); | 291 | perf_results.emulation_speed * 100.0); |
| 292 | telemetry_session->AddField(performance, "Shutdown_Framerate", perf_results.game_fps); | 292 | telemetry_session->AddField(performance, "Shutdown_Framerate", |
| 293 | perf_results.average_game_fps); | ||
| 293 | telemetry_session->AddField(performance, "Shutdown_Frametime", | 294 | telemetry_session->AddField(performance, "Shutdown_Frametime", |
| 294 | perf_results.frametime * 1000.0); | 295 | perf_results.frametime * 1000.0); |
| 295 | telemetry_session->AddField(performance, "Mean_Frametime_MS", | 296 | telemetry_session->AddField(performance, "Mean_Frametime_MS", |
diff --git a/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp b/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp index bbef04a29..2cc0da124 100644 --- a/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp +++ b/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp | |||
| @@ -52,7 +52,6 @@ void nvdisp_disp0::flip(u32 buffer_handle, u32 offset, u32 format, u32 width, u3 | |||
| 52 | addr, offset, width, height, stride, static_cast<PixelFormat>(format), | 52 | addr, offset, width, height, stride, static_cast<PixelFormat>(format), |
| 53 | transform, crop_rect}; | 53 | transform, crop_rect}; |
| 54 | 54 | ||
| 55 | system.GetPerfStats().EndGameFrame(); | ||
| 56 | system.GetPerfStats().EndSystemFrame(); | 55 | system.GetPerfStats().EndSystemFrame(); |
| 57 | system.GPU().SwapBuffers(&framebuffer); | 56 | system.GPU().SwapBuffers(&framebuffer); |
| 58 | system.FrameLimiter().DoFrameLimiting(system.CoreTiming().GetGlobalTimeUs()); | 57 | system.FrameLimiter().DoFrameLimiting(system.CoreTiming().GetGlobalTimeUs()); |
diff --git a/src/core/perf_stats.cpp b/src/core/perf_stats.cpp index b185a3884..c42c437b7 100644 --- a/src/core/perf_stats.cpp +++ b/src/core/perf_stats.cpp | |||
| @@ -69,9 +69,7 @@ void PerfStats::EndSystemFrame() { | |||
| 69 | } | 69 | } |
| 70 | 70 | ||
| 71 | void PerfStats::EndGameFrame() { | 71 | void PerfStats::EndGameFrame() { |
| 72 | std::lock_guard lock{object_mutex}; | 72 | game_frames.fetch_add(1, std::memory_order_relaxed); |
| 73 | |||
| 74 | game_frames += 1; | ||
| 75 | } | 73 | } |
| 76 | 74 | ||
| 77 | double PerfStats::GetMeanFrametime() const { | 75 | double PerfStats::GetMeanFrametime() const { |
| @@ -94,10 +92,11 @@ PerfStatsResults PerfStats::GetAndResetStats(microseconds current_system_time_us | |||
| 94 | const auto interval = duration_cast<DoubleSecs>(now - reset_point).count(); | 92 | const auto interval = duration_cast<DoubleSecs>(now - reset_point).count(); |
| 95 | 93 | ||
| 96 | const auto system_us_per_second = (current_system_time_us - reset_point_system_us) / interval; | 94 | const auto system_us_per_second = (current_system_time_us - reset_point_system_us) / interval; |
| 97 | 95 | const auto current_frames = static_cast<double>(game_frames.load(std::memory_order_relaxed)); | |
| 96 | const auto current_fps = current_frames / interval; | ||
| 98 | const PerfStatsResults results{ | 97 | const PerfStatsResults results{ |
| 99 | .system_fps = static_cast<double>(system_frames) / interval, | 98 | .system_fps = static_cast<double>(system_frames) / interval, |
| 100 | .game_fps = static_cast<double>(game_frames) / interval, | 99 | .average_game_fps = (current_fps + previous_fps) / 2.0, |
| 101 | .frametime = duration_cast<DoubleSecs>(accumulated_frametime).count() / | 100 | .frametime = duration_cast<DoubleSecs>(accumulated_frametime).count() / |
| 102 | static_cast<double>(system_frames), | 101 | static_cast<double>(system_frames), |
| 103 | .emulation_speed = system_us_per_second.count() / 1'000'000.0, | 102 | .emulation_speed = system_us_per_second.count() / 1'000'000.0, |
| @@ -108,7 +107,8 @@ PerfStatsResults PerfStats::GetAndResetStats(microseconds current_system_time_us | |||
| 108 | reset_point_system_us = current_system_time_us; | 107 | reset_point_system_us = current_system_time_us; |
| 109 | accumulated_frametime = Clock::duration::zero(); | 108 | accumulated_frametime = Clock::duration::zero(); |
| 110 | system_frames = 0; | 109 | system_frames = 0; |
| 111 | game_frames = 0; | 110 | game_frames.store(0, std::memory_order_relaxed); |
| 111 | previous_fps = current_fps; | ||
| 112 | 112 | ||
| 113 | return results; | 113 | return results; |
| 114 | } | 114 | } |
diff --git a/src/core/perf_stats.h b/src/core/perf_stats.h index ae4698696..e5d603717 100644 --- a/src/core/perf_stats.h +++ b/src/core/perf_stats.h | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <array> | 7 | #include <array> |
| 8 | #include <atomic> | ||
| 8 | #include <chrono> | 9 | #include <chrono> |
| 9 | #include <cstddef> | 10 | #include <cstddef> |
| 10 | #include <mutex> | 11 | #include <mutex> |
| @@ -15,8 +16,8 @@ namespace Core { | |||
| 15 | struct PerfStatsResults { | 16 | struct PerfStatsResults { |
| 16 | /// System FPS (LCD VBlanks) in Hz | 17 | /// System FPS (LCD VBlanks) in Hz |
| 17 | double system_fps; | 18 | double system_fps; |
| 18 | /// Game FPS (GSP frame submissions) in Hz | 19 | /// Average game FPS (GPU frame renders) in Hz |
| 19 | double game_fps; | 20 | double average_game_fps; |
| 20 | /// Walltime per system frame, in seconds, excluding any waits | 21 | /// Walltime per system frame, in seconds, excluding any waits |
| 21 | double frametime; | 22 | double frametime; |
| 22 | /// Ratio of walltime / emulated time elapsed | 23 | /// Ratio of walltime / emulated time elapsed |
| @@ -72,7 +73,7 @@ private: | |||
| 72 | /// Cumulative number of system frames (LCD VBlanks) presented since last reset | 73 | /// Cumulative number of system frames (LCD VBlanks) presented since last reset |
| 73 | u32 system_frames = 0; | 74 | u32 system_frames = 0; |
| 74 | /// Cumulative number of game frames (GSP frame submissions) since last reset | 75 | /// Cumulative number of game frames (GSP frame submissions) since last reset |
| 75 | u32 game_frames = 0; | 76 | std::atomic<u32> game_frames = 0; |
| 76 | 77 | ||
| 77 | /// Point when the previous system frame ended | 78 | /// Point when the previous system frame ended |
| 78 | Clock::time_point previous_frame_end = reset_point; | 79 | Clock::time_point previous_frame_end = reset_point; |
| @@ -80,6 +81,8 @@ private: | |||
| 80 | Clock::time_point frame_begin = reset_point; | 81 | Clock::time_point frame_begin = reset_point; |
| 81 | /// Total visible duration (including frame-limiting, etc.) of the previous system frame | 82 | /// Total visible duration (including frame-limiting, etc.) of the previous system frame |
| 82 | Clock::duration previous_frame_length = Clock::duration::zero(); | 83 | Clock::duration previous_frame_length = Clock::duration::zero(); |
| 84 | /// Previously computed fps | ||
| 85 | double previous_fps = 0; | ||
| 83 | }; | 86 | }; |
| 84 | 87 | ||
| 85 | class FrameLimiter { | 88 | class FrameLimiter { |