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

Thread: gl_VertexID and *BaseVertex

  1. #1

    gl_VertexID and *BaseVertex

    What value should contain gl_VertexID then using *BaseVertex commands? Should it be index before or after applying BaseVertex offset?

    There is a note here http://www.opengl.org/wiki/Built-in_Variable_%28GLSL%29 :
    Note: gl_VertexID​ will have the base vertex applied to it.
    And another one here http://www.opengl.org/wiki/GLAPI/glD...entsBaseVertex :
    The gl_VertexID​ passed to the Vertex Shader will be the index after being offset by basevertex​, not the index fetched from the buffer.
    And at least on AMD HD 5650 with latest drivers it works this way.
    But on NVIDIA GeForce GTX 780 gl_VertexID equals to index directly from index buffer, before offsetting by BaseVertex.

    Initially, I was thinking it's NVIDIA driver bug. But after looking in the spec I was surprised by the fact that there is no clear answer which way it should be.

    GLSL spec says just that:
    The variable gl_VertexID is a vertex shader input variable that holds an integer index for the vertex, asdefined under “ShaderInputs” in section 2.11.7 “Varying Variables” in the OpenGL Graphics System
    Specification. Whilethe variable gl_VertexID is always present, its value is not always defined.
    And GL 3.3 spec:
    gl_VertexID holds the integer index i implicitly passed by DrawArrays or
    one of the other drawing commands defined in section 2.8.3.
    And section 2.8.3 "Drawing Commands" didn't say anything about which value should go into gl_VertexID.

    (I've used 3.3 spec because I'm targeting 3.3, but latest 4.4 spec also didn't cover this aspect.)

    So who is buggy? Is it NVIDIA drivers? Or AMD drivers and GL wiki? Or maybe it is a bug in the specification and HW vendors can implement it any way they like?

    Here is a small test app with source:
    http://www.faogen.com/files/base_vertex.zip


    It should draw two rects, one red and one green if gl_VertexID include BaseVertex offset or two red rects if it comes directly from the index buffer. Both 32 and 64-bit versions included in case there is a difference between 32/64 bit drivers.

  2. #2
    Advanced Member Frequent Contributor arekkusu's Avatar
    Join Date
    Nov 2003
    Posts
    783
    Quote Originally Posted by grisha View Post
    maybe it is a bug in the specification
    Read ARB_shader_draw_parameters.

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
  •