1
votes

I'm a bit confused as to why you can set active an array of vertex buffers but only one index buffer? Could that one index buffer address the vertices from all the vertex buffers? And if so how would i specify which buffer which index belongs to?

Another question i have is that since i'm using indexed triangle lists, the index data is roughly the same size as vertex data per mesh. I was thinking about creating one index buffer per one vertex buffer. I will be dynamically adding meshes until one of the buffers runs out at which point another pair is created. Inevitably by doing this, one of the buffers in the pair will always fill up before the other one and that leftover space will never get used. Does that space actually get marked as reserved in the gpu? Like for instance, could i fit 4 buffers that contain 32MB of data but are created with byte width of 64MB into 128MB of vram?

1

1 Answers

1
votes

The same indices must be used with all vertex buffers at the same time. The purpose of this is to allow different vertex buffers to contain different components of the vertex data. For example, you might decide store the positions in one vertex buffer and the texture coordinates in a second buffer. The zeroth index would access the first position from the first vertex buffer and the first texture coordinate from the second.

This would save bandwidth if you wanted to update the texture coordinates every frame but never change the positions.

Multiple vertex buffers are also used in instancing.

When you create a vertex or index buffer, you specify the size of the buffer. This amount of memory is then reserved in video ram and cannot be used by anything else.

So if I understand your question, no you can't fit four 64mb buffers into 128 mb of ram.