PDA

View Full Version : VBO mapping



razor
12-07-2003, 03:23 PM
Hey All,

I'm trying to update parts of a large VBO. I basically map the buffer ((Vector4*)glMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB)), then write to the parts of the array that has changed, then unmap the buffer (glUnmapBufferARB(GL_ARRAY_BUFFER_ARB)).

I do not get any openGL errors, but the buffer data is definitely not what i want it to be after doing the update (lots of what seems like garbage).... Is it not possible to map the buffer and only update parts of it? do i need to write the full buffer when mapping it (it does works when i do write the whole buffer, unfortunately it's much more inefficient to do so because i need to rewrite data that should already be there).

[This message has been edited by razor (edited 12-07-2003).]

[This message has been edited by razor (edited 12-07-2003).]

Enbar
12-07-2003, 04:04 PM
What you're describing is how it should work only if you're making a glBufferData(NULL) call before the mapping as this invalidates the current data. If you're not doing this it sounds like a driver bug. What hardware and drivers are you using?

That said for performance reasons you don't want to do what you described. The reason is because when mapping data and then updating only part of it the vpu will have to idle to ensure synchronization while the cpu updates the data. It would be more efficient to use glBufferSubData() which won't require this idling. It is rare that you would want to use map/unmap unless you call glBufferData(NULL) first.

razor
12-07-2003, 08:13 PM
My gfx card is a Radeon 9800 PRO. I'm running the latest drivers from the ATI website.

Regarding synchronizing with the driver... i have many VBOs that i update sequentially in the manner described, so the card should be able to work on the other ones while i lock one individually.