pipe-loader: Don't destroy the winsys in the sw loader
[mesa.git] / src / gallium / auxiliary / pipe-loader / pipe_loader_sw.c
index abc87a2c744bb967713ace6d78338b720b9939b9..fa317f22aaeb6424aff56e9180cbb05360253cee 100644 (file)
 #include "util/u_dl.h"
 #include "sw/dri/dri_sw_winsys.h"
 #include "sw/null/null_sw_winsys.h"
+#ifdef HAVE_PIPE_LOADER_XLIB
+/* Explicitly wrap the header to ease build without X11 headers */
 #include "sw/xlib/xlib_sw_winsys.h"
+#endif
 #include "target-helpers/inline_sw_helper.h"
 #include "state_tracker/drisw_api.h"
 
@@ -49,7 +52,7 @@ static struct sw_winsys *(*backends[])() = {
    null_sw_create
 };
 
-#ifdef HAVE_WINSYS_XLIB
+#ifdef HAVE_PIPE_LOADER_XLIB
 bool
 pipe_loader_sw_probe_xlib(struct pipe_loader_device **devs, Display *display)
 {
@@ -72,6 +75,7 @@ pipe_loader_sw_probe_xlib(struct pipe_loader_device **devs, Display *display)
 }
 #endif
 
+#ifdef HAVE_PIPE_LOADER_DRI
 bool
 pipe_loader_sw_probe_dri(struct pipe_loader_device **devs, struct drisw_loader_funcs *drisw_lf)
 {
@@ -92,6 +96,28 @@ pipe_loader_sw_probe_dri(struct pipe_loader_device **devs, struct drisw_loader_f
 
    return true;
 }
+#endif
+
+bool
+pipe_loader_sw_probe_null(struct pipe_loader_device **devs)
+{
+   struct pipe_loader_sw_device *sdev = CALLOC_STRUCT(pipe_loader_sw_device);
+
+   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;
+   }
+   *devs = &sdev->base;
+
+   return true;
+}
 
 int
 pipe_loader_sw_probe(struct pipe_loader_device **devs, int ndev)
@@ -119,9 +145,6 @@ pipe_loader_sw_release(struct pipe_loader_device **dev)
 {
    struct pipe_loader_sw_device *sdev = pipe_loader_sw_device(*dev);
 
-   if (sdev->ws && sdev->ws->destroy)
-      sdev->ws->destroy(sdev->ws);
-
    if (sdev->lib)
       util_dl_close(sdev->lib);