LLVM_VERSION = @LLVM_VERSION@
HAVE_XF86VIDMODE = @HAVE_XF86VIDMODE@
+
+GALLIUM_PIPE_LOADER_DEFINES = @GALLIUM_PIPE_LOADER_DEFINES@
+GALLIUM_PIPE_LOADER_LIBS = @GALLIUM_PIPE_LOADER_LIBS@
done
fi
+if test "x$enable_gallium_loader" = xyes; then
+ GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS sw/null"
+ GALLIUM_PIPE_LOADER_DEFINES="-DHAVE_PIPE_LOADER_SW"
+ GALLIUM_PIPE_LOADER_LIBS="\$(TOP)/src/gallium/auxiliary/pipe-loader/libpipe_loader.a"
+ GALLIUM_PIPE_LOADER_LIBS="$GALLIUM_PIPE_LOADER_LIBS \$(TOP)/src/gallium/winsys/sw/null/libws_null.a"
+
+ if test "x$HAVE_WINSYS_XLIB" = xyes; then
+ GALLIUM_PIPE_LOADER_DEFINES="$GALLIUM_PIPE_LOADER_DEFINES -DHAVE_PIPE_LOADER_XLIB"
+ GALLIUM_PIPE_LOADER_LIBS="$GALLIUM_PIPE_LOADER_LIBS \$(TOP)/src/gallium/winsys/sw/xlib/libws_xlib.a"
+ fi
+
+ if test "x$enable_gallium_drm_loader" = xyes; then
+ GALLIUM_PIPE_LOADER_DEFINES="$GALLIUM_PIPE_LOADER_DEFINES -DHAVE_PIPE_LOADER_DRM"
+ fi
+
+ AC_SUBST([GALLIUM_PIPE_LOADER_DEFINES])
+ AC_SUBST([GALLIUM_PIPE_LOADER_LIBS])
+fi
+
dnl Tell Automake which drivers to build
for driver in $GALLIUM_DRIVERS_DIRS; do
case "x$driver" in
AM_CONDITIONAL(HAVE_NOOP_GALLIUM, test x$HAVE_NOOP_GALLIUM = xyes)
AM_CONDITIONAL(NEED_RADEON_GALLIUM, test x$NEED_RADEON_GALLIUM = xyes)
AM_CONDITIONAL(USE_R600_LLVM_COMPILER, test x$USE_R600_LLVM_COMPILER = xyes)
+AM_CONDITIONAL(HAVE_LOADER_GALLIUM, test x$enable_gallium_loader = xyes)
+AM_CONDITIONAL(HAVE_DRM_LOADER_GALLIUM, test x$enable_gallium_drm_loader = xyes)
AC_SUBST([GALLIUM_MAKE_DIRS])
dnl prepend CORE_DIRS to SRC_DIRS
dnl Substitute the config
AC_CONFIG_FILES([configs/autoconf
+ src/gallium/auxiliary/pipe-loader/Makefile
src/gallium/drivers/Makefile
src/gallium/drivers/r300/Makefile
src/gallium/drivers/r600/Makefile
include ../Makefile.template
+default install clean: %: subdirs-%
+
+subdirs-%:
+ @for dir in $(SUBDIRS) ; do \
+ if [ -d $$dir ] ; then \
+ (cd $$dir && $(MAKE) $*) || exit 1; \
+ fi \
+ done
indices/u_indices_gen.c: indices/u_indices_gen.py
$(PYTHON2) $< > $@
+SUBDIRS := pipe-loader
+
C_SOURCES := \
cso_cache/cso_cache.c \
cso_cache/cso_context.c \
--- /dev/null
+AUTOMAKE_OPTIONS = subdir-objects
+
+AM_CPPFLAGS = $(DEFINES) \
+ $(GALLIUM_PIPE_LOADER_DEFINES) \
+ -I$(top_srcdir)/include \
+ -I$(top_srcdir)/src/gallium/include \
+ -I$(top_srcdir)/src/gallium/auxiliary \
+ -I$(top_srcdir)/src/gallium/winsys
+
+AM_CFLAGS = $(PIC_FLAGS)
+
+noinst_LTLIBRARIES =
+
+if HAVE_LOADER_GALLIUM
+noinst_LTLIBRARIES += libpipe_loader.la
+
+libpipe_loader_la_SOURCES = \
+ pipe_loader.h \
+ pipe_loader_priv.h \
+ pipe_loader.c \
+ pipe_loader_sw.c
+
+if HAVE_DRM_LOADER_GALLIUM
+libpipe_loader_la_SOURCES += pipe_loader_drm.c
+AM_CFLAGS += $(LIBDRM_CFLAGS)
+endif
+
+# Provide compatibility with scripts for the old Mesa build system for
+# a while by putting a link to the library in the current directory.
+all-local: libpipe_loader.la
+ ln -f .libs/libpipe_loader.a .
+
+clean-local:
+ rm -f libpipe_loader.a
+endif
+
+# FIXME: Remove when the rest of Gallium is converted to automake.
+default: all
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2012 Francisco Jerez
+ * All Rights Reserved.
+ *
+ * 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, sub license, 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 (including the
+ * next paragraph) 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 NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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.
+ *
+ **************************************************************************/
+
+#include "pipe_loader_priv.h"
+
+#include "util/u_inlines.h"
+#include "util/u_memory.h"
+#include "util/u_string.h"
+#include "util/u_dl.h"
+
+#define MODULE_PREFIX "pipe_"
+
+static int (*backends[])(struct pipe_loader_device **, int) = {
+#ifdef HAVE_PIPE_LOADER_DRM
+ &pipe_loader_drm_probe,
+#endif
+ &pipe_loader_sw_probe
+};
+
+int
+pipe_loader_probe(struct pipe_loader_device **devs, int ndev)
+{
+ int i, n = 0;
+
+ for (i = 0; i < Elements(backends); i++)
+ n += backends[i](&devs[n], MAX2(0, ndev - n));
+
+ return n;
+}
+
+void
+pipe_loader_release(struct pipe_loader_device **devs, int ndev)
+{
+ int i;
+
+ for (i = 0; i < ndev; i++)
+ devs[i]->ops->release(&devs[i]);
+}
+
+struct pipe_screen *
+pipe_loader_create_screen(struct pipe_loader_device *dev,
+ const char *library_paths)
+{
+ return dev->ops->create_screen(dev, library_paths);
+}
+
+struct util_dl_library *
+pipe_loader_find_module(struct pipe_loader_device *dev,
+ 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 = util_strchrnul(library_paths, ':');
+ len = next - library_paths;
+
+ if (len)
+ ret = util_snprintf(path, sizeof(path), "%.*s/%s%s%s",
+ len, library_paths,
+ MODULE_PREFIX, dev->driver_name, UTIL_DL_EXT);
+ else
+ ret = util_snprintf(path, sizeof(path), "%s%s%s",
+ MODULE_PREFIX, dev->driver_name, UTIL_DL_EXT);
+
+ if (ret > 0 && ret < sizeof(path)) {
+ lib = util_dl_open(path);
+ if (lib) {
+ debug_printf("loaded %s\n", path);
+ return lib;
+ }
+ }
+ }
+
+ return NULL;
+}
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2012 Francisco Jerez
+ * All Rights Reserved.
+ *
+ * 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, sub license, 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 (including the
+ * next paragraph) 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 NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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.
+ *
+ **************************************************************************/
+
+/**
+ * \file Library that provides device enumeration and creation of
+ * winsys/pipe_screen instances.
+ */
+
+#ifndef PIPE_LOADER_H
+#define PIPE_LOADER_H
+
+#include "pipe/p_compiler.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct pipe_screen;
+
+enum pipe_loader_device_type {
+ PIPE_LOADER_DEVICE_SOFTWARE,
+ PIPE_LOADER_DEVICE_PCI,
+ NUM_PIPE_LOADER_DEVICE_TYPES
+};
+
+/**
+ * A device known to the pipe loader.
+ */
+struct pipe_loader_device {
+ enum pipe_loader_device_type type;
+
+ union {
+ struct {
+ int vendor_id;
+ int chip_id;
+ } pci;
+ }; /**< Discriminated by \a type */
+
+ const char *driver_name;
+ const struct pipe_loader_ops *ops;
+};
+
+/**
+ * Get a list of known devices.
+ *
+ * \param devs Array that will be filled with pointers to the devices
+ * available in the system.
+ * \param ndev Maximum number of devices to return.
+ * \return Number of devices available in the system.
+ */
+int
+pipe_loader_probe(struct pipe_loader_device **devs, int ndev);
+
+/**
+ * Create a pipe_screen for the specified device.
+ *
+ * \param dev Device the screen will be created for.
+ * \param library_paths Colon-separated list of filesystem paths that
+ * will be used to look for the pipe driver
+ * module that handles this device.
+ */
+struct pipe_screen *
+pipe_loader_create_screen(struct pipe_loader_device *dev,
+ const char *library_paths);
+
+/**
+ * Release resources allocated for a list of devices.
+ *
+ * Should be called when the specified devices are no longer in use to
+ * release any resources allocated by pipe_loader_probe.
+ *
+ * \param devs Devices to release.
+ * \param ndev Number of devices to release.
+ */
+void
+pipe_loader_release(struct pipe_loader_device **devs, int ndev);
+
+#ifdef HAVE_PIPE_LOADER_SW
+
+/**
+ * Get a list of known software devices.
+ *
+ * This function is platform-specific.
+ *
+ * \sa pipe_loader_probe
+ */
+int
+pipe_loader_sw_probe(struct pipe_loader_device **devs, int ndev);
+
+#endif
+
+#ifdef HAVE_PIPE_LOADER_DRM
+
+/**
+ * Get a list of known DRM devices.
+ *
+ * This function is platform-specific.
+ *
+ * \sa pipe_loader_probe
+ */
+int
+pipe_loader_drm_probe(struct pipe_loader_device **devs, int ndev);
+
+/**
+ * Initialize a DRM device in an already opened fd.
+ *
+ * This function is platform-specific.
+ *
+ * \sa pipe_loader_probe
+ */
+boolean
+pipe_loader_drm_probe_fd(struct pipe_loader_device **dev, int fd);
+
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* PIPE_LOADER_H */
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2011 Intel Corporation
+ * Copyright 2012 Francisco Jerez
+ * All Rights Reserved.
+ *
+ * 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, sub license, 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 (including the
+ * next paragraph) 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 NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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.
+ *
+ * Authors:
+ * Kristian Høgsberg <krh@bitplanet.net>
+ * Benjamin Franzke <benjaminfranzke@googlemail.com>
+ *
+ **************************************************************************/
+
+#include <fcntl.h>
+#include <stdio.h>
+#include <libudev.h>
+#include <xf86drm.h>
+
+#include "state_tracker/drm_driver.h"
+#include "pipe_loader_priv.h"
+
+#include "util/u_memory.h"
+#include "util/u_dl.h"
+#include "util/u_debug.h"
+
+#define DRIVER_MAP_GALLIUM_ONLY
+#include "pci_ids/pci_id_driver_map.h"
+
+struct pipe_loader_drm_device {
+ struct pipe_loader_device base;
+ struct util_dl_library *lib;
+ int fd;
+};
+
+#define pipe_loader_drm_device(dev) ((struct pipe_loader_drm_device *)dev)
+
+static boolean
+find_drm_pci_id(struct pipe_loader_drm_device *ddev)
+{
+ struct udev *udev = NULL;
+ struct udev_device *parent, *device = NULL;
+ struct stat stat;
+ const char *pci_id;
+
+ if (fstat(ddev->fd, &stat) < 0)
+ goto fail;
+
+ udev = udev_new();
+ if (!udev)
+ goto fail;
+
+ device = udev_device_new_from_devnum(udev, 'c', stat.st_rdev);
+ if (!device)
+ goto fail;
+
+ parent = udev_device_get_parent(device);
+ if (!parent)
+ goto fail;
+
+ pci_id = udev_device_get_property_value(parent, "PCI_ID");
+ if (!pci_id ||
+ sscanf(pci_id, "%x:%x", &ddev->base.pci.vendor_id,
+ &ddev->base.pci.chip_id) != 2)
+ goto fail;
+
+ return TRUE;
+
+ fail:
+ if (device)
+ udev_device_unref(device);
+ if (udev)
+ udev_unref(udev);
+
+ debug_printf("pci id for fd %d not found\n", ddev->fd);
+ return FALSE;
+}
+
+static boolean
+find_drm_driver_name(struct pipe_loader_drm_device *ddev)
+{
+ struct pipe_loader_device *dev = &ddev->base;
+ int i, j;
+
+ for (i = 0; driver_map[i].driver; i++) {
+ if (dev->pci.vendor_id != driver_map[i].vendor_id)
+ continue;
+
+ if (driver_map[i].num_chips_ids == -1) {
+ dev->driver_name = driver_map[i].driver;
+ goto found;
+ }
+
+ for (j = 0; j < driver_map[i].num_chips_ids; j++) {
+ if (dev->pci.chip_id == driver_map[i].chip_ids[j]) {
+ dev->driver_name = driver_map[i].driver;
+ goto found;
+ }
+ }
+ }
+
+ return FALSE;
+
+ found:
+ debug_printf("driver for %04x:%04x: %s\n", dev->pci.vendor_id,
+ dev->pci.chip_id, dev->driver_name);
+ return TRUE;
+}
+
+static struct pipe_loader_ops pipe_loader_drm_ops;
+
+boolean
+pipe_loader_drm_probe_fd(struct pipe_loader_device **dev, int fd)
+{
+ struct pipe_loader_drm_device *ddev = CALLOC_STRUCT(pipe_loader_drm_device);
+
+ ddev->base.type = PIPE_LOADER_DEVICE_PCI;
+ ddev->base.ops = &pipe_loader_drm_ops;
+ ddev->fd = fd;
+
+ if (!find_drm_pci_id(ddev))
+ goto fail;
+
+ if (!find_drm_driver_name(ddev))
+ goto fail;
+
+ *dev = &ddev->base;
+ return TRUE;
+
+ fail:
+ FREE(ddev);
+ return FALSE;
+}
+
+static int
+open_drm_minor(int minor)
+{
+ char path[PATH_MAX];
+ snprintf(path, sizeof(path), DRM_DEV_NAME, DRM_DIR_NAME, minor);
+ return open(path, O_RDWR, 0);
+}
+
+int
+pipe_loader_drm_probe(struct pipe_loader_device **devs, int ndev)
+{
+ int i, j, fd;
+
+ for (i = 0, j = 0; i < DRM_MAX_MINOR; i++) {
+ fd = open_drm_minor(i);
+ if (fd < 0)
+ continue;
+
+ if (j >= ndev || !pipe_loader_drm_probe_fd(&devs[j], fd))
+ close(fd);
+
+ j++;
+ }
+
+ return j;
+}
+
+static void
+pipe_loader_drm_release(struct pipe_loader_device **dev)
+{
+ struct pipe_loader_drm_device *ddev = pipe_loader_drm_device(*dev);
+
+ if (ddev->lib)
+ util_dl_close(ddev->lib);
+
+ close(ddev->fd);
+ FREE(ddev);
+ *dev = NULL;
+}
+
+static struct pipe_screen *
+pipe_loader_drm_create_screen(struct pipe_loader_device *dev,
+ const char *library_paths)
+{
+ struct pipe_loader_drm_device *ddev = pipe_loader_drm_device(dev);
+ const struct drm_driver_descriptor *dd;
+
+ if (!ddev->lib)
+ ddev->lib = pipe_loader_find_module(dev, library_paths);
+ if (!ddev->lib)
+ return NULL;
+
+ dd = (const struct drm_driver_descriptor *)
+ util_dl_get_proc_address(ddev->lib, "driver_descriptor");
+
+ /* sanity check on the name */
+ if (!dd || strcmp(dd->name, ddev->base.driver_name) != 0)
+ return NULL;
+
+ return dd->create_screen(ddev->fd);
+}
+
+static struct pipe_loader_ops pipe_loader_drm_ops = {
+ .create_screen = pipe_loader_drm_create_screen,
+ .release = pipe_loader_drm_release
+};
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2012 Francisco Jerez
+ * All Rights Reserved.
+ *
+ * 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, sub license, 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 (including the
+ * next paragraph) 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 NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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.
+ *
+ **************************************************************************/
+
+#ifndef PIPE_LOADER_PRIV_H
+#define PIPE_LOADER_PRIV_H
+
+#include "pipe_loader.h"
+
+struct pipe_loader_ops {
+ struct pipe_screen *(*create_screen)(struct pipe_loader_device *dev,
+ const char *library_paths);
+
+ void (*release)(struct pipe_loader_device **dev);
+};
+
+/**
+ * Open the pipe driver module that handles a specified device.
+ */
+struct util_dl_library *
+pipe_loader_find_module(struct pipe_loader_device *dev,
+ const char *library_paths);
+
+#endif /* PIPE_LOADER_PRIV_H */
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2012 Francisco Jerez
+ * All Rights Reserved.
+ *
+ * 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, sub license, 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 (including the
+ * next paragraph) 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 NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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.
+ *
+ **************************************************************************/
+
+#include "pipe_loader_priv.h"
+
+#include "util/u_memory.h"
+#include "util/u_dl.h"
+#include "sw/null/null_sw_winsys.h"
+#include "target-helpers/inline_sw_helper.h"
+#include "state_tracker/xlib_sw_winsys.h"
+
+struct pipe_loader_sw_device {
+ struct pipe_loader_device base;
+ struct util_dl_library *lib;
+ struct sw_winsys *ws;
+};
+
+#define pipe_loader_sw_device(dev) ((struct pipe_loader_sw_device *)dev)
+
+static struct pipe_loader_ops pipe_loader_sw_ops;
+
+static struct sw_winsys *(*backends[])() = {
+#ifdef HAVE_WINSYS_XLIB
+ x11_sw_create,
+#endif
+ null_sw_create
+};
+
+int
+pipe_loader_sw_probe(struct pipe_loader_device **devs, int ndev)
+{
+ int i;
+
+ for (i = 0; i < Elements(backends); i++) {
+ if (i < ndev) {
+ struct pipe_loader_sw_device *sdev = CALLOC_STRUCT(pipe_loader_sw_device);
+
+ sdev->base.type = PIPE_LOADER_DEVICE_SOFTWARE;
+ sdev->base.driver_name = "swrast";
+ sdev->base.ops = &pipe_loader_sw_ops;
+ sdev->ws = backends[i]();
+ devs[i] = &sdev->base;
+ }
+ }
+
+ return i;
+}
+
+static void
+pipe_loader_sw_release(struct pipe_loader_device **dev)
+{
+ struct pipe_loader_sw_device *sdev = pipe_loader_sw_device(*dev);
+
+ if (sdev->lib)
+ util_dl_close(sdev->lib);
+
+ FREE(sdev);
+ *dev = NULL;
+}
+
+static struct pipe_screen *
+pipe_loader_sw_create_screen(struct pipe_loader_device *dev,
+ const char *library_paths)
+{
+ struct pipe_loader_sw_device *sdev = pipe_loader_sw_device(dev);
+ struct pipe_screen *(*init)(struct sw_winsys *);
+
+ if (!sdev->lib)
+ sdev->lib = pipe_loader_find_module(dev, library_paths);
+ if (!sdev->lib)
+ return NULL;
+
+ init = (void *)util_dl_get_proc_address(sdev->lib, "swrast_create_screen");
+ if (!init)
+ return NULL;
+
+ return init(sdev->ws);
+}
+
+static struct pipe_loader_ops pipe_loader_sw_ops = {
+ .create_screen = pipe_loader_sw_create_screen,
+ .release = pipe_loader_sw_release
+};