In order to update my uniform buffer objects I use glBufferSubData
. Is it faster to use glBufferSubData
or glMapBuffer
with glUnmapBuffer
?
glMapBuffer maps to the client's address space the entire data store of the buffer object currently bound to target . The data can then be directly read and/or written relative to the returned pointer, depending on the specified access policy.
Buffer Objects are OpenGL Objects that store an array of unformatted memory allocated by the OpenGL context (AKA the GPU). These can be used to store vertex data, pixel data retrieved from images or the framebuffer, and a variety of other things.
Show activity on this post. The good thing about glMapBuffer is that you dont need to copy the data first in an array and then use glBufferSubData to fill the opengl buffer. With glMapBuffer, you can copy the data directly to part of memory which opengl will fetch to GPU when it is necessary.
nVidia mentions that it could have one if you call glBufferSubDataARB () when the GPU is already working on the area. But in your case, I think you are good.
As a consequence there could be a loss of performance. if you use BufferSubData, then there is a synchronization so that you don’t write over a buffer already being used. however, if that is the first time you write to this buffer, there is no synchronization required, so your two API calls should not be that bad. AMD Fellow.
The good thing about glMapBuffer
is that you dont need to copy the data first in an array and then use glBufferSubData
to fill the opengl buffer. With glMapBuffer
, you can copy the data directly to part of memory which opengl will fetch to GPU when it is necessary. From my point of view, there glMapBuffer
should be faster when you want to fill a big buffer which is going to be updated frequently. Also, how you are copying the data into the buffer between glMapBuffer
and glUnmapBuffer
is also important.
If show us the code which you are using the glMapBuffer
and how big is the data, then we can judge easier. Anyway, in the end measurements can show you which one is better.
UPDATE: OpenGL Insight Asynchronous Buffer Transfer Chapter. In this chapter, the implicit synchronization
of glMapBuffer
and glSubBufferData
functions may be interesting for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With