opengles emulator: added FPS statistics printout
Make the renderer print FPS statistics every 1 second. Need to set SHOW_FPS_STATS=1 Change-Id: I69e8c43a779e685ae0b34974d1ef33ad75e7a7e4
This commit is contained in:
@@ -21,6 +21,7 @@
|
|||||||
#include "GL2Dispatch.h"
|
#include "GL2Dispatch.h"
|
||||||
#include "ThreadInfo.h"
|
#include "ThreadInfo.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include "TimeUtils.h"
|
||||||
|
|
||||||
FrameBuffer *FrameBuffer::s_theFrameBuffer = NULL;
|
FrameBuffer *FrameBuffer::s_theFrameBuffer = NULL;
|
||||||
HandleType FrameBuffer::s_nextHandle = 0;
|
HandleType FrameBuffer::s_nextHandle = 0;
|
||||||
@@ -352,8 +353,11 @@ FrameBuffer::FrameBuffer(int p_x, int p_y, int p_width, int p_height) :
|
|||||||
m_prevReadSurf(EGL_NO_SURFACE),
|
m_prevReadSurf(EGL_NO_SURFACE),
|
||||||
m_prevDrawSurf(EGL_NO_SURFACE),
|
m_prevDrawSurf(EGL_NO_SURFACE),
|
||||||
m_subWin(NULL),
|
m_subWin(NULL),
|
||||||
m_subWinDisplay(NULL)
|
m_subWinDisplay(NULL),
|
||||||
|
m_statsNumFrames(0),
|
||||||
|
m_statsStartTime(0LL)
|
||||||
{
|
{
|
||||||
|
m_fpsStats = getenv("SHOW_FPS_STATS") != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
FrameBuffer::~FrameBuffer()
|
FrameBuffer::~FrameBuffer()
|
||||||
@@ -653,6 +657,21 @@ bool FrameBuffer::post(HandleType p_colorbuffer)
|
|||||||
}
|
}
|
||||||
ret = (*c).second->post();
|
ret = (*c).second->post();
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
|
||||||
|
//
|
||||||
|
// output FPS statistics
|
||||||
|
//
|
||||||
|
if (m_fpsStats) {
|
||||||
|
long long currTime = GetCurrentTimeMS();
|
||||||
|
m_statsNumFrames++;
|
||||||
|
if (currTime - m_statsStartTime >= 1000) {
|
||||||
|
float dt = (float)(currTime - m_statsStartTime) / 1000.0f;
|
||||||
|
printf("FPS: %5.3f\n", (float)m_statsNumFrames / dt);
|
||||||
|
m_statsStartTime = currTime;
|
||||||
|
m_statsNumFrames = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
s_egl.eglSwapBuffers(m_eglDisplay, m_eglSurface);
|
s_egl.eglSwapBuffers(m_eglDisplay, m_eglSurface);
|
||||||
}
|
}
|
||||||
unbind_locked();
|
unbind_locked();
|
||||||
|
|||||||
@@ -106,5 +106,9 @@ private:
|
|||||||
EGLSurface m_prevDrawSurf;
|
EGLSurface m_prevDrawSurf;
|
||||||
EGLNativeWindowType m_subWin;
|
EGLNativeWindowType m_subWin;
|
||||||
EGLNativeDisplayType m_subWinDisplay;
|
EGLNativeDisplayType m_subWinDisplay;
|
||||||
|
|
||||||
|
int m_statsNumFrames;
|
||||||
|
long long m_statsStartTime;
|
||||||
|
bool m_fpsStats;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user