Jump to content
  • Advertisement
Sign in to follow this  
EarthBanana

OpenGL Invalidating Buffers

This topic is 2075 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

There are a lot of cool new tools with opengl 4.4 - like immutable storage for buffer objects - but reading about all of these things from the opengl wiki leaves me wondering...

 

Should I be invalidating buffer objects before doing reallocation?

 

The wiki says that on invalidating a buffer object, pending draw calls and other operations will complete using the old data in the buffer, which is what I would hope for since opengl can draw things whenever the best time to draw them might be.

 

My question is this, if I call glBufferData() and fill the buffer with some other data, will pending draw calls that opengl has not executed yet use the old data as it would if I invalidated the buffer? Or should I invalidate the buffer before I call glBufferData with new data?

Share this post


Link to post
Share on other sites
Advertisement

My question is this, if I call glBufferData() and fill the buffer with some other data, will pending draw calls that opengl has not executed yet use the old data as it would if I invalidated the buffer? Or should I invalidate the buffer before I call glBufferData with new data?

 

No need to invalidate. The draw call will use the buffer data that was present when the draw call was made.

 

glInvalidateBufferData() and friends are basically a performance hint for the driver, indicating you don't need the content of the buffer anymore. This allows the driver to optimize some stuff internally (avoiding clears, release internal memory, clearing texture cache). It makes no guarantee as to what will actually happen - for all you know the driver can completely ignore those calls.

 

The ARB definition has a very good explanation and examples on how to use it. You can also check G-Truc OGL 4.4 overview.

 

[EDIT] BTW, you can't call glBufferData() on an immutable buffer object.

Edited by N.I.B.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!