1

this question is a bit related to this one, but quite some time has gone by since it was asked. The basic premise: I have device-local (non-mappable) vertex buffers with interleaved attributes. These attributes are (partially) interleaved due to benchmark results of the hardware I'm targetting. Now I need to update some of these attributes, both from other device-local buffers as well as from host.

EDIT: as an example, I have the following vertex buffer setup: 1

Now I want to update, say, only the normals of object 2 or I want to move said object into another buffer which lacks vertex colors (while not having the object data available on host-side anymore). As far as I can tell, I have three options:

  1. copy the data (possibly partially) into a host-mappable buffer (or two, in case of copying between device-local buffers). There we can update the attributes we want and then copy the data wholesale.
  2. use a compute shader to copy only those attributes we want.
  3. ditch interleaved attributes.

The first option has the obvious downside of having additional copies as well as GPU-CPU synchronization. The second involves shader invocations instead of using the DMA to perform the copy, but I don't know how bad this really is. Number 3 isn't much of an option considering that my benchmarks indicate that it's still the way to go for some integrated GPUs, but I'd consider it if the other options make the update process too slow.

Is there something I'm missing? Perhaps some secret strided-copy function that got added in one of the later OpenGL versions?

PS: Vulkan has the option of copying multiple buffer regions at once. I have not seen something similar in OpenGL. Am I correct in assuming that OpenGL doesn't offer something like that?

genpfault
  • 51,148
  • 11
  • 85
  • 139
IGarFieldI
  • 515
  • 3
  • 12
  • I added a picture which hopefully illustrates the buffer setup I have. – IGarFieldI Mar 19 '23 at 22:49
  • You can do this using a pack/unpack to a temporary 1d texture with GL_PACK_ROW_LENGTH and GL_UNPACK_ROW_LENGTH set to the stride between objects. However, I'd strongly discourage you from doing so. It's better to keep a copy of the data, change the data on the CPU, and then issue a glBufferSubData. – Yakov Galka Mar 26 '23 at 14:59

0 Answers0