summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorDolphin Bot <dolphin-emu-bot@users.noreply.github.com>2014-07-18 12:59:04 +0200
committerDolphin Bot <dolphin-emu-bot@users.noreply.github.com>2014-07-18 12:59:04 +0200
commitb9dc69105d0529c74a4f3c8f3579fa699f2d7bdc (patch)
tree2b2d159bf145e2849fb2a59108e9effb3c12fdfe /Source/Core
parenta180cd60ee9d5bfb0f92084515ee4b28c1a260e6 (diff)
parenteaa7460636f01f7779154259d492568c9d2dee1e (diff)
Merge pull request #595 from Armada651/pref_log
FPSCounter: Flush the logs every second and close them when the renderer is shut down.
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/VideoBackends/D3D/Render.cpp10
-rw-r--r--Source/Core/VideoBackends/OGL/Render.cpp7
-rw-r--r--Source/Core/VideoCommon/FPSCounter.cpp50
-rw-r--r--Source/Core/VideoCommon/FPSCounter.h31
-rw-r--r--Source/Core/VideoCommon/RenderBase.cpp4
-rw-r--r--Source/Core/VideoCommon/RenderBase.h3
6 files changed, 50 insertions, 55 deletions
diff --git a/Source/Core/VideoBackends/D3D/Render.cpp b/Source/Core/VideoBackends/D3D/Render.cpp
index adb9613213..2699b56a46 100644
--- a/Source/Core/VideoBackends/D3D/Render.cpp
+++ b/Source/Core/VideoBackends/D3D/Render.cpp
@@ -38,8 +38,6 @@
namespace DX11
{
-static int s_fps = 0;
-
static u32 s_LastAA = 0;
static Television s_television;
@@ -181,8 +179,6 @@ Renderer::Renderer(void *&window_handle)
{
int x, y, w_temp, h_temp;
- FPSCounter::Initialize();
-
Host_GetRenderWindowSize(x, y, w_temp, h_temp);
D3D::Create((HWND)window_handle);
@@ -903,7 +899,7 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbHeight,const EFBRectangl
// Finish up the current frame, print some stats
if (g_ActiveConfig.bShowFPS)
{
- std::string fps = StringFromFormat("FPS: %d\n", s_fps);
+ std::string fps = StringFromFormat("FPS: %d\n", m_fps_counter.m_fps);
D3D::font.DrawTextScaled(0, 0, 20, 0.0f, 0xFF00FFFF, fps);
}
@@ -952,10 +948,6 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbHeight,const EFBRectangl
FramebufferManagerBase::SetLastXfbHeight(h);
}
- // update FPS counter
- if (XFBWrited)
- s_fps = FPSCounter::Update();
-
// Flip/present backbuffer to frontbuffer here
D3D::Present();
diff --git a/Source/Core/VideoBackends/OGL/Render.cpp b/Source/Core/VideoBackends/OGL/Render.cpp
index 5fb486c6d9..c9b373918b 100644
--- a/Source/Core/VideoBackends/OGL/Render.cpp
+++ b/Source/Core/VideoBackends/OGL/Render.cpp
@@ -85,7 +85,6 @@ VideoConfig g_ogl_config;
// Declarations and definitions
// ----------------------------
-static int s_fps = 0;
static GLuint s_ShowEFBCopyRegions_VBO = 0;
static GLuint s_ShowEFBCopyRegions_VAO = 0;
static SHADER s_ShowEFBCopyRegions;
@@ -339,10 +338,8 @@ Renderer::Renderer()
OSDInternalW = 0;
OSDInternalH = 0;
- s_fps=0;
s_ShowEFBCopyRegions_VBO = 0;
s_blendMode = 0;
- FPSCounter::Initialize();
bool bSuccess = true;
@@ -688,7 +685,7 @@ void Renderer::DrawDebugInfo()
std::string debug_info;
if (g_ActiveConfig.bShowFPS)
- debug_info += StringFromFormat("FPS: %d\n", s_fps);
+ debug_info += StringFromFormat("FPS: %d\n", m_fps_counter.m_fps);
if (SConfig::GetInstance().m_ShowLag)
debug_info += StringFromFormat("Lag: %" PRIu64 "\n", Movie::g_currentLagCount);
@@ -1585,8 +1582,6 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbHeight,const EFBRectangl
}
}
- if (XFBWrited)
- s_fps = FPSCounter::Update();
// ---------------------------------------------------------------------
if (!DriverDetails::HasBug(DriverDetails::BUG_BROKENSWAP))
{
diff --git a/Source/Core/VideoCommon/FPSCounter.cpp b/Source/Core/VideoCommon/FPSCounter.cpp
index 10bfebb26f..1ce46377c7 100644
--- a/Source/Core/VideoCommon/FPSCounter.cpp
+++ b/Source/Core/VideoCommon/FPSCounter.cpp
@@ -10,54 +10,38 @@
#include "VideoCommon/FPSCounter.h"
#include "VideoCommon/VideoConfig.h"
-namespace FPSCounter
-{
#define FPS_REFRESH_INTERVAL 1000
-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 Common::Timer s_render_time;
-static std::ofstream s_bench_file;
-
-void Initialize()
+FPSCounter::FPSCounter()
{
- s_counter = s_fps_last_counter = 0;
- s_fps = 0;
-
- s_update_time.Update();
- s_render_time.Update();
-
- if (s_bench_file.is_open())
- s_bench_file.close();
+ m_update_time.Update();
+ m_render_time.Update();
}
-static void LogRenderTimeToFile(u64 val)
+void FPSCounter::LogRenderTimeToFile(u64 val)
{
- if (!s_bench_file.is_open())
- s_bench_file.open(File::GetUserPath(D_LOGS_IDX) + "render_time.txt");
+ if (!m_bench_file.is_open())
+ m_bench_file.open(File::GetUserPath(D_LOGS_IDX) + "render_time.txt");
- s_bench_file << val << std::endl;
+ m_bench_file << val << std::endl;
}
-int Update()
+int FPSCounter::Update()
{
- if (s_update_time.GetTimeDifference() >= FPS_REFRESH_INTERVAL)
+ if (m_update_time.GetTimeDifference() >= FPS_REFRESH_INTERVAL)
{
- s_update_time.Update();
- s_fps = s_counter - s_fps_last_counter;
- s_fps_last_counter = s_counter;
+ m_update_time.Update();
+ m_fps = m_counter - m_fps_last_counter;
+ m_fps_last_counter = m_counter;
+ m_bench_file.flush();
}
if (g_ActiveConfig.bLogRenderTimeToFile)
{
- LogRenderTimeToFile(s_render_time.GetTimeDifference());
- s_render_time.Update();
+ LogRenderTimeToFile(m_render_time.GetTimeDifference());
+ m_render_time.Update();
}
- s_counter++;
- return s_fps;
+ m_counter++;
+ return m_fps;
}
-} \ No newline at end of file
diff --git a/Source/Core/VideoCommon/FPSCounter.h b/Source/Core/VideoCommon/FPSCounter.h
index 9bdee876eb..bb1dc7922d 100644
--- a/Source/Core/VideoCommon/FPSCounter.h
+++ b/Source/Core/VideoCommon/FPSCounter.h
@@ -4,12 +4,29 @@
#pragma once
-namespace FPSCounter
+#include <fstream>
+
+#include "Common/Timer.h"
+
+class FPSCounter
{
-// Initializes the FPS counter.
-void Initialize();
+public:
+ unsigned int m_fps;
+
+ // Initializes the FPS counter.
+ FPSCounter();
+
+ // Called when a frame is rendered. Returns the value to be displayed on
+ // screen as the FPS counter (updated every second).
+ int Update();
+
+private:
+ unsigned int m_counter;
+ unsigned int m_fps_last_counter;
+ Common::Timer m_update_time;
+
+ Common::Timer m_render_time;
+ std::ofstream m_bench_file;
-// Called when a frame is rendered. Returns the value to be displayed on
-// screen as the FPS counter (updated every second).
-int Update();
-}
+ void LogRenderTimeToFile(u64 val);
+};
diff --git a/Source/Core/VideoCommon/RenderBase.cpp b/Source/Core/VideoCommon/RenderBase.cpp
index 508dda77ca..4ba52d09fe 100644
--- a/Source/Core/VideoCommon/RenderBase.cpp
+++ b/Source/Core/VideoCommon/RenderBase.cpp
@@ -29,6 +29,7 @@
#include "VideoCommon/CPMemory.h"
#include "VideoCommon/Debugger.h"
#include "VideoCommon/Fifo.h"
+#include "VideoCommon/FPSCounter.h"
#include "VideoCommon/FramebufferManagerBase.h"
#include "VideoCommon/MainBase.h"
#include "VideoCommon/OpcodeDecoding.h"
@@ -519,6 +520,9 @@ void Renderer::Swap(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle&
// TODO: merge more generic parts into VideoCommon
g_renderer->SwapImpl(xfbAddr, fbWidth, fbHeight, rc, Gamma);
+ if (XFBWrited)
+ g_renderer->m_fps_counter.Update();
+
frameCount++;
GFX_DEBUGGER_PAUSE_AT(NEXT_FRAME, true);
diff --git a/Source/Core/VideoCommon/RenderBase.h b/Source/Core/VideoCommon/RenderBase.h
index 16b17ae8de..8707219d82 100644
--- a/Source/Core/VideoCommon/RenderBase.h
+++ b/Source/Core/VideoCommon/RenderBase.h
@@ -19,6 +19,7 @@
#include "Common/MathUtil.h"
#include "Common/Thread.h"
#include "VideoCommon/BPMemory.h"
+#include "VideoCommon/FPSCounter.h"
#include "VideoCommon/FramebufferManagerBase.h"
#include "VideoCommon/NativeVertexFormat.h"
#include "VideoCommon/VideoCommon.h"
@@ -150,6 +151,8 @@ protected:
static bool s_skipSwap;
static bool XFBWrited;
+ FPSCounter m_fps_counter;
+
private:
static PEControl::PixelFormat prev_efb_format;
static unsigned int efb_scale_numeratorX;