From 010b2f9497ab256d9e8041207902948331af5b4b Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Tue, 13 Feb 2024 14:50:50 -0500 Subject: [PATCH] gallium/meson: Deconflate swrast/softpipe/llvmpipe This adds explicit names for softpipe and llvmpipe to the gallium driver list. "swrast" is treated as a compatibility name that selects both. We clarify how lavapipe depends on (just) llvmpipe, and we make it possible to build llvmpipe without softpipe. Part-of: --- meson.build | 30 +++++++++++++++------ meson_options.txt | 3 ++- src/egl/main/egldevice.c | 2 +- src/egl/meson.build | 4 --- src/gallium/drivers/llvmpipe/meson.build | 8 +++--- src/gallium/drivers/softpipe/meson.build | 2 +- src/gallium/frontends/dri/dri2.c | 4 +-- src/gallium/frontends/dri/meson.build | 4 --- src/gallium/frontends/hgl/meson.build | 6 ----- src/gallium/meson.build | 20 +++++++++++--- src/gallium/targets/dri/dri_target.c | 2 +- src/gallium/targets/dril/meson.build | 4 +-- src/gallium/targets/lavapipe/meson.build | 2 +- src/gallium/targets/libgl-xlib/meson.build | 4 --- src/gallium/targets/pipe-loader/meson.build | 2 +- src/gallium/targets/wgl/wgl.c | 2 +- src/gallium/tests/meson.build | 2 +- 17 files changed, 55 insertions(+), 46 deletions(-) diff --git a/meson.build b/meson.build index c96ca0626a6..d0932a11a83 100644 --- a/meson.build +++ b/meson.build @@ -165,12 +165,19 @@ elif gallium_drivers.contains('all') ] endif +# compatibility for meson configurations asking for 'swrast' +with_swrast = gallium_drivers.contains('swrast') +if with_swrast + warning('`gallium-drivers=swrast` is a deprecated alias for `gallium-drivers=softpipe,llvmpipe` and will be removed in version 25.0') +endif + with_gallium_radeonsi = gallium_drivers.contains('radeonsi') with_gallium_r300 = gallium_drivers.contains('r300') with_gallium_r600 = gallium_drivers.contains('r600') with_gallium_nouveau = gallium_drivers.contains('nouveau') with_gallium_freedreno = gallium_drivers.contains('freedreno') -with_gallium_softpipe = gallium_drivers.contains('swrast') +with_gallium_softpipe = with_swrast or gallium_drivers.contains('softpipe') +with_gallium_llvmpipe = with_swrast or gallium_drivers.contains('llvmpipe') with_gallium_vc4 = gallium_drivers.contains('vc4') with_gallium_v3d = gallium_drivers.contains('v3d') with_gallium_panfrost = gallium_drivers.contains('panfrost') @@ -189,6 +196,12 @@ foreach gallium_driver : gallium_drivers pre_args += '-DHAVE_@0@'.format(gallium_driver.to_upper()) endforeach +# compatibility for "swrast" as an internal-ish driver name +with_gallium_swrast = with_gallium_softpipe or with_gallium_llvmpipe +if with_gallium_swrast + pre_args += '-DHAVE_SWRAST' +endif + with_gallium = gallium_drivers.length() != 0 with_gallium_kmsro = system_has_kms_drm and [ with_gallium_asahi, @@ -248,6 +261,8 @@ if with_any_vk and host_machine.system() == 'windows' and meson.version().versio error('Vulkan drivers on Windows require meson 1.3 or newer') endif +with_any_llvmpipe = with_gallium_llvmpipe or with_swrast_vk + freedreno_kmds = get_option('freedreno-kmds') if freedreno_kmds.length() != 0 and freedreno_kmds != [ 'msm' ] and with_freedreno_vk if freedreno_kmds.contains('msm') @@ -307,9 +322,6 @@ if with_nouveau_vk pre_args += '-DHAVE_NVK' endif -if with_swrast_vk and not with_gallium_softpipe - error('swrast vulkan requires gallium swrast') -endif if with_gallium_tegra and not with_gallium_nouveau error('tegra driver requires nouveau driver') endif @@ -514,7 +526,7 @@ if with_glx != 'disabled' elif with_glx == 'xlib' if not with_gallium error('xlib based GLX requires at least one gallium driver') - elif not with_gallium_softpipe + elif not with_gallium_swrast error('xlib based GLX requires softpipe or llvmpipe.') elif with_dri error('xlib conflicts with any dri driver') @@ -748,7 +760,7 @@ endif with_gallium_st_nine = get_option('gallium-nine') if with_gallium_st_nine - if not with_gallium_softpipe + if not with_gallium_swrast error('The nine state tracker requires gallium softpipe/llvmpipe.') elif not [ with_gallium_crocus, @@ -771,7 +783,7 @@ if with_gallium_st_nine endif with_gallium_st_d3d10umd = get_option('gallium-d3d10umd') if with_gallium_st_d3d10umd - if not with_gallium_softpipe + if not with_gallium_swrast error('The d3d10umd state tracker requires gallium softpipe/llvmpipe.') endif endif @@ -1818,6 +1830,8 @@ elif with_amd_vk and with_aco_tests error('ACO tests require LLVM, but LLVM is disabled.') elif with_swrast_vk error('The following drivers require LLVM: Lavapipe. One of these is enabled, but LLVM is disabled.') +elif with_gallium_llvmpipe + error('The following drivers require LLVM: llvmpipe. It is enabled, but LLVM is disabled.') elif with_gallium_clover error('The OpenCL "Clover" state tracker requires LLVM, but LLVM is disabled.') elif with_clc @@ -2006,7 +2020,7 @@ if dep_unwind.found() endif if with_osmesa - if not with_gallium_softpipe + if not with_gallium_swrast error('OSMesa gallium requires gallium softpipe or llvmpipe.') endif if host_machine.system() == 'windows' diff --git a/meson_options.txt b/meson_options.txt index 753bebd961e..66b0d6c6fe4 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -89,10 +89,11 @@ option( 'auto', 'kmsro', 'radeonsi', 'r300', 'r600', 'nouveau', 'freedreno', 'swrast', 'v3d', 'vc4', 'etnaviv', 'tegra', 'i915', 'svga', 'virgl', 'panfrost', 'iris', 'lima', 'zink', 'd3d12', 'asahi', 'crocus', 'all', + 'softpipe', 'llvmpipe', ], description : 'List of gallium drivers to build. If this is set to auto ' + 'all drivers applicable to the target OS/architecture ' + - 'will be built' + 'will be built.' ) option( diff --git a/src/egl/main/egldevice.c b/src/egl/main/egldevice.c index daa2aa0a27e..9d0c47296c8 100644 --- a/src/egl/main/egldevice.c +++ b/src/egl/main/egldevice.c @@ -351,7 +351,7 @@ _eglQueryDevicesEXT(EGLint max_devices, _EGLDevice **devices, num_devs = _eglDeviceRefreshList(); devs = _eglGlobal.DeviceList; -#ifdef GALLIUM_SOFTPIPE +#ifdef HAVE_SWRAST swrast = devs; #else swrast = NULL; diff --git a/src/egl/meson.build b/src/egl/meson.build index ee785a3a923..634fd3e9007 100644 --- a/src/egl/meson.build +++ b/src/egl/meson.build @@ -10,10 +10,6 @@ link_for_egl = [] deps_for_egl = [] incs_for_egl = [inc_include, inc_src, inc_egl] -if with_gallium_softpipe - c_args_for_egl += '-DGALLIUM_SOFTPIPE' -endif - files_egl = files( 'main/eglapi.c', 'main/eglarray.c', diff --git a/src/gallium/drivers/llvmpipe/meson.build b/src/gallium/drivers/llvmpipe/meson.build index 35e616bc371..33b4bec5f61 100644 --- a/src/gallium/drivers/llvmpipe/meson.build +++ b/src/gallium/drivers/llvmpipe/meson.build @@ -105,15 +105,13 @@ libllvmpipe = static_library( dependencies : [ dep_llvm, idep_nir_headers, idep_mesautil, dep_libdrm], ) -# This overwrites the softpipe driver dependency, but itself depends on the -# softpipe dependency. -driver_swrast = declare_dependency( +driver_llvmpipe = declare_dependency( compile_args : '-DGALLIUM_LLVMPIPE', link_with : libllvmpipe, - dependencies : [driver_swrast, dep_llvm, idep_mesautil], + dependencies : [dep_llvm, idep_mesautil], ) -if with_tests and with_gallium_softpipe and draw_with_llvm +if with_tests foreach t : ['lp_test_format', 'lp_test_arit', 'lp_test_blend', 'lp_test_conv', 'lp_test_printf', 'lp_test_lookup_multiple'] test( diff --git a/src/gallium/drivers/softpipe/meson.build b/src/gallium/drivers/softpipe/meson.build index 9beb9b4c3ca..2dea9aeb43a 100644 --- a/src/gallium/drivers/softpipe/meson.build +++ b/src/gallium/drivers/softpipe/meson.build @@ -67,7 +67,7 @@ libsoftpipe = static_library( dependencies : idep_nir, ) -driver_swrast = declare_dependency( +driver_softpipe = declare_dependency( compile_args : '-DGALLIUM_SOFTPIPE', link_with : libsoftpipe ) diff --git a/src/gallium/frontends/dri/dri2.c b/src/gallium/frontends/dri/dri2.c index 45bff9c3766..35cdd882eb1 100644 --- a/src/gallium/frontends/dri/dri2.c +++ b/src/gallium/frontends/dri/dri2.c @@ -2322,7 +2322,7 @@ fail: static const __DRIconfig ** dri_swrast_kms_init_screen(struct dri_screen *screen, bool driver_name_is_inferred) { -#if defined(GALLIUM_SOFTPIPE) +#if defined(HAVE_SWRAST) const __DRIconfig **configs; struct pipe_screen *pscreen = NULL; @@ -2352,7 +2352,7 @@ dri_swrast_kms_init_screen(struct dri_screen *screen, bool driver_name_is_inferr fail: dri_release_screen(screen); -#endif // GALLIUM_SOFTPIPE +#endif // HAVE_SWRAST return NULL; } diff --git a/src/gallium/frontends/dri/meson.build b/src/gallium/frontends/dri/meson.build index 408a94deec7..6448d9386fd 100644 --- a/src/gallium/frontends/dri/meson.build +++ b/src/gallium/frontends/dri/meson.build @@ -42,10 +42,6 @@ if with_gallium_zink and not with_platform_android deps_for_libdri += vulkan_wsi_deps endif -if with_gallium_softpipe - libdri_c_args += '-DGALLIUM_SOFTPIPE' -endif - libdri = static_library( 'dri', [ files_libdri, sha1_h ], diff --git a/src/gallium/frontends/hgl/meson.build b/src/gallium/frontends/hgl/meson.build index 0286d35aeed..418e71be6d2 100644 --- a/src/gallium/frontends/hgl/meson.build +++ b/src/gallium/frontends/hgl/meson.build @@ -6,11 +6,6 @@ files_libsthgl = files( 'hgl.c', ) -libsthgl_c_args = [] -if with_gallium_softpipe - libsthgl_c_args += '-DGALLIUM_SOFTPIPE' -endif - libsthgl = static_library( 'sthgl', files_libsthgl, @@ -18,6 +13,5 @@ libsthgl = static_library( inc_include, inc_util, inc_mesa, inc_mapi, inc_src, inc_gallium, inc_gallium_aux ], - c_args : [libsthgl_c_args], gnu_symbol_visibility : 'hidden', ) diff --git a/src/gallium/meson.build b/src/gallium/meson.build index dcc8e6a6f9b..46029d1a151 100644 --- a/src/gallium/meson.build +++ b/src/gallium/meson.build @@ -44,12 +44,26 @@ if with_platform_haiku endif if with_gallium_softpipe subdir('drivers/softpipe') - if draw_with_llvm - subdir('drivers/llvmpipe') - endif +else + driver_softpipe = declare_dependency() +endif +if with_any_llvmpipe + subdir('drivers/llvmpipe') +else + driver_llvmpipe = declare_dependency() +endif +if with_gallium_llvmpipe and with_gallium_softpipe + driver_swrast = declare_dependency( + dependencies : [ driver_softpipe, driver_llvmpipe ], + ) +elif with_gallium_llvmpipe + driver_swrast = driver_llvmpipe +elif with_gallium_softpipe + driver_swrast = driver_softpipe else driver_swrast = declare_dependency() endif + if with_gallium_asahi subdir('winsys/asahi/drm') subdir('drivers/asahi') diff --git a/src/gallium/targets/dri/dri_target.c b/src/gallium/targets/dri/dri_target.c index e065f9656cc..e61622a69e3 100644 --- a/src/gallium/targets/dri/dri_target.c +++ b/src/gallium/targets/dri/dri_target.c @@ -12,7 +12,7 @@ PUBLIC const __DRIextension **__driDriverGetExtensions_##drivername(void) \ return galliumdrm_driver_extensions; \ } -#if defined(GALLIUM_SOFTPIPE) +#if defined(HAVE_SWRAST) const __DRIextension **__driDriverGetExtensions_swrast(void); diff --git a/src/gallium/targets/dril/meson.build b/src/gallium/targets/dril/meson.build index e1ba0198efc..071c695a05a 100644 --- a/src/gallium/targets/dril/meson.build +++ b/src/gallium/targets/dril/meson.build @@ -103,8 +103,8 @@ foreach d : [[with_gallium_kmsro, [ [with_gallium_radeonsi, 'radeonsi_dri.so'], [with_gallium_nouveau, 'nouveau_dri.so'], [with_gallium_freedreno, ['msm_dri.so', 'kgsl_dri.so']], - [with_gallium_softpipe, 'swrast_dri.so'], - [with_gallium_softpipe and with_gallium_drisw_kms, 'kms_swrast_dri.so'], + [with_gallium_swrast, 'swrast_dri.so'], + [with_gallium_swrast and with_gallium_drisw_kms, 'kms_swrast_dri.so'], [with_gallium_v3d, 'v3d_dri.so'], [with_gallium_vc4, 'vc4_dri.so'], [with_gallium_panfrost, ['panfrost_dri.so', 'panthor_dri.so']], diff --git a/src/gallium/targets/lavapipe/meson.build b/src/gallium/targets/lavapipe/meson.build index 19bf33a55a7..6f7371ff742 100644 --- a/src/gallium/targets/lavapipe/meson.build +++ b/src/gallium/targets/lavapipe/meson.build @@ -13,7 +13,7 @@ libvulkan_lvp = shared_library( # The linker still expects a definition for weak symbols at build time, just not at runtime. # We have to forcibly ignore undefined symbols, which unfortunately applies to all symbols. override_options : ['b_lundef=@0@'.format(host_machine.system() == 'darwin' ? 'false' : get_option('b_lundef').to_string())], - dependencies : driver_swrast, + dependencies : driver_llvmpipe, name_prefix : host_machine.system() == 'windows' ? '' : [], install : true, ) diff --git a/src/gallium/targets/libgl-xlib/meson.build b/src/gallium/targets/libgl-xlib/meson.build index 2c830c0ab86..2b0362b358b 100644 --- a/src/gallium/targets/libgl-xlib/meson.build +++ b/src/gallium/targets/libgl-xlib/meson.build @@ -5,9 +5,6 @@ # Static targets are always enabled in autotools (unless you modify # configure.ac) -gallium_xlib_c_args = [ - '-DGALLIUM_SOFTPIPE', -] gallium_xlib_ld_args = [] gallium_xlib_link_with = [] gallium_xlib_link_depends = [] @@ -27,7 +24,6 @@ libgl = shared_library( inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux, inc_gallium_winsys, inc_gallium_drivers, include_directories('../../frontends/glx/xlib'), ], - c_args : [gallium_xlib_c_args], gnu_symbol_visibility : 'hidden', link_args : [ld_args_bsymbolic, ld_args_gc_sections, gallium_xlib_ld_args], link_depends : gallium_xlib_link_depends, diff --git a/src/gallium/targets/pipe-loader/meson.build b/src/gallium/targets/pipe-loader/meson.build index 94a9e652b1c..c7cbcb31eda 100644 --- a/src/gallium/targets/pipe-loader/meson.build +++ b/src/gallium/targets/pipe-loader/meson.build @@ -36,7 +36,7 @@ pipe_loaders = [ [with_gallium_freedreno, 'msm', driver_freedreno, []], [with_gallium_kmsro, 'kmsro', _kmsro_targets, [libpipe_loader_dynamic]], [with_gallium_svga, 'vmwgfx', driver_svga, []], - [with_gallium_softpipe, 'swrast', driver_swrast, [libwsw, libws_null, libswdri, libswkmsdri]], + [with_gallium_swrast, 'swrast', driver_swrast, [libwsw, libws_null, libswdri, libswkmsdri]], ] foreach x : pipe_loaders diff --git a/src/gallium/targets/wgl/wgl.c b/src/gallium/targets/wgl/wgl.c index 041c4b349a5..75ec547cfd7 100644 --- a/src/gallium/targets/wgl/wgl.c +++ b/src/gallium/targets/wgl/wgl.c @@ -170,7 +170,7 @@ wgl_present(struct pipe_screen *screen, * other structs such as this stw_winsys as well... */ -#if defined(GALLIUM_LLVMPIPE) || defined(GALLIUM_SOFTPIPE) +#if defined(HAVE_SWRAST) struct sw_winsys *winsys = NULL; struct sw_displaytarget *dt = NULL; #endif diff --git a/src/gallium/tests/meson.build b/src/gallium/tests/meson.build index 5296e4fae32..698da5fc214 100644 --- a/src/gallium/tests/meson.build +++ b/src/gallium/tests/meson.build @@ -5,6 +5,6 @@ if not with_platform_windows # pipe-loader doesn't build on windows. subdir('trivial') endif -if with_gallium_softpipe +if with_gallium_swrast subdir('unit') endif