[Piglit] [PATCH 5/7] egl: Convert tests to using epoxy for EGL function pointer management.

Eric Anholt eric at anholt.net
Mon Feb 24 11:41:12 PST 2014


v2: Also apply epoxy to egl_khr_create_context/common.h (by Fabian
    Bieler)
---
 tests/egl/egl-query-surface.c                      |  1 -
 tests/egl/egl-util.h                               |  3 +-
 .../CMakeLists.no_api.txt                          |  1 +
 tests/egl/spec/egl_khr_create_context/common.h     | 28 +-------
 .../ext_image_dma_buf_import/CMakeLists.gles1.txt  | 12 ++--
 .../ext_image_dma_buf_import/CMakeLists.gles2.txt  |  4 +-
 tests/spec/ext_image_dma_buf_import/image_common.c | 77 ----------------------
 tests/spec/ext_image_dma_buf_import/image_common.h | 44 -------------
 tests/spec/oes_draw_texture/oes_draw_texture.c     | 20 ++----
 tests/util/piglit-util-egl.h                       |  3 +-
 10 files changed, 18 insertions(+), 175 deletions(-)
 delete mode 100644 tests/spec/ext_image_dma_buf_import/image_common.c

diff --git a/tests/egl/egl-query-surface.c b/tests/egl/egl-query-surface.c
index d6424e4..bff0185 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 e1caa94..5bfd3ee 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 3c3fe36..d43defc 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_LDFLAGS}
 )
 
 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 7aabe7b..ba443fc 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 fa96303..289c943 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 80f1c83..deb002a 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 af01c3d..0000000
--- 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 3ace6bc..f7545c7 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 75cfd92..26aa8bc 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 62ce749..46f4fa3 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"
 
-- 
1.9.rc1



More information about the Piglit mailing list