mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2025-04-28 21:37:58 +03:00
Collect samples over one second for FPS counter and average. (#377)
This commit is contained in:
parent
dd294a30d4
commit
3081aec7c1
1 changed files with 8 additions and 1 deletions
|
@ -2358,11 +2358,18 @@ static void DrawFPS()
|
|||
double time = ImGui::GetTime();
|
||||
static double updateTime = time;
|
||||
static double fps = 0;
|
||||
static double totalDeltaTime = 0.0;
|
||||
static uint32_t totalDeltaCount = 0;
|
||||
|
||||
totalDeltaTime += g_presentProfiler.value.load();
|
||||
totalDeltaCount++;
|
||||
|
||||
if (time - updateTime >= 1.0f)
|
||||
{
|
||||
fps = 1000.0 / g_presentProfiler.value.load();
|
||||
fps = 1000.0 / std::max(totalDeltaTime / double(totalDeltaCount), 1.0);
|
||||
updateTime = time;
|
||||
totalDeltaTime = 0.0;
|
||||
totalDeltaCount = 0;
|
||||
}
|
||||
|
||||
auto drawList = ImGui::GetBackgroundDrawList();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue