I have a situation, where I have an array of vertices on the CPU side, for which, besides rendering-relevant data, like their position, I have a lot of other data at each vertex. All vertex data is updated (more or less) every frame, requiring transferring the changes over to the GPU every time.
So far I have used two approaches, neither of which I am particularly happy with:
Just copy everything over to the GPU. This might seem silly, but my application does not use a significant amount of VRAM overall, so this is no issue in that regard, but of course, when the vertex count increases, so does the amount of data needlessly transferred to the GPU every frame, which does become a performance issue.
Keep separate arrays for the GPU-relevant vertex data and the non-relevant vertex data. While this solves the unnecessary transfer issue, I find it very clunky to work with on the CPU side, since I at all times have to keep two arrays in sync. Ideally, I would like to have one clean struct per vertex, which I can easily work with.
Is there some other approach to this?
Something I could think of, which unfortunately doesn't seem to exist in OpenGL, is a variant of
glBufferData, which I could tell some stride and offset, like with
glVertexAttribPointer, which parts of each data block I want to transfer to the buffer in VRAM.
There also might be some way to neatly solve this with some C++ features that I am not aware of. Some way to have two arrays act as one, or something like that.
Any ideas and suggestions are appreciated.