Commit 0952c7de by Nicolas Capens Committed by Nicolas Capens

Fix initial framerate and show maximum.

We don't start timing until after the first frame finished rendering and is presented, so the frame count has to be 0 at that point. Change-Id: Ic242bb5625c6c50694e7625008565ee421859624 Reviewed-on: https://swiftshader-review.googlesource.com/12488Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Tested-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent bc6ce4f1
......@@ -57,7 +57,7 @@ namespace sw
};
}
#else // !__ANDROID__
#else // !__linux__
#include <atomic>
......
......@@ -148,24 +148,30 @@ namespace sw
if(false) // Draw the framerate on screen
{
static double fpsTime = sw::Timer::seconds();
static int framesSec = 0;
static int frames = -1;
double time = sw::Timer::seconds();
double delta = time - fpsTime;
framesSec++;
frames++;
static double FPS = 0.0;
static double maxFPS = 0.0;
if(delta > 1.0)
{
FPS = framesSec / delta;
FPS = frames / delta;
fpsTime = time;
framesSec = 0;
frames = 0;
if(FPS > maxFPS)
{
maxFPS = FPS;
}
}
char string[256];
sprintf(string, "FPS: %.1f", FPS);
sprintf(string, "FPS: %.2f (max: %.2f)", FPS, maxFPS);
libX11->XDrawString(x_display, x_window, x_gc, 50, 50, string, strlen(string));
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment