Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: glVertexPoint non-interleaved, tightly packed vertex data?

  1. #1
    Newbie Newbie
    Join Date
    Aug 2013
    Posts
    2

    Question glVertexPoint non-interleaved, tightly packed vertex data?

    I have an application that draws vertex points interleved: (X1,Y1,Z1,X2,Y2,Z2...Xn,Yn,Zn) and it works. For large amounts of data, the setting of these points becomes VERY slow due to the interleve. I would like to set the vertex data without interleving (X1,X2...Xn,Y1,Y2...Yn,Z1,Z2...Zn) and still use glDrawArray and potentially shift to VBOs in near future. Is this possible using glVertexPoint? If not, is there a data structure in OpenGL that will allow this type of memory arrangement or am I on the wrong track entirely?

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Apr 2010
    Posts
    751
    Just to be sure X1,Y1,Z1 are the x,y,z-coordinates of your first position? That is not what is usually called interleaved vertex data, that term is usually used to describe the data layout if you have multiple vertex attributes (e.g. position, normal, tex coord). In that case you can store all the positions next to each other (Px1,Py1,Pz1, Px2,Py2,Pz2, ...) in memory and in a different location all the normals (Nx1,Ny1,Nz1, Nx2,Ny2,Nz2, ...) and the same for the tex coords (Tu1,Tv1, Tu2,Tv2, ...) that means the data for a single vertex is found in three different locations in memory. Alternatively you can interleave the attributes and store all data that makes up a single vertex next to each other (Px1,Py1,Pz1,Nx1,Ny1,Nz1,Tu1,Tv1, Px2,Py2,Pz2,Nx2,Ny2,Nz2,Tu2,Tv2, ...) now all the data that makes up each vertex is packed together, but to go from vertex to vertex you make larger jumps through memory.

    Note that in both cases the values that make up a single attribute of a vertex are still next to each other. You seem to want to store the values that make up a single attribute to be stored, but that's not how the vertex specification APIs are specified and also not how the hardware operates so OpenGL would have to re-arrange it for you, which would be slow. Your performance problem probably comes from using client side data and transferring it to the GPU on each draw, use vertex data stored in buffers, aka VBOs, to only transfer data to the GPU once and keep it there.

  3. #3
    Senior Member OpenGL Pro
    Join Date
    Jan 2007
    Posts
    1,201
    Yes, you're actually not interleaving at all to begin with, which is probably one reason why you're slow, as interleaving is actually faster with hardware T&L, as the GPU can usually fetch all attributes for a single vertex in one read, it's more cache-friendly, and if your vertex size is smaller that the GPU's cache line size it can even pre-fetch following vertices.

    You may be influenced by an ancient Intel web page which made the case for non-interleaved vertex data being faster. Yes, it could be in the software T&L days, and Intel only made software T&L parts at that time, so of course they're going to push something that's better for their hardware. That's out-dated information; those days are over.

    The way you're proposing would be much slower as now the GPU can't read your vertex data sequentially at all.

  4. #4
    Newbie Newbie
    Join Date
    Aug 2013
    Posts
    2
    This was not an attempt to speed up drawing, but the actual loading of dynamic data into my structures. Loading one vertex at a time was taking too much time. I will interleave the color vertex with this to help with drawing, so thanks for the extra info. Still learning OpenGL so every little bit helps.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •