[Piglit] [PATCH] general/draw: Test that checks propper render order in mixed draw setups.

Timothy Arceri tarceri at itsqueeze.com
Wed Jun 6 00:10:21 UTC 2018


On 05/06/18 16:05, Mathias.Froehlich at gmx.net wrote:
> From: Mathias Fröhlich <mathias.froehlich at web.de>
> 
> Hi all,
> 
> The description below,
> Please review!!
> 
> best
> Mathias
> 
> 
> 
> The test checks for propper immediate mode flushes when array draws
> are mixed with immediate mode draws.
> The test abstracts out what went wrong in bugzilla #106594.
> 
> Signed-off-by: Mathias Fröhlich <Mathias.Froehlich at web.de>
> ---
>   tests/general/CMakeLists.gl.txt     |   1 +
>   tests/general/draw-flush-vertices.c | 111 ++++++++++++++++++++++++++++
>   2 files changed, 112 insertions(+)
>   create mode 100644 tests/general/draw-flush-vertices.c
> 
> diff --git a/tests/general/CMakeLists.gl.txt b/tests/general/CMakeLists.gl.txt
> index ceec9f0b6..7f530974e 100644
> --- a/tests/general/CMakeLists.gl.txt
> +++ b/tests/general/CMakeLists.gl.txt
> @@ -40,6 +40,7 @@ piglit_add_executable (draw-batch draw-batch.c)
>   piglit_add_executable (draw-copypixels-sync draw-copypixels-sync.c)
>   piglit_add_executable (draw-elements draw-elements.c)
>   piglit_add_executable (draw-elements-vs-inputs draw-elements-vs-inputs.c)
> +piglit_add_executable (draw-flush-vertices draw-flush-vertices.c)
>   piglit_add_executable (draw-pixel-with-texture draw-pixel-with-texture.c)
>   piglit_add_executable (draw-sync draw-sync.c)
>   piglit_add_executable (draw-pixels draw-pixels.c)
> diff --git a/tests/general/draw-flush-vertices.c b/tests/general/draw-flush-vertices.c
> new file mode 100644
> index 000000000..9932a6bc0
> --- /dev/null
> +++ b/tests/general/draw-flush-vertices.c
> @@ -0,0 +1,111 @@
> +/*
> + * Copyright © 2018 Mathias Fröhlich <Mathias.Froehlich at web.de>
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice (including the next
> + * paragraph) shall be included in all copies or substantial portions of the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
> + * DEALINGS IN THE SOFTWARE.
> + *
> + * Authors:
> + *    Mathias Fröhlich <Mathias.Froehlich at web.de>
> + */
> +
> +/* The test does mixes immediate mode and array draws, but does not
> + * not do an other draw setup past the immediate mode draw. By that
> + * it checks for the order of draws that may be inverted if the queued
> + * immediate mode draws are not properly flushed before the array draw.
> + */
> +
> +#include "piglit-util-gl.h"
> +
> +PIGLIT_GL_TEST_CONFIG_BEGIN
> +
> +	config.supports_gl_compat_version = 11;
> +
> +	config.window_width = 32;
> +	config.window_height = 32;
> +	config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
> +	config.khr_no_error_support = PIGLIT_NO_ERRORS;
> +
> +PIGLIT_GL_TEST_CONFIG_END
> +
> +void piglit_init(int argc, char **argv)
> +{
> +	piglit_require_gl_version(11);
> +
> +	piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
> +
> +	glDisable(GL_DEPTH_TEST);
> +	glClearColor(0.0, 0.0, 0.0, 1.0);
> +}

nit:

Normally we try to put piglit_init() at the bottom so we can get right 
into the interesting things first.

Otherwise this is:

Acked-by: Timothy Arceri <tarceri at itsqueeze.com>

Thanks for writing a piglit test to cover this!

> +
> +
> +enum piglit_result
> +piglit_display(void)
> +{
> +	const GLfloat Vertices[2*4] = {
> +		0, 0,
> +		piglit_width, 0,
> +		piglit_width, piglit_height,
> +		0, piglit_height
> +	};
> +	const GLfloat Colors[4*3] = {
> +		1, 0, 0,
> +		1, 0, 0,
> +		1, 0, 0,
> +		1, 0, 0
> +	};
> +
> +	GLboolean pass = GL_TRUE;
> +
> +	glViewport(0, 0, piglit_width, piglit_height);
> +
> +	glEnableClientState(GL_VERTEX_ARRAY);
> +	glVertexPointer(2, GL_FLOAT, sizeof(GLfloat)*2, Vertices);
> +	glEnableClientState(GL_COLOR_ARRAY);
> +	glColorPointer(3, GL_FLOAT, sizeof(GLfloat)*3, Colors);
> +
> +	glClear(GL_COLOR_BUFFER_BIT);
> +
> +	/* Draw a blue quad */
> +	glBegin(GL_QUADS);
> +	glColor3f(0, 0, 1);
> +	glVertex2fv(&Vertices[0]);
> +	glVertex2fv(&Vertices[2]);
> +	glVertex2fv(&Vertices[4]);
> +	glVertex2fv(&Vertices[6]);
> +	glEnd();
> +
> +	/* OpenGL has to make sure that prior to the glDrawArrays call
> +	 * all immediate mode rendering has landed.
> +	 */
> +
> +	/* Draw a red quad */
> +	glDrawArrays(GL_QUADS, 0, 4);
> +
> +	if (!piglit_check_gl_error(GL_NO_ERROR))
> +		piglit_report_result(PIGLIT_FAIL);
> +
> +	/* Check for a red quad that is drawn last */
> +	pass = piglit_probe_pixel_rgb(piglit_width/2, piglit_height/2, Colors)
> +		&& pass;
> +
> +	glFinish();
> +	piglit_present_results();
> +
> +	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
> +}
> 


More information about the Piglit mailing list