Vertex buffer objects in OpenGL ES on iPhone

Posts: 2
Joined: 2009.01
Post: #1
Has anyone had success using vertex buffer objects on iPhone? I switched from doing glDrawArray calls from memory I allocated to using STATIC mode buffer objects, and saw no real difference in performance. After that I switched to using glDrawElements, which was comparable. According to the profile I got in Shark, the single largest time-consuming function in my entire app, by a landslide, is CopyIndexedData. I was hoping not to see copying occurring, since that is one of the potential big advantages of using VBO's.

A separate issue: It seems that calling glBindBuffer somehow messes up my client side state in regard to glVertexPointer, etc. I was hoping to cut out some unnecessary calls. I wasn't sure whether or not that state was supposed to be preserved, actually, but calls to glGetPointerv return the correct values. (Offsets, in this case, representing my vertex format. Obviously, if I were using pointers to memory, I would expect to have to change them before each glDrawElements call.)


Quote this message in a reply
Posts: 32
Joined: 2008.10
Post: #2
From my benchmarks, using glDrawElements with indices is actually slower than just ploughing through the data with glDrawArrays (no indices).

Also, my benchmarks show that some models (large polygon count) are better as VBO's, and smaller models are not. For the iPhone, you're usually using smaller models anyway, so try to avoid VBO's for them. You just have to tune each model until you discover what works best.

Likewise, texture size also plays a significant role. Tune your size (ie 256x256 vs 512x512) for each model based on average view distance.

By tuning the above three parameters, I went from 28fps to 60fps on the iPhone.

PS - You cannot rely on glVertexPointer maintaining its value. It will change after each call to glDrawArrays. When drawing the same object twice, you have to repeat calls to glVertexPointer.
Quote this message in a reply
Posts: 6
Joined: 2008.12
Post: #3
Well, I'd like also to share my experience.

I've been programming on Opengl and Opengl ES for some time, just for fun: I never found any performance improvements using VBO vs. VAR's, no matter what platform (Mac, PC, iPhone).

I have read on Gamedev some people saying that performance increase is noticeable only when using a large number of vertices.
Well, I didn't cope with that too: doesn't matter if the mesh is 1000 or 10000 triangles, performances are still the same.
Quote this message in a reply
Posts: 269
Joined: 2005.04
Post: #4
The answer is rather unfortunate: it depends.

The benefit of indexed arrays with glDrawElements over non-indexed arrays and glDrawArrays (and triangle strips over triangles) is that you can potentially send far fewer vertices to be drawn. They're not that much faster to draw since it's the same number of triangles, it just has the potential to be much faster to transfer the data. Same deal with VBOs. If your geometry isn't optimized for tri-strips or indexing, or you're not transfer bound you may not notice much of a difference.
Quote this message in a reply
Posts: 5
Joined: 2008.10
Post: #5
ZooMan Wrote:Has anyone had success using vertex buffer objects on iPhone?

Yes, I use VBOs in Darts. My art path is Cheetah3D -> custom export script -> .c and .h for model data. Then I have a VertexBufferObject class that creates a VBO and binds the model data to it. With this, there's no time overhead parsing model data from file in Resources (that will never change until your next release).

Good luck,
Quote this message in a reply
Posts: 2
Joined: 2009.01
Post: #6
Well, that sounds like a similar result to what I've seen. I think what I would like to ask the people at Apple is, does it HAVE to be this slow? Specifically, why is there a COPY going on at the time of the DrawElements/DrawArray call? As far as I can tell, I am not GPU bound, but in fact CPU bound doing this copy. Bachus, do you think that this function represents the "transfer" you are referring to? I was really hoping said transfer would be asynchronous, and driven by the DMA controller to the GPU. Can we lobby Apple to optimize the code path for VBO's to avoid an extraneous copy?
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  OpenGL Differences between iPhone Sim and Real iPhone SparkyNZ 5 8,567 Apr 13, 2011 11:40 AM
Last Post: SparkyNZ
  Depth Buffer woes in OpenGL ES 2.0 Macmenace 5 10,398 Mar 8, 2010 10:45 AM
Last Post: Macmenace
  opengl es 2.0 and the stencil buffer NelsonMandella 1 5,899 Sep 30, 2009 06:09 AM
Last Post: arekkusu
  Pixel and Vertex Shaders on the iPhone Elphaba 5 5,541 May 29, 2009 01:03 PM
Last Post: kendric
  Do you activate depth buffer when doing 2D games and opengl es? riruilo 13 13,880 Apr 3, 2009 11:02 AM
Last Post: miq01