mesa; add a dummy _mesa_error_no_memory() symbol to libglsl_util
[mesa.git] / src / gallium / state_trackers / xa / xa_tracker.c
index cda6501fcd4f04a24ee3db27746dee3e9b0928c8..f69ac8edf2774a1dfd2d824d4a2ea6fc0c55ef4f 100644 (file)
  * Thomas Hellstrom <thellstrom-at-vmware-dot-com>
  */
 
+#include <unistd.h>
 #include "xa_tracker.h"
 #include "xa_priv.h"
 #include "pipe/p_state.h"
 #include "pipe/p_format.h"
+#include "pipe-loader/pipe_loader.h"
 #include "state_tracker/drm_driver.h"
 #include "util/u_inlines.h"
 
@@ -139,11 +141,21 @@ xa_tracker_create(int drm_fd)
     struct xa_tracker *xa = calloc(1, sizeof(struct xa_tracker));
     enum xa_surface_type stype;
     unsigned int num_formats;
+    int loader_fd;
 
     if (!xa)
        return NULL;
 
-    xa->screen = driver_descriptor.create_screen(drm_fd);
+#if GALLIUM_STATIC_TARGETS
+    xa->screen = dd_create_screen(drm_fd);
+    (void) loader_fd; /* silence unused var warning */
+#else
+    loader_fd = dup(drm_fd);
+    if (loader_fd == -1)
+        return NULL;
+    if (pipe_loader_drm_probe_fd(&xa->dev, loader_fd, false))
+       xa->screen = pipe_loader_create_screen(xa->dev, PIPE_SEARCH_DIR);
+#endif
     if (!xa->screen)
        goto out_no_screen;
 
@@ -190,6 +202,10 @@ xa_tracker_create(int drm_fd)
  out_no_pipe:
     xa->screen->destroy(xa->screen);
  out_no_screen:
+#if !GALLIUM_STATIC_TARGETS
+    if (xa->dev)
+       pipe_loader_release(&xa->dev, 1);
+#endif
     free(xa);
     return NULL;
 }
@@ -200,6 +216,9 @@ xa_tracker_destroy(struct xa_tracker *xa)
     free(xa->supported_formats);
     xa_context_destroy(xa->default_ctx);
     xa->screen->destroy(xa->screen);
+#if !GALLIUM_STATIC_TARGETS
+    pipe_loader_release(&xa->dev, 1);
+#endif
     free(xa);
 }
 
@@ -363,6 +382,7 @@ xa_surface_from_handle(struct xa_tracker *xa,
 {
     struct winsys_handle whandle;
     memset(&whandle, 0, sizeof(whandle));
+    whandle.type = DRM_API_HANDLE_TYPE_SHARED;
     whandle.handle = handle;
     whandle.stride = stride;
     return surface_create(xa, width, height, depth, stype, xa_format, flags, &whandle);