Jump to content
  • Advertisement
Sign in to follow this  
aarbron

Usage of glBufferSubData

This topic is 1337 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

Let's say you need to update 10 separate bytes in your buffer, you could

  • call glBufferSubData 10 times
  • postpone and call SubData once, with the smallest dirty region

Which one is better?

Share this post


Link to post
Share on other sites
Advertisement

The second version is definitely better unless there are several megabytes in between those single bytes (or, if the buffer is not too terribly large, orphan it and re-upload the complete buffer). Doing a client/server sync and initiating a transfer on the PCIe bus are what are the main performance costs involved with updating a buffer. Avoiding or minimizing these is what you want.

 

On the hardware level, whether or not you send one byte or a few ten thousand bytes over the bus in one transfer, makes little or no difference at all. Latency is high, but bandwidth is also high. Means pushing anything over the bus at all is what you have to pay for, not so much how much (well, within reasonable numbers, of course... needlessly pushing gigabytes of data certainly does take time).

 

Mapping the buffer with explicit flush might also be a viable option (only marking the actual changes), though I've never tried how well that works for single bytes.

 

Using persistently mapped buffers (the new funky AZDO stuff) appears to be slightly slower overall (as compared to a constant buffer), but works surprisingly well if you have regular updates. I guess the hardware still has to do bus transfers (how else would it work?) but that seems to happen "magically" and a lot more streamlined with a lot fewer (virtually none?) syncs/stalls.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!