[Glamor] [PATCH] autoconf: configuration for egl, gbm and dri3 support

Gaetan Nadon memsize at videotron.ca
Sun Dec 15 10:38:18 PST 2013


Additional tests have been added for the dri3 glamor code to use:
    Declaration of DRM_FORMAT_ARGB8888
    Declaration of EGL_KHR_image is declared
    Declaration of EGL_KHR_gl_texture_2D_image
    Declaration of EGL_EXT_image_dma_buf_import
    EGLNativePixmapType must refer to a gbm_bo structure
    Libgbm is at version 9 or greater

The tests are performed if the libraries/headers are present, they are not
limited to the dri3 support context. They are reusable.

One missing behaviour has been added. When the user explicitly requests
dri3 support and it can not be provided, abort the configuration.
This is the case when user types "--enable-glamor-dri3".

Summary of the test scenarios:
EGL:no	GBM:no	--enable-glamor-dri3=auto|no
EGL:no	GBM:v8	--enable-glamor-dri3=auto|no
EGL:yes	GBM:no	--enable-glamor-dri3=auto|no
EGL:yes	GBM:no	--enable-glamor-dri3=yes
EGL:yes	GBM:v8	--enable-glamor-dri3=auto|no
EGL:yes	GBM:v9	--enable-glamor-dri3=auto
EGL:yes	GBM:v9	--enable-glamor-dri3=no
EGL:yes	GBM:v9	--enable-glamor-dri3=auto EGL_KHR_gl_texture_2D_image is missing
EGL:yes	GBM:v9	--enable-glamor-dri3=auto DRM_FORMAT_ARGB8888 is missing

Reported-by: Axel Davy <axel.davy at ens.fr>
Signed-off-by: Gaetan Nadon <memsize at videotron.ca>
---
 configure.ac |  143 +++++++++++++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 122 insertions(+), 21 deletions(-)

diff --git a/configure.ac b/configure.ac
index b1c4c7f..d5a09d5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -56,13 +56,9 @@ PKG_PROG_PKG_CONFIG
 PKG_CHECK_MODULES(XORG, [xorg-server >= 1.10])
 PKG_CHECK_MODULES(DRI2, [dri2proto >= 2.6])
 
-LIBDRM="libdrm >= 2.4.23"
 LIBGL="gl >= 7.1.0"
 LIBPIXMAN="pixman-1 >= 0.21.8"
-LIBEGL="egl"
 LIBGLESV2="glesv2"
-LIBGBM="gbm"
-LIBGBMv9="gbm >= 9"
 
 # Define a configure option for an alternate input module directory
 AC_ARG_WITH(xorg-module-dir,
@@ -123,33 +119,138 @@ if test "x$GLAMOR_XV" = xyes; then
    AC_DEFINE(GLAMOR_XV,1,[Build Xv support])
 fi
 
-PKG_CHECK_MODULES([LIBDRM], $LIBDRM)
-PKG_CHECK_MODULES(EGL, $LIBEGL, [EGL=yes], [EGL=no])
-AM_CONDITIONAL([EGL], [test "x$EGL" = xyes])
+# ---------------------------------------------------------------------
+#     Configuration for LIBDRM
+# ---------------------------------------------------------------------
 
-if test "x$EGL = xyes"; then
-   PKG_CHECK_MODULES(GBM, $LIBGBM, [GBM=yes], [GBM=no])
-   if test "x$GBM" = xyes; then
-     AC_DEFINE(GLAMOR_HAS_GBM, 1, [Use GBM.])
-     AC_DEFINE(GLX_USE_SHARED_DISPATCH, 1, [GLX and GLAMOR share the glapi dispatch table.])
-   fi
+PKG_CHECK_MODULES([LIBDRM], [libdrm >= 2.4.23])
+
+# Check for this 32bpp format in drm_fourcc.h
+SAVE_CFLAGS=$CFLAGS
+CFLAGS="$LIBDRM_CFLAGS"
+AC_CHECK_DECLS([DRM_FORMAT_ARGB8888],
+     [have_drm_argb8888=yes], [have_drm_argb8888=no],[
+     AC_INCLUDES_DEFAULT
+     #include <drm_fourcc.h>
+])
+CFLAGS=$SAVE_CFLAGS
+
+# ---------------------------------------------------------------------
+#     Configuration for Glamor EGL
+# ---------------------------------------------------------------------
+
+# The EGL library is required to build the glamor egl support library
+PKG_CHECK_MODULES(EGL, [egl], [have_egl=yes], [have_egl=no])
+AM_CONDITIONAL([EGL], [test "x$have_egl" = xyes])
+
+# Check for the presence of some EGL extensions
+have_egl_image=yes
+if test "x$have_egl" = xyes; then
+    SAVE_CFLAGS=$CFLAGS
+    CFLAGS="$EGL_CFLAGS"
+    AC_CHECK_DECLS([EGL_KHR_image,
+                    EGL_KHR_gl_texture_2D_image,
+                    EGL_EXT_image_dma_buf_import],
+         [],[have_egl_image=no],[
+         AC_INCLUDES_DEFAULT
+         #include <EGL/egl.h>
+         #include <EGL/eglext.h>
+    ])
+    CFLAGS=$SAVE_CFLAGS
 fi
 
-PKG_CHECK_MODULES(GBMv9, $LIBGBMv9, [GBMv9=yes], [GBMv9=no])
+# ---------------------------------------------------------------------
+#     Configuration for Glamor GBM
+# ---------------------------------------------------------------------
 
-AC_MSG_CHECKING([Enable Glamor Dri3 helpers])
-AC_ARG_ENABLE(glamor-dri3, AS_HELP_STRING([--enable-glamor-dri3], [Build glamor Dri3 helpers (default: yes if libgbm >= 9 is detected)]), [GLAMOR_DRI3_HELPERS="$enableval"], [GLAMOR_DRI3_HELPERS=yes])
+# Check for the Graphics Buffer Management library
+PKG_CHECK_MODULES(GBM, [gbm], [have_gbm=yes], [have_gbm=no])
 
-if test "x$GLAMOR_DRI3_HELPERS" = xyes -a "x$GBMv9" = xno; then
-   GLAMOR_DRI3_HELPERS=no
+# Both EGL and GBM libraries are required for glamor to use GBM
+if test "x$have_egl" = xyes; then
+    if test "x$have_gbm" = xyes; then
+        AC_DEFINE(GLAMOR_HAS_GBM, 1, [Use GBM.])
+        AC_DEFINE(GLX_USE_SHARED_DISPATCH, 1, [GLX and GLAMOR share the glapi dispatch table.])
+    fi
 fi
 
-AC_MSG_RESULT([$GLAMOR_DRI3_HELPERS])
+# Portion of the code supporting DRI3 needs gbm >=9
+if test "x$have_gbm" = xyes; then
+    AC_MSG_CHECKING([for GBM >= 9])
+    PKG_CHECK_EXISTS([gbm >= 9], [have_gbm9=yes], [have_gbm9=no])
+    AC_MSG_RESULT([$have_gbm9])
+fi
 
-if test "x$GLAMOR_DRI3_HELPERS" = xyes; then
-    AC_DEFINE(GLAMOR_HAS_DRI3_SUPPORT, 1, [Enable Dri3 helpers])
+
+# Check that the EGLNativePixmapType is a struct gbm_bo
+# We need libgbm to perform the test.
+if test "x$have_gbm" = xyes; then
+    XORG_TESTSET_CFLAG([COMPAT_CFLAGS], [-Werror])
+    XORG_TESTSET_CFLAG([COMPAT_CFLAGS], [-Wc++-compat])
+    SAVE_CFLAGS=$CFLAGS
+    CFLAGS="$EGL_CFLAGS $GBM_CFLAGS $COMPAT_CFLAGS"
+    AC_MSG_CHECKING([whether EGLNativePixmapType refers to a gbm_bo structure])
+    AC_COMPILE_IFELSE([
+        AC_LANG_PROGRAM([
+            #include <unistd.h>
+            #include <gbm.h>
+            #include <EGL/egl.h>
+            #include <EGL/eglext.h>],[
+            struct gbm_bo *bo = gbm_bo_create (gbm_create_device(1), 0, 0, GBM_FORMAT_ARGB8888,
+                                GBM_BO_USE_RENDERING | GBM_BO_USE_SCANOUT);
+            EGLNativePixmapType native_pixmap;
+            native_pixmap = bo;
+            bo = native_pixmap;]
+        )],
+        [have_egl_pixmap_type=yes;
+         AC_DEFINE([HAVE_EGL_NATIVE_PIXMAP_TYPE], 1,
+            [Define to 1 if "typedef struct gbm_bo *EGLNativePixmapType"])],
+        [have_egl_pixmap_type=no]
+    )
+    CFLAGS=$SAVE_CFLAGS
+    AC_MSG_RESULT([$have_egl_pixmap_type])
+fi
+
+# ---------------------------------------------------------------------
+#     Configure Glamor for DRI3 Support
+# ---------------------------------------------------------------------
+
+# Define a configure option for DRI3 support
+AC_ARG_ENABLE(glamor-dri3,
+    AS_HELP_STRING([--enable-glamor-dri3],
+                   [Build glamor DRI3 helpers (default: auto)]),
+                   [request_dri3="$enableval"],
+                   [request_dri3=auto])
+
+# Check for missing dependencies for DRI3 support
+have_dri3=yes
+if test "x$have_egl" = xno ||
+   test "x$have_egl_image" = xno ||
+   test "x$have_drm_argb8888" = xno ||
+   test "x$have_egl_pixmap_type" = xno ||
+   test "x$have_gbm" = xno ||
+   test "x$have_gbm9" = xno; then
+    have_dri3=no;
 fi
 
+# Enable DRI3 support based on previous tests and user's request
+AC_MSG_CHECKING([whether to include GLAMOR DRI3 helpers])
+case $request_dri3,$have_dri3 in
+    auto,yes | yes,yes)
+            AC_MSG_RESULT([yes])
+            AC_DEFINE([GLAMOR_HAS_DRI3_SUPPORT], 1, [Enable DRI3 helpers])
+        ;;
+    yes,no)
+            AC_MSG_RESULT([no])
+            AC_MSG_ERROR([DRI3 support requested, but some dependencies are missing.])        
+        ;;
+    *)
+        AC_MSG_RESULT([no])
+        ;;
+esac
+
+# ---------------------------------------------------------------------
+
 dnl
 dnl TLS detection
 dnl
-- 
1.7.9.5



More information about the Glamor mailing list