[Piglit] [PATCH] glx-choosefbconfig-defaults: New glXChooseFBConfig test

Fredrik Höglund fredrik at kde.org
Tue Feb 11 08:22:51 PST 2014


On Tuesday 11 February 2014, Ian Romanick wrote:
> On 02/02/2014 07:42 AM, Fredrik Höglund wrote:
> > Verify that glXChooseFBConfig uses the default values in table 3.4 in
> > the GLX 1.4 specification for attributes not specified in attribList.
> > 
> > This test currently fails on Mesa.
> 
> Which cases?  All of them if we supported a
> stereo-level=1-colorindex-transparent visual? :)

The case that fails is GLX_DRAWABLE_TYPE.  It should default to
GLX_WINDOW_BIT, but we return configs that don't support windows.

This looks to be a regression in Mesa 9.2 from commit
4473af7aca97d3607869547.

Looking at the code I think GLX_RENDER_TYPE would also fail
if Mesa supported color-index configs.

> > ---
> >  tests/all.py                            |   1 +
> >  tests/glx/CMakeLists.gl.txt             |   1 +
> >  tests/glx/glx-choosefbconfig-defaults.c | 130 ++++++++++++++++++++++++++++++++
> >  3 files changed, 132 insertions(+)
> >  create mode 100644 tests/glx/glx-choosefbconfig-defaults.c
> > 
> > diff --git a/tests/all.py b/tests/all.py
> > index b8d0edb..6bf09c3 100644
> > --- a/tests/all.py
> > +++ b/tests/all.py
> > @@ -686,6 +686,7 @@ add_plain_test(glx, 'glx-dont-care-mask')
> >  add_plain_test(glx, 'glx-close-display')
> >  add_concurrent_test(glx, 'glx-fbconfig-sanity')
> >  add_concurrent_test(glx, 'glx-fbconfig-compliance')
> > +add_concurrent_test(glx, 'glx-choosefbconfig-defaults')
> 
> Isn't there a GLX 1.3 section?  Hmm... I guess there's not that many GLX
> tests to make it worth adding one (and moving existing tests around).
> 
> >  add_plain_test(glx, 'glx-fbo-binding')
> >  add_plain_test(glx, 'glx-multi-context-ib-1')
> >  add_plain_test(glx, 'glx-multithread')
> > diff --git a/tests/glx/CMakeLists.gl.txt b/tests/glx/CMakeLists.gl.txt
> > index 7f3a713..b7ee38e 100644
> > --- a/tests/glx/CMakeLists.gl.txt
> > +++ b/tests/glx/CMakeLists.gl.txt
> > @@ -24,6 +24,7 @@ IF(PIGLIT_BUILD_GLX_TESTS)
> >  	)
> >  	piglit_add_executable (glx-fbconfig-sanity glx-fbconfig-sanity.c)
> >  	piglit_add_executable (glx-fbconfig-compliance glx-fbconfig-compliance.c)
> > +	piglit_add_executable (glx-choosefbconfig-defaults glx-choosefbconfig-defaults.c)
> >  	piglit_add_executable (glx-fbo-binding glx-fbo-binding.c)
> >  	piglit_add_executable (glx-shader-sharing glx-shader-sharing.c)
> >  	piglit_add_executable (glx-close-display glx-close-display.c)
> > diff --git a/tests/glx/glx-choosefbconfig-defaults.c b/tests/glx/glx-choosefbconfig-defaults.c
> > new file mode 100644
> > index 0000000..8b1d5ce
> > --- /dev/null
> > +++ b/tests/glx/glx-choosefbconfig-defaults.c
> > @@ -0,0 +1,130 @@
> > +/*
> > + * Copyright © 2014 Fredrik Höglund
> > + *
> > + * 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.
> > + */
> > +
> > +/** @file glx-choosefbconfig-defaults.c
> > + *
> > + * Verify that glXChooseFBConfig uses the default values in table 3.4 in
> > + * the GLX 1.4 specification for attributes not specified in attribList.
> 
> I think we should quote the part of the table that's actually being
> tested.  That way the next person that comes along (probably to debug
> the test failure) doesn't have to dig around in the spec.
> 
> Are the defaults only listed in the 1.4 spec, or are they in the 1.3
> spec too?

They are listed in 1.3 too.  The 1.4 spec adds GLX_SAMPLES, but that's
actually not relevant for this test, since the match critera for that one
is Smaller.

> > + */
> > +
> > +#include "piglit-util-gl-common.h"
> > +#include "piglit-glx-util.h"
> > +
> > +int piglit_width = 10;
> > +int piglit_height = 10;
> > +
> > +static PFNGLXCHOOSEFBCONFIGPROC ChooseFBConfig = NULL;
> > +static PFNGLXGETFBCONFIGATTRIBPROC GetFBConfigAttrib = NULL;
> > +
> > +int
> > +main(int argc, char **argv)
> > +{
> > +	Display *dpy;
> > +	int i;
> > +	int result = PIGLIT_PASS;
> > +	GLXFBConfig *configs;
> > +	const int attribs[] = { 0 }; /* Use default values for all attribs */
> > +	int num_configs;
> > +
> > +	dpy = XOpenDisplay(NULL);
> > +	if (dpy == NULL) {
> > +		fprintf(stderr, "couldn't open display\n");
> > +		piglit_report_result(PIGLIT_FAIL);
> > +	}
> > +
> > +	/* Test requires at least GLX version 1.3.  Otherwise there is no
> > +	 * glXChooseFBConfigs function.
> > +	 */
> > +	piglit_require_glx_version(dpy, 1, 3);
> > +	piglit_require_glx_extension(dpy, "GLX_ARB_get_proc_address");
> 
> glXGetProcAddress is part of GLX 1.3.  Also, the Linux OpenGL ABI
> requires GLX_ARB_get_proc_address.  You don't need to check it. :)  With
> that and the comment above fixed
> 
> Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>

The dangers of copy & paste :)

It looks like that should be fixed in the other GLX 1.3 tests as well.

> > +	ChooseFBConfig = (PFNGLXCHOOSEFBCONFIGPROC)
> > +		glXGetProcAddressARB((GLubyte *) "glXChooseFBConfig");
> > +	GetFBConfigAttrib = (PFNGLXGETFBCONFIGATTRIBPROC)
> > +		glXGetProcAddressARB((GLubyte *) "glXGetFBConfigAttrib");
> > +
> > +	configs = ChooseFBConfig(dpy, DefaultScreen(dpy), attribs, &num_configs);
> > +
> > +	/* Iterate over the list of fbconfigs.  Check that only fbconfigs
> > +	 * with attributes that match the default values listed in
> > +	 * table 3.4 were selected.
> > +	 */
> > +	for (i = 0; i < num_configs; i++) {
> > +		int draw_type;
> > +		int config_id = 0;
> > +		int render_type;
> > +		int transparent_type;
> > +		int level;
> > +		int stereo;
> > +
> > +		GetFBConfigAttrib(dpy, configs[i], GLX_FBCONFIG_ID,
> > +				  &config_id);
> > +		GetFBConfigAttrib(dpy, configs[i], GLX_DRAWABLE_TYPE,
> > +				  &draw_type);
> > +		GetFBConfigAttrib(dpy, configs[i], GLX_RENDER_TYPE,
> > +				  &render_type);
> > +		GetFBConfigAttrib(dpy, configs[i], GLX_TRANSPARENT_TYPE,
> > +				  &transparent_type);
> > +		GetFBConfigAttrib(dpy, configs[i], GLX_LEVEL,
> > +				  &level);
> > +		GetFBConfigAttrib(dpy, configs[i], GLX_STEREO,
> > +				  &stereo);
> > +
> > +		if ((draw_type & GLX_WINDOW_BIT) == 0) {
> > +			fprintf(stderr, "FBConfig 0x%x does not have "
> > +				"the GLX_WINDOW_BIT set\n", config_id);
> > +			result = PIGLIT_FAIL;
> > +		}
> > +
> > +		if (render_type != GLX_RGBA_BIT) {
> > +			fprintf(stderr, "FBConfig 0x%x does not have "
> > +				"the GLX_RGBA_BIT set\n",
> > +				config_id);
> > +			result = PIGLIT_FAIL;
> > +		}
> > +
> > +		if (transparent_type != GLX_NONE) {
> > +			fprintf(stderr, "FBConfig 0x%x does not have "
> > +				"GLX_TRANSPARENT_TYPE set to GLX_NONE\n",
> > +				config_id);
> > +			result = PIGLIT_FAIL;
> > +		}
> > +
> > +		if (level != 0) {
> > +			fprintf(stderr, "FBConfig 0x%x does not have "
> > +				"GLX_LEVEL set to zero\n",
> > +				config_id);
> > +			result = PIGLIT_FAIL;
> > +		}
> > +
> > +		if (stereo != False) {
> > +			fprintf(stderr, "FBConfig 0x%x does not have "
> > +				"GLX_STEREO set to False\n",
> > +				config_id);
> > +			result = PIGLIT_FAIL;
> > +		}
> > +	}
> > +
> > +	piglit_report_result(result);
> > +	return 0;
> > +}
> 
> 



More information about the Piglit mailing list