diff options
author | Ian Romanick <ian.d.romanick@intel.com> | 2012-06-12 12:22:58 -0700 |
---|---|---|
committer | Ian Romanick <ian.d.romanick@intel.com> | 2012-07-20 11:30:12 -0700 |
commit | 478ac6763e3f1c27afeb39dbfba01f652072499e (patch) | |
tree | 8d8e82f1c629df967f644831ae90133e1f375fe9 | |
parent | cc05b536309f1c46cd4af68e0cb74354a04521e2 (diff) |
glx_ext_create_context_es2_profile: Verify that the invalid ES versions are rejected
NVIDIA's closed-source driver passes this test. AMD's closed-source
driver has not been tested.
v2: Based on discussions whtih James Jones (NVIDIA), expect
GLXBadProfileARB instead of BadMatch.
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
Cc: James Jones <jajones@nvidia.com>
-rw-r--r-- | tests/all.tests | 1 | ||||
-rw-r--r-- | tests/spec/glx_arb_create_context/CMakeLists.gl.txt | 1 | ||||
-rw-r--r-- | tests/spec/glx_arb_create_context/invalid-es-version.c | 111 |
3 files changed, 113 insertions, 0 deletions
diff --git a/tests/all.tests b/tests/all.tests index e082421c0..ff8f595d1 100644 --- a/tests/all.tests +++ b/tests/all.tests @@ -713,6 +713,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 e64f41098..51933d5e0 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 000000000..d02367974 --- /dev/null +++ b/tests/spec/glx_arb_create_context/invalid-es-version.c @@ -0,0 +1,111 @@ +/* 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_profile spec says: + * + * "* If attribute GLX_CONTEXT_PROFILE_MASK_ARB has no bits set; + * has any bits set other than GLX_CONTEXT_CORE_PROFILE_BIT_ARB + * and GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; has more than + * one of these bits set; or if the implementation does not + * support the requested profile, then GLXBadProfileARB is + * generated." + * + * Implementations that support GLX_EXT_create_context_es2_profile can + * only support GLX_CONTEXT_ES2_PROFILE_BIT_EXT with version 2.0. + * Therefore, they cannot support that profile with any other version, + * and GLXBadProfileARB should be generated. + */ + if (!validate_glx_error_code(Success, GLXBadProfileARB)) { + 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; +} |