mirror of https://github.com/AxioDL/metaforce.git
FPS Counter and debug overlay CVAR
This commit is contained in:
parent
9d78305360
commit
7fb4c45046
|
@ -66,6 +66,9 @@ void ViewManager::TestGameView::think() {
|
|||
if (m_cvarCommons.m_debugOverlayShowFrameCounter->toBoolean())
|
||||
overlayText += fmt::format(FMT_STRING("Frame: {}\n"), g_StateManager->GetUpdateFrameIndex());
|
||||
|
||||
if (m_cvarCommons.m_debugOverlayShowFramerate->toBoolean())
|
||||
overlayText += fmt::format(FMT_STRING("FPS: {}\n"), urde::CGraphics::GetFPS());
|
||||
|
||||
if (m_cvarCommons.m_debugOverlayShowInGameTime->toBoolean()) {
|
||||
double igt = g_GameState->GetTotalPlayTime();
|
||||
u32 ms = u64(igt * 1000) % 1000;
|
||||
|
|
|
@ -34,6 +34,9 @@ SViewport g_Viewport = {
|
|||
0, 0, 640, 480, 640 / 2.f, 480 / 2.f, 0.0f,
|
||||
};
|
||||
u32 CGraphics::g_FrameCounter = 0;
|
||||
u32 CGraphics::g_Framerate = 0;
|
||||
u32 CGraphics::g_FramesPast = 0;
|
||||
frame_clock::time_point CGraphics::g_FrameStartTime = frame_clock::now();
|
||||
|
||||
const std::array<zeus::CMatrix3f, 6> CGraphics::skCubeBasisMats{{
|
||||
/* Right */
|
||||
|
@ -126,6 +129,8 @@ void CGraphics::EndScene() {
|
|||
CLineRenderer::UpdateBuffers();
|
||||
|
||||
++g_FrameCounter;
|
||||
|
||||
UpdateFPSCounter();
|
||||
}
|
||||
|
||||
void CGraphics::SetAlphaCompare(ERglAlphaFunc comp0, u8 ref0, ERglAlphaOp op, ERglAlphaFunc comp1, u8 ref1) {}
|
||||
|
@ -444,6 +449,18 @@ void CGraphics::TickRenderTimings() {
|
|||
g_DefaultSeconds = g_RenderTimings / 60.f;
|
||||
}
|
||||
|
||||
static constexpr u64 FPS_REFRESH_RATE = 1000;
|
||||
void CGraphics::UpdateFPSCounter() {
|
||||
++g_FramesPast;
|
||||
|
||||
std::chrono::duration<double, std::milli> timeElapsed = frame_clock::now() - g_FrameStartTime;
|
||||
if (timeElapsed.count() > FPS_REFRESH_RATE) {
|
||||
g_Framerate = g_FramesPast;
|
||||
g_FrameStartTime = frame_clock::now();
|
||||
g_FramesPast = 0;
|
||||
}
|
||||
}
|
||||
|
||||
boo::IGraphicsDataFactory::Platform CGraphics::g_BooPlatform = boo::IGraphicsDataFactory::Platform::Null;
|
||||
boo::IGraphicsDataFactory* CGraphics::g_BooFactory = nullptr;
|
||||
boo::IGraphicsCommandQueue* CGraphics::g_BooMainCommandQueue = nullptr;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include <array>
|
||||
#include <vector>
|
||||
#include <chrono>
|
||||
|
||||
#include "Runtime/RetroTypes.hpp"
|
||||
|
||||
|
@ -18,6 +19,8 @@
|
|||
#include <zeus/CVector2i.hpp>
|
||||
#include <zeus/CVector2f.hpp>
|
||||
|
||||
using frame_clock = std::chrono::high_resolution_clock;
|
||||
|
||||
namespace urde {
|
||||
extern hecl::CVar* g_disableLighting;
|
||||
class CLight;
|
||||
|
@ -309,7 +312,12 @@ public:
|
|||
static float GetSecondsMod900();
|
||||
static void TickRenderTimings();
|
||||
static u32 g_FrameCounter;
|
||||
static u32 g_Framerate;
|
||||
static u32 g_FramesPast;
|
||||
static frame_clock::time_point g_FrameStartTime;
|
||||
static u32 GetFrameCounter() { return g_FrameCounter; }
|
||||
static u32 GetFPS() { return g_Framerate; }
|
||||
static void UpdateFPSCounter();
|
||||
|
||||
static boo::IGraphicsDataFactory::Platform g_BooPlatform;
|
||||
static const boo::SystemChar* g_BooPlatformName;
|
||||
|
|
Loading…
Reference in New Issue