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

Fredrik Höglund fredrik at kde.org
Sun Feb 2 07:42:10 PST 2014


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.
---
 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')
 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.
+ */
+
+#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");
+
+	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;
+}
-- 
1.8.5.3



More information about the Piglit mailing list