2018-01-13 03:53:33 +01:00
|
|
|
#include "dxvk_hud_fps.h"
|
|
|
|
|
|
|
|
#include <iomanip>
|
|
|
|
|
|
|
|
namespace dxvk::hud {
|
|
|
|
|
|
|
|
HudFps::HudFps()
|
|
|
|
: m_fpsString("FPS: "),
|
|
|
|
m_prevUpdate(Clock::now()) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
HudFps::~HudFps() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void HudFps::update() {
|
|
|
|
m_frameCount += 1;
|
|
|
|
|
|
|
|
const TimePoint now = Clock::now();
|
|
|
|
const TimeDiff elapsed = std::chrono::duration_cast<TimeDiff>(now - m_prevUpdate);
|
|
|
|
|
|
|
|
if (elapsed.count() >= UpdateInterval) {
|
|
|
|
const int64_t fps = (10'000'000ll * m_frameCount) / elapsed.count();
|
|
|
|
m_fpsString = str::format("FPS: ", fps / 10, ".", fps % 10);
|
|
|
|
|
|
|
|
m_prevUpdate = now;
|
|
|
|
m_frameCount = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
HudPos HudFps::renderText(
|
|
|
|
const Rc<DxvkContext>& context,
|
|
|
|
HudTextRenderer& renderer,
|
|
|
|
HudPos position) {
|
|
|
|
renderer.drawText(context, 16.0f,
|
|
|
|
{ position.x, position.y },
|
2018-01-22 01:20:07 +01:00
|
|
|
{ 1.0f, 1.0f, 1.0f, 1.0f },
|
2018-01-13 03:53:33 +01:00
|
|
|
m_fpsString);
|
|
|
|
|
2018-04-03 14:49:13 +02:00
|
|
|
return HudPos { position.x, position.y + 24 };
|
2018-01-13 03:53:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|