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

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


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


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].

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?

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]

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.

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.