1
0
Fork 0
forked from suyu/suyu

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)
This commit is contained in:
jroweboy 2019-09-22 15:40:57 +02:00 committed by FearlessTobi
parent 3bfba23362
commit 64dbc92b61
3 changed files with 17 additions and 2 deletions

View file

@ -4,6 +4,8 @@
#include <SDL.h>
#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<unsigned, unsigned> minimal_size) {

View file

@ -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;
};

View file

@ -186,8 +186,6 @@ int main(int argc, char** argv) {
system.SetFilesystem(std::make_shared<FileSys::RealVfsFilesystem>());
system.GetFileSystemController().CreateFactories(*system.GetFilesystem());
SCOPE_EXIT({ system.Shutdown(); });
const Core::System::ResultStatus load_result{system.Load(*emu_window, filepath)};
switch (load_result) {
@ -227,6 +225,8 @@ int main(int argc, char** argv) {
system.RunLoop();
}
system.Shutdown();
detached_tasks.WaitForAllTasks();
return 0;
}