[Mesa-dev] [PATCH 4/5] meson: add support for xlib glx

Dylan Baker dylan at pnwbakers.com
Fri Nov 3 00:06:28 UTC 2017


There is a bunch of churn in the main meson.build so that we can
correctly set the auto tristate of GLX. In particular, don't build
xlib-based glx when dri and gallium are disabled but vulkan is enabled,
in that case just turn glx off.

Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
 meson.build                      | 85 +++++++++++++++++++++++-----------------
 src/mesa/drivers/x11/meson.build | 39 ++++++++++++++++++
 src/mesa/meson.build             |  8 ++--
 3 files changed, 90 insertions(+), 42 deletions(-)
 create mode 100644 src/mesa/drivers/x11/meson.build

diff --git a/meson.build b/meson.build
index d22d49535af..51ff0febde7 100644
--- a/meson.build
+++ b/meson.build
@@ -127,14 +127,6 @@ if _drivers != ''
   with_dri = true
 endif
 
-if not (with_dri or with_gallium)
-  with_gles1 = false
-  with_gles2 = false
-  with_opengl = false
-  with_any_opengl = false
-  with_shared_glapi = false
-endif
-
 if with_dri_swrast and with_gallium_softpipe
   error('Only one swrast provider can be built')
 endif
@@ -167,6 +159,43 @@ if _platforms != ''
   egl_native_platform = _split[0]
 endif
 
+with_intel_vk = false
+with_amd_vk = false
+with_any_vk = false
+_vulkan_drivers = get_option('vulkan-drivers')
+if _vulkan_drivers != ''
+  _split = _vulkan_drivers.split(',')
+  with_intel_vk = _split.contains('intel')
+  with_amd_vk = _split.contains('amd')
+  with_any_vk = with_amd_vk or with_intel_vk
+  if not (with_platform_x11 or with_platform_wayland or with_platform_android)
+    error('Vulkan requires at least one platform (x11, wayland, android)')
+  endif
+endif
+
+with_glx = get_option('glx')
+if with_glx == 'auto'
+  if with_dri
+    with_glx = 'dri'
+  elif with_gallium
+    with_glx = 'gallium-xlib'
+  elif with_platform_x11 and with_any_opengl and not with_any_vk
+    # The automatic behavior should not be to turn on xlib based glx when
+    # building only vulkan drivers
+    with_glx = 'xlib'
+  else
+    with_glx = 'disabled'
+  endif
+endif
+
+if not (with_dri or with_gallium or with_glx == 'xlib')
+  with_gles1 = false
+  with_gles2 = false
+  with_opengl = false
+  with_any_opengl = false
+  with_shared_glapi = false
+endif
+
 with_gbm = get_option('gbm')
 if with_gbm == 'auto' and with_dri  # TODO: or gallium
   with_gbm = host_machine.system() == 'linux'
@@ -201,7 +230,6 @@ if with_egl and with_gallium_radeonsi and not (with_platform_drm or with_platfor
 endif
 
 pre_args += '-DGLX_USE_TLS'
-with_glx = get_option('glx')
 if with_glx != 'disabled'
   if not (with_platform_x11 and with_any_opengl)
     if with_glx == 'auto'
@@ -215,18 +243,12 @@ if with_glx != 'disabled'
     elif with_dri
       error('gallium-xlib conflicts with any dri driver')
     endif
-  elif with_glx == 'dri' and not with_dri
-    error('dri based GLX requires at least one DRI driver')
-  elif with_glx == 'auto'
+  elif with_glx == 'xlib' 
     if with_dri
-      with_glx = 'dri'
-    elif with_gallium
-      with_glx = 'gallium-xlib'
-    elif with_platform_x11 and with_any_opengl
-      with_glx = 'xlib'
-    else
-      with_glx = 'disabled'
+      error('xlib conflicts with any dri driver')
     endif
+  elif with_glx == 'dri' and not with_dri
+    error('dri based GLX requires at least one DRI driver')
   endif
 endif
 
@@ -242,20 +264,6 @@ if with_vulkan_icd_dir == ''
   with_vulkan_icd_dir = join_paths(get_option('datadir'), 'vulkan/icd.d')
 endif
 
-with_intel_vk = false
-with_amd_vk = false
-with_any_vk = false
-_vulkan_drivers = get_option('vulkan-drivers')
-if _vulkan_drivers != ''
-  _split = _vulkan_drivers.split(',')
-  with_intel_vk = _split.contains('intel')
-  with_amd_vk = _split.contains('amd')
-  with_any_vk = with_amd_vk or with_intel_vk
-  if not (with_platform_x11 or with_platform_wayland or with_platform_android)
-    error('Vulkan requires at least one platform (x11, wayland, android)')
-  endif
-endif
-
 with_dri2 = (with_dri or with_any_vk) and with_dri_platform == 'drm'
 with_dri3 = get_option('dri3')
 if with_dri3 == 'auto'
@@ -302,8 +310,7 @@ if with_platform_x11
     pre_args += '-DHAVE_X11_PLATFORM'
   endif
   if with_glx == 'xlib'
-    # TODO
-    error('TODO')
+    pre_args += '-DUSE_XSHM'
   elif with_glx == 'gallium-xlib'
     # TODO
     error('TODO')
@@ -786,7 +793,11 @@ dep_xcb_sync = []
 dep_xcb_xfixes = []
 dep_xshmfence = []
 if with_platform_x11
-  if with_glx == 'dri' and with_dri_platform == 'drm'
+  if with_glx == 'xlib'
+    dep_x11 = dependency('x11')
+    dep_xext = dependency('xext')
+    dep_xcb = dependency('xcb')
+  elif with_glx == 'dri' and with_dri_platform == 'drm'
     dep_x11 = dependency('x11')
     dep_xext = dependency('xext')
     dep_xdamage = dependency('xdamage', version : '>= 1.1')
@@ -807,7 +818,7 @@ if with_platform_x11
       dep_xshmfence = dependency('xshmfence', version : '>= 1.1')
     endif
   endif
-  if with_glx != 'disabled'
+  if with_glx == 'dri'
     dep_dri2proto = dependency('dri2proto', version : '>= 2.8')
     dep_glproto = dependency('glproto', version : '>= 1.4.14')
   endif
diff --git a/src/mesa/drivers/x11/meson.build b/src/mesa/drivers/x11/meson.build
new file mode 100644
index 00000000000..bb4fda14cb8
--- /dev/null
+++ b/src/mesa/drivers/x11/meson.build
@@ -0,0 +1,39 @@
+# Copyright © 2017 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 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.
+
+gl_link_with = []
+if with_shared_glapi
+  gl_link_with += libglapi
+endif
+
+libgl = shared_library(
+  'GL',
+  files(
+    'fakeglx.c', 'glxapi.c', 'xfonts.c', 'xm_api.c', 'xm_buffer.c', 'xm_dd.c',
+    'xm_line.c', 'xm_tri.c',
+  ),
+  include_directories : [
+    inc_include, inc_src, inc_mesa, inc_mapi, inc_gallium, inc_gallium_aux
+  ],
+  link_with : [libmesa_classic, libglapi_static, gl_link_with],
+  dependencies : [dep_x11, dep_xext, dep_xcb, dep_thread],
+  version : '1.6.0',
+  install : true,
+)
diff --git a/src/mesa/meson.build b/src/mesa/meson.build
index 20d06aad4dd..b839fd02981 100644
--- a/src/mesa/meson.build
+++ b/src/mesa/meson.build
@@ -19,15 +19,10 @@
 # SOFTWARE.
 
 # TODO: main/tests
-# TODO: xlib_glx
-# TODO: osmesa
-# TODO: asm_offsets
 
 subdir('program')
 subdir('main')
 
-# program files
-# program nir files
 # files shared between classic mesa and gallium mesa
 files_libmesa_common = files(
   'program/arbprogparse.c',
@@ -721,6 +716,9 @@ subdir('drivers/dri')
 if with_osmesa == 'classic'
   subdir('drivers/osmesa')
 endif
+if with_glx == 'xlib'
+  subdir('drivers/x11')
+endif
 if with_tests
   subdir('main/tests')
 endif
-- 
2.15.0



More information about the mesa-dev mailing list