It seems like glBufferSubData
is overwriting or somehow mangling data between my glDrawArrays
calls. I\'m working in Windows 7 64bit, with that la
Those usage flags are mostly correct for this scenario, though you might consider trying GL_STREAM_DRAW
.
Your driver appears to be failing to implicitly synchronize for some reason, so you might want to try a technique that eliminates the need for synchronization in the first place. I would suggest Buffer Orphaning: call glBufferData (...)
with NULL for the data pointer prior to sending data. This will allow commands that are currently using the UBO to continue using the original data store without forcing synchronization, since you will allocate a new data store before sending new data. When the earlier mentioned commands finish the original data store will be orphaned and the GL implementation will free it.
In newer OpenGL implementations you can use glInvalidateBuffer[Sub]Data (...)
to hint the driver into doing what was discussed above. Likewise, you can use glMapBufferRange (...)
with appropriate flags to control all of this behavior more explicitly. Unmapping will implicitly flush and synchronize access to a buffer object unless told otherwise, this might get your driver to do its job if you do not want to mess around with synchronization-free buffer update logic.
Most of what I mentioned is discussed in more detail here.