[Piglit] [PATCH 08/23] util, tests: Replace GLUT visual enums with PIGLTI_GL_VISUAL enums

Kenneth Graunke kenneth at whitecape.org
Wed Oct 3 16:43:07 PDT 2012


On 09/28/2012 01:48 PM, Chad Versace wrote:
> I'm trying to transition Piglit from using GLUT to using Waffle. That
> requires either killing or wrapping all GLUT code.
>
> Define enum piglit_gl_visual in piglit-framework.h, of which each value
> matches its corresponding GLUT visual enum.
>
> Do the following substitution in all util and test sources:
>      GLUT_RGB            -> PIGLIT_GL_VISUAL_RGB
>      GLUT_RGBA           -> PIGLIT_GL_VISUAL_RGBA
>      GLUT_INDEX          -> PIGLIT_GL_VISUAL_INDEX
>      GLUT_DOUBLE         -> PIGLIT_GL_VISUAL_DOUBLE
>      GLUT_ACCUM          -> PIGLIT_GL_VISUAL_ACCUM
>      GLUT_ALPHA          -> PIGLIT_GL_VISUAL_ALPHA
>      GLUT_DEPTH          -> PIGLIT_GL_VISUAL_DEPTH
>      GLUT_STENCIL        -> PIGLIT_GL_VISUAL_STENCIL
>
> Signed-off-by: Chad Versace <chad.versace at linux.intel.com>
>
> =========================================================================
>
> This is a giant sed-job patch. Here is an example diff of a test file.
>
> diff --git a/tests/asmparsertest/asmparsertest.c b/tests/asmparsertest/asmparsertest.c
> index c0f977e..e187603 100644
> --- a/tests/asmparsertest/asmparsertest.c
> +++ b/tests/asmparsertest/asmparsertest.c
> @@ -33,7 +33,7 @@
>   PIGLIT_GL_TEST_MAIN(
>       250 /*window_width*/,
>       250 /*window_height*/,
> -    GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH)
> +    PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_SINGLE | PIGLIT_GL_VISUAL_DEPTH)
>
>   char *
>   unix_line_endings(const char *input, size_t length)
>
> =========================================================================
>
> And here is the complete diff for tests/util.
>
> diff --git a/tests/util/piglit-framework-fbo.c b/tests/util/piglit-framework-fbo.c
> index 8610724..f9046d8 100644
> --- a/tests/util/piglit-framework-fbo.c
> +++ b/tests/util/piglit-framework-fbo.c
> @@ -261,7 +261,7 @@ piglit_framework_fbo_gl_init(const struct piglit_gl_test_info *info)
>   			       tex,
>   			       0);
>
> -	if (info->window_visual & (GLUT_DEPTH | GLUT_STENCIL)) {
> +	if (info->window_visual & (PIGLIT_GL_VISUAL_DEPTH | PIGLIT_GL_VISUAL_STENCIL)) {
>   		/* Create a combined depth+stencil texture and attach it
>   		 * to the depth and stencil attachment points.
>   		 */
> diff --git a/tests/util/piglit-framework.h b/tests/util/piglit-framework.h
> index f93fcba..6114dd3 100644
> --- a/tests/util/piglit-framework.h
> +++ b/tests/util/piglit-framework.h
> @@ -29,6 +29,26 @@
>   #include <stdbool.h>
>
>   /**
> + * A bitmask of these enums specifies visual attributes for the test's window.
> + *
> + * Each enum has the same value of its corresponding GLUT enum. That is, for
> + * each X, `PIGLIT_GL_VISUAL_X == GLUT_X`.
> + *
> + * \see piglit_gl_test_info::window_visual
> + */
> +enum piglit_gl_visual {
> +	PIGLIT_GL_VISUAL_RGB 		= 0,
> +	PIGLIT_GL_VISUAL_RGBA 		= 0,
> +	PIGLIT_GL_VISUAL_SINGLE 	= 0,

Really weird that RGB and RGBA are the same.  I guess I would've 
expected RGBA to be shorthand for RGB | ALPHA.  But that's what GLUT does.

At some point, I'd like to see double buffering become the default (so 
DOUBLE becomes 0, and SINGLE requires you to specify something).  DOUBLE 
is really the common case these days.

> +	PIGLIT_GL_VISUAL_INDEX 		= 1 << 0,

I assume this is color index.  This could probably just be dropped at 
some point...no tests currently use it and since we removed Mesa's 
support for color indexing, I don't see it coming back...ever.

> +	PIGLIT_GL_VISUAL_DOUBLE 	= 1 << 1,
> +	PIGLIT_GL_VISUAL_ACCUM 		= 1 << 2,
> +	PIGLIT_GL_VISUAL_ALPHA 		= 1 << 3,
> +	PIGLIT_GL_VISUAL_DEPTH 		= 1 << 4,
> +	PIGLIT_GL_VISUAL_STENCIL 	= 1 << 5,
> +};
> +
> +/**
>    * @brief Info needed to run an OpenGL test.
>    *
>    * To run a test, pass this to piglit_gl_test_run().
> @@ -43,7 +63,9 @@ struct piglit_gl_test_info {
>   	int window_width;
>   	int window_height;
>
> -	/** A bitmask such as `GLUT_RGBA | GLUT_DOUBLE`. */
> +	/**
> +	 * A bitmask of `enum piglit_gl_visual`.
> +	 */
>   	int window_visual;
>
>   	/**



More information about the Piglit mailing list