VBO to VBO data transfer

Is there a way to transfer data directly from one VBO to another in a glTexSubImage2D() manner?

I’ll try to illustrate the problem on a simple example…
Let we have 4 buffers (in the example the first buffer contains 1s, the second 2s, and so on), and each buffer should be copied to a proper segment of the resulting buffer. The first in the upper left quarter, the second in the upper right, and so on.

in   result
----------
11 -> 1100
11 -> 1100
      0000
      0000
----------
22 -> 1122
22 -> 1122
      0000
      0000
----------
33 -> 1122
33 -> 1122
      3300
      3300
----------
44 -> 1122
44 -> 1122
      3344
      3344

I know that GL 3.1 supports glCopyBufferSubData(), but this function treats VBO like 1D array. There is no way to specify a stride. :frowning:

glMapBuffer() could be used, but on that way data should be copied back to client (RAM) memory first, and then again to the GPU’s memory. In order to eliminate transferring data from the server-side to the client-side, currently, I’m keeping a copy of all buffers in RAM.

I guess that it cannot be solved on the other way, but I hope that your advices can help me to improve the performance.

Thank you in advance!

There is also glMapBufferRange which allow to map only a subset of a buffer. It can be used in combination with glFlushMappedBufferRange to flush only subsets of the mapped region which may help in your case IMO.

What about transform feedback? You can bind 4 buffers there.

I know that, but locking a part of a buffer means at least locking one half of it, because of its 1D structure and sub-block arrangement. On the other hand, the buffer cannot be drawn unless it is fully updated, so partial locking brings no benefits.

The buffers are static, so I didn’t consider using transform feedback. But I’ll take a look at it.

Thank you guys! Any suggestion is welcome! :slight_smile:

This is vertex buffer, right? Vertex buffer is useless without index buffer. Keep your vertex buffer simple and reorder indices in index buffer to achive same functionality.

The point is that I don’t want to change index-buffer, and also I can’t span drawing across different vertex-buffers. The problem arose from the optimization of LOD scheme update. The advantage of my algorithm is in a fact that I have to update only vertex-data (in fact, just a small part), leaving index-buffers unchanged. There is also a problem in splitting one vertex-buffer into four others, but the solution will probably be the same…

Reorder index buffer just once. Your example show that you have 4 quadrants in vertex buffer and you want to update just one of it. I suppose you have index buffer which use vertices stored in existion VBO layout.
If you change VBO to linear layout, changing your index buffer is easy… just put different indices.

When you generate VBO only difference between current and linear layout is in vertex address calculation.

How did you calculate LOD scheme… On CPU or GPU? How complex is your vertex (which attributes)?

Very interesting idea! Thank you for the suggestion, yooyo!

No, I want to group four buffers into one, or to split one into four. After grouping previous four buffers cease to exist, and the same thing happens to a buffer after splitting. The explained process can be repeated through many iterations.

Of course!

The calculation is done on CPU. The complexity of the vertex data is irrelevant. Currently, I divide spatial coordinates, normals, colors and texture coordinates into separate buffers, in order to alleviate the changing of display mode.