diff options
| author | Anthony <Helios747@users.noreply.github.com> | 2017-07-30 00:42:36 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-07-30 00:42:36 -0700 |
| commit | 5bad2ee4a4129e734ff4f4d861cedc4cd573df55 (patch) | |
| tree | cd3c3ccc6e35417858499449d774670c3983cb13 /Source/Core/VideoCommon | |
| parent | 5e6d5493165d1214f513b91eaeb4e162d21fdd3e (diff) | |
| parent | 357c55442f3dbdf6f23d16af5362d1a615cb84c1 (diff) | |
Merge pull request #5832 from stenzek/ubershader-prereq
Ubershader prerequisites
Diffstat (limited to 'Source/Core/VideoCommon')
| -rw-r--r-- | Source/Core/VideoCommon/FPSCounter.cpp | 32 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/FPSCounter.h | 14 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/RenderBase.cpp | 2 |
3 files changed, 23 insertions, 25 deletions
diff --git a/Source/Core/VideoCommon/FPSCounter.cpp b/Source/Core/VideoCommon/FPSCounter.cpp index 2d17d00a41..86b3ab5c85 100644 --- a/Source/Core/VideoCommon/FPSCounter.cpp +++ b/Source/Core/VideoCommon/FPSCounter.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #include <fstream> +#include <iomanip> #include "Common/CommonTypes.h" #include "Common/FileUtil.h" @@ -10,12 +11,11 @@ #include "VideoCommon/FPSCounter.h" #include "VideoCommon/VideoConfig.h" -static constexpr u64 FPS_REFRESH_INTERVAL = 1000; +static constexpr u64 FPS_REFRESH_INTERVAL = 250000; FPSCounter::FPSCounter() { - m_update_time.Update(); - m_render_time.Update(); + m_last_time = Common::Timer::GetTimeUs(); } void FPSCounter::LogRenderTimeToFile(u64 val) @@ -23,24 +23,24 @@ void FPSCounter::LogRenderTimeToFile(u64 val) if (!m_bench_file.is_open()) m_bench_file.open(File::GetUserPath(D_LOGS_IDX) + "render_time.txt"); - m_bench_file << val << std::endl; + m_bench_file << std::fixed << std::setprecision(8) << (val / 1000.0) << std::endl; } void FPSCounter::Update() { - if (m_update_time.GetTimeDifference() >= FPS_REFRESH_INTERVAL) - { - m_update_time.Update(); - m_fps = m_counter - m_fps_last_counter; - m_fps_last_counter = m_counter; - m_bench_file.flush(); - } - + u64 time = Common::Timer::GetTimeUs(); + u64 diff = time - m_last_time; if (g_ActiveConfig.bLogRenderTimeToFile) + LogRenderTimeToFile(diff); + + m_frame_counter++; + m_time_since_update += diff; + m_last_time = time; + + if (m_time_since_update >= FPS_REFRESH_INTERVAL) { - LogRenderTimeToFile(m_render_time.GetTimeDifference()); - m_render_time.Update(); + m_fps = m_frame_counter / (m_time_since_update / 1000000.0); + m_frame_counter = 0; + m_time_since_update = 0; } - - m_counter++; } diff --git a/Source/Core/VideoCommon/FPSCounter.h b/Source/Core/VideoCommon/FPSCounter.h index 860734d25b..112256e414 100644 --- a/Source/Core/VideoCommon/FPSCounter.h +++ b/Source/Core/VideoCommon/FPSCounter.h @@ -6,7 +6,7 @@ #include <fstream> -#include "Common/Timer.h" +#include "Common/CommonTypes.h" class FPSCounter { @@ -17,14 +17,12 @@ public: // Called when a frame is rendered (updated every second). void Update(); - unsigned int GetFPS() const { return m_fps; } + float GetFPS() const { return m_fps; } private: - unsigned int m_fps = 0; - unsigned int m_counter = 0; - unsigned int m_fps_last_counter = 0; - Common::Timer m_update_time; - - Common::Timer m_render_time; + u64 m_last_time = 0; + u64 m_time_since_update = 0; + u32 m_frame_counter = 0; + float m_fps = 0; std::ofstream m_bench_file; void LogRenderTimeToFile(u64 val); diff --git a/Source/Core/VideoCommon/RenderBase.cpp b/Source/Core/VideoCommon/RenderBase.cpp index 45e2006cb6..9f425e4cd2 100644 --- a/Source/Core/VideoCommon/RenderBase.cpp +++ b/Source/Core/VideoCommon/RenderBase.cpp @@ -337,7 +337,7 @@ void Renderer::DrawDebugText() if (g_ActiveConfig.bShowFPS || SConfig::GetInstance().m_ShowFrameCount) { if (g_ActiveConfig.bShowFPS) - final_cyan += StringFromFormat("FPS: %u", m_fps_counter.GetFPS()); + final_cyan += StringFromFormat("FPS: %.2f", m_fps_counter.GetFPS()); if (g_ActiveConfig.bShowFPS && SConfig::GetInstance().m_ShowFrameCount) final_cyan += " - "; |
