diff options
author | Adam Jackson <ajax@redhat.com> | 2013-03-07 07:01:14 -0500 |
---|---|---|
committer | Adam Jackson <ajax@redhat.com> | 2013-03-08 11:48:04 -0500 |
commit | 343384b8bb3f7e5f2e5f3d1495345c6707e5d41b (patch) | |
tree | 0d6ffe45b4cb05305c72aed82ca38b2a0986405a | |
parent | 03b3587c9e8927af7f1e475e44532ddce5b521b5 (diff) |
glx_arb_create_context: Add current-no-framebuffer test
Signed-off-by: Adam Jackson <ajax@redhat.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/current-no-framebuffer.c | 90 |
3 files changed, 92 insertions, 0 deletions
diff --git a/tests/all.tests b/tests/all.tests index 1dccd9ad..cb0c21c9 100644 --- a/tests/all.tests +++ b/tests/all.tests @@ -392,6 +392,7 @@ import_context['query context info'] = PlainExecTest(['glx-query-context-info-ex create_context = Group(); glx['GLX_ARB_create_context'] = create_context +create_context['current with no framebuffer'] = concurrent_test('glx-create-context-current-no-framebuffer') create_context['default major version'] = concurrent_test('glx-create-context-default-major-version') create_context['default minor version'] = concurrent_test('glx-create-context-default-minor-version') create_context['invalid attribute'] = concurrent_test('glx-create-context-invalid-attribute') diff --git a/tests/spec/glx_arb_create_context/CMakeLists.gl.txt b/tests/spec/glx_arb_create_context/CMakeLists.gl.txt index 76c403a4..e913d784 100644 --- a/tests/spec/glx_arb_create_context/CMakeLists.gl.txt +++ b/tests/spec/glx_arb_create_context/CMakeLists.gl.txt @@ -23,6 +23,7 @@ IF(PIGLIT_BUILD_GLX_TESTS) ${X11_X11_LIB} ) piglit_add_executable (glx-create-context-core-profile core-profile.c common.c) + piglit_add_executable (glx-create-context-current-no-framebuffer current-no-framebuffer.c common.c) piglit_add_executable (glx-create-context-default-major-version default-major-version.c common.c) 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) diff --git a/tests/spec/glx_arb_create_context/current-no-framebuffer.c b/tests/spec/glx_arb_create_context/current-no-framebuffer.c new file mode 100644 index 00000000..8f2956e7 --- /dev/null +++ b/tests/spec/glx_arb_create_context/current-no-framebuffer.c @@ -0,0 +1,90 @@ +/* + * Copyright 2013 Red Hat, Inc. + * + * 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-gl-common.h" +#include "piglit-glx-util.h" +#include "common.h" + +int main(int argc, char **argv) +{ + static const int attribs[] = { + GLX_CONTEXT_MAJOR_VERSION_ARB, 3, + GLX_CONTEXT_MINOR_VERSION_ARB, 0, + None + }; + GLXContext ctx; + int major; + int minor; + int result = PIGLIT_PASS; + + GLX_ARB_create_context_setup(); + + /* + * The GLX_ARB_create_context spec says: + * + * In the description of glXMakeContextCurrent, replace the text + * "If either <draw> or <read> are not a valid GLX drawable, a + * GLXBadDrawable error is generated." + * + * with + * + * "If either <draw> or <read> are not a valid GLX drawable, a + * GLXBadDrawable error is generated, unless <draw> and <read> are + * both None and the OpenGL version supported by <ctx> is 3.0 or + * greater. In this case the context is made current without a + * default framebuffer, as defined in chapter 4 of the OpenGL 3.0 + * Specification." + * + * Request an OpenGL 3.0 context, and then make it current with None + * for both the drawable and readable. + */ + ctx = glXCreateContextAttribsARB(dpy, fbconfig, NULL, True, attribs); + + if (!ctx) { + /* + * Well, is 3.0 supported at all? The spec says: + * + * * If <config> does not support compatible OpenGL contexts + * providing the requested API major and minor version, + * forward-compatible flag, and debug context flag, + * GLXBadFBConfig is generated. + */ + if (validate_glx_error_code(Success, GLXBadFBConfig)) { + fprintf(stderr, "GL 3.0 not supported\n"); + result = PIGLIT_SKIP; + } else { + fprintf(stderr, "Failed to create a 3.0 context\n"); + result = PIGLIT_WARN; + } + } else { + if (!glXMakeContextCurrent(dpy, None, None, ctx)) + result = PIGLIT_FAIL; + else if (!validate_glx_error_code(Success, -1)) + result = PIGLIT_FAIL; + + glXDestroyContext(dpy, ctx); + } + GLX_ARB_create_context_teardown(); + + piglit_report_result(result); + return 0; +} |