diff options
author | Ian Romanick <ian.d.romanick@intel.com> | 2015-09-16 10:13:31 -0400 |
---|---|---|
committer | Ian Romanick <ian.d.romanick@intel.com> | 2019-06-26 08:31:49 -0700 |
commit | 6d132bebe6adbf1e92b806a6dbf2963ea3b9a4a1 (patch) | |
tree | 6bf26fde9f7aa2e89f0673b0344dd8898f5547de | |
parent | 8dec0fabab5df61dbbfffa282dea8eaa4aa908cb (diff) |
degenerate-prims: Add immediate-mode drawing tests
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=38109
-rw-r--r-- | tests/general/degenerate-prims.c | 75 |
1 files changed, 56 insertions, 19 deletions
diff --git a/tests/general/degenerate-prims.c b/tests/general/degenerate-prims.c index 3403ed099..713608be8 100644 --- a/tests/general/degenerate-prims.c +++ b/tests/general/degenerate-prims.c @@ -48,6 +48,7 @@ struct test_data { /** Select whether or not anything is expected to be drawn. */ bool expect_no_drawing; + bool immediate_mode; }; /** @@ -55,6 +56,7 @@ struct test_data { * * \param expect_no_drawing Select whether or not anything is expected to be * drawn. + * \param immediate_mode Select whether or not to use \c glBegin for drawing. */ static enum piglit_result test_prim(void *_data) @@ -66,9 +68,19 @@ test_prim(void *_data) glClear(GL_COLOR_BUFFER_BIT); - glVertexPointer(2, GL_FLOAT, 0, data->verts); - glEnable(GL_VERTEX_ARRAY); - glDrawArrays(data->prim, 0, data->numVerts); + if (data->immediate_mode) { + const float *const f = data->verts; + + glBegin(data->prim); + for (unsigned i = 0; i < data->numVerts; i++) + glVertex2fv(&f[i * 2]); + glEnd(); + } else { + glVertexPointer(2, GL_FLOAT, 0, data->verts); + glEnable(GL_VERTEX_ARRAY); + glDrawArrays(data->prim, 0, data->numVerts); + glDisable(GL_VERTEX_ARRAY); + } /* Check the color in the window. If the test expected that nothing * would be drawn and the while window is black, the test passes. If @@ -88,7 +100,6 @@ test_prim(void *_data) return pass ? PIGLIT_PASS : PIGLIT_FAIL; } - enum piglit_result piglit_display(void) { @@ -107,25 +118,51 @@ piglit_display(void) glColor3f(1, 1, 1); struct test_data data[] = { - { GL_POINTS, 0, verts2, true }, - { GL_LINES, 1, verts2, true }, - { GL_LINES, 3, verts5, false }, - { GL_LINE_STRIP, 1, verts2, true }, - { GL_LINE_LOOP, 1, verts2, true }, - { GL_TRIANGLES, 2, verts3, true }, - { GL_TRIANGLES, 5, verts5, false }, - { GL_TRIANGLE_STRIP, 2, verts3, true }, - { GL_TRIANGLE_FAN, 2, verts3, true }, - { GL_QUADS, 3, verts4, true }, - { GL_QUADS, 7, verts5, false }, - { GL_QUAD_STRIP, 3, verts4, true }, - { GL_QUAD_STRIP, 5, verts5, false }, - { GL_POLYGON, 2, verts4, true }, + { GL_POINTS, 0, verts2, true, false }, + { GL_LINES, 1, verts2, true, false }, + { GL_LINES, 3, verts5, false, false }, + { GL_LINE_STRIP, 1, verts2, true, false }, + { GL_LINE_LOOP, 1, verts2, true, false }, + { GL_TRIANGLES, 2, verts3, true, false }, + { GL_TRIANGLES, 5, verts5, false, false }, + { GL_TRIANGLE_STRIP, 2, verts3, true, false }, + { GL_TRIANGLE_FAN, 2, verts3, true, false }, + { GL_QUADS, 3, verts4, true, false }, + { GL_QUADS, 7, verts5, false, false }, + { GL_QUAD_STRIP, 3, verts4, true, false }, + { GL_QUAD_STRIP, 5, verts5, false, false }, + { GL_POLYGON, 2, verts4, true, false }, + + /* Immediate mode tests. */ + { GL_POINTS, 0, verts2, true, true }, + { GL_LINES, 1, verts2, true, true }, + { GL_LINES, 3, verts5, false, true }, + { GL_LINE_STRIP, 1, verts2, true, true }, + { GL_LINE_LOOP, 1, verts2, true, true }, + { GL_TRIANGLES, 2, verts3, true, true }, + { GL_TRIANGLES, 5, verts5, false, true }, + { GL_TRIANGLE_STRIP, 2, verts3, true, true }, + { GL_TRIANGLE_FAN, 2, verts3, true, true }, + { GL_QUADS, 3, verts4, true, true }, + { GL_QUADS, 7, verts5, false, true }, + { GL_QUAD_STRIP, 3, verts4, true, true }, + { GL_QUAD_STRIP, 5, verts5, false, true }, + { GL_POLYGON, 2, verts4, true, true }, }; struct piglit_subtest tests[ARRAY_SIZE(data) + 1]; for (int i = 0; i < ARRAY_SIZE(data); ++i) { - tests[i].name = piglit_get_prim_name(data[i].prim); + const char *const prim_name = + piglit_get_prim_name(data[i].prim); + + if (data[i].immediate_mode) { + char *name = NULL; + asprintf(&name, "%s immediate-mode", prim_name); + tests[i].name = name; + } else { + tests[i].name = prim_name; + } + tests[i].option = ""; tests[i].subtest_func = test_prim; tests[i].data = &data[i]; |