I hate Qualcomm, i really do. The mesh class in libgdx is doing everything according to OpenGL best practices and is especially optimized for some nasty Android specific cases. As stated in an earlier post i got 22fps on the hero with a simple SpriteBatch based test. Here’s the code for the render method:
public void render(Application app)
GL10 gl = app.getGraphics().getGL10();
gl.glViewport( 0, 0, app.getGraphics().getWidth(), app.getGraphics().getHeight() );
gl.glClear( GL10.GL_COLOR_BUFFER_BIT );
spriteBatch.drawText( font, "fps: " + fps, 0, app.getGraphics().getHeight(), Color.RED );
.. fps counter update ...
So we clear the screen and then draw a simple fps counter. Now, SpriteBatch works in this way: a Mesh is instanciated with a fixed maximum of vertices it can hold. Each time one of the SpriteBatch.draw/drawText methods are called i first fill a float array with the appropriate data for the quads and then upload them to the mesh which hopefully is a dynamic VBO on the GPU (in some cases it won’t be, e.g. on devices were VBOs are not supported or buggy like on the Behold 2). I of course only upload and render when either the texture changes, SpriteBatch.end() is called or the mesh is completely filled up with quads from previous yet unrendered draw calls. In any case i need to update the VBO with the new vertex data. Any sane programmer using OpenGL would use glBufferSubData in that case as it is specifically designed for updating poritionions of an VBO that is already initiated and for which memory was already allocated. Guess what. Qualcomm screwed that up. That call takes an insanely high amount of time and gets a normally perfect 60fps down to 22fps. Awesome Qualcomm, i applaud you.
Funny extra: the same is true for glSubTexImage2D!
I hope the MSM7200 dies a quick death and that everything is fixed on the Nexus One.
The changes are commited to SVN i will upload a new libgdx version tomorrow.
I could only test on the emulator and my droid for the past 3 weeks. Today i got my hands on the hero i gave to Stefanie. Well, seems like the GLSurfaceView i used and copied from the latest git version does not work on the Hero (however, it does on all emulator versions from 1.5 to 2.1 upwards). That one i fixed. Now the second question is why SpriteBatch is so extra ordinarily slow on the hero. With a simple test that just draws the fps i get 40 on a 1.5 emulator. On my hero i get 22fps. Wtf? I hate the MSM7200 chips so much i could cry…
Sorry for the inconvenience.