From efeadb7fe9e767c80c6a60731b6c38e02959e5fa Mon Sep 17 00:00:00 2001 From: Jules Blok Date: Wed, 9 Jul 2014 17:03:17 +0200 Subject: [PATCH 1/3] FPSCounter: Add "Log render time to file" feature. Allows for a more accurate performance measurement. --- Source/Core/DolphinWX/VideoConfigDiag.cpp | 3 +++ Source/Core/VideoCommon/FPSCounter.cpp | 23 ++++++++++++++++++++++- Source/Core/VideoCommon/VideoConfig.cpp | 2 ++ Source/Core/VideoCommon/VideoConfig.h | 1 + 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/Source/Core/DolphinWX/VideoConfigDiag.cpp b/Source/Core/DolphinWX/VideoConfigDiag.cpp index 26d8b6c76e..bc234902d1 100644 --- a/Source/Core/DolphinWX/VideoConfigDiag.cpp +++ b/Source/Core/DolphinWX/VideoConfigDiag.cpp @@ -127,6 +127,7 @@ wxString disable_fog_desc = wxTRANSLATE("Makes distant objects more visible by r wxString disable_dstalpha_desc = wxTRANSLATE("Disables emulation of a hardware feature called destination alpha, which is used in many games for various graphical effects.\n\nIf unsure, leave this unchecked."); wxString show_fps_desc = wxTRANSLATE("Show the number of frames rendered per second as a measure of emulation speed.\n\nIf unsure, leave this unchecked."); wxString log_fps_to_file_desc = wxTRANSLATE("Log the number of frames rendered per second to User/Logs/fps.txt. Use this feature when you want to measure the performance of Dolphin.\n\nIf unsure, leave this unchecked."); +wxString log_render_time_to_file_desc = wxTRANSLATE("Log the render time of every frame to User/Logs/render_time.txt. Use this feature when you want to measure the performance of Dolphin.\n\nIf unsure, leave this unchecked."); wxString show_input_display_desc = wxTRANSLATE("Display the inputs read by the emulator.\n\nIf unsure, leave this unchecked."); wxString show_stats_desc = wxTRANSLATE("Show various statistics.\n\nIf unsure, leave this unchecked."); wxString texfmt_desc = wxTRANSLATE("Modify textures to show the format they're encoded in. Needs an emulation reset in most cases.\n\nIf unsure, leave this unchecked."); @@ -586,6 +587,8 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con szr_misc->Add(cb_prog_scan); } + szr_misc->Add(CreateCheckBox(page_advanced, _("Log render time to file"), wxGetTranslation(log_render_time_to_file_desc), vconfig.bLogRenderTimeToFile)); + wxStaticBoxSizer* const group_misc = new wxStaticBoxSizer(wxVERTICAL, page_advanced, _("Misc")); szr_advanced->Add(group_misc, 0, wxEXPAND | wxALL, 5); group_misc->Add(szr_misc, 1, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5); diff --git a/Source/Core/VideoCommon/FPSCounter.cpp b/Source/Core/VideoCommon/FPSCounter.cpp index 5ebfdd499d..9706982758 100644 --- a/Source/Core/VideoCommon/FPSCounter.cpp +++ b/Source/Core/VideoCommon/FPSCounter.cpp @@ -20,17 +20,24 @@ static unsigned int s_fps_last_counter = 0; static unsigned long s_last_update_time = 0; static std::ofstream s_bench_file; +static Common::Timer s_render_time; +static std::ofstream s_time_file; + void Initialize() { s_counter = s_fps_last_counter = 0; s_fps = 0; s_last_update_time = Common::Timer::GetTimeMs(); + s_render_time.Update(); + if (s_bench_file.is_open()) s_bench_file.close(); + if (s_time_file.is_open()) + s_time_file.close(); } -static void LogFPSToFile(unsigned long val) +static void LogFPSToFile(u64 val) { if (!s_bench_file.is_open()) s_bench_file.open(File::GetUserPath(D_LOGS_IDX) + "fps.txt"); @@ -38,6 +45,14 @@ static void LogFPSToFile(unsigned long val) s_bench_file << StringFromFormat("%lu\n", val); } +static void LogRenderTimeToFile(u64 val) +{ + if (!s_time_file.is_open()) + s_time_file.open(File::GetUserPath(D_LOGS_IDX) + "render_time.txt"); + + s_time_file << StringFromFormat("%lu\n", val); +} + int Update() { if (Common::Timer::GetTimeMs() - s_last_update_time >= FPS_REFRESH_INTERVAL) @@ -49,6 +64,12 @@ int Update() LogFPSToFile(s_fps); } + if (g_ActiveConfig.bLogRenderTimeToFile) + { + LogRenderTimeToFile(s_render_time.GetTimeDifference()); + s_render_time.Update(); + } + s_counter++; return s_fps; } diff --git a/Source/Core/VideoCommon/VideoConfig.cpp b/Source/Core/VideoCommon/VideoConfig.cpp index c01b7e5461..aa68ff2e76 100644 --- a/Source/Core/VideoCommon/VideoConfig.cpp +++ b/Source/Core/VideoCommon/VideoConfig.cpp @@ -58,6 +58,7 @@ void VideoConfig::Load(const std::string& ini_file) settings->Get("SafeTextureCacheColorSamples", &iSafeTextureCache_ColorSamples,128); settings->Get("ShowFPS", &bShowFPS, false); settings->Get("LogFPSToFile", &bLogFPSToFile, false); + settings->Get("LogRenderTimeToFile", &bLogRenderTimeToFile, false); settings->Get("ShowInputDisplay", &bShowInputDisplay, false); settings->Get("OverlayStats", &bOverlayStats, false); settings->Get("OverlayProjStats", &bOverlayProjStats, false); @@ -230,6 +231,7 @@ void VideoConfig::Save(const std::string& ini_file) settings->Set("SafeTextureCacheColorSamples", iSafeTextureCache_ColorSamples); settings->Set("ShowFPS", bShowFPS); settings->Set("LogFPSToFile", bLogFPSToFile); + settings->Set("LogRenderTimeToFile", bLogRenderTimeToFile); settings->Set("ShowInputDisplay", bShowInputDisplay); settings->Set("OverlayStats", bOverlayStats); settings->Set("OverlayProjStats", bOverlayProjStats); diff --git a/Source/Core/VideoCommon/VideoConfig.h b/Source/Core/VideoCommon/VideoConfig.h index 1747fef374..3200de8afd 100644 --- a/Source/Core/VideoCommon/VideoConfig.h +++ b/Source/Core/VideoCommon/VideoConfig.h @@ -84,6 +84,7 @@ struct VideoConfig final bool bTexFmtOverlayCenter; bool bShowEFBCopyRegions; bool bLogFPSToFile; + bool bLogRenderTimeToFile; // Render bool bWireFrame; From 61d44cf73fd6ab337e4108081363b5617418e988 Mon Sep 17 00:00:00 2001 From: Jules Blok Date: Wed, 9 Jul 2014 17:15:41 +0200 Subject: [PATCH 2/3] FPSCounter: Use a Timer for the FPS update time. --- Source/Core/VideoCommon/FPSCounter.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/Core/VideoCommon/FPSCounter.cpp b/Source/Core/VideoCommon/FPSCounter.cpp index 9706982758..8509889d5f 100644 --- a/Source/Core/VideoCommon/FPSCounter.cpp +++ b/Source/Core/VideoCommon/FPSCounter.cpp @@ -17,7 +17,7 @@ namespace FPSCounter static unsigned int s_counter = 0; static unsigned int s_fps = 0; static unsigned int s_fps_last_counter = 0; -static unsigned long s_last_update_time = 0; +static Common::Timer s_update_time; static std::ofstream s_bench_file; static Common::Timer s_render_time; @@ -27,8 +27,8 @@ void Initialize() { s_counter = s_fps_last_counter = 0; s_fps = 0; - s_last_update_time = Common::Timer::GetTimeMs(); + s_update_time.Update(); s_render_time.Update(); if (s_bench_file.is_open()) @@ -55,9 +55,9 @@ static void LogRenderTimeToFile(u64 val) int Update() { - if (Common::Timer::GetTimeMs() - s_last_update_time >= FPS_REFRESH_INTERVAL) + if (s_update_time.GetTimeDifference() >= FPS_REFRESH_INTERVAL) { - s_last_update_time = Common::Timer::GetTimeMs(); + s_update_time.Update(); s_fps = s_counter - s_fps_last_counter; s_fps_last_counter = s_counter; if (g_ActiveConfig.bLogFPSToFile) From 95b579746f80d477eedd2ba43fa403b570620986 Mon Sep 17 00:00:00 2001 From: Jules Blok Date: Wed, 9 Jul 2014 17:56:11 +0200 Subject: [PATCH 3/3] Replace "Log FPS to file" by the "Log render time to file" feature. --- Source/Core/DolphinWX/VideoConfigDiag.cpp | 5 +---- Source/Core/VideoCommon/FPSCounter.cpp | 21 ++++----------------- Source/Core/VideoCommon/VideoConfig.cpp | 2 -- Source/Core/VideoCommon/VideoConfig.h | 1 - 4 files changed, 5 insertions(+), 24 deletions(-) diff --git a/Source/Core/DolphinWX/VideoConfigDiag.cpp b/Source/Core/DolphinWX/VideoConfigDiag.cpp index bc234902d1..6a21fadce0 100644 --- a/Source/Core/DolphinWX/VideoConfigDiag.cpp +++ b/Source/Core/DolphinWX/VideoConfigDiag.cpp @@ -126,7 +126,6 @@ wxString wireframe_desc = wxTRANSLATE("Render the scene as a wireframe.\n\nIf un wxString disable_fog_desc = wxTRANSLATE("Makes distant objects more visible by removing fog, thus increasing the overall detail.\nDisabling fog will break some games which rely on proper fog emulation.\n\nIf unsure, leave this unchecked."); wxString disable_dstalpha_desc = wxTRANSLATE("Disables emulation of a hardware feature called destination alpha, which is used in many games for various graphical effects.\n\nIf unsure, leave this unchecked."); wxString show_fps_desc = wxTRANSLATE("Show the number of frames rendered per second as a measure of emulation speed.\n\nIf unsure, leave this unchecked."); -wxString log_fps_to_file_desc = wxTRANSLATE("Log the number of frames rendered per second to User/Logs/fps.txt. Use this feature when you want to measure the performance of Dolphin.\n\nIf unsure, leave this unchecked."); wxString log_render_time_to_file_desc = wxTRANSLATE("Log the render time of every frame to User/Logs/render_time.txt. Use this feature when you want to measure the performance of Dolphin.\n\nIf unsure, leave this unchecked."); wxString show_input_display_desc = wxTRANSLATE("Display the inputs read by the emulator.\n\nIf unsure, leave this unchecked."); wxString show_stats_desc = wxTRANSLATE("Show various statistics.\n\nIf unsure, leave this unchecked."); @@ -323,7 +322,7 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con { SettingCheckBox* render_to_main_cb; szr_other->Add(CreateCheckBox(page_general, _("Show FPS"), wxGetTranslation(show_fps_desc), vconfig.bShowFPS)); - szr_other->Add(CreateCheckBox(page_general, _("Log FPS to file"), wxGetTranslation(log_fps_to_file_desc), vconfig.bLogFPSToFile)); + szr_other->Add(CreateCheckBox(page_general, _("Log render time to file"), wxGetTranslation(log_render_time_to_file_desc), vconfig.bLogRenderTimeToFile)); szr_other->Add(CreateCheckBox(page_general, _("Auto adjust Window Size"), wxGetTranslation(auto_window_size_desc), SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderWindowAutoSize)); szr_other->Add(CreateCheckBox(page_general, _("Keep window on top"), wxGetTranslation(keep_window_on_top_desc), SConfig::GetInstance().m_LocalCoreStartupParameter.bKeepWindowOnTop)); szr_other->Add(CreateCheckBox(page_general, _("Hide Mouse Cursor"), wxGetTranslation(hide_mouse_cursor_desc), SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor)); @@ -587,8 +586,6 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con szr_misc->Add(cb_prog_scan); } - szr_misc->Add(CreateCheckBox(page_advanced, _("Log render time to file"), wxGetTranslation(log_render_time_to_file_desc), vconfig.bLogRenderTimeToFile)); - wxStaticBoxSizer* const group_misc = new wxStaticBoxSizer(wxVERTICAL, page_advanced, _("Misc")); szr_advanced->Add(group_misc, 0, wxEXPAND | wxALL, 5); group_misc->Add(szr_misc, 1, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5); diff --git a/Source/Core/VideoCommon/FPSCounter.cpp b/Source/Core/VideoCommon/FPSCounter.cpp index 8509889d5f..e678abe0b1 100644 --- a/Source/Core/VideoCommon/FPSCounter.cpp +++ b/Source/Core/VideoCommon/FPSCounter.cpp @@ -18,10 +18,9 @@ static unsigned int s_counter = 0; static unsigned int s_fps = 0; static unsigned int s_fps_last_counter = 0; static Common::Timer s_update_time; -static std::ofstream s_bench_file; static Common::Timer s_render_time; -static std::ofstream s_time_file; +static std::ofstream s_bench_file; void Initialize() { @@ -33,24 +32,14 @@ void Initialize() if (s_bench_file.is_open()) s_bench_file.close(); - if (s_time_file.is_open()) - s_time_file.close(); -} - -static void LogFPSToFile(u64 val) -{ - if (!s_bench_file.is_open()) - s_bench_file.open(File::GetUserPath(D_LOGS_IDX) + "fps.txt"); - - s_bench_file << StringFromFormat("%lu\n", val); } static void LogRenderTimeToFile(u64 val) { - if (!s_time_file.is_open()) - s_time_file.open(File::GetUserPath(D_LOGS_IDX) + "render_time.txt"); + if (!s_bench_file.is_open()) + s_bench_file.open(File::GetUserPath(D_LOGS_IDX) + "render_time.txt"); - s_time_file << StringFromFormat("%lu\n", val); + s_bench_file << StringFromFormat("%lu\n", val); } int Update() @@ -60,8 +49,6 @@ int Update() s_update_time.Update(); s_fps = s_counter - s_fps_last_counter; s_fps_last_counter = s_counter; - if (g_ActiveConfig.bLogFPSToFile) - LogFPSToFile(s_fps); } if (g_ActiveConfig.bLogRenderTimeToFile) diff --git a/Source/Core/VideoCommon/VideoConfig.cpp b/Source/Core/VideoCommon/VideoConfig.cpp index aa68ff2e76..77e4eb819c 100644 --- a/Source/Core/VideoCommon/VideoConfig.cpp +++ b/Source/Core/VideoCommon/VideoConfig.cpp @@ -57,7 +57,6 @@ void VideoConfig::Load(const std::string& ini_file) settings->Get("UseRealXFB", &bUseRealXFB, 0); settings->Get("SafeTextureCacheColorSamples", &iSafeTextureCache_ColorSamples,128); settings->Get("ShowFPS", &bShowFPS, false); - settings->Get("LogFPSToFile", &bLogFPSToFile, false); settings->Get("LogRenderTimeToFile", &bLogRenderTimeToFile, false); settings->Get("ShowInputDisplay", &bShowInputDisplay, false); settings->Get("OverlayStats", &bOverlayStats, false); @@ -230,7 +229,6 @@ void VideoConfig::Save(const std::string& ini_file) settings->Set("UseRealXFB", bUseRealXFB); settings->Set("SafeTextureCacheColorSamples", iSafeTextureCache_ColorSamples); settings->Set("ShowFPS", bShowFPS); - settings->Set("LogFPSToFile", bLogFPSToFile); settings->Set("LogRenderTimeToFile", bLogRenderTimeToFile); settings->Set("ShowInputDisplay", bShowInputDisplay); settings->Set("OverlayStats", bOverlayStats); diff --git a/Source/Core/VideoCommon/VideoConfig.h b/Source/Core/VideoCommon/VideoConfig.h index 3200de8afd..595ded24ec 100644 --- a/Source/Core/VideoCommon/VideoConfig.h +++ b/Source/Core/VideoCommon/VideoConfig.h @@ -83,7 +83,6 @@ struct VideoConfig final bool bTexFmtOverlayEnable; bool bTexFmtOverlayCenter; bool bShowEFBCopyRegions; - bool bLogFPSToFile; bool bLogRenderTimeToFile; // Render