开发者

glDrawElements extremally slow on Android ( HTC Wildfire )

I'm testing OpenGL performance on an Android phone ( HTC Wildfire to be exact ), and I came acro开发者_StackOverflow中文版ss a strange thing - when I try to draw a textured indexed rectangle the size of the screen ( 320 x 480 ), I can get a framerate up to 40 fps!!! - and that's only when I use a 32x32 texture.

If I increase the texture size to 256x256, the performance drops down to 35 frames.

My question is - how is it possible for all those Android games to run smoothly and still be so full of cool graphics.


There are a bunch of different ways to eek performance out of your device.

  1. Make sure you aren't doing blending, or drawing that you don't need and from experience a lot of the lower end HTC devices (eg the desire) are fill rate limited.
  2. Use triangle strips instead of triangles.
  3. Use draw elements and cache your calls eg load your vertex buffer and call draw multiple times for a frame.

But most importantly use the DDMS with method profiling to determine where your bottle necks actually are they may be places you don't expect them eg logging, gc, slow operation in a loop. You will be able to see how much of the time is due to rendering and how much for other operations. (look for GLImpl.glDrawElements)

My biggest ones were with GC kicking in too often (5 times per second and causing my fps to be very sluggish), something you will see with mem allocations often in places you won't even think of. Eg if you are concatenating a string to a float with the + operator or using traditional java get() functions everywhere or (worst) collections, these create a large number of objects that can trigger GC.

Also if you have expensive operations separate them out into a separate thread.

Also I am assuming you are creating your texture once and using the same index each time. I have seen some tutorials which create the texture every time a frame is rendered.

With extensive use of the DDMS I was able to take fps from 12 to 50 on the HTC Desire for a busy scene.

Hope that gets you going in the right direction :)


In my own experience, they don't on devices like the wildfire.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜