diff options
-rw-r--r-- | tests/all.py | 1 | ||||
-rw-r--r-- | tests/glx/CMakeLists.gl.txt | 1 | ||||
-rw-r--r-- | tests/glx/glx-buffer-age.c | 117 |
3 files changed, 119 insertions, 0 deletions
diff --git a/tests/all.py b/tests/all.py index 664201985..d8fba3b64 100644 --- a/tests/all.py +++ b/tests/all.py @@ -705,6 +705,7 @@ add_plain_test(glx, 'glx-swap-pixmap-bad') add_plain_test(glx, 'glx-swap-singlebuffer') add_plain_test(glx, 'glx-make-current') add_plain_test(glx, 'glx-make-glxdrawable-current') +add_plain_test(glx, 'glx-buffer-age') add_concurrent_test(glx, 'glx-pixmap-life') add_concurrent_test(glx, 'glx-pixmap13-life') add_concurrent_test(glx, 'glx-pixmap-multi') diff --git a/tests/glx/CMakeLists.gl.txt b/tests/glx/CMakeLists.gl.txt index 7f3a71391..eeb1d7ad8 100644 --- a/tests/glx/CMakeLists.gl.txt +++ b/tests/glx/CMakeLists.gl.txt @@ -70,6 +70,7 @@ IF(PIGLIT_BUILD_GLX_TESTS) piglit_add_executable (glx-copy-sub-buffer glx-copy-sub-buffer.c) piglit_add_executable (glx-query-drawable glx-query-drawable.c) + piglit_add_executable (glx-buffer-age glx-buffer-age.c) piglit_add_executable (glx-string-sanity glx-string-sanity.c) ENDIF(PIGLIT_BUILD_GLX_TESTS) diff --git a/tests/glx/glx-buffer-age.c b/tests/glx/glx-buffer-age.c new file mode 100644 index 000000000..35a9e0c22 --- /dev/null +++ b/tests/glx/glx-buffer-age.c @@ -0,0 +1,117 @@ +/* + * Copyright Christopher James Halse Rogers <christopher.halse.rogers at canonical.com> + * Copyright 2010 Red Hat, Inc. + * Copyright 2014 Adel Gadllah <adel.gadllah@gmail.com> + * + * 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. + * + * Authors: + * Christopher James Halse Rogers <christopher.halse.rogers at canonical.com> + * Adam Jackson <ajax@redhat.com> + * Adel Gadllah <adel.gadllah@gmail.com> + * + * Derived from glx-copy-sub-buffer.c + * + */ + +/** @file glx-buffer-age.c + * + * Test that GLX_EXT_buffer_age works as advertised + */ + +#include "piglit-util-gl-common.h" +#include "piglit-glx-util.h" + +#ifndef GLX_BACK_BUFFER_AGE_EXT +#define GLX_BACK_BUFFER_AGE_EXT 0x20F4 +#endif + +int piglit_width = 100, piglit_height = 100; +static Display *dpy; +static Window window; +static XVisualInfo *visinfo; + +enum piglit_result +draw(Display *dpy) +{ + GLXContext ctx; + GLboolean pass; + unsigned int age; + int i; + static GLfloat colors[3][4] = {{1.0, 0.0, 0.0, 1.0}, + {0.0, 1.0, 0.0, 1.0}, + {0.0, 0.0, 1.0, 1.0}}; + GLfloat probe[4]; + enum piglit_result result; + + ctx = piglit_get_glx_context(dpy, visinfo); + glXMakeCurrent(dpy, window, ctx); + piglit_dispatch_default_init(PIGLIT_DISPATCH_GL); + + for (i = 0; i < 3; i++) { + glClearColor(colors[i][0], + colors[i][1], + colors[i][2], + colors[i][3]); + glClear(GL_COLOR_BUFFER_BIT); + glXSwapBuffers(dpy, window); + } + + glXQueryDrawable(dpy, window, GLX_BACK_BUFFER_AGE_EXT, &age); + + if (age == 0 || age > 3) { + result = PIGLIT_SKIP; + goto out; + } + + pass = piglit_probe_pixel_rgba_silent(0, 0, colors[3 - age], probe); + result = pass ? PIGLIT_PASS : PIGLIT_FAIL; + +out: + glXMakeCurrent(dpy, None, NULL); + glXDestroyContext(dpy, ctx); + + return result; +} + + +int +main(int argc, char **argv) +{ + int i; + + for(i = 1; i < argc; i++) { + if (!strcmp(argv[i], "-auto")) + piglit_automatic = 1; + else + fprintf(stderr, "Unknown option: %s\n", argv[i]); + } + + dpy = piglit_get_glx_display(); + piglit_require_glx_extension(dpy, "EXT_buffer_age"); + visinfo = piglit_get_glx_visual(dpy); + window = piglit_get_glx_window(dpy, visinfo); + + XMapWindow(dpy, window); + + piglit_glx_event_loop(dpy, draw); + + return 0; +} |