gallium: remove dynamic pipe-loader
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run

Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/833>
This commit is contained in:
Karol Herbst 2025-05-26 17:37:50 +02:00 committed by Marge Bot
parent cd78417514
commit 30c5c7d811
19 changed files with 6 additions and 369 deletions

View file

@ -1082,11 +1082,6 @@ Gallium environment variables
specifies a file for logging all errors, warnings, etc. rather than
stderr.
.. envvar:: GALLIUM_PIPE_SEARCH_DIR
specifies an alternate search directory for pipe-loader which overrides
the compile-time path based on the install location.
.. envvar:: GALLIUM_PRINT_OPTIONS
if non-zero, print all the Gallium environment variables which are

View file

@ -47,7 +47,7 @@ libpipe_loader_static = static_library(
inc_util, inc_loader, inc_gallium, inc_include, inc_src, inc_gallium_aux,
inc_gallium_winsys, inc_gallium_drivers,
],
c_args : [libpipe_loader_defines, '-DGALLIUM_STATIC_TARGETS=1', renderonly_drivers_c_args],
c_args : [libpipe_loader_defines, renderonly_drivers_c_args],
gnu_symbol_visibility : 'hidden',
link_with : [libpipe_loader_links],
dependencies : [dep_libdrm, idep_xmlconfig, idep_mesautil],

View file

@ -30,8 +30,6 @@
#include "util/u_inlines.h"
#include "util/u_memory.h"
#include "util/u_string.h"
#include "util/u_dl.h"
#include "util/u_file.h"
#include "util/xmlconfig.h"
#include "util/driconf.h"
@ -42,8 +40,6 @@
#define PATH_MAX _MAX_PATH
#endif
#define MODULE_PREFIX "pipe_"
static int (*backends[])(struct pipe_loader_device **, int) = {
#ifdef HAVE_LIBDRM
&pipe_loader_drm_probe,
@ -186,37 +182,3 @@ pipe_loader_create_screen(struct pipe_loader_device *dev, bool driver_name_is_in
{
return pipe_loader_create_screen_vk(dev, false, driver_name_is_inferred);
}
struct util_dl_library *
pipe_loader_find_module(const char *driver_name,
const char *library_paths)
{
struct util_dl_library *lib;
const char *next;
char path[PATH_MAX];
int len, ret;
for (next = library_paths; *next; library_paths = next + 1) {
next = strchrnul(library_paths, ':');
len = next - library_paths;
if (len)
ret = snprintf(path, sizeof(path), "%.*s/%s%s%s",
len, library_paths,
MODULE_PREFIX, driver_name, UTIL_DL_EXT);
else
ret = snprintf(path, sizeof(path), "%s%s%s",
MODULE_PREFIX, driver_name, UTIL_DL_EXT);
if (ret > 0 && ret < sizeof(path) && u_file_access(path, 0) != -1) {
lib = util_dl_open(path);
if (lib) {
return lib;
}
fprintf(stderr, "ERROR: Failed to load pipe driver at `%s': %s\n",
path, util_dl_error());
}
}
return NULL;
}

View file

@ -45,7 +45,6 @@
#include "util/log.h"
#include "util/os_file.h"
#include "util/u_memory.h"
#include "util/u_dl.h"
#include "util/u_debug.h"
#include "util/xmlconfig.h"
@ -60,9 +59,6 @@
struct pipe_loader_drm_device {
struct pipe_loader_device base;
const struct drm_driver_descriptor *dd;
#ifndef GALLIUM_STATIC_TARGETS
struct util_dl_library *lib;
#endif
int fd;
};
@ -70,7 +66,6 @@ struct pipe_loader_drm_device {
static const struct pipe_loader_ops pipe_loader_drm_ops;
#ifdef GALLIUM_STATIC_TARGETS
static const struct drm_driver_descriptor *driver_descriptors[] = {
&i915_driver_descriptor,
&iris_driver_descriptor,
@ -93,36 +88,15 @@ static const struct drm_driver_descriptor *driver_descriptors[] = {
&lima_driver_descriptor,
&zink_driver_descriptor,
};
#endif
static const struct drm_driver_descriptor *
get_driver_descriptor(const char *driver_name, struct util_dl_library **plib)
get_driver_descriptor(const char *driver_name)
{
#ifdef GALLIUM_STATIC_TARGETS
for (int i = 0; i < ARRAY_SIZE(driver_descriptors); i++) {
if (strcmp(driver_descriptors[i]->driver_name, driver_name) == 0)
return driver_descriptors[i];
}
return &kmsro_driver_descriptor;
#else
const char *search_dir = os_get_option("GALLIUM_PIPE_SEARCH_DIR");
if (search_dir == NULL)
search_dir = PIPE_SEARCH_DIR;
*plib = pipe_loader_find_module(driver_name, search_dir);
if (!*plib)
return NULL;
const struct drm_driver_descriptor *dd =
(const struct drm_driver_descriptor *)
util_dl_get_proc_address(*plib, "driver_descriptor");
/* sanity check on the driver name */
if (dd && strcmp(dd->driver_name, driver_name) == 0)
return dd;
#endif
return NULL;
}
static int
@ -176,7 +150,6 @@ pipe_loader_drm_probe_fd_nodup(struct pipe_loader_device **dev, int fd, bool zin
if (strcmp(ddev->base.driver_name, "virtio_gpu") == 0) {
struct virgl_renderer_capset_drm caps;
if (get_nctx_caps(fd, &caps) == 0) {
#ifdef GALLIUM_STATIC_TARGETS
for (int i = 0; i < ARRAY_SIZE(driver_descriptors); i++) {
if (!driver_descriptors[i]->probe_nctx)
continue;
@ -187,17 +160,10 @@ pipe_loader_drm_probe_fd_nodup(struct pipe_loader_device **dev, int fd, bool zin
ddev->base.driver_name = strdup(driver_descriptors[i]->driver_name);
break;
}
#else
mesa_logw("Dynamic pipe loader does not support virtgpu native context");
#endif
}
}
struct util_dl_library **plib = NULL;
#ifndef GALLIUM_STATIC_TARGETS
plib = &ddev->lib;
#endif
ddev->dd = get_driver_descriptor(ddev->base.driver_name, plib);
ddev->dd = get_driver_descriptor(ddev->base.driver_name);
/* vgem is a virtual device; don't try using it with kmsro */
if (strcmp(ddev->base.driver_name, "vgem") == 0)
@ -205,7 +171,7 @@ pipe_loader_drm_probe_fd_nodup(struct pipe_loader_device **dev, int fd, bool zin
/* kmsro supports lots of drivers, try as a fallback */
if (!ddev->dd && !zink)
ddev->dd = get_driver_descriptor("kmsro", plib);
ddev->dd = get_driver_descriptor("kmsro");
if (!ddev->dd)
goto fail;
@ -214,10 +180,6 @@ pipe_loader_drm_probe_fd_nodup(struct pipe_loader_device **dev, int fd, bool zin
return true;
fail:
#ifndef GALLIUM_STATIC_TARGETS
if (ddev->lib)
util_dl_close(ddev->lib);
#endif
FREE(ddev->base.driver_name);
FREE(ddev);
return false;
@ -297,11 +259,6 @@ pipe_loader_drm_release(struct pipe_loader_device **dev)
{
struct pipe_loader_drm_device *ddev = pipe_loader_drm_device(*dev);
#ifndef GALLIUM_STATIC_TARGETS
if (ddev->lib)
util_dl_close(ddev->lib);
#endif
close(ddev->fd);
FREE(ddev->base.driver_name);
pipe_loader_base_release(dev);
@ -396,9 +353,8 @@ const struct driOptionDescription *
pipe_loader_drm_get_driconf_by_name(const char *driver_name, unsigned *count)
{
driOptionDescription *driconf = NULL;
struct util_dl_library *lib = NULL;
const struct drm_driver_descriptor *dd =
get_driver_descriptor(driver_name, &lib);
get_driver_descriptor(driver_name);
if (!dd) {
*count = 0;
@ -442,8 +398,6 @@ pipe_loader_drm_get_driconf_by_name(const char *driver_name, unsigned *count)
}
}
}
if (lib)
util_dl_close(lib);
return driconf;
}

View file

@ -55,13 +55,6 @@ struct pipe_loader_ops {
void (*release)(struct pipe_loader_device **dev);
};
/**
* Open the pipe driver module that contains the specified driver.
*/
struct util_dl_library *
pipe_loader_find_module(const char *driver_name,
const char *library_paths);
/**
* Free the base device structure.
*

View file

@ -34,7 +34,6 @@
#include "util/detect_os.h"
#include "util/os_file.h"
#include "util/u_memory.h"
#include "util/u_dl.h"
#include "sw/dri/dri_sw_winsys.h"
#include "sw/kms-dri/kms_dri_sw_winsys.h"
#include "sw/null/null_sw_winsys.h"
@ -49,9 +48,6 @@
struct pipe_loader_sw_device {
struct pipe_loader_device base;
const struct sw_driver_descriptor *dd;
#ifndef GALLIUM_STATIC_TARGETS
struct util_dl_library *lib;
#endif
struct sw_winsys *ws;
int fd;
};
@ -63,7 +59,6 @@ static const struct pipe_loader_ops pipe_loader_sw_ops;
static const struct pipe_loader_ops pipe_loader_vk_ops;
#endif
#ifdef GALLIUM_STATIC_TARGETS
static const struct sw_driver_descriptor driver_descriptors = {
.create_screen = sw_screen_create_vk,
.winsys = {
@ -92,9 +87,8 @@ static const struct sw_driver_descriptor driver_descriptors = {
{ 0 },
}
};
#endif
#if defined(GALLIUM_STATIC_TARGETS) && defined(HAVE_ZINK) && defined(HAVE_DRI)
#if defined(HAVE_ZINK) && defined(HAVE_DRI)
static const struct sw_driver_descriptor kopper_driver_descriptors = {
.create_screen = sw_screen_create_zink,
.winsys = {
@ -131,29 +125,9 @@ pipe_loader_sw_probe_init_common(struct pipe_loader_sw_device *sdev)
sdev->base.ops = &pipe_loader_sw_ops;
sdev->fd = -1;
#ifdef GALLIUM_STATIC_TARGETS
sdev->dd = &driver_descriptors;
if (!sdev->dd)
return false;
#else
const char *search_dir = os_get_option("GALLIUM_PIPE_SEARCH_DIR");
if (search_dir == NULL)
search_dir = PIPE_SEARCH_DIR;
sdev->lib = pipe_loader_find_module("swrast", search_dir);
if (!sdev->lib)
return false;
sdev->dd = (const struct sw_driver_descriptor *)
util_dl_get_proc_address(sdev->lib, "swrast_driver_descriptor");
if (!sdev->dd){
util_dl_close(sdev->lib);
sdev->lib = NULL;
return false;
}
#endif
return true;
}
@ -166,42 +140,13 @@ pipe_loader_vk_probe_init_common(struct pipe_loader_sw_device *sdev)
sdev->base.ops = &pipe_loader_vk_ops;
sdev->fd = -1;
#ifdef GALLIUM_STATIC_TARGETS
sdev->dd = &kopper_driver_descriptors;
if (!sdev->dd)
return false;
#else
const char *search_dir = os_get_option("GALLIUM_PIPE_SEARCH_DIR");
if (search_dir == NULL)
search_dir = PIPE_SEARCH_DIR;
sdev->lib = pipe_loader_find_module("swrast", search_dir);
if (!sdev->lib)
return false;
sdev->dd = (const struct sw_driver_descriptor *)
util_dl_get_proc_address(sdev->lib, "swrast_driver_descriptor");
if (!sdev->dd){
util_dl_close(sdev->lib);
sdev->lib = NULL;
return false;
}
#endif
return true;
}
#endif
static void
pipe_loader_sw_probe_teardown_common(struct pipe_loader_sw_device *sdev)
{
#ifndef GALLIUM_STATIC_TARGETS
if (sdev->lib)
util_dl_close(sdev->lib);
#endif
}
#ifdef HAVE_DRI
bool
pipe_loader_sw_probe_dri(struct pipe_loader_device **devs, const struct drisw_loader_funcs *drisw_lf)
@ -228,7 +173,6 @@ pipe_loader_sw_probe_dri(struct pipe_loader_device **devs, const struct drisw_lo
return true;
fail:
pipe_loader_sw_probe_teardown_common(sdev);
FREE(sdev);
return false;
}
@ -258,7 +202,6 @@ pipe_loader_vk_probe_dri(struct pipe_loader_device **devs)
return true;
fail:
pipe_loader_sw_probe_teardown_common(sdev);
FREE(sdev);
return false;
}
@ -294,7 +237,6 @@ pipe_loader_sw_probe_kms(struct pipe_loader_device **devs, int fd)
return true;
fail:
pipe_loader_sw_probe_teardown_common(sdev);
if (sdev->fd != -1)
close(sdev->fd);
FREE(sdev);
@ -327,7 +269,6 @@ pipe_loader_sw_probe_null(struct pipe_loader_device **devs)
return true;
fail:
pipe_loader_sw_probe_teardown_common(sdev);
FREE(sdev);
return false;
}
@ -372,7 +313,6 @@ pipe_loader_sw_probe_wrapped(struct pipe_loader_device **dev,
return true;
fail:
pipe_loader_sw_probe_teardown_common(sdev);
FREE(sdev);
return false;
}
@ -384,10 +324,6 @@ pipe_loader_sw_release(struct pipe_loader_device **dev)
pipe_loader_sw_device(*dev);
sdev->ws->destroy(sdev->ws);
#ifndef GALLIUM_STATIC_TARGETS
if (sdev->lib)
util_dl_close(sdev->lib);
#endif
#ifdef HAVE_DRISW_KMS
if (sdev->fd != -1)

View file

@ -1,87 +0,0 @@
# Copyright © 2017-2018 Intel Corporation
# SPDX-License-Identifier: MIT
pipe_loader_link_args = [ld_args_gc_sections, ld_args_build_id]
pipe_loader_link_deps = []
pipe_loader_link_with = [libgallium, libgalliumvl_stub]
pipe_loader_comp_args = []
pipe_loader_incs = [
inc_include, inc_src, inc_util, inc_gallium, inc_gallium_drivers,
inc_gallium_winsys, inc_gallium_aux,
]
if (with_gallium_mediafoundation or with_gallium_va or with_gallium_vdpau)
pipe_loader_link_with += libgalliumvlwinsys
endif
pipe_loader_install_dir = join_paths(get_option('libdir'), 'gallium-pipe')
_kmsro_targets = [
driver_kmsro, driver_v3d, driver_vc4, driver_freedreno, driver_etnaviv,
driver_panfrost, driver_lima, driver_asahi,
]
if with_gallium_v3d
_kmsro_targets += [idep_xmlconfig, dep_expat]
endif
pipe_loaders = [
[with_gallium_i915, 'i915', driver_i915, []],
[with_gallium_crocus, 'crocus', [driver_crocus, idep_xmlconfig], []],
[with_gallium_iris, 'iris', [driver_iris, idep_xmlconfig], []],
[with_gallium_nouveau, 'nouveau', driver_nouveau, []],
[with_gallium_r300, 'r300', driver_r300, []],
[with_gallium_r600, 'r600', driver_r600, []],
[with_gallium_radeonsi, 'radeonsi', [driver_radeonsi, idep_xmlconfig], []],
[with_gallium_freedreno, 'msm', driver_freedreno, []],
[with_gallium_kmsro, 'kmsro', _kmsro_targets, [libpipe_loader_dynamic]],
[with_gallium_svga, 'vmwgfx', driver_svga, []],
[with_gallium_swrast, 'swrast', driver_swrast, [libwsw, libws_null, libswdri, libswkmsdri]],
]
foreach x : pipe_loaders
if not x[0]
continue
endif
pipe_sym_config = configuration_data()
foreach d : [[x[1] in ['r300', 'r600', 'radeonsi'], 'radeon_drm_winsys_create'],
[x[1] == 'radeonsi', 'amdgpu_winsys_create'],
[x[1] == 'radeonsi' and amd_with_llvm, 'ac_init_shared_llvm_once'],
[x[1] != 'swrast', 'driver_descriptor'],
[x[1] == 'swrast', 'swrast_driver_descriptor']]
if d[0]
pipe_sym_config.set(d[1], d[1] + ';')
else
pipe_sym_config.set(d[1], '')
endif
endforeach
pipe_sym = configure_file(input : 'pipe.sym.in', output : 'pipe_@0@.sym'.format(x[1]), configuration : pipe_sym_config)
cur_pipe_loader_link_args = pipe_loader_link_args
cur_pipe_loader_link_deps = pipe_loader_link_deps
if with_ld_version_script
cur_pipe_loader_link_args += [
'-Wl,--version-script', join_paths(meson.current_build_dir(), 'pipe_@0@.sym'.format(x[1]))
]
cur_pipe_loader_link_deps += pipe_sym
endif
shared_library(
'pipe_@0@'.format(x[1]),
'pipe_@0@.c'.format(x[1]),
c_args : [pipe_loader_comp_args, '-DPIPE_LOADER_DYNAMIC=1'],
cpp_args : [pipe_loader_comp_args],
gnu_symbol_visibility : 'hidden',
link_args : cur_pipe_loader_link_args,
link_depends : cur_pipe_loader_link_deps,
include_directories : pipe_loader_incs,
link_with : [pipe_loader_link_with, x[3]],
dependencies : [idep_mesautil, idep_nir, dep_thread, x[2]],
name_prefix : '',
install : true,
install_dir : pipe_loader_install_dir,
)
endforeach

View file

@ -1,13 +0,0 @@
{
global:
@driver_descriptor@
@swrast_driver_descriptor@
# Workaround for an LLVM warning with -simplifycfg-sink-common
# due to LLVM being initialized multiple times.
@radeon_drm_winsys_create@
@amdgpu_winsys_create@
@ac_init_shared_llvm_once@
local:
*;
};

View file

@ -1,5 +0,0 @@
#include "frontend/drm_driver.h"
#include "target-helpers/drm_helper.h"
#include "target-helpers/inline_debug_helper.h"
#include "crocus/drm/crocus_drm_public.h"
#include "util/driconf.h"

View file

@ -1,5 +0,0 @@
#include "frontend/drm_driver.h"
#include "target-helpers/drm_helper.h"
#include "target-helpers/inline_debug_helper.h"
#include "i915/drm/i915_drm_public.h"
#include "i915/i915_public.h"

View file

@ -1,5 +0,0 @@
#include "frontend/drm_driver.h"
#include "target-helpers/drm_helper.h"
#include "target-helpers/inline_debug_helper.h"
#include "iris/drm/iris_drm_public.h"
#include "util/driconf.h"

View file

@ -1,6 +0,0 @@
#include "target-helpers/inline_debug_helper.h"
#include "frontend/drm_driver.h"
#include "kmsro/drm/kmsro_drm_public.h"
#define GALLIUM_KMSRO_ONLY
#include "target-helpers/drm_helper.h"

View file

@ -1,5 +0,0 @@
#include "target-helpers/drm_helper.h"
#include "target-helpers/inline_debug_helper.h"
#include "frontend/drm_driver.h"
#include "freedreno/drm/freedreno_drm_public.h"

View file

@ -1,5 +0,0 @@
#include "target-helpers/drm_helper.h"
#include "target-helpers/inline_debug_helper.h"
#include "frontend/drm_driver.h"
#include "nouveau/drm/nouveau_drm_public.h"

View file

@ -1,5 +0,0 @@
#include "target-helpers/drm_helper.h"
#include "target-helpers/inline_debug_helper.h"
#include "frontend/drm_driver.h"
#include "winsys/radeon_winsys.h"
#include "r300/r300_public.h"

View file

@ -1,5 +0,0 @@
#include "frontend/drm_driver.h"
#include "target-helpers/drm_helper.h"
#include "target-helpers/inline_debug_helper.h"
#include "winsys/radeon_winsys.h"
#include "r600/r600_public.h"

View file

@ -1,5 +0,0 @@
#include "frontend/drm_driver.h"
#include "target-helpers/drm_helper.h"
#include "target-helpers/inline_debug_helper.h"
#include "radeonsi/si_public.h"
#include "util/driconf.h"

View file

@ -1,51 +0,0 @@
#include "target-helpers/inline_sw_helper.h"
#include "target-helpers/inline_debug_helper.h"
#include "frontend/sw_driver.h"
#include "sw/dri/dri_sw_winsys.h"
#include "sw/kms-dri/kms_dri_sw_winsys.h"
#include "sw/null/null_sw_winsys.h"
#include "sw/wrapper/wrapper_sw_winsys.h"
PUBLIC struct pipe_screen *
swrast_create_screen(struct sw_winsys *ws, const struct pipe_screen_config *config, bool sw_vk);
struct pipe_screen *
swrast_create_screen(struct sw_winsys *ws, const struct pipe_screen_config *config, bool sw_vk)
{
struct pipe_screen *screen;
screen = sw_screen_create(ws);
if (screen)
screen = debug_screen_wrap(screen);
return screen;
}
PUBLIC
const struct sw_driver_descriptor swrast_driver_descriptor = {
.create_screen = swrast_create_screen,
.winsys = {
#ifdef HAVE_DRI
{
.name = "dri",
.create_winsys_dri = dri_create_sw_winsys,
},
#endif
#ifdef HAVE_DRISW_KMS
{
.name = "kms_dri",
.create_winsys_kms_dri = kms_dri_create_winsys,
},
#endif
{
.name = "null",
.create_winsys = null_sw_create,
},
{
.name = "wrapped",
.create_winsys_wrapped = wrapper_sw_winsys_wrap_pipe_screen,
},
{ 0 },
}
};

View file

@ -1,6 +0,0 @@
#include "target-helpers/inline_debug_helper.h"
#include "target-helpers/drm_helper.h"
#include "frontend/drm_driver.h"
#include "svga/drm/svga_drm_public.h"
#include "svga/svga_public.h"