A few closely-related questions regarding buffer objects in OpenGL.
Besides persistent mapping, is there any other reason to allocate an immutable buffer? Even if the user allocates memory for the buffer only once, with mutable buffers he always has the ability to do it again if he needs to. Plus, with mutable buffers you can explicitly specify a usage hint.
How do people usually change data through a mapped pointer? The way I see it, you can either make changes to a single element, or multiple. For single-element changes all I could think of is an
operator[]
on a mapped pointer as if it was a C-style array. For multi-element changes, only thing I could think of is amemcpy
, but in that case isn't it just better to useglBufferSubData
?- Speaking of
glBufferSubData
, is there truly any difference between calling it and just doing amemcpy
on a mapped pointer? I've heard the former does more than 1memcpy
, is it true? - Is there a known reason why you can't specify a usage hint for an immutable buffer?
I know these questions are mostly about performance, and thus can be answered with a simple "just do some profiling and see", but at the time of me asking this it's not so much about performance as it is about design - i.e., I want to know the good practices of choosing between a mutable buffer vs an immutable one, and how should I be modifying their contents.