zeb
zeb

Reputation: 1125

Is it better glBufferSubData or glMapBuffer

In order to update my uniform buffer objects I use glBufferSubData. Is it faster to use glBufferSubData or glMapBuffer with glUnmapBuffer?

Upvotes: 17

Views: 18010

Answers (1)

mmostajab
mmostajab

Reputation: 2037

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.

Upvotes: 15

Related Questions