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 5 of 5

Thread: Interleaving VBOs

  1. #1
    Intern Contributor
    Join Date
    Apr 2015
    Posts
    75

    Question Interleaving VBOs

    Hey , i have a Question regarding interleaving VBO's . Currently i am using glMap to map the buffer and copy the data into the buffer. At the moment i have a struct called VertexData looking something along the lines:

    Code :
    struct VertexData
    {
       vec3 position;
       vec3 normal;
       vec2 uv;
       .....
    }

    Here is the possible alternate variant of the vertexdata structure
    Code :
    struct VertexData
    {
      vector<vec3> positions;
      vector<vec3> normals;
      vector<vec2> uvs;
      .....
    }

    So the VBO layout is something like VertexData[0],VertexData[1],VertexData[n]. My Question is if i am going to notice (or will be there) any significant performance boost if the data layout is something like VertexPositions[0-n],VertexNormals[0-n],VertexUV[0-n] .... etc. As i understand both methods are type of interleaving the data in the buffer. Does it matter which layout i use ?
    Thanks in advance

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Jan 2007
    Posts
    1,716
    The first method is going to be faster because the GPU will be able to fetch an entire vertex from a contiguous region of memory.

  3. #3
    Intern Contributor
    Join Date
    Apr 2015
    Posts
    75
    So the one i am using now

    Code :
    struct VertexData
    {
       vec3 position;
       vec3 normal;
       vec2 uv;
       .....
    }

  4. #4
    Senior Member OpenGL Pro
    Join Date
    Jan 2007
    Posts
    1,716
    Yes, the one you are using now. Please see http://http.developer.nvidia.com/GPU...gems_ch28.html for more info:
    Access vertex data in a relatively sequential manner. Modern GPUs cache memory accesses when fetching vertices. As in any memory hierarchy, spatial locality of reference helps maximize hits in the cache, thus reducing bandwidth requirements.
    All this is assuming that vertex fetching is actually a measurable bottleneck in your program, of course, but as a general rule the way you are doing it now is preferred.

  5. #5
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Posts
    2,476
    A counterpoint is that if the vertex data isn't static, interleaved attributes may increase the cost of uploads, as you'll effectively have to upload all of the attributes even if only some of them were modified.

    A related issue is that manipulating vertex data on the CPU will typically have worse locality with interleaved attributes because iterating over the vertices will end up reading and caching all of the attributes, not just the ones which are actually used.

    But for static data, interleaved attributes will typically be better (and at least no worse) than using a separate region for each attribute.

Tags for this Thread

Posting Permissions

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