AnsweredAssumed Answered

Issue with GL_PRIMITIVE_RESTART

Question asked by artem.bochkarev on Jul 10, 2020

AMD Radeon RX 5500 XT, 19.2.2, 20.4.2, 20.5.1 versions checked.

 

I created minimal sample to reproduce issue, main.cpp attached(uses glfw, glad and glm).

Additional line to zero is drawn in some cases.

Ok case:
glDrawElements( GL_LINE_STRIP, indexes.size() - 2, INDEX_TYPE_GL, (void*)(indexes.data() + 2) );

glDisable( GL_PRIMITIVE_RESTART );

glDrawArrays( GL_LINES, 0, 2 );

 

Wrong case, data is splitted to separate draw calls:

glDrawElements( GL_LINE_STRIP, 6, INDEX_TYPE_GL, (void*)(indexes.data() + 7) );
glDrawElements( GL_LINE_STRIP, 5, INDEX_TYPE_GL, (void*)( indexes.data() + 2 ) );

glDisable( GL_PRIMITIVE_RESTART );

glDrawArrays( GL_LINES, 0, 2 );

 

Without glDrawArrays also ok:

glDrawElements( GL_LINE_STRIP, 6, INDEX_TYPE_GL, (void*)(indexes.data() + 7) );
glDrawElements( GL_LINE_STRIP, 5, INDEX_TYPE_GL, (void*)( indexes.data() + 2 ) );

glDisable( GL_PRIMITIVE_RESTART );

 

I tried to change buffers before glDrawArrays call and to use index buffers. But any draw calls after: 

glDrawElements( GL_LINE_STRIP, 6, INDEX_TYPE_GL, (void*)(indexes.data() + 7) );
glDrawElements( GL_LINE_STRIP, 5, INDEX_TYPE_GL, (void*)( indexes.data() + 2 ) );

causes this wrong line to be drawn.

 

If use 0 as restart index this additional line is drawn not to (0, 0, 0) vertex, but to the first vertex in the current VBO.

Outcomes