summaryrefslogtreecommitdiff
path: root/lib/mesa/src/gallium/auxiliary/pipe-loader
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2016-05-29 10:22:51 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2016-05-29 10:22:51 +0000
commitc9223eed3c16cd3e98a8f56dda953d8f299de0e3 (patch)
tree53e2a1c3f13bcf6b4ed201d7bc135e7213c94ebe /lib/mesa/src/gallium/auxiliary/pipe-loader
parent6e8f2d062ab9c198239b9283b2b7ed12f4ea17d8 (diff)
Import Mesa 11.2.2
Diffstat (limited to 'lib/mesa/src/gallium/auxiliary/pipe-loader')
-rw-r--r--lib/mesa/src/gallium/auxiliary/pipe-loader/Makefile.am32
-rw-r--r--lib/mesa/src/gallium/auxiliary/pipe-loader/SConscript33
-rw-r--r--lib/mesa/src/gallium/auxiliary/pipe-loader/pipe_loader.c12
-rw-r--r--lib/mesa/src/gallium/auxiliary/pipe-loader/pipe_loader.h22
-rw-r--r--lib/mesa/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c179
-rw-r--r--lib/mesa/src/gallium/auxiliary/pipe-loader/pipe_loader_priv.h3
-rw-r--r--lib/mesa/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c226
7 files changed, 398 insertions, 109 deletions
diff --git a/lib/mesa/src/gallium/auxiliary/pipe-loader/Makefile.am b/lib/mesa/src/gallium/auxiliary/pipe-loader/Makefile.am
index 8c8379965..8039a957b 100644
--- a/lib/mesa/src/gallium/auxiliary/pipe-loader/Makefile.am
+++ b/lib/mesa/src/gallium/auxiliary/pipe-loader/Makefile.am
@@ -9,20 +9,40 @@ AM_CFLAGS = \
$(GALLIUM_CFLAGS) \
$(VISIBILITY_CFLAGS)
-noinst_LTLIBRARIES = libpipe_loader.la
+noinst_LTLIBRARIES = \
+ libpipe_loader_static.la \
+ libpipe_loader_dynamic.la
-libpipe_loader_la_SOURCES = \
+libpipe_loader_static_la_CFLAGS = \
+ $(AM_CFLAGS) \
+ -DGALLIUM_STATIC_TARGETS=1
+
+libpipe_loader_dynamic_la_CFLAGS = \
+ $(AM_CFLAGS) \
+ -DPIPE_SEARCH_DIR=\"$(libdir)/gallium-pipe\"
+
+libpipe_loader_static_la_SOURCES = \
$(COMMON_SOURCES)
-if HAVE_DRM_LOADER_GALLIUM
+libpipe_loader_dynamic_la_SOURCES = \
+ $(COMMON_SOURCES)
+
+if HAVE_LIBDRM
AM_CFLAGS += \
$(LIBDRM_CFLAGS)
-libpipe_loader_la_SOURCES += \
+libpipe_loader_static_la_SOURCES += \
$(DRM_SOURCES)
-libpipe_loader_la_LIBADD = \
- $(top_builddir)/src/loader/libloader.la
+libpipe_loader_dynamic_la_SOURCES += \
+ $(DRM_SOURCES)
endif
+libpipe_loader_static_la_LIBADD = \
+ $(top_builddir)/src/loader/libloader.la
+
+libpipe_loader_dynamic_la_LIBADD = \
+ $(top_builddir)/src/loader/libloader.la
+
+EXTRA_DIST = SConscript
diff --git a/lib/mesa/src/gallium/auxiliary/pipe-loader/SConscript b/lib/mesa/src/gallium/auxiliary/pipe-loader/SConscript
new file mode 100644
index 000000000..14e1b350a
--- /dev/null
+++ b/lib/mesa/src/gallium/auxiliary/pipe-loader/SConscript
@@ -0,0 +1,33 @@
+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 8e79f853b..aef996c46 100644
--- a/lib/mesa/src/gallium/auxiliary/pipe-loader/pipe_loader.c
+++ b/lib/mesa/src/gallium/auxiliary/pipe-loader/pipe_loader.c
@@ -32,10 +32,15 @@
#include "util/u_string.h"
#include "util/u_dl.h"
+#ifdef _MSC_VER
+#include <stdlib.h>
+#define PATH_MAX _MAX_PATH
+#endif
+
#define MODULE_PREFIX "pipe_"
static int (*backends[])(struct pipe_loader_device **, int) = {
-#ifdef HAVE_PIPE_LOADER_DRM
+#ifdef HAVE_LIBDRM
&pipe_loader_drm_probe,
#endif
&pipe_loader_sw_probe
@@ -69,10 +74,9 @@ pipe_loader_configuration(struct pipe_loader_device *dev,
}
struct pipe_screen *
-pipe_loader_create_screen(struct pipe_loader_device *dev,
- const char *library_paths)
+pipe_loader_create_screen(struct pipe_loader_device *dev)
{
- return dev->ops->create_screen(dev, library_paths);
+ return dev->ops->create_screen(dev);
}
struct util_dl_library *
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 9b8712666..690d088ed 100644
--- a/lib/mesa/src/gallium/auxiliary/pipe-loader/pipe_loader.h
+++ b/lib/mesa/src/gallium/auxiliary/pipe-loader/pipe_loader.h
@@ -82,13 +82,9 @@ 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);
+pipe_loader_create_screen(struct pipe_loader_device *dev);
/**
* Query the configuration parameters for the specified device.
@@ -112,8 +108,6 @@ pipe_loader_configuration(struct pipe_loader_device *dev,
void
pipe_loader_release(struct pipe_loader_device **devs, int ndev);
-#ifdef HAVE_PIPE_LOADER_DRI
-
/**
* Initialize sw dri device give the drisw_loader_funcs.
*
@@ -125,7 +119,15 @@ bool
pipe_loader_sw_probe_dri(struct pipe_loader_device **devs,
struct drisw_loader_funcs *drisw_lf);
-#endif
+/**
+ * Initialize a kms backed sw device given an fd.
+ *
+ * This function is platform-specific.
+ *
+ * \sa pipe_loader_probe
+ */
+bool
+pipe_loader_sw_probe_kms(struct pipe_loader_device **devs, int fd);
/**
* Initialize a null sw device.
@@ -158,8 +160,6 @@ boolean
pipe_loader_sw_probe_wrapped(struct pipe_loader_device **dev,
struct pipe_screen *screen);
-#ifdef HAVE_PIPE_LOADER_DRM
-
/**
* Get a list of known DRM devices.
*
@@ -180,8 +180,6 @@ pipe_loader_drm_probe(struct pipe_loader_device **devs, int ndev);
bool
pipe_loader_drm_probe_fd(struct pipe_loader_device **dev, int fd);
-#endif
-
#ifdef __cplusplus
}
#endif
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 1799df7e4..994a28438 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
@@ -36,6 +36,7 @@
#include <unistd.h>
#include "loader.h"
+#include "target-helpers/drm_helper_public.h"
#include "state_tracker/drm_driver.h"
#include "pipe_loader_priv.h"
@@ -50,13 +51,123 @@
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;
};
#define pipe_loader_drm_device(dev) ((struct pipe_loader_drm_device *)dev)
-static struct pipe_loader_ops pipe_loader_drm_ops;
+static const struct pipe_loader_ops pipe_loader_drm_ops;
+
+#ifdef GALLIUM_STATIC_TARGETS
+static const struct drm_conf_ret throttle_ret = {
+ DRM_CONF_INT,
+ {2},
+};
+
+static const struct drm_conf_ret share_fd_ret = {
+ DRM_CONF_BOOL,
+ {true},
+};
+
+static inline const struct drm_conf_ret *
+configuration_query(enum drm_conf conf)
+{
+ switch (conf) {
+ case DRM_CONF_THROTTLE:
+ return &throttle_ret;
+ case DRM_CONF_SHARE_FD:
+ return &share_fd_ret;
+ default:
+ break;
+ }
+ return NULL;
+}
+
+static const struct drm_driver_descriptor driver_descriptors[] = {
+ {
+ .name = "i915",
+ .driver_name = "i915",
+ .create_screen = pipe_i915_create_screen,
+ .configuration = configuration_query,
+ },
+#ifdef USE_VC4_SIMULATOR
+ /* VC4 simulator and ILO (i965) are mutually exclusive (error at
+ * configure). As the latter is unconditionally added, keep this one above
+ * it.
+ */
+ {
+ .name = "i965",
+ .driver_name = "vc4",
+ .create_screen = pipe_vc4_create_screen,
+ .configuration = configuration_query,
+ },
+#endif
+ {
+ .name = "i965",
+ .driver_name = "i915",
+ .create_screen = pipe_ilo_create_screen,
+ .configuration = configuration_query,
+ },
+ {
+ .name = "nouveau",
+ .driver_name = "nouveau",
+ .create_screen = pipe_nouveau_create_screen,
+ .configuration = configuration_query,
+ },
+ {
+ .name = "r300",
+ .driver_name = "radeon",
+ .create_screen = pipe_r300_create_screen,
+ .configuration = configuration_query,
+ },
+ {
+ .name = "r600",
+ .driver_name = "radeon",
+ .create_screen = pipe_r600_create_screen,
+ .configuration = configuration_query,
+ },
+ {
+ .name = "radeonsi",
+ .driver_name = "radeon",
+ .create_screen = pipe_radeonsi_create_screen,
+ .configuration = configuration_query,
+ },
+ {
+ .name = "vmwgfx",
+ .driver_name = "vmwgfx",
+ .create_screen = pipe_vmwgfx_create_screen,
+ .configuration = configuration_query,
+ },
+ {
+ .name = "kgsl",
+ .driver_name = "freedreno",
+ .create_screen = pipe_freedreno_create_screen,
+ .configuration = configuration_query,
+ },
+ {
+ .name = "msm",
+ .driver_name = "freedreno",
+ .create_screen = pipe_freedreno_create_screen,
+ .configuration = configuration_query,
+ },
+ {
+ .name = "virtio_gpu",
+ .driver_name = "virtio-gpu",
+ .create_screen = pipe_virgl_create_screen,
+ .configuration = configuration_query,
+ },
+ {
+ .name = "vc4",
+ .driver_name = "vc4",
+ .create_screen = pipe_vc4_create_screen,
+ .configuration = configuration_query,
+ },
+};
+#endif
bool
pipe_loader_drm_probe_fd(struct pipe_loader_device **dev, int fd)
@@ -81,10 +192,36 @@ pipe_loader_drm_probe_fd(struct pipe_loader_device **dev, int fd)
if (!ddev->base.driver_name)
goto fail;
+#ifdef GALLIUM_STATIC_TARGETS
+ for (int i = 0; i < ARRAY_SIZE(driver_descriptors); i++) {
+ if (strcmp(driver_descriptors[i].name, ddev->base.driver_name) == 0) {
+ ddev->dd = &driver_descriptors[i];
+ break;
+ }
+ }
+ if (!ddev->dd)
+ goto fail;
+#else
+ ddev->lib = pipe_loader_find_module(&ddev->base, PIPE_SEARCH_DIR);
+ if (!ddev->lib)
+ goto fail;
+
+ ddev->dd = (const struct drm_driver_descriptor *)
+ util_dl_get_proc_address(ddev->lib, "driver_descriptor");
+
+ /* sanity check on the name */
+ if (!ddev->dd || strcmp(ddev->dd->name, ddev->base.driver_name) != 0)
+ goto fail;
+#endif
+
*dev = &ddev->base;
return true;
fail:
+#ifndef GALLIUM_STATIC_TARGETS
+ if (ddev->lib)
+ util_dl_close(ddev->lib);
+#endif
FREE(ddev);
return false;
}
@@ -105,8 +242,9 @@ pipe_loader_drm_probe(struct pipe_loader_device **devs, int ndev)
for (i = DRM_RENDER_NODE_MIN_MINOR, j = 0;
i <= DRM_RENDER_NODE_MAX_MINOR; i++) {
- fd = open_drm_render_node_minor(i);
struct pipe_loader_device *dev;
+
+ fd = open_drm_render_node_minor(i);
if (fd < 0)
continue;
@@ -132,8 +270,10 @@ 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);
@@ -146,47 +286,22 @@ pipe_loader_drm_configuration(struct pipe_loader_device *dev,
enum drm_conf conf)
{
struct pipe_loader_drm_device *ddev = pipe_loader_drm_device(dev);
- const struct drm_driver_descriptor *dd;
-
- 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)
+ if (!ddev->dd->configuration)
return NULL;
- if (!dd->configuration)
- return NULL;
-
- return dd->configuration(conf);
+ return ddev->dd->configuration(conf);
}
static struct pipe_screen *
-pipe_loader_drm_create_screen(struct pipe_loader_device *dev,
- const char *library_paths)
+pipe_loader_drm_create_screen(struct pipe_loader_device *dev)
{
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);
+ return ddev->dd->create_screen(ddev->fd);
}
-static struct pipe_loader_ops pipe_loader_drm_ops = {
+static const struct pipe_loader_ops pipe_loader_drm_ops = {
.create_screen = pipe_loader_drm_create_screen,
.configuration = pipe_loader_drm_configuration,
.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 d3b025221..da2ca8c6e 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
@@ -31,8 +31,7 @@
#include "pipe_loader.h"
struct pipe_loader_ops {
- struct pipe_screen *(*create_screen)(struct pipe_loader_device *dev,
- const char *library_paths);
+ struct pipe_screen *(*create_screen)(struct pipe_loader_device *dev);
const struct drm_conf_ret *(*configuration)(struct pipe_loader_device *dev,
enum drm_conf conf);
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 679493019..c8e1f134c 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
@@ -30,45 +30,161 @@
#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"
#include "sw/wrapper/wrapper_sw_winsys.h"
-#include "target-helpers/inline_sw_helper.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"
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;
};
#define pipe_loader_sw_device(dev) ((struct pipe_loader_sw_device *)dev)
-static struct pipe_loader_ops pipe_loader_sw_ops;
+static const struct pipe_loader_ops pipe_loader_sw_ops;
-static struct sw_winsys *(*backends[])() = {
- null_sw_create
+#ifdef GALLIUM_STATIC_TARGETS
+static const struct sw_driver_descriptor driver_descriptors = {
+ .create_screen = sw_screen_create,
+ .winsys = {
+#ifdef HAVE_PIPE_LOADER_DRI
+ {
+ .name = "dri",
+ .create_winsys = dri_create_sw_winsys,
+ },
+#endif
+#ifdef HAVE_PIPE_LOADER_KMS
+ {
+ .name = "kms_dri",
+ .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
+ {
+ .name = "null",
+ .create_winsys = null_sw_create,
+ },
+ {
+ .name = "wrapped",
+ .create_winsys = wrapper_sw_winsys_wrap_pipe_screen,
+ },
+#endif
+ { 0 },
+ }
};
+#endif
+
+static bool
+pipe_loader_sw_probe_init_common(struct pipe_loader_sw_device *sdev)
+{
+ sdev->base.type = PIPE_LOADER_DEVICE_SOFTWARE;
+ sdev->base.driver_name = "swrast";
+ sdev->base.ops = &pipe_loader_sw_ops;
+
+#ifdef GALLIUM_STATIC_TARGETS
+ sdev->dd = &driver_descriptors;
+ if (!sdev->dd)
+ return false;
+#else
+ sdev->lib = pipe_loader_find_module(&sdev->base, PIPE_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;
+}
+
+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_PIPE_LOADER_DRI
bool
pipe_loader_sw_probe_dri(struct pipe_loader_device **devs, struct drisw_loader_funcs *drisw_lf)
{
struct pipe_loader_sw_device *sdev = CALLOC_STRUCT(pipe_loader_sw_device);
+ int i;
if (!sdev)
return false;
- sdev->base.type = PIPE_LOADER_DEVICE_SOFTWARE;
- sdev->base.driver_name = "swrast";
- sdev->base.ops = &pipe_loader_sw_ops;
- sdev->ws = dri_create_sw_winsys(drisw_lf);
- if (!sdev->ws) {
- FREE(sdev);
- return false;
+ if (!pipe_loader_sw_probe_init_common(sdev))
+ goto fail;
+
+ for (i = 0; sdev->dd->winsys[i].name; i++) {
+ if (strcmp(sdev->dd->winsys[i].name, "dri") == 0) {
+ sdev->ws = sdev->dd->winsys[i].create_winsys(drisw_lf);
+ break;
+ }
}
+ if (!sdev->ws)
+ goto fail;
+
*devs = &sdev->base;
+ return true;
+
+fail:
+ pipe_loader_sw_probe_teardown_common(sdev);
+ FREE(sdev);
+ return false;
+}
+#endif
+
+#ifdef HAVE_PIPE_LOADER_KMS
+bool
+pipe_loader_sw_probe_kms(struct pipe_loader_device **devs, int fd)
+{
+ struct pipe_loader_sw_device *sdev = CALLOC_STRUCT(pipe_loader_sw_device);
+ int i;
+ if (!sdev)
+ return false;
+
+ if (!pipe_loader_sw_probe_init_common(sdev))
+ goto fail;
+
+ for (i = 0; sdev->dd->winsys[i].name; i++) {
+ if (strcmp(sdev->dd->winsys[i].name, "kms_dri") == 0) {
+ sdev->ws = sdev->dd->winsys[i].create_winsys(fd);
+ break;
+ }
+ }
+ if (!sdev->ws)
+ goto fail;
+
+ *devs = &sdev->base;
return true;
+
+fail:
+ pipe_loader_sw_probe_teardown_common(sdev);
+ FREE(sdev);
+ return false;
}
#endif
@@ -76,38 +192,40 @@ bool
pipe_loader_sw_probe_null(struct pipe_loader_device **devs)
{
struct pipe_loader_sw_device *sdev = CALLOC_STRUCT(pipe_loader_sw_device);
+ int i;
if (!sdev)
return false;
- sdev->base.type = PIPE_LOADER_DEVICE_SOFTWARE;
- sdev->base.driver_name = "swrast";
- sdev->base.ops = &pipe_loader_sw_ops;
- sdev->ws = null_sw_create();
- if (!sdev->ws) {
- FREE(sdev);
- return false;
+ if (!pipe_loader_sw_probe_init_common(sdev))
+ goto fail;
+
+ for (i = 0; sdev->dd->winsys[i].name; i++) {
+ if (strcmp(sdev->dd->winsys[i].name, "null") == 0) {
+ sdev->ws = sdev->dd->winsys[i].create_winsys();
+ break;
+ }
}
- *devs = &sdev->base;
+ if (!sdev->ws)
+ goto fail;
+ *devs = &sdev->base;
return true;
+
+fail:
+ pipe_loader_sw_probe_teardown_common(sdev);
+ FREE(sdev);
+ return false;
}
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);
- /* TODO: handle CALLOC_STRUCT failure */
+ int i = 1;
- 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;
+ if (i <= ndev) {
+ if (!pipe_loader_sw_probe_null(devs)) {
+ i--;
}
}
@@ -119,21 +237,30 @@ pipe_loader_sw_probe_wrapped(struct pipe_loader_device **dev,
struct pipe_screen *screen)
{
struct pipe_loader_sw_device *sdev = CALLOC_STRUCT(pipe_loader_sw_device);
+ int i;
if (!sdev)
return false;
- sdev->base.type = PIPE_LOADER_DEVICE_SOFTWARE;
- sdev->base.driver_name = "swrast";
- sdev->base.ops = &pipe_loader_sw_ops;
- sdev->ws = wrapper_sw_winsys_wrap_pipe_screen(screen);
+ if (!pipe_loader_sw_probe_init_common(sdev))
+ goto fail;
- if (!sdev->ws) {
- FREE(sdev);
- return false;
+ for (i = 0; sdev->dd->winsys[i].name; i++) {
+ if (strcmp(sdev->dd->winsys[i].name, "wrapped") == 0) {
+ sdev->ws = sdev->dd->winsys[i].create_winsys(screen);
+ break;
+ }
}
+ if (!sdev->ws)
+ goto fail;
+
*dev = &sdev->base;
return true;
+
+fail:
+ pipe_loader_sw_probe_teardown_common(sdev);
+ FREE(sdev);
+ return false;
}
static void
@@ -141,8 +268,10 @@ pipe_loader_sw_release(struct pipe_loader_device **dev)
{
struct pipe_loader_sw_device *sdev = pipe_loader_sw_device(*dev);
+#ifndef GALLIUM_STATIC_TARGETS
if (sdev->lib)
util_dl_close(sdev->lib);
+#endif
FREE(sdev);
*dev = NULL;
@@ -156,28 +285,19 @@ pipe_loader_sw_configuration(struct pipe_loader_device *dev,
}
static struct pipe_screen *
-pipe_loader_sw_create_screen(struct pipe_loader_device *dev,
- const char *library_paths)
+pipe_loader_sw_create_screen(struct pipe_loader_device *dev)
{
struct pipe_loader_sw_device *sdev = pipe_loader_sw_device(dev);
- struct pipe_screen *(*init)(struct sw_winsys *);
+ struct pipe_screen *screen;
- 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){
- util_dl_close(sdev->lib);
- sdev->lib = NULL;
- return NULL;
- }
+ screen = sdev->dd->create_screen(sdev->ws);
+ if (!screen)
+ sdev->ws->destroy(sdev->ws);
- return init(sdev->ws);
+ return screen;
}
-static struct pipe_loader_ops pipe_loader_sw_ops = {
+static const struct pipe_loader_ops pipe_loader_sw_ops = {
.create_screen = pipe_loader_sw_create_screen,
.configuration = pipe_loader_sw_configuration,
.release = pipe_loader_sw_release