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/12488
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/Common/MutexLock.hpp b/src/Common/MutexLock.hpp
index 65b4d7e..3a071c9 100644
--- a/src/Common/MutexLock.hpp
+++ b/src/Common/MutexLock.hpp
@@ -57,7 +57,7 @@
};
}
-#else // !__ANDROID__
+#else // !__linux__
#include <atomic>
diff --git a/src/Main/FrameBufferX11.cpp b/src/Main/FrameBufferX11.cpp
index 2cfda6c..eeef9f2 100644
--- a/src/Main/FrameBufferX11.cpp
+++ b/src/Main/FrameBufferX11.cpp
@@ -148,24 +148,30 @@
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));
}
}