Turn the FPSCounter namespace into a class.
This commit is contained in:
parent
6def4ead01
commit
3b978f7c27
|
@ -27,6 +27,7 @@
|
||||||
#include "VideoCommon/AVIDump.h"
|
#include "VideoCommon/AVIDump.h"
|
||||||
#include "VideoCommon/BPFunctions.h"
|
#include "VideoCommon/BPFunctions.h"
|
||||||
#include "VideoCommon/Fifo.h"
|
#include "VideoCommon/Fifo.h"
|
||||||
|
#include "VideoCommon/FPSCounter.h"
|
||||||
#include "VideoCommon/ImageWrite.h"
|
#include "VideoCommon/ImageWrite.h"
|
||||||
#include "VideoCommon/OnScreenDisplay.h"
|
#include "VideoCommon/OnScreenDisplay.h"
|
||||||
#include "VideoCommon/PixelEngine.h"
|
#include "VideoCommon/PixelEngine.h"
|
||||||
|
@ -898,7 +899,7 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbHeight,const EFBRectangl
|
||||||
// Finish up the current frame, print some stats
|
// Finish up the current frame, print some stats
|
||||||
if (g_ActiveConfig.bShowFPS)
|
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);
|
D3D::font.DrawTextScaled(0, 0, 20, 0.0f, 0xFF00FFFF, fps);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#include "VideoCommon/BPStructs.h"
|
#include "VideoCommon/BPStructs.h"
|
||||||
#include "VideoCommon/DriverDetails.h"
|
#include "VideoCommon/DriverDetails.h"
|
||||||
#include "VideoCommon/Fifo.h"
|
#include "VideoCommon/Fifo.h"
|
||||||
|
#include "VideoCommon/FPSCounter.h"
|
||||||
#include "VideoCommon/ImageWrite.h"
|
#include "VideoCommon/ImageWrite.h"
|
||||||
#include "VideoCommon/OnScreenDisplay.h"
|
#include "VideoCommon/OnScreenDisplay.h"
|
||||||
#include "VideoCommon/PixelEngine.h"
|
#include "VideoCommon/PixelEngine.h"
|
||||||
|
@ -335,7 +336,6 @@ Renderer::Renderer()
|
||||||
OSDInternalW = 0;
|
OSDInternalW = 0;
|
||||||
OSDInternalH = 0;
|
OSDInternalH = 0;
|
||||||
|
|
||||||
s_fps=0;
|
|
||||||
s_ShowEFBCopyRegions_VBO = 0;
|
s_ShowEFBCopyRegions_VBO = 0;
|
||||||
s_blendMode = 0;
|
s_blendMode = 0;
|
||||||
|
|
||||||
|
@ -683,7 +683,7 @@ void Renderer::DrawDebugInfo()
|
||||||
std::string debug_info;
|
std::string debug_info;
|
||||||
|
|
||||||
if (g_ActiveConfig.bShowFPS)
|
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)
|
if (SConfig::GetInstance().m_ShowLag)
|
||||||
debug_info += StringFromFormat("Lag: %" PRIu64 "\n", Movie::g_currentLagCount);
|
debug_info += StringFromFormat("Lag: %" PRIu64 "\n", Movie::g_currentLagCount);
|
||||||
|
|
|
@ -10,61 +10,44 @@
|
||||||
#include "VideoCommon/FPSCounter.h"
|
#include "VideoCommon/FPSCounter.h"
|
||||||
#include "VideoCommon/VideoConfig.h"
|
#include "VideoCommon/VideoConfig.h"
|
||||||
|
|
||||||
namespace FPSCounter
|
|
||||||
{
|
|
||||||
#define FPS_REFRESH_INTERVAL 1000
|
#define FPS_REFRESH_INTERVAL 1000
|
||||||
|
|
||||||
static unsigned int s_counter = 0;
|
FPSCounter::FPSCounter()
|
||||||
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()
|
|
||||||
{
|
{
|
||||||
s_counter = s_fps_last_counter = 0;
|
m_update_time.Update();
|
||||||
s_fps = 0;
|
m_render_time.Update();
|
||||||
|
|
||||||
s_update_time.Update();
|
|
||||||
s_render_time.Update();
|
|
||||||
|
|
||||||
if (s_bench_file.is_open())
|
|
||||||
s_bench_file.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Shutdown()
|
FPSCounter::~FPSCounter()
|
||||||
{
|
{
|
||||||
if (s_bench_file.is_open())
|
if (m_bench_file.is_open())
|
||||||
s_bench_file.close();
|
m_bench_file.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void LogRenderTimeToFile(u64 val)
|
void FPSCounter::LogRenderTimeToFile(u64 val)
|
||||||
{
|
{
|
||||||
if (!s_bench_file.is_open())
|
if (!m_bench_file.is_open())
|
||||||
s_bench_file.open(File::GetUserPath(D_LOGS_IDX) + "render_time.txt");
|
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();
|
m_update_time.Update();
|
||||||
s_fps = s_counter - s_fps_last_counter;
|
m_fps = m_counter - m_fps_last_counter;
|
||||||
s_fps_last_counter = s_counter;
|
m_fps_last_counter = m_counter;
|
||||||
s_bench_file.flush();
|
m_bench_file.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_ActiveConfig.bLogRenderTimeToFile)
|
if (g_ActiveConfig.bLogRenderTimeToFile)
|
||||||
{
|
{
|
||||||
LogRenderTimeToFile(s_render_time.GetTimeDifference());
|
LogRenderTimeToFile(m_render_time.GetTimeDifference());
|
||||||
s_render_time.Update();
|
m_render_time.Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
s_counter++;
|
m_counter++;
|
||||||
return s_fps;
|
return m_fps;
|
||||||
}
|
}
|
||||||
}
|
|
|
@ -4,15 +4,32 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
namespace FPSCounter
|
#include <fstream>
|
||||||
|
|
||||||
|
#include "Common/Timer.h"
|
||||||
|
|
||||||
|
class FPSCounter
|
||||||
{
|
{
|
||||||
// Initializes the FPS counter.
|
public:
|
||||||
void Initialize();
|
unsigned int m_fps;
|
||||||
|
|
||||||
// Shutdown the FPS counter by closing the logs.
|
// Initializes the FPS counter.
|
||||||
void Shutdown();
|
FPSCounter();
|
||||||
|
|
||||||
// Called when a frame is rendered. Returns the value to be displayed on
|
// Shutdown the FPS counter by closing the logs.
|
||||||
// screen as the FPS counter (updated every second).
|
~FPSCounter();
|
||||||
int Update();
|
|
||||||
}
|
// 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;
|
||||||
|
|
||||||
|
void LogRenderTimeToFile(u64 val);
|
||||||
|
};
|
||||||
|
|
|
@ -65,8 +65,6 @@ int Renderer::s_LastEFBScale;
|
||||||
bool Renderer::s_skipSwap;
|
bool Renderer::s_skipSwap;
|
||||||
bool Renderer::XFBWrited;
|
bool Renderer::XFBWrited;
|
||||||
|
|
||||||
unsigned int Renderer::s_fps = 0;
|
|
||||||
|
|
||||||
PEControl::PixelFormat Renderer::prev_efb_format = PEControl::INVALID_FMT;
|
PEControl::PixelFormat Renderer::prev_efb_format = PEControl::INVALID_FMT;
|
||||||
unsigned int Renderer::efb_scale_numeratorX = 1;
|
unsigned int Renderer::efb_scale_numeratorX = 1;
|
||||||
unsigned int Renderer::efb_scale_numeratorY = 1;
|
unsigned int Renderer::efb_scale_numeratorY = 1;
|
||||||
|
@ -87,8 +85,6 @@ Renderer::Renderer()
|
||||||
|
|
||||||
OSDChoice = 0;
|
OSDChoice = 0;
|
||||||
OSDTime = 0;
|
OSDTime = 0;
|
||||||
|
|
||||||
FPSCounter::Initialize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Renderer::~Renderer()
|
Renderer::~Renderer()
|
||||||
|
@ -105,8 +101,6 @@ Renderer::~Renderer()
|
||||||
if (pFrameDump.IsOpen())
|
if (pFrameDump.IsOpen())
|
||||||
pFrameDump.Close();
|
pFrameDump.Close();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FPSCounter::Shutdown();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::RenderToXFB(u32 xfbAddr, const EFBRectangle& sourceRc, u32 fbWidth, u32 fbHeight, float Gamma)
|
void Renderer::RenderToXFB(u32 xfbAddr, const EFBRectangle& sourceRc, u32 fbWidth, u32 fbHeight, float Gamma)
|
||||||
|
@ -529,7 +523,7 @@ void Renderer::Swap(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle&
|
||||||
g_renderer->SwapImpl(xfbAddr, fbWidth, fbHeight, rc, Gamma);
|
g_renderer->SwapImpl(xfbAddr, fbWidth, fbHeight, rc, Gamma);
|
||||||
|
|
||||||
if (XFBWrited)
|
if (XFBWrited)
|
||||||
s_fps = FPSCounter::Update();
|
g_renderer->m_fps_counter.Update();
|
||||||
|
|
||||||
frameCount++;
|
frameCount++;
|
||||||
GFX_DEBUGGER_PAUSE_AT(NEXT_FRAME, true);
|
GFX_DEBUGGER_PAUSE_AT(NEXT_FRAME, true);
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include "Common/MathUtil.h"
|
#include "Common/MathUtil.h"
|
||||||
#include "Common/Thread.h"
|
#include "Common/Thread.h"
|
||||||
#include "VideoCommon/BPMemory.h"
|
#include "VideoCommon/BPMemory.h"
|
||||||
|
#include "VideoCommon/FPSCounter.h"
|
||||||
#include "VideoCommon/FramebufferManagerBase.h"
|
#include "VideoCommon/FramebufferManagerBase.h"
|
||||||
#include "VideoCommon/NativeVertexFormat.h"
|
#include "VideoCommon/NativeVertexFormat.h"
|
||||||
#include "VideoCommon/VideoCommon.h"
|
#include "VideoCommon/VideoCommon.h"
|
||||||
|
@ -150,7 +151,7 @@ protected:
|
||||||
static bool s_skipSwap;
|
static bool s_skipSwap;
|
||||||
static bool XFBWrited;
|
static bool XFBWrited;
|
||||||
|
|
||||||
static unsigned int s_fps;
|
FPSCounter m_fps_counter;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static PEControl::PixelFormat prev_efb_format;
|
static PEControl::PixelFormat prev_efb_format;
|
||||||
|
|
Loading…
Reference in New Issue