[Piglit] [PATCH 5/5] glx_ext_create_context_es2_profile: Verify that the invalid ES versions are rejected

Ian Romanick idr at freedesktop.org
Tue Jun 12 14:30:20 PDT 2012


From: Ian Romanick <ian.d.romanick at intel.com>

NVIDIA's closed-source driver fails this test.  GLXBadProfileARB is
generated instead of BadMatch.  The specification isn't specific about
what error should be generated, but I don't think GLXBadProfileARB is
correct.  GLXBadProfileARB seems to only be generated in cases where
the bit mask specified for GLX_CONTEXT_PROFILE_MASK_ARB is invalid.
Cases where the GLX_CONTEXT_PROFILE_MASK_ARB is incongruous with the
specified version either result in GLX_CONTEXT_PROFILE_MASK_ARB being
ignored or BadMatch.

AMD's closed-source driver has not been tested.

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
Cc: James Jones <jajones at nvidia.com>
---
 tests/all.tests                                    |    1 +
 .../spec/glx_arb_create_context/CMakeLists.gl.txt  |    1 +
 .../glx_arb_create_context/invalid-es-version.c    |  105 ++++++++++++++++++++
 3 files changed, 107 insertions(+), 0 deletions(-)
 create mode 100644 tests/spec/glx_arb_create_context/invalid-es-version.c

diff --git a/tests/all.tests b/tests/all.tests
index 1c158e7..8ce68c6 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -693,6 +693,7 @@ create_context_profile['pre-GL3 profile'] = PlainExecTest(['glx-create-context-p
 create_context_es2_profile = Group();
 glx['GLX_EXT_create_context_es2_profile'] = create_context_es2_profile
 create_context_es2_profile['indirect rendering ES2 profile'] = PlainExecTest(['glx-create-context-indirect-es2-profile'])
+create_context_es2_profile['invalid OpenGL ES version'] = PlainExecTest(['glx-create-context-invalid-es-version'])
 
 texturing = Group()
 add_concurrent_test(texturing, '1-1-linear-texture')
diff --git a/tests/spec/glx_arb_create_context/CMakeLists.gl.txt b/tests/spec/glx_arb_create_context/CMakeLists.gl.txt
index e64f410..51933d5 100644
--- a/tests/spec/glx_arb_create_context/CMakeLists.gl.txt
+++ b/tests/spec/glx_arb_create_context/CMakeLists.gl.txt
@@ -27,6 +27,7 @@ IF(BUILD_GLX_TESTS)
 	piglit_add_executable (glx-create-context-default-minor-version default-minor-version.c common.c)
 	piglit_add_executable (glx-create-context-indirect-es2-profile indirect-es2-profile.c common.c)
 	piglit_add_executable (glx-create-context-invalid-attribute invalid-attribute.c common.c)
+	piglit_add_executable (glx-create-context-invalid-es-version invalid-es-version.c common.c)
 	piglit_add_executable (glx-create-context-invalid-flag invalid-flag.c common.c)
 	piglit_add_executable (glx-create-context-invalid-flag-forward-compatible invalid-flag-forward-compatible.c common.c)
 	piglit_add_executable (glx-create-context-invalid-gl-version invalid-gl-version.c common.c)
diff --git a/tests/spec/glx_arb_create_context/invalid-es-version.c b/tests/spec/glx_arb_create_context/invalid-es-version.c
new file mode 100644
index 0000000..cf6e1ff
--- /dev/null
+++ b/tests/spec/glx_arb_create_context/invalid-es-version.c
@@ -0,0 +1,105 @@
+/* Copyright © 2011 Intel Corporation
+ *
+ * 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.
+ */
+#include "piglit-util.h"
+#include "piglit-glx-util.h"
+#include "common.h"
+
+static bool try_version(int major, int minor)
+{
+	const int attribs[] = {
+		GLX_CONTEXT_MAJOR_VERSION_ARB,
+		major,
+		GLX_CONTEXT_MINOR_VERSION_ARB,
+		minor,
+		GLX_CONTEXT_PROFILE_MASK_ARB,
+		GLX_CONTEXT_ES2_PROFILE_BIT_EXT,
+		None
+	};
+	GLXContext ctx;
+	bool pass = true;
+
+	ctx = glXCreateContextAttribsARB(dpy, fbconfig, NULL, True, attribs);
+	XSync(dpy, 0);
+
+	if (ctx != NULL) {
+		fprintf(stderr,
+			"Created OpenGL ES context with invalid version "
+			"%d.%d\n",
+			major, minor);
+		glXDestroyContext(dpy, ctx);
+		pass = false;
+	}
+
+	/* The GLX_ARB_create_context spec says:
+	 *
+	 *     "If attributes GLX_CONTEXT_MAJOR_VERSION_ARB and
+	 *     GLX_CONTEXT_MINOR_VERSION_ARB, when considered together with
+	 *     attributes GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB and
+	 *     GLX_RENDER_TYPE, specify an OpenGL version and feature set that
+	 *     are not defined, BadMatch is generated."
+	 */
+	if (!validate_glx_error_code(BadMatch, -1)) {
+		if (ctx == NULL)
+			fprintf(stderr, "Version = %d.%d\n", major, minor);
+
+		pass = false;
+	}
+
+	return pass;
+}
+
+int main(int argc, char **argv)
+{
+	bool pass = true;
+
+	GLX_ARB_create_context_setup();
+	piglit_require_glx_extension(dpy, "GLX_ARB_create_context_profile");
+	piglit_require_glx_extension(dpy, "GLX_EXT_create_context_es2_profile");
+
+	/* The GLX_EXT_create_context_es2_profile spec says:
+	 *
+	 *     "... If the version requested is 2.0, and the
+	 *     GLX_CONTEXT_ES2_PROFILE_BIT_EXT bit is set in the
+	 *     GLX_CONTEXT_PROFILE_MASK_ARB attribute (see below),
+	 *     then the context returned will implement OpenGL ES
+	 *     2.0. This is the only way in which an implementation
+	 *     may request an OpenGL ES 2.0 context."
+	 *
+	 * Try a bunch of OpenGL ES versions that don't exist.
+	 */
+	pass = try_version(1, 2) && pass;
+	pass = try_version(2, 1) && pass;
+	pass = try_version(3, 0) && pass;
+
+	/* These versions of ES exist, but future versions of the GLX
+	 * extension may add the ability to create contexts with these
+	 * versions.  When that happens, these checks will need to be
+	 * predicated by the non-existence of that extension.
+	 */
+	pass = try_version(1, 0) && pass;
+	pass = try_version(1, 1) && pass;
+
+	GLX_ARB_create_context_teardown();
+
+	piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
+	return 0;
+}
-- 
1.7.6.5



More information about the Piglit mailing list