Interleaved or tightly-packed VertexArrays?

Member
Posts: 469
Joined: 2002.10
Post: #1
Which is better? Interleaved or packed for vertexArrays? by how much?

---Kelvin--
15.4" MacBook Pro revA
1.83GHz/2GB/250GB
Quote this message in a reply
Luminary
Posts: 5,125
Joined: 2002.04
Post: #2
I actually benchmarked this to find out, and discovered that there was no noticeable difference between vertex formats.
Quote this message in a reply
Member
Posts: 469
Joined: 2002.10
Post: #3
Does it matter if I waste space with a wide stride?
e.g. pass a struct like this:
Code:
struct Vertex {
    Vector2f tex;
    Vector3f norm;
    Vector3f loc;
    int someOther junk;
    int moreJunk;
public:
...
};

...
Vertex *verts = new Vertex[someArrayLength];
glInterleavedArrays(GL_T2F_N3F_V3F, sizeof(Vertex), verts);
Am I wasting space on the card if I do this?

---Kelvin--
15.4" MacBook Pro revA
1.83GHz/2GB/250GB
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #4
premature optimisation, just profile fix slow bits etc etc

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
Sage
Posts: 1,231
Joined: 2002.10
Post: #5
This is more of a memory access pattern issue for your app, updating vertex attributes. In general I think you will get slightly higher performance if you ensure all your writes are tightly packed and in sequential order (some architectures have write combining, so updates to sequential bytes/words may actually be written over the bus in large (i.e. 128 bit) bursts if possible.)

As for wasting space on the GPU-- that is opaque to your app. The internal layout of the GPU copy of vertex data depends on the GPU. The GL framework will copy and/or resort and/or format convert your data as needed, based on what is most efficient for the GPU. In any case, it won't be copying any non-attribute data you interleave in your struct. But the same memory access rules apply, since it has to read your data somehow.
Quote this message in a reply
Member
Posts: 469
Joined: 2002.10
Post: #6
arekkusu Wrote:This is more of a memory access pattern issue for your app, updating vertex attributes. In general I think you will get slightly higher performance if you ensure all your writes are tightly packed and in sequential order (some architectures have write combining, so updates to sequential bytes/words may actually be written over the bus in large (i.e. 128 bit) bursts if possible.)

As for wasting space on the GPU-- that is opaque to your app. The internal layout of the GPU copy of vertex data depends on the GPU. The GL framework will copy and/or resort and/or format convert your data as needed, based on what is most efficient for the GPU. In any case, it won't be copying any non-attribute data you interleave in your struct. But the same memory access rules apply, since it has to read your data somehow.
perfect. thanks.

---Kelvin--
15.4" MacBook Pro revA
1.83GHz/2GB/250GB
Quote this message in a reply
Member
Posts: 469
Joined: 2002.10
Post: #7
unknown Wrote:premature optimisation, just profile fix slow bits etc etc
Actually no, I fixed all the other bits. Right now I'm fixing geometry upload performance. So while I'm adding in vertex arrays, etc to the code, knowing what format is particularly relevant.

---Kelvin--
15.4" MacBook Pro revA
1.83GHz/2GB/250GB
Quote this message in a reply
Post Reply