Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

So, this seems odd to me. I upload a large buffer of vertices, then every frame I call glBindbuffer and then the appropriate gl*Pointer functions with offsets into the buffer, then I use glDrawArrays to draw all of my triangles.

I'm only drawing about 100K triangles, however I'm getting about 15FPS.

This is where it gets weird, if I change it to not call glBindBuffer, then change the gl*Pointer calls to be actual pointers into the array I have in system memory, and then call glDrawArrays the same, my framerate jumps up to about 50FPS.

Any idea what I weird thing I could be doing that would cause this? Did I maybe forget to call glEnable(GL_ALLOW_VBOS_TO_RUN_FAST) or something?

share|improve this question

2 Answers 2

glBindBuffer is expensive, but not so much that you can expect a noticeable impact from a single bind (or several dozen of them, for that matter).

Did you check that you have the right usage flags when creating the buffer storage with glBufferData? For your scenario, GL_STATIC_DRAW is the ALLOW_IT_TO_RUN_FAST flag. If you accidentially use the wrong flags, it might do silly things with your buffer.

I've seen performance drop of nearly two full frames worth on a readback into a PBO once only because I used the wrong flags. When you get that one wrong, it is a "wtf, this cannot possibly take 30 ms???" experience.

share|improve this answer
1  
Yeah, I'm using GL_Static_Draw, that's the sort of thing I thought it might be however. –  Arelius Mar 11 '11 at 23:05
    
A buffer holding 100k triangles, resp. 300k vertices should be no challenge to a somewhat modern graphics card, but ... what does glGet say on GL_MAX_ELEMENTS_VERTICES? I assume you're checking glGetError as standard procedure too? –  dm.skt Mar 11 '11 at 23:19
    
2048? I am also checking glGetError. –  Arelius Mar 11 '11 at 23:29
    
Doesn't that seem awfully small? This is on an i7 MacBook Pro, It's supposed to have nvidia graphics. –  Arelius Mar 11 '11 at 23:36
1  
Just googling around, I found this which seems to be a printout of the 330M (the discrete graphics in the 2010 MacBook Pro) and it says "GL_MAX_ELEMENTS_VERTICES: 1048576". Try installing gfxCardStatus and make sure your discrete card is being used and not the integrated Intel chip; that might actually explain the system memory being faster too, since the integrated chip leeches off of system memory (I think) and should therefore have fast access to it... –  Ricket Mar 14 '11 at 13:08

I think its a code specific problem not problem with VBOs..

  • make sure you are not copying VBOs every time.
  • make sure you are not misusing VBOs functions (I think there is a small difference between using VBOs in openGL 3.0 and previous versions).
  • make sure that openGL is not generating an Error.
  • debug your openGL code using gDebugger.
share|improve this answer
    
Copy them once, Additionally the code that runs to upload them is still getting uploaded, they are just going unused. I've been debugging with gDebugger, no warnings or errors. –  Arelius Mar 11 '11 at 22:33
    
Look at the stats generated by gDebugger too - you may be doing something weird by mistake. –  Jari Komppa Mar 14 '11 at 13:59
    
@Jari, nothing obvious. –  Arelius Mar 14 '11 at 21:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.