<div dir="ltr"><div dir="ltr">I added the link.<br>Thanks a lot for review)</div><div dir="ltr"><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Feb 18, 2019 at 4:00 PM <<a href="mailto:asimiklit.work@gmail.com">asimiklit.work@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">From: Andrii Simiklit <<a href="mailto:andrii.simiklit@globallogic.com" target="_blank">andrii.simiklit@globallogic.com</a>><br>
<br>
Looks like this test should be able to catch this kind of the regressions<br>
os I add it here.<br>
This test should draw green rectangle if everything is ok.<br>
But in case of bug which makes us unable to disable<br>
the primitive restart option it should draw just one triangle.<br>
<br>
The solution was suggested.<br>
<br>
v2: Added the link to the bug in the comment of the new function<br>
    ( Lionel Landwerlin <<a href="mailto:lionel.g.landwerlin@intel.com" target="_blank">lionel.g.landwerlin@intel.com</a>> )<br>
<br>
Bugzilla: <a href="https://bugs.freedesktop.org/show_bug.cgi?id=109451" rel="noreferrer" target="_blank">https://bugs.freedesktop.org/show_bug.cgi?id=109451</a><br>
Reviewed-by: Lionel Landwerlin <<a href="mailto:lionel.g.landwerlin@intel.com" target="_blank">lionel.g.landwerlin@intel.com</a>><br>
Signed-off-by: Andrii Simiklit <<a href="mailto:andrii.simiklit@globallogic.com" target="_blank">andrii.simiklit@globallogic.com</a>><br>
---<br>
 tests/general/primitive-restart.c | 73 +++++++++++++++++++++++++++++++<br>
 1 file changed, 73 insertions(+)<br>
<br>
diff --git a/tests/general/primitive-restart.c b/tests/general/primitive-restart.c<br>
index 4219a6c5b..941540451 100644<br>
--- a/tests/general/primitive-restart.c<br>
+++ b/tests/general/primitive-restart.c<br>
@@ -75,6 +75,11 @@ static bool Have_31;<br>
 static bool TestGL31;<br>
<br>
<br>
+static void<br>
+enable_restart(GLuint restart_index);<br>
+static void<br>
+disable_restart(void);<br>
+<br>
 static bool<br>
 check_rendering(void)<br>
 {<br>
@@ -184,6 +189,72 @@ test_begin_end(GLenum primMode)<br>
    return pass;<br>
 }<br>
<br>
+static void<br>
+write_vec2_value(GLfloat * verts, GLuint vidx, GLfloat x, GLfloat y)<br>
+{<br>
+   verts[(vidx * 2) + 0] = x;<br>
+   verts[(vidx * 2) + 1] = y;<br>
+}<br>
+/* This test should draw green rectangle if everything is ok.<br>
+ * But in case of bug which makes us unable to disable<br>
+ * the primitive restart option it should draw just one triangle.<br>
+ * Bugzilla: <a href="https://bugs.freedesktop.org/show_bug.cgi?id=109451" rel="noreferrer" target="_blank">https://bugs.freedesktop.org/show_bug.cgi?id=109451</a><br>
+ */<br>
+static bool<br>
+test_shared_ib_restart()<br>
+{<br>
+   bool pass = true;<br>
+   GLfloat verts[256 * 2];<br>
+   memset(&verts, 0, sizeof(verts));<br>
+   //left-bottom<br>
+   write_vec2_value(verts, 0, 0.0f, 0.0f);<br>
+   //right-bottom<br>
+   write_vec2_value(verts, 1, piglit_width, 0.0f);<br>
+   //left-top<br>
+   write_vec2_value(verts, 2, 0.0f, piglit_height);<br>
+   //right-top<br>
+   write_vec2_value(verts, 255, piglit_width, piglit_height);<br>
+<br>
+   const GLubyte indices[] = { 0, 1, 2, 255, 0 };<br>
+   const GLfloat expected[3] = { 0.0f, 1.0f, 0.0f };<br>
+   GLuint vbo1, vbo2;<br>
+<br>
+   piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);<br>
+<br>
+   glClear(GL_COLOR_BUFFER_BIT);<br>
+<br>
+   glColor4fv(green);<br>
+<br>
+   glGenBuffers(1, &vbo1);<br>
+   glBindBuffer(GL_ARRAY_BUFFER, vbo1);<br>
+   glBufferData(GL_ARRAY_BUFFER, sizeof(verts), verts, GL_DYNAMIC_DRAW);<br>
+   glVertexPointer(2, GL_FLOAT, 0, (void *)0);<br>
+<br>
+   glGenBuffers(1, &vbo2);<br>
+   glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vbo2);<br>
+   glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW);<br>
+   glEnableClientState(GL_VERTEX_ARRAY);<br>
+<br>
+   //We should draw something with an enabled restart option to check that<br>
+   //it could be correctly disabled<br>
+   enable_restart(0xff);<br>
+   glDrawElements(GL_LINE_STRIP, ARRAY_SIZE(indices), GL_UNSIGNED_BYTE, (void*)0);<br>
+   disable_restart();<br>
+<br>
+   //Draw full screen rectangle<br>
+   glDrawElements(GL_TRIANGLE_STRIP, ARRAY_SIZE(indices) - 1, GL_UNSIGNED_BYTE, (void*)0);<br>
+<br>
+   glDisableClientState(GL_VERTEX_ARRAY);<br>
+   glBindBuffer(GL_ARRAY_BUFFER, 0);<br>
+   glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);<br>
+   glDeleteBuffers(1, &vbo1);<br>
+   glDeleteBuffers(1, &vbo2);<br>
+   glFinish();<br>
+   pass = (piglit_probe_rect_rgb(0, 0, piglit_width, piglit_height, expected) != 0) && pass;<br>
+   piglit_present_results();<br>
+   return pass;<br>
+}<br>
+<br>
<br>
 static void<br>
 enable_restart(GLuint restart_index)<br>
@@ -503,6 +574,7 @@ primitive_restart_test(VBO_CFG vbo_cfg)<br>
<br>
    if (Have_NV) {<br>
       TestGL31 = false;<br>
+      pass = test_shared_ib_restart() && pass;<br>
       pass = test_begin_end(GL_TRIANGLE_STRIP) && pass;<br>
       pass = test_begin_end(GL_LINE_STRIP) && pass;<br>
       pass = test_draw_elements(vbo_cfg, GL_TRIANGLE_STRIP, GL_UNSIGNED_BYTE) && pass;<br>
@@ -521,6 +593,7 @@ primitive_restart_test(VBO_CFG vbo_cfg)<br>
<br>
    if (Have_31) {<br>
       TestGL31 = true;<br>
+      pass = test_shared_ib_restart() && pass;<br>
       pass = test_draw_elements(vbo_cfg, GL_TRIANGLE_STRIP, GL_UNSIGNED_BYTE) && pass;<br>
       pass = test_draw_elements(vbo_cfg, GL_TRIANGLE_STRIP, GL_UNSIGNED_SHORT) && pass;<br>
       pass = test_draw_elements(vbo_cfg, GL_TRIANGLE_STRIP, GL_UNSIGNED_INT) && pass;<br>
-- <br>
2.17.1<br>
<br>
</blockquote></div></div></div>