<p>It is slightly better to combine buffers since it reduces the amount of state that OpenGL has to track, which reduces memory usage overall, and helps reduce state changes.</p>
<p>But you only really get those benefits if you have a large number of these buffers floating around, on the order of thousands of them.</p>
<p>Usually it is better to go with whichever method best fits the code base that is supporting them since a simpler code base is easier to maintain, and will generally have less bugs. Then get fancy only if performance or memory constraints become an issue.</p>

CC BY-SA 4.0
2021-11-15T12:31:20.937Z
2021-11-15T12:31:20.937Z
pmw1234
<p>Suppose a GLTF file provides a single <code>N</code> byte buffer which includes all vertex data for multiple meshes. The first <code>m</code> bytes are interleaved vertex positions, normals etc. for one geometry and the remaining data is non-interleaved data for other geometries. All meshes will be rendered eventually.</p>
<p>How is the data best uploaded to the GPU?</p>
<p>Is it best to upload the whole <code>N</code> bytes and then use <code>vertexAttribPointer()</code> to define the layout or is it better to upload the different buffer regions separately, one for each mesh? Or is there a benefit to separating the first <code>m</code> bytes of interleaved data from the remaining non-interleaved data? The overall footprint on the GPU would be the same.</p>

<rendering><webgl><gltf>
Uploading interleaved data in gltf buffers
dubious
# Uploading interleaved data in gltf buffers

(Asked by: username_0 on 2021-11-15)

Suppose a GLTF file provides a single `N` byte buffer which includes all vertex data for multiple meshes. The first `m` bytes are interleaved vertex positions, normals etc. for one geometry and the remaining data is non-interleaved data for other geometries. All meshes will be rendered eventually.

How is the data best uploaded to the GPU?

Is it best to upload the whole `N` bytes and then use `vertexAttribPointer()` to define the layout or is it better to upload the different buffer regions separately, one for each mesh? Or is there a benefit to separating the first `m` bytes of interleaved data from the remaining non-interleaved data? The overall footprint on the GPU would be the same.

**Tags:** rendering, webgl, gltf


---

## 1 answers

### Answer by username_1 on 2021-11-15. Score: 1 | Accepted answer

It is slightly better to combine buffers since it reduces the amount of state that OpenGL has to track, which reduces memory usage overall, and helps reduce state changes.

But you only really get those benefits if you have a large number of these buffers floating around, on the order of thousands of them.

Usually it is better to go with whichever method best fits the code base that is supporting them since a simpler code base is easier to maintain, and will generally have less bugs. Then get fancy only if performance or memory constraints become an issue.


---

