radeon-gallium: Use FLINK to do proper global buffers.
authorCorbin Simpson <MostAwesomeDude@gmail.com>
Sun, 5 Jul 2009 18:55:47 +0000 (11:55 -0700)
committerCorbin Simpson <MostAwesomeDude@gmail.com>
Sun, 5 Jul 2009 18:55:47 +0000 (11:55 -0700)
src/gallium/winsys/drm/radeon/core/radeon_buffer.c
src/gallium/winsys/drm/radeon/core/radeon_buffer.h
src/gallium/winsys/drm/radeon/core/radeon_drm.c

index 93748e225673d05d492f08f3b6c98c92a571d163..263f684a8e096da5158253388fe2ee6d94522c6a 100644 (file)
@@ -200,6 +200,7 @@ struct radeon_winsys* radeon_pipe_winsys(int fd)
         return NULL;
     }
 
+    radeon_ws->priv->fd = fd;
     radeon_ws->priv->bom = radeon_bo_manager_gem_ctor(fd);
 
     radeon_ws->base.flush_frontbuffer = radeon_flush_frontbuffer;
index ca8bbb3c117366e3894c9419e173fe4b59be635f..14c463d702cb31f0a0d02e8efc76fa674354a91c 100644 (file)
 struct radeon_pipe_buffer {
     struct pipe_buffer  base;
     struct radeon_bo    *bo;
+    boolean flinked;
+    uint32_t flink;
 };
 
 #define RADEON_MAX_BOS 24
 
 struct radeon_winsys_priv {
+    /* DRM FD */
+    int fd;
+
     /* Radeon BO manager. */
     struct radeon_bo_manager* bom;
 
index 4cad96041f3b04a2cf55c78a84ee1b13aecda706..8561e124d0b553a5dc4e3ca967ed29e9bf6e77eb 100644 (file)
@@ -113,10 +113,28 @@ boolean radeon_global_handle_from_buffer(struct drm_api* api,
                                          struct pipe_buffer* buffer,
                                          unsigned* handle)
 {
-    /* XXX WTF is the difference here? global? */
+    int retval, fd;
+    struct drm_gem_flink flink;
     struct radeon_pipe_buffer* radeon_buffer =
         (struct radeon_pipe_buffer*)buffer;
-    *handle = radeon_buffer->bo->handle;
+
+    if (!radeon_buffer->flinked) {
+        fd = ((struct radeon_winsys*)screen->winsys)->priv->fd;
+
+        flink.handle = radeon_buffer->bo->handle;
+
+        retval = ioctl(fd, DRM_IOCTL_GEM_FLINK, &flink);
+        if (retval) {
+            debug_printf("radeon: DRM_IOCTL_GEM_FLINK failed, error %d\n",
+                    retval);
+            return FALSE;
+        }
+
+        radeon_buffer->flink = flink.name;
+        radeon_buffer->flinked = TRUE;
+    }
+
+    *handle = radeon_buffer->flink;
     return TRUE;
 }