diff options
author | Eric Anholt <eric@anholt.net> | 2013-12-12 13:10:20 -0800 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2014-04-11 11:12:33 -0700 |
commit | 7b66ed1dad43e2c6353700b6225c391a0c9ba2dc (patch) | |
tree | b73d23cc90e6d4d05bdb81611ef94fd2f2c1d0a8 | |
parent | a8c7358c0061c75f0d00535b7bdb5f98dcf16b79 (diff) |
egl: Convert tests to using epoxy for EGL function pointer management.
v2: Also apply epoxy to egl_khr_create_context/common.h (by Fabian
Bieler)
v3: Remove more conditional compiile stuff thanks to epoxy.
v4: Rebase on the non-pkgconfig epoxy change.
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> (v2)
-rw-r--r-- | tests/egl/egl-nok-swap-region.c | 29 | ||||
-rw-r--r-- | tests/egl/egl-nok-texture-from-pixmap.c | 20 | ||||
-rw-r--r-- | tests/egl/egl-query-surface.c | 1 | ||||
-rw-r--r-- | tests/egl/egl-util.h | 3 | ||||
-rw-r--r-- | tests/egl/spec/egl_ext_client_extensions/CMakeLists.no_api.txt | 1 | ||||
-rw-r--r-- | tests/egl/spec/egl_khr_create_context/common.h | 28 | ||||
-rw-r--r-- | tests/spec/ext_image_dma_buf_import/CMakeLists.gles1.txt | 12 | ||||
-rw-r--r-- | tests/spec/ext_image_dma_buf_import/CMakeLists.gles2.txt | 4 | ||||
-rw-r--r-- | tests/spec/ext_image_dma_buf_import/image_common.c | 77 | ||||
-rw-r--r-- | tests/spec/ext_image_dma_buf_import/image_common.h | 44 | ||||
-rw-r--r-- | tests/spec/oes_draw_texture/oes_draw_texture.c | 20 | ||||
-rw-r--r-- | tests/util/piglit-util-egl.h | 3 |
12 files changed, 24 insertions, 218 deletions
diff --git a/tests/egl/egl-nok-swap-region.c b/tests/egl/egl-nok-swap-region.c index b32bec981..9591310f8 100644 --- a/tests/egl/egl-nok-swap-region.c +++ b/tests/egl/egl-nok-swap-region.c @@ -29,12 +29,9 @@ */ #include "piglit-util-gl-common.h" +#include "piglit-util-egl.h" #include "egl-util.h" -#ifdef EGL_NOK_swap_region - -const char *extensions[] = { "EGL_NOK_swap_region", NULL }; - static enum piglit_result draw(struct egl_state *state) { @@ -66,16 +63,9 @@ draw(struct egl_state *state) { 55, 55, red }, { 55, state->height - 55, green }, }; - PFNEGLSWAPBUFFERSREGIONNOK swap_buffers_region; int i; - swap_buffers_region = (PFNEGLSWAPBUFFERSREGIONNOK) - eglGetProcAddress("eglSwapBuffersRegionNOK"); - - if (swap_buffers_region == NULL) { - fprintf(stderr, "could not getproc eglSwapBuffersRegionNOK"); - piglit_report_result(PIGLIT_PASS); - } + piglit_require_egl_extension("EGL_NOK_swap_region"); /* Clear background to green */ glClearColor(0.0, 1.0, 0.0, 1.0); @@ -83,7 +73,7 @@ draw(struct egl_state *state) eglSwapBuffers(state->egl_dpy, state->surf); glClearColor(1.0, 0.0, 0.0, 1.0); glClear(GL_COLOR_BUFFER_BIT); - swap_buffers_region(state->egl_dpy, state->surf, 4, rects); + eglSwapBuffersRegionNOK(state->egl_dpy, state->surf, 4, rects); glFinish(); @@ -103,20 +93,7 @@ main(int argc, char *argv[]) struct egl_test test; egl_init_test(&test); - test.extensions = extensions; test.draw = draw; return egl_util_run(&test, argc, argv); } - -#else - -int -main(int argc, char *argv[]) -{ - piglit_report_result(PIGLIT_SKIP); - - return 0; -} - -#endif diff --git a/tests/egl/egl-nok-texture-from-pixmap.c b/tests/egl/egl-nok-texture-from-pixmap.c index 026e17bc8..95268b680 100644 --- a/tests/egl/egl-nok-texture-from-pixmap.c +++ b/tests/egl/egl-nok-texture-from-pixmap.c @@ -29,12 +29,9 @@ */ #include "piglit-util-gl-common.h" +#include "piglit-util-egl.h" #include "egl-util.h" -#ifdef EGL_NOK_texture_from_pixmap - -const char *extensions[] = { "EGL_NOK_texture_from_pixmap", NULL }; - static const EGLint pixmap_attribs[] = { EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGB, EGL_TEXTURE_TARGET, EGL_TEXTURE_2D, @@ -49,6 +46,8 @@ draw(struct egl_state *state) float red[] = { 0.4, 0.0, 0.0, 1.0 }; float purple[] = { 0.5, 0.0, 0.5, 1.0 }; + piglit_require_egl_extension("EGL_NOK_texture_from_pixmap"); + if (!eglGetConfigAttrib(state->egl_dpy, state->cfg, EGL_Y_INVERTED_NOK, &inv)) { fprintf(stderr, @@ -106,20 +105,7 @@ main(int argc, char *argv[]) struct egl_test test; egl_init_test(&test); - test.extensions = extensions; test.draw = draw; return egl_util_run(&test, argc, argv); } - -#else - -int -main(int argc, char *argv[]) -{ - piglit_report_result(PIGLIT_SKIP); - - return 0; -} - -#endif diff --git a/tests/egl/egl-query-surface.c b/tests/egl/egl-query-surface.c index d6424e4de..bff0185bc 100644 --- a/tests/egl/egl-query-surface.c +++ b/tests/egl/egl-query-surface.c @@ -29,7 +29,6 @@ * For usage information, see usage_error(). */ -#include <EGL/egl.h> #include "piglit-util-egl.h" #include "egl-util.h" diff --git a/tests/egl/egl-util.h b/tests/egl/egl-util.h index e1caa9432..5bfd3ee26 100644 --- a/tests/egl/egl-util.h +++ b/tests/egl/egl-util.h @@ -13,8 +13,7 @@ #include <X11/Xutil.h> #include <X11/keysym.h> #include <GL/gl.h> -#include <EGL/egl.h> -#include <EGL/eglext.h> +#include <epoxy/egl.h> struct egl_state { Display *dpy; diff --git a/tests/egl/spec/egl_ext_client_extensions/CMakeLists.no_api.txt b/tests/egl/spec/egl_ext_client_extensions/CMakeLists.no_api.txt index 3c3fe3653..b954a660e 100644 --- a/tests/egl/spec/egl_ext_client_extensions/CMakeLists.no_api.txt +++ b/tests/egl/spec/egl_ext_client_extensions/CMakeLists.no_api.txt @@ -1,5 +1,6 @@ link_libraries( piglitutil + ${EPOXY_LIBRARY} ) piglit_add_executable(egl_ext_client_extensions egl_ext_client_extensions.c) diff --git a/tests/egl/spec/egl_khr_create_context/common.h b/tests/egl/spec/egl_khr_create_context/common.h index 7aabe7b28..ba443fc9e 100644 --- a/tests/egl/spec/egl_khr_create_context/common.h +++ b/tests/egl/spec/egl_khr_create_context/common.h @@ -22,33 +22,7 @@ #include "piglit-util-gl-common.h" #include <X11/Xlib.h> -#include <EGL/egl.h> -#include <EGL/eglext.h> - -/* In case eglext.h isn't new enough: */ -#ifndef EGL_KHR_create_context -#define EGL_KHR_create_context 1 -#define EGL_CONTEXT_MAJOR_VERSION_KHR EGL_CONTEXT_CLIENT_VERSION -#define EGL_CONTEXT_MINOR_VERSION_KHR 0x30FB -#define EGL_CONTEXT_FLAGS_KHR 0x30FC -#define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR 0x30FD -#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR 0x31BD -#define EGL_NO_RESET_NOTIFICATION_KHR 0x31BE -#define EGL_LOSE_CONTEXT_ON_RESET_KHR 0x31BF -#define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR 0x00000001 -#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002 -#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR 0x00000004 -#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001 -#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR 0x00000002 -#endif - -/* Old versions of eglext.h may define EGL_KHR_create_context without defining - * the EGL_OPENGL_ES3_BIT_KHR, because the bit was not defined until version - * 13 of the extension. - */ -#ifndef EGL_OPENGL_ES3_BIT_KHR -#define EGL_OPENGL_ES3_BIT_KHR 0x00000040 -#endif +#include <epoxy/egl.h> extern EGLDisplay egl_dpy; extern EGLConfig cfg; diff --git a/tests/spec/ext_image_dma_buf_import/CMakeLists.gles1.txt b/tests/spec/ext_image_dma_buf_import/CMakeLists.gles1.txt index fa9630381..289c94399 100644 --- a/tests/spec/ext_image_dma_buf_import/CMakeLists.gles1.txt +++ b/tests/spec/ext_image_dma_buf_import/CMakeLists.gles1.txt @@ -18,12 +18,12 @@ if(PIGLIT_BUILD_DMA_BUF_TESTS) ${LIBDRM_INCLUDE_DIRS} ) - piglit_add_executable(ext_image_dma_buf_import-invalid_hints invalid_hints.c image_common.c) - piglit_add_executable(ext_image_dma_buf_import-invalid_attributes invalid_attributes.c image_common.c) - piglit_add_executable(ext_image_dma_buf_import-missing_attributes missing_attributes.c image_common.c) - piglit_add_executable(ext_image_dma_buf_import-ownership_transfer ownership_transfer.c image_common.c) - piglit_add_executable(ext_image_dma_buf_import-intel_unsupported_format intel_unsupported_format.c image_common.c) - piglit_add_executable(ext_image_dma_buf_import-intel_external_sampler_only intel_external_sampler_only.c image_common.c) + piglit_add_executable(ext_image_dma_buf_import-invalid_hints invalid_hints.c) + piglit_add_executable(ext_image_dma_buf_import-invalid_attributes invalid_attributes.c) + piglit_add_executable(ext_image_dma_buf_import-missing_attributes missing_attributes.c) + piglit_add_executable(ext_image_dma_buf_import-ownership_transfer ownership_transfer.c) + piglit_add_executable(ext_image_dma_buf_import-intel_unsupported_format intel_unsupported_format.c) + piglit_add_executable(ext_image_dma_buf_import-intel_external_sampler_only intel_external_sampler_only.c) endif() # vim: ft=cmake: diff --git a/tests/spec/ext_image_dma_buf_import/CMakeLists.gles2.txt b/tests/spec/ext_image_dma_buf_import/CMakeLists.gles2.txt index 80f1c8355..deb002ad5 100644 --- a/tests/spec/ext_image_dma_buf_import/CMakeLists.gles2.txt +++ b/tests/spec/ext_image_dma_buf_import/CMakeLists.gles2.txt @@ -16,8 +16,8 @@ if(PIGLIT_BUILD_DMA_BUF_TESTS) ${LIBDRM_INCLUDE_DIRS} ) - piglit_add_executable(ext_image_dma_buf_import-sample_rgb sample_rgb.c sample_common.c image_common.c) - piglit_add_executable(ext_image_dma_buf_import-intel_external_sampler_with_dma_only intel_external_sampler_with_dma_only.c image_common.c) + piglit_add_executable(ext_image_dma_buf_import-sample_rgb sample_rgb.c sample_common.c) + piglit_add_executable(ext_image_dma_buf_import-intel_external_sampler_with_dma_only intel_external_sampler_with_dma_only.c) endif() # vim: ft=cmake: diff --git a/tests/spec/ext_image_dma_buf_import/image_common.c b/tests/spec/ext_image_dma_buf_import/image_common.c deleted file mode 100644 index af01c3dcf..000000000 --- a/tests/spec/ext_image_dma_buf_import/image_common.c +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright © 2013 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 "image_common.h" - -static void -image_common_unsupported(const char *name) -{ - printf("Function \"%s\" not supported on this implementation\n", name); - piglit_report_result(PIGLIT_SKIP); -} - -static void -resolve_eglCreateImageKHR() -{ - if (piglit_is_egl_extension_supported(eglGetCurrentDisplay(), - "EGL_KHR_image_base")) - image_common_dispatch_eglCreateImageKHR = - (PFNEGLCREATEIMAGEKHRPROC) eglGetProcAddress( - "eglCreateImageKHR"); - else - image_common_unsupported("CreateImageKHR"); -} - -static EGLImageKHR EGLAPIENTRY -stub_eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target, - EGLClientBuffer buffer, const EGLint *attrib_list) -{ - resolve_eglCreateImageKHR(); - return image_common_dispatch_eglCreateImageKHR(dpy, ctx, target, buffer, - attrib_list); -} - -PFNEGLCREATEIMAGEKHRPROC image_common_dispatch_eglCreateImageKHR = - stub_eglCreateImageKHR; - -static void -resolve_eglDestroyImageKHR() -{ - if (piglit_is_egl_extension_supported(eglGetCurrentDisplay(), - "EGL_KHR_image_base")) - image_common_dispatch_eglDestroyImageKHR = - (PFNEGLDESTROYIMAGEKHRPROC ) eglGetProcAddress( - "eglDestroyImageKHR"); - else - image_common_unsupported("DestroyImageKHR"); -} - -static EGLBoolean EGLAPIENTRY -stub_eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR image) -{ - resolve_eglDestroyImageKHR(); - return image_common_dispatch_eglDestroyImageKHR(dpy, image); -} - -PFNEGLDESTROYIMAGEKHRPROC image_common_dispatch_eglDestroyImageKHR = - stub_eglDestroyImageKHR; diff --git a/tests/spec/ext_image_dma_buf_import/image_common.h b/tests/spec/ext_image_dma_buf_import/image_common.h index 3ace6bc4f..f7545c75c 100644 --- a/tests/spec/ext_image_dma_buf_import/image_common.h +++ b/tests/spec/ext_image_dma_buf_import/image_common.h @@ -23,54 +23,10 @@ #ifndef IMAGE_COMMON_H #define IMAGE_COMMON_H -/** - * Temporary local dispatcer for EGL extensions. This can be replaced with the - * proper support once it is in place for EGL in the piglit core. - * - * A call in the tests is re-directed by the precompiler to a dispatcher that - * checks the availability of the real extension and takes care of the linking. - */ - #include <unistd.h> #include <drm_fourcc.h> #include "piglit-util-egl.h" #include "piglit-util-gl-common.h" -/* We define here the enums for EGL_EXT_image_dma_buf_import because, as of - * today (2013-09-10), the eglext.h on many systems lack them. The first Mesa - * version in which eglext.h defined the enums was Mesa 9.2 (2013-08-27). - */ -#ifndef EGL_EXT_image_dma_buf_import -#define EGL_EXT_image_dma_buf_import 1 -#define EGL_LINUX_DMA_BUF_EXT 0x3270 -#define EGL_LINUX_DRM_FOURCC_EXT 0x3271 -#define EGL_DMA_BUF_PLANE0_FD_EXT 0x3272 -#define EGL_DMA_BUF_PLANE0_OFFSET_EXT 0x3273 -#define EGL_DMA_BUF_PLANE0_PITCH_EXT 0x3274 -#define EGL_DMA_BUF_PLANE1_FD_EXT 0x3275 -#define EGL_DMA_BUF_PLANE1_OFFSET_EXT 0x3276 -#define EGL_DMA_BUF_PLANE1_PITCH_EXT 0x3277 -#define EGL_DMA_BUF_PLANE2_FD_EXT 0x3278 -#define EGL_DMA_BUF_PLANE2_OFFSET_EXT 0x3279 -#define EGL_DMA_BUF_PLANE2_PITCH_EXT 0x327A -#define EGL_YUV_COLOR_SPACE_HINT_EXT 0x327B -#define EGL_SAMPLE_RANGE_HINT_EXT 0x327C -#define EGL_YUV_CHROMA_HORIZONTAL_SITING_HINT_EXT 0x327D -#define EGL_YUV_CHROMA_VERTICAL_SITING_HINT_EXT 0x327E -#define EGL_ITU_REC601_EXT 0x327F -#define EGL_ITU_REC709_EXT 0x3280 -#define EGL_ITU_REC2020_EXT 0x3281 -#define EGL_YUV_FULL_RANGE_EXT 0x3282 -#define EGL_YUV_NARROW_RANGE_EXT 0x3283 -#define EGL_YUV_CHROMA_SITING_0_EXT 0x3284 -#define EGL_YUV_CHROMA_SITING_0_5_EXT 0x3285 -#endif - -extern PFNEGLCREATEIMAGEKHRPROC image_common_dispatch_eglCreateImageKHR; -#define eglCreateImageKHR image_common_dispatch_eglCreateImageKHR - -extern PFNEGLDESTROYIMAGEKHRPROC image_common_dispatch_eglDestroyImageKHR; -#define eglDestroyImageKHR image_common_dispatch_eglDestroyImageKHR - #endif /* IMAGE_COMMON_H */ diff --git a/tests/spec/oes_draw_texture/oes_draw_texture.c b/tests/spec/oes_draw_texture/oes_draw_texture.c index 75cfd924f..26aa8bc66 100644 --- a/tests/spec/oes_draw_texture/oes_draw_texture.c +++ b/tests/spec/oes_draw_texture/oes_draw_texture.c @@ -28,8 +28,6 @@ * Test GL_OES_draw_texture. */ -#include <EGL/egl.h> - #include "piglit-util-gl-common.h" #define TEXTURE_SIZE 2 @@ -50,8 +48,6 @@ static const float green[4] = { 0.0f, 1.0f, 0.0f, 0.25f }; static const float blue[4] = { 0.0f, 0.0f, 1.0f, 0.50f }; static const float white[4] = { 1.0f, 1.0f, 1.0f, 1.0f }; -static PFNGLDRAWTEXIOESPROC piglit_glDrawTexiOES; - /** * Test the basic use of glDrawTex */ @@ -68,7 +64,7 @@ test_basic(void) glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, crop); /* draw the RGBW texture */ - piglit_glDrawTexiOES(0, 0, 0, piglit_width, piglit_height); + glDrawTexiOES(0, 0, 0, piglit_width, piglit_height); pass = piglit_probe_pixel_rgb(x, y, red); pass = piglit_probe_pixel_rgb(x + 5, y, green) && pass; @@ -97,7 +93,7 @@ test_negative_crop(void) glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, crop); /* draw the RGBW texture with negative crop */ - piglit_glDrawTexiOES(0, 0, 0, piglit_width, piglit_height); + glDrawTexiOES(0, 0, 0, piglit_width, piglit_height); pass = piglit_probe_pixel_rgb(x, y, white); pass = piglit_probe_pixel_rgb(x + 5, y, blue) && pass; @@ -128,7 +124,7 @@ test_right_top_crop(void) glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, crop); /* draw the right top quarter of RGBW texture */ - piglit_glDrawTexiOES(0, 0, 0, piglit_width, piglit_height); + glDrawTexiOES(0, 0, 0, piglit_width, piglit_height); pass = piglit_probe_pixel_rgb(x, y, white); pass = piglit_probe_pixel_rgb(x + 5, y, white) && pass; @@ -159,7 +155,7 @@ test_right_top_win(void) glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, crop); /* draw the RGBW texture at the right top */ - piglit_glDrawTexiOES(half_width, half_height, 0, half_width, half_height); + glDrawTexiOES(half_width, half_height, 0, half_width, half_height); pass = piglit_probe_pixel_rgb(x, y, red); pass = piglit_probe_pixel_rgb(x + 5, y, green) && pass; @@ -190,9 +186,9 @@ test_depth(void) glEnable(GL_DEPTH_TEST); /* draw at near plane */ - piglit_glDrawTexiOES(0, 0, 0, piglit_width, piglit_height); + glDrawTexiOES(0, 0, 0, piglit_width, piglit_height); /* draw at far plane: should be no-op */ - piglit_glDrawTexiOES(0, 0, 1, piglit_width / 2, piglit_height / 2); + glDrawTexiOES(0, 0, 1, piglit_width / 2, piglit_height / 2); glDisable(GL_DEPTH_TEST); @@ -229,10 +225,6 @@ piglit_init(int argc, char **argv) GLuint tex; piglit_require_extension("GL_OES_draw_texture"); - piglit_glDrawTexiOES = (PFNGLDRAWTEXIOESPROC) - eglGetProcAddress("glDrawTexiOES"); - if (!piglit_glDrawTexiOES) - piglit_report_result(PIGLIT_FAIL); piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE); diff --git a/tests/util/piglit-util-egl.h b/tests/util/piglit-util-egl.h index 62ce74943..46f4fa341 100644 --- a/tests/util/piglit-util-egl.h +++ b/tests/util/piglit-util-egl.h @@ -25,8 +25,7 @@ #define EGL_EGLEXT_PROTOTYPES -#include <EGL/egl.h> -#include <EGL/eglext.h> +#include <epoxy/egl.h> #include "piglit-util.h" |