DanielHawson
05-15-2004, 09:16 AM
I understand that glBufferSubDataARB and glMapBufferARB won't return until the GPU has finished using the corresponding bit of data, yet you can discard the buffer (I believe it has to be the entire buffer) and map it, avoiding any synchronisation issues (glBufferData with NULL, then glMapBuffer), while glBufferDataARB is less costly than glMapBufferARB AND doesn't suffer from being locked out by the GPU.
I would have thought that it would be glUnmapBuffer that had to synchronise with the GPU and that glMapBuffer wouldn't need to wait for the GPU to finish using the data. Why is the synchronisation on glMapBuffer?
Will there still be synchronisation issues if you call glMapBuffer, asking for read only access?
If there's no synchronisation with the GPU on mapping read only buffers but there is for write/read-write, wouldn't it be better for glMapBuffer to automatically invalidate/discard the buffer in use by the GPU, for write/read-write access? Why wouldn't you call glBufferData with NULL followed by glMapData, as advised by nvidia's VBO white paper?
Presumably, if I wanted to change just one vertex colour in a large VBO, I would be better to do a glBufferSubData over a 'discard and map', or even a glBufferData. But then if I wanted to refresh an entire vertex buffer, with completely new data, I'd want to do a glBufferData above all. If so, then surely there's a point at which it becomes more efficient to do a complete upload (glBufferData or discard and map) over doing a glBufferSubData, due to the latter being locked out? Has anyone investigated this and produced any performance comparisons?
Finally, when would you want to do the 'discard and map' (glBufferData with NULL, then glMapData) over doing the plain old upload (glBufferData)?
I would have thought that it would be glUnmapBuffer that had to synchronise with the GPU and that glMapBuffer wouldn't need to wait for the GPU to finish using the data. Why is the synchronisation on glMapBuffer?
Will there still be synchronisation issues if you call glMapBuffer, asking for read only access?
If there's no synchronisation with the GPU on mapping read only buffers but there is for write/read-write, wouldn't it be better for glMapBuffer to automatically invalidate/discard the buffer in use by the GPU, for write/read-write access? Why wouldn't you call glBufferData with NULL followed by glMapData, as advised by nvidia's VBO white paper?
Presumably, if I wanted to change just one vertex colour in a large VBO, I would be better to do a glBufferSubData over a 'discard and map', or even a glBufferData. But then if I wanted to refresh an entire vertex buffer, with completely new data, I'd want to do a glBufferData above all. If so, then surely there's a point at which it becomes more efficient to do a complete upload (glBufferData or discard and map) over doing a glBufferSubData, due to the latter being locked out? Has anyone investigated this and produced any performance comparisons?
Finally, when would you want to do the 'discard and map' (glBufferData with NULL, then glMapData) over doing the plain old upload (glBufferData)?