diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2021-07-22 10:50:50 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2021-07-22 10:50:50 +0000 |
commit | 9130ec005fbc78a62420643414d8354d0929ca50 (patch) | |
tree | 6762777acdd2d4eee17ef87290e80dc7afe2b73d /lib/mesa/src/gallium/auxiliary/pipe-loader | |
parent | ca11beabae33eb59fb981b8adf50b1d47a2a98f0 (diff) |
Merge Mesa 21.1.5
Diffstat (limited to 'lib/mesa/src/gallium/auxiliary/pipe-loader')
6 files changed, 123 insertions, 171 deletions
diff --git a/lib/mesa/src/gallium/auxiliary/pipe-loader/SConscript b/lib/mesa/src/gallium/auxiliary/pipe-loader/SConscript deleted file mode 100644 index 14e1b350a..000000000 --- a/lib/mesa/src/gallium/auxiliary/pipe-loader/SConscript +++ /dev/null @@ -1,33 +0,0 @@ -Import('*') - -env = env.Clone() - -env.MSVC2013Compat() - -env.Append(CPPPATH = [ - '#/src/loader', - '#/src/gallium/winsys', -]) - -env.Append(CPPDEFINES = [ - ('HAVE_PIPE_LOADER_DRI', '1'), - ('DROP_PIPE_LOADER_MISC', '1'), - ('GALLIUM_STATIC_TARGETS', '1'), -]) - -source = env.ParseSourceList('Makefile.sources', 'COMMON_SOURCES') - -if env['HAVE_DRM']: - source += env.ParseSourceList('Makefile.sources', 'DRM_SOURCES') - - env.PkgUseModules('DRM') - env.Append(LIBS = [libloader]) - -pipe_loader = env.ConvenienceLibrary( - target = 'pipe_loader', - source = source, -) - -env.Alias('pipe_loader', pipe_loader) - -Export('pipe_loader') diff --git a/lib/mesa/src/gallium/auxiliary/pipe-loader/pipe_loader.c b/lib/mesa/src/gallium/auxiliary/pipe-loader/pipe_loader.c index e0fb249b6..4b6ac054f 100644 --- a/lib/mesa/src/gallium/auxiliary/pipe-loader/pipe_loader.c +++ b/lib/mesa/src/gallium/auxiliary/pipe-loader/pipe_loader.c @@ -27,13 +27,14 @@ #include "pipe_loader_priv.h" +#include "util/u_cpu_detect.h" #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/xmlpool.h" +#include "util/driconf.h" #include <string.h> @@ -51,11 +52,9 @@ static int (*backends[])(struct pipe_loader_device **, int) = { &pipe_loader_sw_probe }; -const char gallium_driinfo_xml[] = - DRI_CONF_BEGIN +const driOptionDescription gallium_driconf[] = { #include "driinfo_gallium.h" - DRI_CONF_END -; +}; int pipe_loader_probe(struct pipe_loader_device **devs, int ndev) @@ -87,32 +86,63 @@ pipe_loader_base_release(struct pipe_loader_device **dev) *dev = NULL; } +static driOptionDescription * +merge_driconf(const driOptionDescription *driver_driconf, unsigned driver_count, + unsigned *merged_count) +{ + unsigned gallium_count = ARRAY_SIZE(gallium_driconf); + driOptionDescription *merged = malloc((driver_count + gallium_count) * + sizeof(*merged)); + if (!merged) { + *merged_count = 0; + return NULL; + } + + memcpy(merged, gallium_driconf, sizeof(*merged) * gallium_count); + memcpy(&merged[gallium_count], driver_driconf, sizeof(*merged) * driver_count); + + *merged_count = driver_count + gallium_count; + return merged; +} + void pipe_loader_load_options(struct pipe_loader_device *dev) { if (dev->option_info.info) return; - const char *xml_options = dev->ops->get_driconf_xml(dev); - if (!xml_options) - xml_options = gallium_driinfo_xml; + unsigned driver_count, merged_count; + const driOptionDescription *driver_driconf = + dev->ops->get_driconf(dev, &driver_count); + + const driOptionDescription *merged_driconf = + merge_driconf(driver_driconf, driver_count, &merged_count); - driParseOptionInfo(&dev->option_info, xml_options); + driParseOptionInfo(&dev->option_info, merged_driconf, merged_count); driParseConfigFiles(&dev->option_cache, &dev->option_info, 0, - dev->driver_name, NULL, NULL, 0); + dev->driver_name, NULL, NULL, 0, NULL, 0); + free((void *)merged_driconf); } char * pipe_loader_get_driinfo_xml(const char *driver_name) { + unsigned driver_count = 0; + const driOptionDescription *driver_driconf = NULL; + #ifdef HAVE_LIBDRM - char *xml = pipe_loader_drm_get_driinfo_xml(driver_name); -#else - char *xml = NULL; + driver_driconf = pipe_loader_drm_get_driconf_by_name(driver_name, + &driver_count); #endif - if (!xml) - xml = strdup(gallium_driinfo_xml); + unsigned merged_count; + const driOptionDescription *merged_driconf = + merge_driconf(driver_driconf, driver_count, &merged_count); + free((void *)driver_driconf); + + char *xml = driGetOptionsXml(merged_driconf, merged_count); + + free((void *)merged_driconf); return xml; } @@ -122,6 +152,7 @@ pipe_loader_create_screen(struct pipe_loader_device *dev) { struct pipe_screen_config config; + util_cpu_detect(); pipe_loader_load_options(dev); config.options = &dev->option_cache; diff --git a/lib/mesa/src/gallium/auxiliary/pipe-loader/pipe_loader.h b/lib/mesa/src/gallium/auxiliary/pipe-loader/pipe_loader.h index a0d9c8a7d..ab89ed6f6 100644 --- a/lib/mesa/src/gallium/auxiliary/pipe-loader/pipe_loader.h +++ b/lib/mesa/src/gallium/auxiliary/pipe-loader/pipe_loader.h @@ -34,7 +34,7 @@ #define PIPE_LOADER_H #include "pipe/p_compiler.h" -#include "state_tracker/drm_driver.h" +#include "frontend/drm_driver.h" #include "util/xmlconfig.h" #ifdef __cplusplus @@ -199,14 +199,12 @@ bool pipe_loader_drm_probe_fd(struct pipe_loader_device **dev, int fd); /** - * Get the driinfo XML used for the DRM driver of the given name, if any. + * Get the dri options used for the DRM driver of the given name, if any. * - * The returned string is heap-allocated. + * The returned array is heap-allocated. */ -char * -pipe_loader_drm_get_driinfo_xml(const char *driver_name); - -extern const char gallium_driinfo_xml[]; +const struct driOptionDescription * +pipe_loader_drm_get_driconf_by_name(const char *driver_name, unsigned *count); #ifdef __cplusplus } diff --git a/lib/mesa/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c b/lib/mesa/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c index 7d90285a4..8147c3ca3 100644 --- a/lib/mesa/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c +++ b/lib/mesa/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c @@ -39,12 +39,14 @@ #include "loader.h" #include "target-helpers/drm_helper_public.h" -#include "state_tracker/drm_driver.h" +#include "frontend/drm_driver.h" #include "pipe_loader_priv.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" #define DRM_RENDER_NODE_DEV_NAME_FORMAT "%s/renderD%d" #define DRM_RENDER_NODE_MAX_NODES 63 @@ -65,88 +67,25 @@ 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[] = { - { - .driver_name = "i915", - .create_screen = pipe_i915_create_screen, - }, - { - .driver_name = "iris", - .create_screen = pipe_iris_create_screen, - .driconf_xml = &iris_driconf_xml, - }, - { - .driver_name = "nouveau", - .create_screen = pipe_nouveau_create_screen, - }, - { - .driver_name = "r300", - .create_screen = pipe_r300_create_screen, - }, - { - .driver_name = "r600", - .create_screen = pipe_r600_create_screen, - }, - { - .driver_name = "radeonsi", - .create_screen = pipe_radeonsi_create_screen, - .driconf_xml = &radeonsi_driconf_xml, - }, - { - .driver_name = "vmwgfx", - .create_screen = pipe_vmwgfx_create_screen, - }, - { - .driver_name = "kgsl", - .create_screen = pipe_freedreno_create_screen, - }, - { - .driver_name = "msm", - .create_screen = pipe_freedreno_create_screen, - }, - { - .driver_name = "virtio_gpu", - .create_screen = pipe_virgl_create_screen, - .driconf_xml = &virgl_driconf_xml, - }, - { - .driver_name = "v3d", - .create_screen = pipe_v3d_create_screen, - .driconf_xml = &v3d_driconf_xml, - }, - { - .driver_name = "vc4", - .create_screen = pipe_vc4_create_screen, - .driconf_xml = &v3d_driconf_xml, - }, - { - .driver_name = "panfrost", - .create_screen = pipe_panfrost_create_screen, - }, - { - .driver_name = "etnaviv", - .create_screen = pipe_etna_create_screen, - }, - { - .driver_name = "tegra", - .create_screen = pipe_tegra_create_screen, - }, - { - .driver_name = "lima", - .create_screen = pipe_lima_create_screen, - }, - { - .driver_name = "zink", - .create_screen = pipe_zink_create_screen, - }, +static const struct drm_driver_descriptor *driver_descriptors[] = { + &i915_driver_descriptor, + &iris_driver_descriptor, + &nouveau_driver_descriptor, + &r300_driver_descriptor, + &r600_driver_descriptor, + &radeonsi_driver_descriptor, + &vmwgfx_driver_descriptor, + &kgsl_driver_descriptor, + &msm_driver_descriptor, + &virtio_gpu_driver_descriptor, + &v3d_driver_descriptor, + &vc4_driver_descriptor, + &panfrost_driver_descriptor, + &etnaviv_driver_descriptor, + &tegra_driver_descriptor, + &lima_driver_descriptor, + &zink_driver_descriptor, }; - -static const struct drm_driver_descriptor default_driver_descriptor = { - .driver_name = "kmsro", - .create_screen = pipe_kmsro_create_screen, - .driconf_xml = &v3d_driconf_xml, -}; - #endif static const struct drm_driver_descriptor * @@ -154,12 +93,16 @@ get_driver_descriptor(const char *driver_name, struct util_dl_library **plib) { #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]; + if (strcmp(driver_descriptors[i]->driver_name, driver_name) == 0) + return driver_descriptors[i]; } - return &default_driver_descriptor; + return &kmsro_driver_descriptor; #else - *plib = pipe_loader_find_module(driver_name, PIPE_SEARCH_DIR); + const char *search_dir = getenv("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; @@ -213,6 +156,10 @@ pipe_loader_drm_probe_fd_nodup(struct pipe_loader_device **dev, int fd) #endif ddev->dd = get_driver_descriptor(ddev->base.driver_name, plib); + /* vgem is a virtual device; don't try using it with kmsro */ + if (strcmp(ddev->base.driver_name, "vgem") == 0) + goto fail; + /* kmsro supports lots of drivers, try as a fallback */ if (!ddev->dd) ddev->dd = get_driver_descriptor("kmsro", plib); @@ -239,7 +186,7 @@ pipe_loader_drm_probe_fd(struct pipe_loader_device **dev, int fd) bool ret; int new_fd; - if (fd < 0 || (new_fd = fcntl(fd, F_DUPFD_CLOEXEC, 3)) < 0) + if (fd < 0 || (new_fd = os_dupfd_cloexec(fd)) < 0) return false; ret = pipe_loader_drm_probe_fd_nodup(dev, new_fd); @@ -303,15 +250,13 @@ pipe_loader_drm_release(struct pipe_loader_device **dev) pipe_loader_base_release(dev); } -static const char * -pipe_loader_drm_get_driconf_xml(struct pipe_loader_device *dev) +static const struct driOptionDescription * +pipe_loader_drm_get_driconf(struct pipe_loader_device *dev, unsigned *count) { struct pipe_loader_drm_device *ddev = pipe_loader_drm_device(dev); - if (!ddev->dd->driconf_xml) - return NULL; - - return *ddev->dd->driconf_xml; + *count = ddev->dd->driconf_count; + return ddev->dd->driconf; } static struct pipe_screen * @@ -323,24 +268,30 @@ pipe_loader_drm_create_screen(struct pipe_loader_device *dev, return ddev->dd->create_screen(ddev->fd, config); } -char * -pipe_loader_drm_get_driinfo_xml(const char *driver_name) +const struct driOptionDescription * +pipe_loader_drm_get_driconf_by_name(const char *driver_name, unsigned *count) { - char *xml = NULL; + driOptionDescription *driconf = NULL; struct util_dl_library *lib = NULL; const struct drm_driver_descriptor *dd = get_driver_descriptor(driver_name, &lib); - if (dd && dd->driconf_xml && *dd->driconf_xml) - xml = strdup(*dd->driconf_xml); - + if (!dd) { + *count = 0; + } else { + *count = dd->driconf_count; + size_t size = sizeof(*driconf) * *count; + driconf = malloc(size); + memcpy(driconf, dd->driconf, size); + } if (lib) util_dl_close(lib); - return xml; + + return driconf; } static const struct pipe_loader_ops pipe_loader_drm_ops = { .create_screen = pipe_loader_drm_create_screen, - .get_driconf_xml = pipe_loader_drm_get_driconf_xml, + .get_driconf = pipe_loader_drm_get_driconf, .release = pipe_loader_drm_release }; diff --git a/lib/mesa/src/gallium/auxiliary/pipe-loader/pipe_loader_priv.h b/lib/mesa/src/gallium/auxiliary/pipe-loader/pipe_loader_priv.h index 01b7c5442..7f87cacd9 100644 --- a/lib/mesa/src/gallium/auxiliary/pipe-loader/pipe_loader_priv.h +++ b/lib/mesa/src/gallium/auxiliary/pipe-loader/pipe_loader_priv.h @@ -34,7 +34,8 @@ struct pipe_loader_ops { struct pipe_screen *(*create_screen)(struct pipe_loader_device *dev, const struct pipe_screen_config *config); - const char *(*get_driconf_xml)(struct pipe_loader_device *dev); + const struct driOptionDescription *(*get_driconf)(struct pipe_loader_device *dev, + unsigned *count); void (*release)(struct pipe_loader_device **dev); }; diff --git a/lib/mesa/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c b/lib/mesa/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c index c2a3896b8..daf154685 100644 --- a/lib/mesa/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c +++ b/lib/mesa/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c @@ -31,6 +31,7 @@ #include "pipe_loader_priv.h" +#include "util/os_file.h" #include "util/u_memory.h" #include "util/u_dl.h" #include "sw/dri/dri_sw_winsys.h" @@ -38,9 +39,11 @@ #include "sw/null/null_sw_winsys.h" #include "sw/wrapper/wrapper_sw_winsys.h" #include "target-helpers/sw_helper_public.h" -#include "state_tracker/drisw_api.h" -#include "state_tracker/sw_driver.h" -#include "state_tracker/sw_winsys.h" +#include "target-helpers/inline_debug_helper.h" +#include "frontend/drisw_api.h" +#include "frontend/sw_driver.h" +#include "frontend/sw_winsys.h" + struct pipe_loader_sw_device { struct pipe_loader_device base; @@ -72,11 +75,7 @@ static const struct sw_driver_descriptor driver_descriptors = { .create_winsys = kms_dri_create_winsys, }, #endif -/** - * XXX: Do not include these two for non autotools builds. - * They don't have neither opencl nor nine, where these are used. - */ -#ifndef DROP_PIPE_LOADER_MISC +#ifndef __ANDROID__ { .name = "null", .create_winsys = null_sw_create, @@ -104,7 +103,11 @@ pipe_loader_sw_probe_init_common(struct pipe_loader_sw_device *sdev) if (!sdev->dd) return false; #else - sdev->lib = pipe_loader_find_module("swrast", PIPE_SEARCH_DIR); + const char *search_dir = getenv("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; @@ -175,7 +178,7 @@ pipe_loader_sw_probe_kms(struct pipe_loader_device **devs, int fd) if (!pipe_loader_sw_probe_init_common(sdev)) goto fail; - if (fd < 0 || (sdev->fd = fcntl(fd, F_DUPFD_CLOEXEC, 3)) < 0) + if (fd < 0 || (sdev->fd = os_dupfd_cloexec(fd)) < 0) goto fail; for (i = 0; sdev->dd->winsys[i].name; i++) { @@ -293,9 +296,10 @@ pipe_loader_sw_release(struct pipe_loader_device **dev) pipe_loader_base_release(dev); } -static const char * -pipe_loader_sw_get_driconf_xml(struct pipe_loader_device *dev) +static const struct driOptionDescription * +pipe_loader_sw_get_driconf(struct pipe_loader_device *dev, unsigned *count) { + *count = 0; return NULL; } @@ -310,11 +314,11 @@ pipe_loader_sw_create_screen(struct pipe_loader_device *dev, if (!screen) sdev->ws->destroy(sdev->ws); - return screen; + return screen ? debug_screen_wrap(screen) : NULL; } static const struct pipe_loader_ops pipe_loader_sw_ops = { .create_screen = pipe_loader_sw_create_screen, - .get_driconf_xml = pipe_loader_sw_get_driconf_xml, + .get_driconf = pipe_loader_sw_get_driconf, .release = pipe_loader_sw_release }; |