MapBufferARB: what are the pros and the cons?

Started by
2 comments, last by Code-R 18 years, 6 months ago
Title says it all ;) TIA
Advertisement
PRO: convenient to use.
CON: can be slower than glBufferSubData due to sync issues.

Answer as short as question ;)

If you need more precise information, then ask more precise questions: it mainly depends on how exactly you're using it.
MapBuffer can also allow the use of dynamic data without any unnecessary use of memcpy(). BufferSubData requires at least one memcpy.

Ie, MapBuffer, then generate your data directly into the VBO, rather than

myBuffer = malloc(x)
generateData(myBuffer)
glBufferSubData(myBuffer) // memcpy to internal GL storage

But, BufferSubData can be done out-of-line, ie, GL can save your data, and splice it in to the VBO once ongoing rendering is done, without holding up your app. MapBuffer (likely) requires the GL to synchronously flush all usage of that object out of the pipeline, then potentially copy data back to system memory (although if it does this, you're using the wrong storage hint).

They both exist, because there are situations where they each should be used. Neither is universally better.
Quote:Original post by Yann L
PRO: convenient to use.
CON: can be slower than glBufferSubData due to sync issues.

Answer as short as question ;)

If you need more precise information, then ask more precise questions: it mainly depends on how exactly you're using it.


Ahem, yes, you are totally correct about the length thing.
well, I wanted to know if there's any downside to it that'd make me better off using BufferDataARB instead of mapping and writing to the pointer provided? would it be slower?

This topic is closed to new replies.

Advertisement