From 64dbc92b614bfa388d31007788bf725c4e4b59e3 Mon Sep 17 00:00:00 2001 From: jroweboy Date: Sun, 22 Sep 2019 15:40:57 +0200 Subject: Add FPS to SDL title bar Also fix a small issue with incorrect shutdown ordering in SDL. Previously the system would still be running so the telemetry task didn't launch and detached_tasks would assert(count == 0) --- src/yuzu_cmd/emu_window/emu_window_sdl2.cpp | 12 ++++++++++++ src/yuzu_cmd/emu_window/emu_window_sdl2.h | 3 +++ 2 files changed, 15 insertions(+) (limited to 'src/yuzu_cmd/emu_window') diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp b/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp index a6edc089a..aa69cc9c8 100644 --- a/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp +++ b/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp @@ -4,6 +4,8 @@ #include #include "common/logging/log.h" +#include "common/scm_rev.h" +#include "core/core.h" #include "input_common/keyboard.h" #include "input_common/main.h" #include "input_common/motion_emu.h" @@ -170,6 +172,16 @@ void EmuWindow_SDL2::PollEvents() { break; } } + + const u32 current_time = SDL_GetTicks(); + if (current_time > last_time + 2000) { + const auto results = Core::System::GetInstance().GetAndResetPerfStats(); + const auto title = fmt::format( + "yuzu {} | {}-{} | FPS: {:.0f} ({:.0%})", Common::g_build_fullname, + Common::g_scm_branch, Common::g_scm_desc, results.game_fps, results.emulation_speed); + SDL_SetWindowTitle(render_window, title.c_str()); + last_time = current_time; + } } void EmuWindow_SDL2::OnMinimalClientAreaChangeRequest(std::pair minimal_size) { diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2.h b/src/yuzu_cmd/emu_window/emu_window_sdl2.h index d8051ebdf..eaa971f77 100644 --- a/src/yuzu_cmd/emu_window/emu_window_sdl2.h +++ b/src/yuzu_cmd/emu_window/emu_window_sdl2.h @@ -60,4 +60,7 @@ protected: /// Internal SDL2 render window SDL_Window* render_window; + + /// Keeps track of how often to update the title bar during gameplay + u32 last_time = 0; }; -- cgit v1.2.3