From: Dylan Baker Date: Fri, 22 Sep 2017 19:55:00 +0000 (-0700) Subject: meson: build glx X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a47c525f3281a27;p=mesa.git meson: build glx This gets GLX and the loader building. The resulting GLX and i965 have been tested on piglit and seem to work fine. This patch leaves a lot of todo's in it's wake, GLX is quite complicated, and the build options involved are many, and the goal at the moment is to get dri and gallium drivers building. v2: - fix typo "vaule" -> "value" - put the not on the correct element of the conditional - Put correct description of dri3 option in this patch not the next one (Eric A) - fix non glvnd version (Eric A) - build glx tests - move loader include variables to this patch (Eric A) v3: - set the version correctly for GL_LIB_NAME in libglx v4: - set pkgconfig private fields Signed-off-by: Dylan Baker Reviewed-by: Eric Anholt --- diff --git a/include/meson.build b/include/meson.build index beb57e3e044..e33a8569d76 100644 --- a/include/meson.build +++ b/include/meson.build @@ -51,7 +51,7 @@ if with_opengl ) endif -if with_glx +if with_glx != 'disabled' install_headers('GL/glx.h', 'GL/glext.h', 'GL/glx_mangle.h', subdir : 'GL') endif diff --git a/meson.build b/meson.build index 958bd2313f1..86e1cc98f81 100644 --- a/meson.build +++ b/meson.build @@ -33,7 +33,6 @@ pre_args = [ '-DPACKAGE_BUGREPORT="https://bugs.freedesktop.org/enter_bug.cgi?product=Mesa"', ] -with_dri3 = true # XXX: need a switch for this with_vulkan_icd_dir = get_option('vulkan-icd-dir') with_tests = get_option('build-tests') with_valgrind = get_option('valgrind') @@ -47,11 +46,11 @@ with_gles1 = get_option('gles1') with_gles2 = get_option('gles2') with_opengl = get_option('opengl') with_any_opengl = with_opengl or with_gles1 or with_gles2 -with_shared_glapi = get_option('shared-glapi') +# Only build shared_glapi if at least one OpenGL API is enabled +with_shared_glapi = get_option('shared-glapi') and with_any_opengl # TODO: these will need options, but at the moment they just control header # installs -with_glx = false with_osmesa = false # shared-glapi is required if at least two OpenGL APIs are being built @@ -84,6 +83,30 @@ if not with_dri with_shared_glapi = false endif +# TODO: other OSes +with_dri_platform = 'drm' + +with_gallium = false +# TODO: gallium drivers + +# TODO: conditionalize libdrm requirement +dep_libdrm = dependency('libdrm', version : '>= 2.4.75') +pre_args += '-DHAVE_LIBDRM' + +with_dri2 = with_dri_platform == 'drm' and dep_libdrm.found() +with_dri3 = get_option('dri3') +if with_dri3 == 'auto' + if host_machine.system() == 'linux' + with_dri3 = true + else + with_dri3 = false + endif +elif with_dri3 == 'yes' + with_dri3 = true +else + with_dri3 = false +endif + # TODO: there are more platforms required for non-vulkan drivers with_platform_wayland = false with_platform_x11 = false @@ -94,20 +117,65 @@ if _platforms != '' with_platform_wayland = _split.contains('wayland') endif +with_glx = get_option('glx') +if with_glx != 'disabled' + pre_args += '-DGLX_USE_TLS' + if not (with_platform_x11 and with_any_opengl) and with_glx != 'auto' + error('Cannot build GLX support without X11 platform support and at least one OpenGL API') + elif with_glx == 'gallium-xlib' + if not with_gallium + error('Gallium-xlib based GLX requires at least one gallium driver') + 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' + 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' + endif + endif +endif + +with_glvnd = get_option('glvnd') +if with_glvnd and with_glx != 'dri' + message('glvnd requires dri based glx') +endif + +# TODO: toggle for this +with_glx_direct = true + 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) error('Vulkan requires at least one platform (x11, wayland)') endif + if with_platform_x11 and not with_dri3 + error('Vulkan drivers require dri3 for X11 support') + endif +endif + +if with_dri # TODO: or gallium + if with_glx == 'disabled' # TODO: or egl + error('building dri or gallium drivers require at least one window system') + endif endif prog_python2 = find_program('python2') @@ -378,9 +446,6 @@ dep_expat = dependency('expat') # its not linux and and wont dep_m = cc.find_library('m', required : false) -# TODO: conditionalize libdrm requirement -dep_libdrm = dependency('libdrm', version : '>= 2.4.75') -pre_args += '-DHAVE_LIBDRM' dep_libdrm_amdgpu = [] if with_amd_vk dep_libdrm_amdgpu = dependency('libdrm_amdgpu', version : '>= 2.4.82') @@ -411,6 +476,12 @@ else ] endif +dep_glvnd = [] +if with_glvnd + dep_glvnd = dependency('libglvnd', version : '>= 0.2.0') + pre_args += '-DUSE_LIBGLVND=1' +endif + # TODO: make this conditional dep_valgrind = dependency('valgrind', required : false) if dep_valgrind.found() and with_valgrind @@ -442,18 +513,8 @@ dep_selinux = [] # TODO: gallium drivers -# TODO: libglvnd - # TODO: symbol mangling -# TODO: dri handling - -# TODO: shared-glapi - -# TODO: libgl requirements - -# TODO: GLX configuration - # TODO: egl configuration if with_platform_wayland @@ -470,33 +531,65 @@ endif dep_xcb_dri2 = [] dep_xcb_dri3 = [] +dep_dri2proto = [] +dep_glproto = [] +dep_x11 = [] +dep_xf86vm = [] if with_platform_x11 - dep_xcb_dri2 = [ - dependency('x11-xcb'), - dependency('xcb'), - dependency('xcb-dri2', version : '>= 1.8'), - dependency('xcb-xfixes'), - ] - pre_args += '-DHAVE_X11_PLATFORM' - if with_dri3 - dep_xcb_dri3 = [ - dep_xcb_dri2, - dependency('xcb-dri3'), - dependency('xcb-present'), - dependency('xcb-sync'), - dependency('xshmfence', version : '>= 1.1'), - ] + if with_glx == 'xlib' + # TODO + error('TODO') + elif with_glx == 'gallium-xlib' + # TODO + error('TODO') else - # TODO: dri3 is required for vulkan + pre_args += '-DGLX_INDIRECT_RENDERING' + if with_glx_direct + pre_args += '-DGLX_DIRECT_RENDERING' + endif + if with_dri_platform == 'drm' + pre_args += '-DGLX_USE_DRM' + dep_dri2proto = dependency('dri2proto', version : '>= 2.8') + dep_x11 = [ + dependency('x11'), + dependency('xext'), + dependency('xdamage', version : '>= 1.1'), + dependency('xfixes'), + dependency('x11-xcb'), + dependency('xcb'), + dependency('xcb-glx', version : '>= 1.8.1'), + ] + + dep_xf86vm = dependency('xf86vm', required : false) + endif + # TODO: XF86VIDMODE + endif + if with_glx != 'disabled' + dep_glproto = dependency('glproto', version : '>= 1.4.14') + endif + if with_any_vk or (with_glx == 'dri' and with_dri_platform == 'drm') + dep_xcb_dri2 = [ + dependency('x11-xcb'), + dependency('xcb'), + dependency('xcb-dri2', version : '>= 1.8'), + dependency('xcb-xfixes'), + ] + pre_args += '-DHAVE_X11_PLATFORM' + if with_dri3 + pre_args += '-DHAVE_DRI3' + dep_xcb_dri3 = [ + dep_xcb_dri2, + dependency('xcb-dri3'), + dependency('xcb-present'), + dependency('xcb-sync'), + dependency('xshmfence', version : '>= 1.1'), + ] + endif endif endif # TODO: platforms for !vulkan -# TODO: dri paths - -# TODO: dri drivers - # TODO: osmesa # TODO: egl diff --git a/meson_options.txt b/meson_options.txt index f352f384c14..09adce02860 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -20,6 +20,8 @@ option('platforms', type : 'string', value : 'x11,wayland', description : 'comma separated list of window systems to support. wayland, x11, surfaceless, drm, etc.') +option('dri3', type : 'combo', value : 'auto', choices : ['auto', 'yes', 'no'], + description : 'enable support for dri3') option('dri-drivers', type : 'string', value : 'i965', description : 'comma separated list of dri drivers to build.') option('vulkan-drivers', type : 'string', value : 'intel,amd', @@ -36,6 +38,10 @@ option('gles2', type : 'boolean', value : true, description : 'Build support for OpenGL ES 2.x and 3.x') option('opengl', type : 'boolean', value : true, description : 'Build support for OpenGL (all versions)') +option('glx', type : 'combo', value : 'auto', choices : ['auto', 'disabled', 'dri', 'xlib', 'gallium-xlib'], + description : 'Build support for GLX platform') +option('glvnd', type : 'boolean', value : false, + description : 'Enable GLVND support.') option('asm', type : 'boolean', value : true, description : 'Build assembly code if possible') option('valgrind', type : 'boolean', value : true, diff --git a/src/glx/meson.build b/src/glx/meson.build new file mode 100644 index 00000000000..70718df4d35 --- /dev/null +++ b/src/glx/meson.build @@ -0,0 +1,207 @@ +# 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. + +# TODO: +#subdir('windows') + +files_libglx = files( + 'clientattrib.c', + 'clientinfo.c', + 'compsize.c', + 'create_context.c', + 'eval.c', + 'glxclient.h', + 'glxcmds.c', + 'glxconfig.c', + 'glxconfig.h', + 'glxcurrent.c', + 'glx_error.c', + 'glx_error.h', + 'glxext.c', + 'glxextensions.c', + 'glxextensions.h', + 'glxhash.c', + 'glxhash.h', + 'glx_pbuffer.c', + 'glx_query.c', + 'indirect_glx.c', + 'indirect_init.h', + 'indirect_texture_compression.c', + 'indirect_transpose_matrix.c', + 'indirect_vertex_array.c', + 'indirect_vertex_array.h', + 'indirect_vertex_array_priv.h', + 'indirect_vertex_program.c', + 'indirect_window_pos.c', + 'packrender.h', + 'packsingle.h', + 'pixel.c', + 'pixelstore.c', + 'query_renderer.c', + 'render2.c', + 'renderpix.c', + 'single2.c', + 'singlepix.c', + 'vertarr.c', +) + +extra_libs_libglx = [] + +if with_dri + files_libglx += files( + 'dri_common.c', + 'dri_common.h', + 'dri_common_query_renderer.c', + 'dri_common_interop.c', + 'xfont.c', + 'drisw_glx.c', + 'drisw_priv.h', + ) +endif + +# dri2 +if with_dri and with_dri_platform == 'drm' and dep_libdrm.found() + files_libglx += files( + 'dri2.c', + 'dri2_glx.c', + 'dri2.h', + 'dri2_priv.h', + 'dri_glx.c', + 'dri_sarea.h', + 'XF86dri.c', + 'xf86dri.h', + 'xf86dristr.h', + ) +endif + +if with_dri3 + files_libglx += files('dri3_glx.c', 'dri3_priv.h') +endif + +if with_appledri + files_libglx += files('applegl_glx.c') +elif with_windowsdri + files_libglx += files('driwindows_glx.c') + # TODO + #extra_libs_libglx += [ + #libwindowsdri, + #libwindowsglx, + #] +endif + +dri_driver_dir = join_paths(get_option('prefix'), get_option('libdir'), 'dri') +if not with_glvnd + gl_lib_name = 'GL' + gl_lib_version = '1.2.0' +else + gl_lib_name = 'GLX_mesa' + gl_lib_version = '0' + files_libglx += files( + 'g_glxglvnddispatchfuncs.c', + 'g_glxglvnddispatchindices.h', + 'glxglvnd.c', + 'glxglvnd.h', + 'glxglvnddispatchfuncs.h', + ) +endif + +gl_lib_cargs = [ + '-D_REENTRANT', '-DDEFAULT_DRIVER_DIR="@0@"'.format(dri_driver_dir), +] + +if dep_xf86vm != [] and dep_xf86vm.found() + gl_lib_cargs += '-DHAVE_XF86VIDMODE' +endif + +libglx = static_library( + 'glx', + [files_libglx, glx_generated], + include_directories : [ + inc_common, inc_glapi, inc_loader, + include_directories('../../include/GL/internal'), + ], + c_args : [c_vis_args, gl_lib_cargs, + '-DGL_LIB_NAME="lib@0@.so.@1@"'.format(gl_lib_name, gl_lib_version.split('.')[0])], + link_with : [libloader, libloader_dri3_helper, libmesa_util, libxmlconfig], + dependencies : [dep_libdrm, dep_dri2proto, dep_glproto, dep_x11, dep_glvnd], + build_by_default : false, +) + +# workaround for bug #2180 +dummy_c = custom_target( + 'dummy_c', + output : 'dummy.c', + command : [prog_touch, '@OUTPUT@'], +) + +if with_glx == 'dri' + libgl = shared_library( + gl_lib_name, + dummy_c, # workaround for bug #2180 + include_directories : [ + inc_common, inc_glapi, inc_loader, + include_directories('../../include/GL/internal'), + ], + link_with : [libglapi_static, libglapi], + link_whole : libglx, + link_args : [ld_args_bsymbolic, ld_args_gc_sections], + dependencies : [dep_libdrm, dep_dl, dep_m, dep_thread, dep_x11, + dep_xcb_dri2, dep_xcb_dri3], + version : gl_lib_version, + install : true, + ) + + gl_priv_reqs = [ + 'x11', 'xext', 'xdamage >= 1.1', 'xfixes', 'x11-xcb', 'xcb', + 'xcb-glx >= 1.8.1', 'libdrm >= 2.4.75', + ] + if dep_xf86vm.found() + gl_priv_reqs += 'xf86vm' + endif + if with_dri_platform == 'drm' + gl_priv_reqs += 'xcb-dri2 >= 1.8' + endif + + gl_priv_libs = [] + if dep_thread.found() + gl_priv_libs += ['-lpthread', '-pthread'] + endif + if dep_m.found() + gl_priv_libs += '-lm' + endif + if dep_dl.found() + gl_priv_libs += '-ldl' + endif + + pkg.generate( + name : 'gl', + filebase : 'gl', + description : 'Mesa OpenGL Library', + version : meson.project_version(), + libraries : libgl, + libraries_private : gl_priv_libs, + requires_private : gl_priv_reqs, + variables : ['glx_tls=yes'], + ) +endif + +if with_tests + subdir('tests') +endif diff --git a/src/glx/tests/meson.build b/src/glx/tests/meson.build new file mode 100644 index 00000000000..d81b76906da --- /dev/null +++ b/src/glx/tests/meson.build @@ -0,0 +1,49 @@ +# 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. + +if with_shared_glapi + files_glx_test = files( + 'clientinfo_unittest.cpp', + 'create_context_unittest.cpp', + 'enum_sizes.cpp', + 'fake_glx_screen.cpp', + 'fake_glx_screen.h', + 'indirect_api.cpp', + 'mock_xdisplay.h', + 'query_renderer_unittest.cpp', + ) + if with_dri2 + files_glx_test += files('query_renderer_implementation_unittest.cpp') + endif + + glx_test = executable( + 'glx-test', + [files_glx_test, glx_indirect_size_h], + link_with : [libglx, libglapi], + include_directories : [ + include_directories('..', '../../../include/GL/internal'), + inc_src, inc_include, inc_mesa, inc_mapi, + ], + dependencies : [dep_libdrm, dep_thread, idep_gtest] + ) + + test('glx-test', glx_test) + test('glx-dispatch-index-check', find_program('dispatch-index-check')) +endif diff --git a/src/loader/meson.build b/src/loader/meson.build new file mode 100644 index 00000000000..425620372aa --- /dev/null +++ b/src/loader/meson.build @@ -0,0 +1,44 @@ +# 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. + +inc_loader = include_directories('.') + +if with_platform_x11 and with_dri3 + libloader_dri3_helper = static_library( + 'loader_dri3_helper', + ['loader_dri3_helper.c', 'loader_dri3_helper.h'], + c_args : c_vis_args, + include_directories : inc_include, + dependencies : [dep_xcb_dri3, dep_libdrm], + build_by_default : false, + ) +else + libloader_dri3_helper = [] +endif + +libloader = static_library( + 'loader', + ['loader.c', 'loader.h', 'pci_id_driver_map.c', 'pci_id_driver_map.h', + xmlpool_options_h], + c_args : [c_vis_args, '-DUSE_DRICONF'], + include_directories : [inc_include, inc_src, inc_util], + dependencies : dep_libdrm, + build_by_default : false, +) diff --git a/src/mapi/glapi/meson.build b/src/mapi/glapi/meson.build index d09cf94e36f..d3e070d0d1a 100644 --- a/src/mapi/glapi/meson.build +++ b/src/mapi/glapi/meson.build @@ -18,6 +18,8 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. +inc_glapi = include_directories('.') + static_glapi_files = [] static_glapi_args = [] diff --git a/src/meson.build b/src/meson.build index 8e0860bb5a5..f49ad9e0e7e 100644 --- a/src/meson.build +++ b/src/meson.build @@ -44,7 +44,6 @@ subdir('util') subdir('mapi/glapi/gen') subdir('mapi') # TODO: opengl -# TODO: glx # TODO: osmesa subdir('compiler') subdir('egl/wayland/wayland-drm') @@ -53,8 +52,8 @@ subdir('amd') subdir('intel') # TODO: vc4 subdir('mesa') +subdir('loader') +subdir('glx') # TODO: dri_glx -# TODO: gbm # TODO: egl -# TODO: radv # TODO: gallium