From 93bba98ff6297068cebe059dd4e6dec2146dec63 Mon Sep 17 00:00:00 2001 From: Alexander Sabourenkov Date: Mon, 19 Nov 2012 23:28:35 +0400 Subject: [PATCH] GL 3.0 forward-compatible context test --- .../spec/glx_arb_create_context/CMakeLists.gl.txt | 1 + .../spec/glx_arb_create_context/fc-point-sprite.c | 121 ++++++++++++++++++++ 2 files changed, 122 insertions(+) create mode 100644 tests/spec/glx_arb_create_context/fc-point-sprite.c diff --git a/tests/spec/glx_arb_create_context/CMakeLists.gl.txt b/tests/spec/glx_arb_create_context/CMakeLists.gl.txt index 76c403a..01557a2 100644 --- a/tests/spec/glx_arb_create_context/CMakeLists.gl.txt +++ b/tests/spec/glx_arb_create_context/CMakeLists.gl.txt @@ -40,6 +40,7 @@ IF(PIGLIT_BUILD_GLX_TESTS) piglit_add_executable (glx-create-context-valid-attribute-empty valid-attribute-empty.c common.c) piglit_add_executable (glx-create-context-valid-attribute-null valid-attribute-null.c common.c) piglit_add_executable (glx-create-context-valid-flag-forward-compatible valid-flag-forward-compatible.c common.c) + piglit_add_executable (glx-create-context-fc-point-sprite fc-point-sprite.c common.c) ENDIF(PIGLIT_BUILD_GLX_TESTS) # vim: ft=cmake: diff --git a/tests/spec/glx_arb_create_context/fc-point-sprite.c b/tests/spec/glx_arb_create_context/fc-point-sprite.c new file mode 100644 index 0000000..65cdc7c --- /dev/null +++ b/tests/spec/glx_arb_create_context/fc-point-sprite.c @@ -0,0 +1,121 @@ +/* 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-gl-common.h" +#include "piglit-glx-util.h" +#include "common.h" + +static bool try_flag(int flag) +{ + const int attribs[] = { + GLX_CONTEXT_MAJOR_VERSION_ARB, 3, + GLX_CONTEXT_MINOR_VERSION_ARB, 0, + GLX_CONTEXT_FLAGS_ARB, flag, + None + }; + GLXContext ctx; + + ctx = glXCreateContextAttribsARB(dpy, fbconfig, NULL, True, attribs); + XSync(dpy, 0); + + if (ctx != NULL) { + /* The GLX_ARB_create_context spec says: + * + * "If the GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB is set + * in GLX_CONTEXT_FLAGS_ARB, then a + * context will becreated. Forward-compatible contexts are + * defined only for OpenGL versions 3.0 and later. They + * must not support functionality marked as + * by that version of the API, while a + * non-forward-compatible context must support all + * functionality in that version, deprecated or not." + * + * The glspec30.20080811.pdf says: + * + * "The features deprecated in OpenGL 3.0 are + * summarized below, + * + * and later in the same section: + * + * "* Non-sprite points (section 3.4) - Enable/Disable + * targets POINT SMOOTH and POINT SPRITE, and all + * associated state. Point rasterization is always per- + * formed as though POINT SPRITE were enabled." + * + */ + + glXMakeContextCurrent(dpy, glxWin, glxWin, ctx); + piglit_dispatch_default_init(); + while (GL_NO_ERROR != glGetError()); + glEnable(GL_POINT_SPRITE); + int e = glGetError(); + fprintf(stderr, "flag = 0x%08x err = 0x%08x\n", flag, e); + if ((GL_NO_ERROR == e) && flag) { + glXDestroyContext(dpy, ctx); + fprintf(stderr, "flag = 0x%08x\n", flag); + return false; + } + glXDestroyContext(dpy, ctx); + } else { + fprintf(stderr, "flag = 0x%08x ctx = null\n", flag); + /* 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 does not support compatible OpenGL + * contexts providing the requested API major and minor + * version, forward-compatible flag, and debug context + * flag, GLXBadFBConfig is generated." + * + * The glspec30.20080811.pdf says: + * + * "To aid developers in writing applications which will + * run on such future versions, it is possible to create + * an OpenGL 3.0 context which does not support + * deprecated features. + */ + + return false; + } + + return true; +} + +int main(int argc, char **argv) +{ + bool pass = true; + + GLX_ARB_create_context_setup(); + + pass = try_flag(0) && pass; + pass = try_flag(GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB) && pass; + + GLX_ARB_create_context_teardown(); + + piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); + return 0; +} -- 1.7.10.4