View Full Version : Transform Feedback and Primitive ReStart

10-27-2014, 08:44 PM
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

10-28-2014, 08:59 AM
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

GLuint indices[] = {0,1,2,999,3,4,5};
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].

10-28-2014, 12:16 PM
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?

10-28-2014, 12:20 PM
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]

10-28-2014, 07:37 PM
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.

10-29-2014, 03:14 PM
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.