During development, I've run into something rather odd that I was hoping someone here might be able to explain.
It appears that, per frame, the first draw command to the GL context - be it a 1px poly, a glClear() call, or a simple texture draw - appear to take a minimum of 14ms. All other rendering must wait upon that first call completing whatever it's doing. The target resolution does not appear to affect this result.
Note that I am timing entirely inside the onDrawFrame() method, so it should not be affected by the buffer copy. Here's the snippet I use:
int total;
int count;
public void onDrawFrame(GL10 gl)
{
long start = System.currentTimeMillis();
GLES20.glClear( GLES20.GL_COLOR_BUFFER_BIT );
total += (System.currentTimeMillis() - start);
count++;
if(count >= 100)
{
System.out.println((total/count)+"ms");
total = 0;
count = 0; }
}
If I do anything other than a GL operation (e.g. ALL the in-game logic), the system runs sub-millisecond and can't even be measured.
Even more interesting is that it appears that GLSurfaceView is automatically clearing the buffer. I dropped the glClear() to see what difference I'd get and expected to see overdraw. I did not see any overdraw. Not even my favorite, "oh, this is the buffer from two frames ago". The screen is quite obviously being cleared. (The only thing I left running was the warp stars. There was no background texture.)
This issue is rather frustrating since only 2ms are left to render the rest of the frame. This leads to late or dropped frames, which is the opposite of what I want to see.
This leads me to my questions for you, my fellow developers:
- Has anyone else seen this and/or know what it is?
- Is it possibly an issue with the GLSurfaceView design? Should I be eliminating the GLSurfaceView panel from my design and create the GL context myself?
- Is it possible that this is a problem with the Mali-400 GPU and isn't exhibited by the Tegra 3?
My setup is as follows:
- Using the GLES20 context (OpenGL ES 2.0)
- Developing on an MK808 (Dual core Rockchip Cortex A9 w/Mali-400 Quad Core GPU)
- 720p display that can accept a 1080p signal (tried both)
Your help is most appreciated!