[Piglit] [PATCH] primitive-restart: test transform feedback for GL >= 3.0
Marek Olšák
maraeo at gmail.com
Wed Jun 27 16:01:31 PDT 2012
Hi Jordan,
please could you NOT change behavior of existing tests, so that it's
not seen as a "regression" when comparing different test results and
the test starts failing?
The preferred way to update a test is either by adding command-line
arguments enabling the new code or by forking the test. Either way,
there should be a new test item in all.tests.
Thanks,
Marek
On Thu, Jun 28, 2012 at 12:41 AM, Jordan Justen
<jordan.l.justen at intel.com> wrote:
> Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
> ---
> tests/general/primitive-restart.c | 62 +++++++++++++++++++++++++++++++++++--
> 1 file changed, 59 insertions(+), 3 deletions(-)
>
> diff --git a/tests/general/primitive-restart.c b/tests/general/primitive-restart.c
> index cbeb882..a8a817f 100644
> --- a/tests/general/primitive-restart.c
> +++ b/tests/general/primitive-restart.c
> @@ -67,7 +67,9 @@ static const GLfloat black[4] = {0.0, 0.0, 0.0, 0.0};
> static GLboolean Have_NV;
> static GLboolean Have_31;
> static GLboolean TestGL31;
> +static GLboolean TestTransformFeedback = GL_FALSE;
>
> +static GLuint generated_query;
>
> static GLboolean
> check_rendering(void)
> @@ -300,6 +302,7 @@ test_draw_by_index(VBO_CFG vbo_cfg, GLboolean one_by_one, GLenum primMode, GLenu
> uintptr_t index_offset = 0;
> uintptr_t vbo_data_size = sizeof(verts) + sizeof(indices);
> GLuint i, j;
> + GLuint expected_primitives_generated;
>
> if ((vbo_cfg != DISABLE_VBO) && (vbo_cfg != VBO_INDEX_ONLY)) {
> create_vbo1 = GL_TRUE;
> @@ -359,6 +362,7 @@ test_draw_by_index(VBO_CFG vbo_cfg, GLboolean one_by_one, GLenum primMode, GLenu
>
> num_elems = j;
> primStr = "GL_TRIANGLE_STRIP";
> + expected_primitives_generated = 24;
> }
> else {
> const GLfloat y = 0.5 * piglit_height;
> @@ -385,6 +389,7 @@ test_draw_by_index(VBO_CFG vbo_cfg, GLboolean one_by_one, GLenum primMode, GLenu
>
> num_elems = j;
> primStr = "GL_LINE_STRIP";
> + expected_primitives_generated = 12;
> }
>
> assert(num_elems <= NUM_ELEMS);
> @@ -436,6 +441,10 @@ test_draw_by_index(VBO_CFG vbo_cfg, GLboolean one_by_one, GLenum primMode, GLenu
>
> glEnableClientState(GL_VERTEX_ARRAY);
>
> + if (TestTransformFeedback) {
> + glBeginQuery(GL_PRIMITIVES_GENERATED, generated_query);
> + }
> +
> assert(glGetError()==0);
> enable_restart(restart_index);
>
> @@ -464,6 +473,21 @@ test_draw_by_index(VBO_CFG vbo_cfg, GLboolean one_by_one, GLenum primMode, GLenu
> }
>
> pass = check_rendering();
> +
> + if (pass && TestTransformFeedback) {
> + GLuint num_generated_primitives;
> +
> + glEndQuery(GL_PRIMITIVES_GENERATED);
> + glGetQueryObjectuiv(generated_query, GL_QUERY_RESULT,
> + &num_generated_primitives);
> +
> + if (expected_primitives_generated != num_generated_primitives) {
> + fprintf(stderr, "Transform Feedback: expected=%u, got=%u\n",
> + expected_primitives_generated, num_generated_primitives);
> + pass = GL_FALSE;
> + }
> + }
> +
> if (!pass) {
> fprintf(stderr, "%s: failure drawing with %s(%s, %s), %s\n",
> TestName,
> @@ -516,6 +540,7 @@ test_draw_arrays(VBO_CFG vbo_cfg)
> GLuint test;
> const GLenum primMode = GL_LINE_STRIP;
> GLuint vbo = 0;
> + GLuint expected_primitives_generated;
>
> x = 0.0;
>
> @@ -556,12 +581,20 @@ test_draw_arrays(VBO_CFG vbo_cfg)
> */
> for (test = 0; test < 3 && pass; test++) {
> /* choose the restart index */
> - if (test == 0)
> + if (test == 0) {
> restart_index = 0;
> - else if (test == 1)
> + expected_primitives_generated = NUM_VERTS - 2;
> + } else if (test == 1) {
> restart_index = NUM_VERTS - 1;
> - else
> + expected_primitives_generated = NUM_VERTS - 2;
> + } else {
> restart_index = NUM_VERTS / 2;
> + expected_primitives_generated = NUM_VERTS - 3;
> + }
> +
> + if (TestTransformFeedback) {
> + glBeginQuery(GL_PRIMITIVES_GENERATED, generated_query);
> + }
>
> /* draw */
> glClear(GL_COLOR_BUFFER_BIT);
> @@ -600,6 +633,24 @@ test_draw_arrays(VBO_CFG vbo_cfg)
> }
> }
> }
> +
> + if (pass && TestTransformFeedback) {
> + GLuint num_generated_primitives;
> +
> + glEndQuery(GL_PRIMITIVES_GENERATED);
> + glGetQueryObjectuiv(generated_query, GL_QUERY_RESULT,
> + &num_generated_primitives);
> +
> + if (expected_primitives_generated != num_generated_primitives) {
> + fprintf(stderr, "Transform Feedback: expected=%u, got=%u\n",
> + expected_primitives_generated, num_generated_primitives);
> + pass = GL_FALSE;
> + }
> + }
> +
> + if (!pass) {
> + break;
> + }
> }
>
> piglit_present_results();
> @@ -685,6 +736,7 @@ piglit_init(int argc, char **argv)
> {
> Have_NV = piglit_is_extension_supported("GL_NV_primitive_restart");
> Have_31 = piglit_get_gl_version() >= 31;
> + TestTransformFeedback = piglit_get_gl_version() >= 30;
>
> if (argc >= 2) {
> VBO_CFG vbo_cfg;
> @@ -711,5 +763,9 @@ piglit_init(int argc, char **argv)
> exit(1);
> }
>
> + if (TestTransformFeedback) {
> + glGenQueries(1, &generated_query);
> + }
> +
> glClearColor(0, 0, 0, 0);
> }
> --
> 1.7.9.5
>
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit
More information about the Piglit
mailing list