Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is glDrawElements() more efficient than glDrawArrays() when there are many duplicate vertices?

I'm trying to squeeze some performance increases out of my iPhone OpenGL ES application. According to Instruments, my tiler utilization is near 100% most of the time, and my FPS is about 24. I'd like to get my FPS up over 30. I can get there by converting from GL_FLOAT to GL_SHORT, but that presents some fairly daunting technical problems for me at the moment. I'd rather not go there.

So, I'm considering switching from glDrawArrays() to glDrawElements(). I have 35 meshes made up of 708 vertices, but a lot of those vertices are shared between faces. I am texture mapping but the mesh is mostly uniform in color. The faces that require special texturing will be left as is.

Let's say I can cut the number of vertices in half. Let's also say that I also organize my geometry in a way that makes sense for the iPhone: say, using Imagination Technologies PVRTTriStrip tool. Ignoring the small amount of extra memory for the index array, that means I've roughly cut the memory bandwidth in half so I should see a fairly nice performance increase.

Is this true, or am I missing or misunderstanding something? Advice is appreciated.

like image 909
Rob Jones Avatar asked Jan 15 '10 16:01

Rob Jones


2 Answers

In case anyone is interested, I went ahead and tried this, without the PVRTTriStrip tool portion. All testing was done on an iPhone 3G. I was able to scale my vertices down from 708 to 113. And since I'm under 255, I'm using GLubyte as my index type. So, I went from:

35 * (708 * 32) = ~774K

To:

35 * (113 * 32 + 708 * 1) = ~148K

Which reduced my total memory bandwidth to under 20% of what it was. My FPS increased to ~34. So, I saw about a 42% improvement in FPS. Overall, I'm pretty happy. I think there's more to be gained, but I have bigger fish to fry now.

Also, I filtered out a bunch of degenerate triangles (not the useful kind) to get my index count down to 522, from 708. From that I saw an increase to ~40 FPS from the ~34 FPS I was seeing.

like image 171
Rob Jones Avatar answered Nov 14 '22 21:11

Rob Jones


If you're hitting a Tiler Utilization of 100% in Instruments (like I was), you're being constrained by the size of your geometry. Of all the things I tried to improve performance, I only noticed a significant bump in framerate when I reduced the geometry size. So, yes, if you can eliminate some vertices from being sent, you should see a boost in performance.

Even though you state that it is difficult to do, I highly recommend converting from GL_FLOAT to GL_SHORTs, because you will see a large jump in rendering speed. I did this in my application, and it wasn't too much of a hassle to implement for the kind of return I got.

like image 39
Brad Larson Avatar answered Nov 14 '22 21:11

Brad Larson