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

Thread: Transform Feedback and Primitive ReStart

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2001
    Location
    Newcastle, NSW Australia
    Posts
    13

    Transform Feedback and Primitive ReStart

    I am using the Transform Feedback to gather the screen coordinate data. I am also using a Primitive Restart in my data. The coordinate that comes through the Transform Feedback for the Primitive Restart is either 4520226 or -4519760. This does not match my Primitive Restart Index.

    What value should I expect in the Transform Feedback buffer for a Primitive Restart.

    I am using NVIDEA graphics card supporting OpenGL 4.4

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Posts
    2,516
    Quote Originally Posted by johnh View Post
    What value should I expect in the Transform Feedback buffer for a Primitive Restart.
    Primitive restart affects primitive assembly. If you're using a mode where some vertices are used by more than one primitive (e.g. line strip, line loop, triangle strip, triangle fan), it causes the following indices to be treated as starting a new sequence (e.g. for a triangle fan, the vertex specified by the immediately-following index will become the shared vertex). If you aren't using such a mode, primitive restart has no effect.

    The transform-feedback output should be as if you had split the draw call into multiple draw calls. So if you had
    Code :
    GLuint indices[] = {0,1,2,999,3,4,5};
    glPrimitiveRestartIndex(999);
    glEnable(GL_PRIMITIVE_RESTART);
    glDrawElements(GL_LINE_LOOP, 7, GL_UNSIGNED_INT, indices);
    the result should be the same as
    Code :
    GLuint indices1[] = {0,1,2};
    glDrawElements(GL_LINE_LOOP, 3, GL_UNSIGNED_INT, indices1);
    GLuint indices2[] = {3,4,5};
    glDrawElements(GL_LINE_LOOP, 3, GL_UNSIGNED_INT, indices2);
    In either case, the output should contain the data for the vertices [0,1,1,2,2,0,3,4,4,5,5,3].

  3. #3
    Junior Member Newbie
    Join Date
    Mar 2001
    Location
    Newcastle, NSW Australia
    Posts
    13
    Thanks for the reply. Yes that is what I expected. I am using a GL_LINE_LOOP and retrieving the transformed coordinate data.

    However the output comes back as [0,1,1,2,2,0,0,INVALID POINT,INVALID POINT,4,4,4,5,5,3] extra data. It is almost as if there are two extra line segments bridging the 2 separate Line Strips. I am OK with that, if I can determine these invalid segments when processing the Feedback data.

    Maybe I need to include the Index value in the FeedBack varyings and check the values?

  4. #4
    Junior Member Newbie
    Join Date
    Mar 2001
    Location
    Newcastle, NSW Australia
    Posts
    13
    Sorry the output I get for a line strip as you have defined is [0,1,1,2,2,INVALID POINT,INVALID POINT,3,3,4,4,5]

  5. #5
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Posts
    2,516
    Have you actually enabled primitive restart with glEnable(GL_PRIMITIVE_RESTART)? And is it supported by your OpenGL version (3.1 or later)? If not, the primitive restart index will be interpreted as a regular vertex index (and will presumably lie outside the bounds of the vertex attribute arrays).

    Are you trying to use a negative value for the restart index? All indices are unsigned.

    If you're using any of the *BaseVertex draw commands, the comparison is performed before the base offset is added.

  6. #6
    Junior Member Newbie
    Join Date
    Mar 2001
    Location
    Newcastle, NSW Australia
    Posts
    13
    Yes failing to enable Primitive Restart was my problem. During the Render loop the Primitive Restart was enabled, but during the Feedback Transform loop it wasn't. All the results now make sense. Thanks.

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
  •