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: Vertex color using GLubyte

  1. #1
    Junior Member Newbie
    Join Date
    Oct 2012
    Posts
    15

    Vertex color using GLubyte

    Hi all,

    I am painting over 3 millions of triangles with vertex color information in this way:

    Code :
    struct vertex 
    {
    GLfloat x,y,z;
    GLubyte r,g,b;
    };
     
    ....
    {
        .....
     
        pMesh->BindBuffer();
        glEnableVertexAttribArray (nPosition);
        glVertexAttribPointer(nPosition, 3, GL_FLOAT, GL_FALSE, nStride, 0 );
        glEnableVertexAttribArray (nColor);
        glVertexAttribPointer(nColor, 3, GL_UNSIGNED_BYTE, GL_TRUE, nStride, BUFFER_OFFSET (nColorOffset) );
        glDrawElements (pMesh->GetMeshType(), nPrimitives, GL_UNSIGNED_INT, BUFFER_OFFSET(_Start*sizeof(GLuint)) );
     
        ....
    }

    and my vertex shader:

    Code :
    #version 330
     
    uniform mat4 MVP_Matrix;
     
    layout(location = 0) in vec4 VertexPosition;
    layout(location = 1) in vec3 VertexColor;
     
    out vec4 fragColor;
     
    void main(void)
    {
       fragColor = vec4 (VertexColor,1.0);
       gl_Position = MVP_Matrix * VertexPosition;
    }

    With Nvidia (Quadro 600) the frame rate is about 60 fps, but with Amd (FirePro V4900) the performance drop to 20 fps.
    This issue only happens with GLubyte, changing the vertex color type to GLFloat, the performance with Amd is equal to Nvdia.

    I am using GLubyte to reduce the memory size of my vertex (geometry could be millions of triangles).

    Will someone please give me some advice on what to do.

    Thanks,

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Jan 2007
    Posts
    1,183
    Switch to 4 bytes (or pad your struct with an extra unused byte) for your color pointer; GPUs don't like 24-bit data and the AMD may be dropping back to software emulation in the per-vertex part of the pipeline. See further here: http://www.opengl.org/wiki/Common_Mi...vertex_formats (the specific calls discussed here are deprecated but the principle behind the advice remains valid).

  3. #3
    Junior Member Newbie
    Join Date
    Oct 2012
    Posts
    15
    Thanks, you saved my day.

  4. #4

Posting Permissions

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