Tips for improving OpenGL ES fill rate on Android

2019-03-27 01:21发布

In my live wallpaper I'm drawing 3 textured quads that covers the whole screen. On Nexus One I get 40fps. I'm looking for ways to improving performance.

The quads are blended on top of each other, textures are loaded from RGB_8888 bitmaps. Textures are 1024x1024.

I've got

glDisable(GL_DITHER);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
glDisable(GL10.GL_LIGHTING);
glDisable(GL_DEPTH_TEST);
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);

Things I've tried, all resulting in the same 40fps:

  • Reduce texture size to 512x512 and 256x256
  • Use draw_texture extension
  • Disable blending
  • Change texture filtering from GL_LINEAR to GL_NEAREST
  • Use VBOs (desperate try, since there are just 3 quads...)
  • Run the drawing code in standalone activity (in case being a live wallpaper somehow affects performance)

If I draw 2 layers instead of 3, fps rises to 45 or so, then drawing just 1 layer sees fps rise to 55. I guess I'm getting limited by fill rate, since turning off and on the potentially costly features result in the same fps, and the only thing that seems to improve fps is just drawing less...

I'm mulling over the idea of texture compression, but supporting the different compression formats doesn't seem like fun. ETC1 has no alpha channel which I need, and I'm not sure if PVRTC and ATITC can even be used from Java and OpenGL ES 1.0 or 1.1.

I'd be glad to hear ideas on what else to try. I can give pointer to the current version of wallpaper and screenshots if that's of use.

3条回答
孤傲高冷的网名
2楼-- · 2019-03-27 01:38

You probably already thought of this, but just in case you didn't:

  • calling glClear at the start of your frame probably isn't necessary
  • you could do the first pass with blending disabled

Also, did you try doing it in 1 pass with a multi-texturing approach?

edit: And another thing: writing to the z-buffer is not needed, so either use a context without z-buffer, or disable depth writing with glDepthMask(GL_FALSE).

查看更多
Emotional °昔
3楼-- · 2019-03-27 01:48

The android opengl framework min3d is able to draw these objects or scenes at a full 60fps.

The framework is opensource and is available for download and use at: http://code.google.com/p/min3d/

I would recommend comparing your code to it to see what you have done wrong/differently in order to improve your performance.

查看更多
爷的心禁止访问
4楼-- · 2019-03-27 01:50

glCompressedTexImage2D is available in Java (and NDK), however available compression format depends on GPU.

The AndroidManifest.xml File > supports-gl-texture

  • PowerVR SGX - Nexus S, Galaxy S/Tab, DROID - PVRTC
  • Adreno - Nexus One, EVO - ATITC
  • Tegra2 - Xoom, Atrix - S3TC

If you use these compression format and want to support various Android devices, you must prepare for many compressed textures, but the GPU native compression texture should improve rendering performance.

查看更多
登录 后发表回答