This imposes naming consistency with other util and framework sources: piglit-util-cl-*, piglit-util-gl-*, and piglit-framework-cl-*.
Signed-off-by: Chad Versace <chad.vers...@linux.intel.com> --- tests/util/CMakeLists.txt | 2 +- tests/util/piglit-framework-fbo.c | 2 +- tests/util/piglit-framework-gl.c | 172 +++++++++++++++++++++++++++++++++++++ tests/util/piglit-framework-gl.h | 159 ++++++++++++++++++++++++++++++++++ tests/util/piglit-framework-glut.c | 2 +- tests/util/piglit-framework.c | 172 ------------------------------------- tests/util/piglit-framework.h | 159 ---------------------------------- tests/util/piglit-util-gl-common.h | 2 +- 8 files changed, 335 insertions(+), 335 deletions(-) create mode 100644 tests/util/piglit-framework-gl.c create mode 100644 tests/util/piglit-framework-gl.h delete mode 100644 tests/util/piglit-framework.c delete mode 100644 tests/util/piglit-framework.h diff --git a/tests/util/CMakeLists.txt b/tests/util/CMakeLists.txt index b60683a..b7be449 100644 --- a/tests/util/CMakeLists.txt +++ b/tests/util/CMakeLists.txt @@ -19,7 +19,7 @@ set(UTIL_GL_SOURCES fdo-bitmap.c piglit-util-gl-common.c piglit-util-gl-enum.c - piglit-framework.c + piglit-framework-gl.c piglit-framework-fbo.c piglit-framework-glut.c piglit_ktx.c diff --git a/tests/util/piglit-framework-fbo.c b/tests/util/piglit-framework-fbo.c index f9046d8..1164f80 100644 --- a/tests/util/piglit-framework-fbo.c +++ b/tests/util/piglit-framework-fbo.c @@ -42,7 +42,7 @@ #include <stdlib.h> #include "piglit-util-gl-common.h" -#include "piglit-framework.h" +#include "piglit-framework-gl.h" #include "piglit-framework-fbo.h" #ifdef PIGLIT_FRAMEWORK_FBO_USE_GLX diff --git a/tests/util/piglit-framework-gl.c b/tests/util/piglit-framework-gl.c new file mode 100644 index 0000000..a6e4653 --- /dev/null +++ b/tests/util/piglit-framework-gl.c @@ -0,0 +1,172 @@ +/* + * Copyright © 2009 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. + */ + +/** + * Simple test case framework. + * + * \author Ian Romanick <ian.d.roman...@intel.com> + */ +#include <assert.h> +#include <string.h> +#include <stdio.h> +#include <stdlib.h> +#include <math.h> + +#include "piglit-util-gl-common.h" +#include "piglit-framework-gl.h" +#include "piglit-framework-fbo.h" +#include "piglit-framework-glut.h" + +bool piglit_use_fbo = false; +int piglit_automatic = 0; +unsigned piglit_winsys_fbo = 0; + +int piglit_width; +int piglit_height; + +void +piglit_gl_test_info_init(struct piglit_gl_test_info *info) +{ + memset(info, 0, sizeof(*info)); +} + +static void +delete_arg(char *argv[], int argc, int arg) +{ + int i; + + for (i = arg + 1; i < argc; i++) { + argv[i - 1] = argv[i]; + } +} + +/** + * Recognized arguments are removed from @a argv. The updated array + * length is returned in @a argc. + */ +static void +process_args(int *argc, char *argv[]) +{ + int j; + + /* Find/remove "-auto" and "-fbo" from the argument vector. + */ + for (j = 1; j < *argc; j++) { + if (!strcmp(argv[j], "-auto")) { + piglit_automatic = 1; + delete_arg(argv, *argc, j--); + *argc -= 1; + } else if (!strcmp(argv[j], "-fbo")) { + piglit_use_fbo = true; + delete_arg(argv, *argc, j--); + *argc -= 1; + } else if (!strcmp(argv[j], "-rlimit")) { + char *ptr; + unsigned long lim; + int i; + + j++; + if (j >= *argc) { + fprintf(stderr, + "-rlimit requires an argument\n"); + piglit_report_result(PIGLIT_FAIL); + } + + lim = strtoul(argv[j], &ptr, 0); + if (ptr == argv[j]) { + fprintf(stderr, + "-rlimit requires an argument\n"); + piglit_report_result(PIGLIT_FAIL); + } + + piglit_set_rlimit(lim); + + /* Remove 2 arguments (hence the 'i - 2') from the + * command line. + */ + for (i = j + 1; i < *argc; i++) { + argv[i - 2] = argv[i]; + } + *argc -= 2; + j -= 2; + } + } +} + +void +piglit_gl_test_run(int argc, char *argv[], + const struct piglit_gl_test_info *info) +{ + process_args(&argc, argv); + + piglit_width = info->window_width; + piglit_height = info->window_height; + + if (piglit_use_fbo) { + if (!piglit_framework_fbo_init(info)) + piglit_use_fbo = false; + } + + if (!piglit_use_fbo) + piglit_framework_glut_init(argc, argv, info); + + info->init(argc, argv); + + if (piglit_use_fbo) { + piglit_framework_fbo_run(info); + } else { + piglit_framework_glut_run(info); + } + + assert(false); +} + +void +piglit_post_redisplay(void) +{ + if (!piglit_use_fbo && !piglit_automatic) + glutPostRedisplay(); +} + +void +piglit_set_keyboard_func(void (*func)(unsigned char key, int x, int y)) +{ + if (!piglit_automatic && !piglit_use_fbo) + glutKeyboardFunc(func); +} + +void +piglit_swap_buffers(void) +{ + if (piglit_use_fbo) + piglit_framework_fbo_swap_buffers(); + else + piglit_framework_glut_swap_buffers(); +} + +void +piglit_set_reshape_func(void (*func)(int w, int h)) +{ + if (!piglit_use_fbo && !piglit_automatic) + glutReshapeFunc(func); +} diff --git a/tests/util/piglit-framework-gl.h b/tests/util/piglit-framework-gl.h new file mode 100644 index 0000000..6114dd3 --- /dev/null +++ b/tests/util/piglit-framework-gl.h @@ -0,0 +1,159 @@ +/* + * Copyright © 2009 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. + */ + +#pragma once +#ifndef PIGLIT_FRAMEWORK_H +#define PIGLIT_FRAMEWORK_H + +#include <assert.h> +#include <stdbool.h> + +/** + * A bitmask of these enums specifies visual attributes for the test's window. + * + * Each enum has the same value of its corresponding GLUT enum. That is, for + * each X, `PIGLIT_GL_VISUAL_X == GLUT_X`. + * + * \see piglit_gl_test_info::window_visual + */ +enum piglit_gl_visual { + PIGLIT_GL_VISUAL_RGB = 0, + PIGLIT_GL_VISUAL_RGBA = 0, + PIGLIT_GL_VISUAL_SINGLE = 0, + PIGLIT_GL_VISUAL_INDEX = 1 << 0, + PIGLIT_GL_VISUAL_DOUBLE = 1 << 1, + PIGLIT_GL_VISUAL_ACCUM = 1 << 2, + PIGLIT_GL_VISUAL_ALPHA = 1 << 3, + PIGLIT_GL_VISUAL_DEPTH = 1 << 4, + PIGLIT_GL_VISUAL_STENCIL = 1 << 5, +}; + +/** + * @brief Info needed to run an OpenGL test. + * + * To run a test, pass this to piglit_gl_test_run(). + * + * This is named piglit_gl_test_info, rather than piglit_test_info, in + * order to distinguish it from other test types, such as EGL and GLX tests. + * + * TODO: Add fields here that declare test requirements on GL context + * TODO: flavor, extensions, and window system. + */ +struct piglit_gl_test_info { + int window_width; + int window_height; + + /** + * A bitmask of `enum piglit_gl_visual`. + */ + int window_visual; + + /** + * This is called once per test, after the GL context has been created + * and made current but before display() is called. + */ + void + (*init)(int argc, char *argv[]); + + /** + * If the test is run in auto mode, then this is called once after + * init(). Otherwise, it is called repeatedly from some ill-defined + * event loop. + */ + enum piglit_result + (*display)(void); +}; + +/** + * Initialize @a info with default values. + */ +void +piglit_gl_test_info_init(struct piglit_gl_test_info *info); + +/** + * Run the OpenGL test described by @a info. Does not return. + */ +void +piglit_gl_test_run(int argc, char *argv[], + const struct piglit_gl_test_info *info); + +#ifdef __cplusplus +# define PIGLIT_EXTERN_C_BEGIN extern "C" { +# define PIGLIT_EXTERN_C_END } +#else +# define PIGLIT_EXTERN_C_BEGIN +# define PIGLIT_EXTERN_C_END +#endif + +/** + * Define a boilerplate main() that should be suitable for most OpenGL test + * executables. + */ +#define PIGLIT_GL_TEST_MAIN(_window_width, \ + _window_height, \ + _window_visual) \ + \ + PIGLIT_EXTERN_C_BEGIN \ + \ + void \ + piglit_init(int argc, char *argv[]); \ + \ + enum piglit_result \ + piglit_display(void); \ + \ + PIGLIT_EXTERN_C_END \ + \ + int \ + main(int argc, char *argv[]) \ + { \ + struct piglit_gl_test_info info; \ + \ + piglit_gl_test_info_init(&info); \ + \ + info.window_width = _window_width; \ + info.window_height = _window_height; \ + info.window_visual = _window_visual; \ + \ + info.init = piglit_init; \ + info.display = piglit_display; \ + \ + piglit_gl_test_run(argc, argv, &info); \ + \ + assert(false); \ + return 0; \ + } + +extern int piglit_automatic; + +extern int piglit_width; +extern int piglit_height; +extern bool piglit_use_fbo; +extern unsigned int piglit_winsys_fbo; + +void piglit_swap_buffers(void); +extern void piglit_present_results(); +void piglit_post_redisplay(void); +void piglit_set_keyboard_func(void (*func)(unsigned char key, int x, int y)); +void piglit_set_reshape_func(void (*func)(int w, int h)); + +#endif /* PIGLIT_FRAMEWORK_H */ diff --git a/tests/util/piglit-framework-glut.c b/tests/util/piglit-framework-glut.c index ea26404..d61eed6 100644 --- a/tests/util/piglit-framework-glut.c +++ b/tests/util/piglit-framework-glut.c @@ -28,7 +28,7 @@ #include <math.h> #include "piglit-util-gl-common.h" -#include "piglit-framework.h" +#include "piglit-framework-gl.h" #include "piglit-framework-glut.h" #ifdef USE_GLX diff --git a/tests/util/piglit-framework.c b/tests/util/piglit-framework.c deleted file mode 100644 index 03a5125..0000000 --- a/tests/util/piglit-framework.c +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright © 2009 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. - */ - -/** - * Simple test case framework. - * - * \author Ian Romanick <ian.d.roman...@intel.com> - */ -#include <assert.h> -#include <string.h> -#include <stdio.h> -#include <stdlib.h> -#include <math.h> - -#include "piglit-util-gl-common.h" -#include "piglit-framework.h" -#include "piglit-framework-fbo.h" -#include "piglit-framework-glut.h" - -bool piglit_use_fbo = false; -int piglit_automatic = 0; -unsigned piglit_winsys_fbo = 0; - -int piglit_width; -int piglit_height; - -void -piglit_gl_test_info_init(struct piglit_gl_test_info *info) -{ - memset(info, 0, sizeof(*info)); -} - -static void -delete_arg(char *argv[], int argc, int arg) -{ - int i; - - for (i = arg + 1; i < argc; i++) { - argv[i - 1] = argv[i]; - } -} - -/** - * Recognized arguments are removed from @a argv. The updated array - * length is returned in @a argc. - */ -static void -process_args(int *argc, char *argv[]) -{ - int j; - - /* Find/remove "-auto" and "-fbo" from the argument vector. - */ - for (j = 1; j < *argc; j++) { - if (!strcmp(argv[j], "-auto")) { - piglit_automatic = 1; - delete_arg(argv, *argc, j--); - *argc -= 1; - } else if (!strcmp(argv[j], "-fbo")) { - piglit_use_fbo = true; - delete_arg(argv, *argc, j--); - *argc -= 1; - } else if (!strcmp(argv[j], "-rlimit")) { - char *ptr; - unsigned long lim; - int i; - - j++; - if (j >= *argc) { - fprintf(stderr, - "-rlimit requires an argument\n"); - piglit_report_result(PIGLIT_FAIL); - } - - lim = strtoul(argv[j], &ptr, 0); - if (ptr == argv[j]) { - fprintf(stderr, - "-rlimit requires an argument\n"); - piglit_report_result(PIGLIT_FAIL); - } - - piglit_set_rlimit(lim); - - /* Remove 2 arguments (hence the 'i - 2') from the - * command line. - */ - for (i = j + 1; i < *argc; i++) { - argv[i - 2] = argv[i]; - } - *argc -= 2; - j -= 2; - } - } -} - -void -piglit_gl_test_run(int argc, char *argv[], - const struct piglit_gl_test_info *info) -{ - process_args(&argc, argv); - - piglit_width = info->window_width; - piglit_height = info->window_height; - - if (piglit_use_fbo) { - if (!piglit_framework_fbo_init(info)) - piglit_use_fbo = false; - } - - if (!piglit_use_fbo) - piglit_framework_glut_init(argc, argv, info); - - info->init(argc, argv); - - if (piglit_use_fbo) { - piglit_framework_fbo_run(info); - } else { - piglit_framework_glut_run(info); - } - - assert(false); -} - -void -piglit_post_redisplay(void) -{ - if (!piglit_use_fbo && !piglit_automatic) - glutPostRedisplay(); -} - -void -piglit_set_keyboard_func(void (*func)(unsigned char key, int x, int y)) -{ - if (!piglit_automatic && !piglit_use_fbo) - glutKeyboardFunc(func); -} - -void -piglit_swap_buffers(void) -{ - if (piglit_use_fbo) - piglit_framework_fbo_swap_buffers(); - else - piglit_framework_glut_swap_buffers(); -} - -void -piglit_set_reshape_func(void (*func)(int w, int h)) -{ - if (!piglit_use_fbo && !piglit_automatic) - glutReshapeFunc(func); -} diff --git a/tests/util/piglit-framework.h b/tests/util/piglit-framework.h deleted file mode 100644 index 6114dd3..0000000 --- a/tests/util/piglit-framework.h +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright © 2009 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. - */ - -#pragma once -#ifndef PIGLIT_FRAMEWORK_H -#define PIGLIT_FRAMEWORK_H - -#include <assert.h> -#include <stdbool.h> - -/** - * A bitmask of these enums specifies visual attributes for the test's window. - * - * Each enum has the same value of its corresponding GLUT enum. That is, for - * each X, `PIGLIT_GL_VISUAL_X == GLUT_X`. - * - * \see piglit_gl_test_info::window_visual - */ -enum piglit_gl_visual { - PIGLIT_GL_VISUAL_RGB = 0, - PIGLIT_GL_VISUAL_RGBA = 0, - PIGLIT_GL_VISUAL_SINGLE = 0, - PIGLIT_GL_VISUAL_INDEX = 1 << 0, - PIGLIT_GL_VISUAL_DOUBLE = 1 << 1, - PIGLIT_GL_VISUAL_ACCUM = 1 << 2, - PIGLIT_GL_VISUAL_ALPHA = 1 << 3, - PIGLIT_GL_VISUAL_DEPTH = 1 << 4, - PIGLIT_GL_VISUAL_STENCIL = 1 << 5, -}; - -/** - * @brief Info needed to run an OpenGL test. - * - * To run a test, pass this to piglit_gl_test_run(). - * - * This is named piglit_gl_test_info, rather than piglit_test_info, in - * order to distinguish it from other test types, such as EGL and GLX tests. - * - * TODO: Add fields here that declare test requirements on GL context - * TODO: flavor, extensions, and window system. - */ -struct piglit_gl_test_info { - int window_width; - int window_height; - - /** - * A bitmask of `enum piglit_gl_visual`. - */ - int window_visual; - - /** - * This is called once per test, after the GL context has been created - * and made current but before display() is called. - */ - void - (*init)(int argc, char *argv[]); - - /** - * If the test is run in auto mode, then this is called once after - * init(). Otherwise, it is called repeatedly from some ill-defined - * event loop. - */ - enum piglit_result - (*display)(void); -}; - -/** - * Initialize @a info with default values. - */ -void -piglit_gl_test_info_init(struct piglit_gl_test_info *info); - -/** - * Run the OpenGL test described by @a info. Does not return. - */ -void -piglit_gl_test_run(int argc, char *argv[], - const struct piglit_gl_test_info *info); - -#ifdef __cplusplus -# define PIGLIT_EXTERN_C_BEGIN extern "C" { -# define PIGLIT_EXTERN_C_END } -#else -# define PIGLIT_EXTERN_C_BEGIN -# define PIGLIT_EXTERN_C_END -#endif - -/** - * Define a boilerplate main() that should be suitable for most OpenGL test - * executables. - */ -#define PIGLIT_GL_TEST_MAIN(_window_width, \ - _window_height, \ - _window_visual) \ - \ - PIGLIT_EXTERN_C_BEGIN \ - \ - void \ - piglit_init(int argc, char *argv[]); \ - \ - enum piglit_result \ - piglit_display(void); \ - \ - PIGLIT_EXTERN_C_END \ - \ - int \ - main(int argc, char *argv[]) \ - { \ - struct piglit_gl_test_info info; \ - \ - piglit_gl_test_info_init(&info); \ - \ - info.window_width = _window_width; \ - info.window_height = _window_height; \ - info.window_visual = _window_visual; \ - \ - info.init = piglit_init; \ - info.display = piglit_display; \ - \ - piglit_gl_test_run(argc, argv, &info); \ - \ - assert(false); \ - return 0; \ - } - -extern int piglit_automatic; - -extern int piglit_width; -extern int piglit_height; -extern bool piglit_use_fbo; -extern unsigned int piglit_winsys_fbo; - -void piglit_swap_buffers(void); -extern void piglit_present_results(); -void piglit_post_redisplay(void); -void piglit_set_keyboard_func(void (*func)(unsigned char key, int x, int y)); -void piglit_set_reshape_func(void (*func)(int w, int h)); - -#endif /* PIGLIT_FRAMEWORK_H */ diff --git a/tests/util/piglit-util-gl-common.h b/tests/util/piglit-util-gl-common.h index c5e814c..8c1a110 100644 --- a/tests/util/piglit-util-gl-common.h +++ b/tests/util/piglit-util-gl-common.h @@ -36,7 +36,7 @@ extern "C" { #define piglit_get_proc_address(x) piglit_dispatch_resolve_function(x) -#include "piglit-framework.h" +#include "piglit-framework-gl.h" #include "piglit-shader.h" extern const uint8_t fdo_bitmap[]; -- 1.7.12.1 _______________________________________________ Piglit mailing list Piglit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/piglit