diff options
-rw-r--r-- | src/gallium/winsys/drm/radeon/core/radeon_buffer.c | 1 | ||||
-rw-r--r-- | src/gallium/winsys/drm/radeon/core/radeon_buffer.h | 5 | ||||
-rw-r--r-- | src/gallium/winsys/drm/radeon/core/radeon_drm.c | 22 |
3 files changed, 26 insertions, 2 deletions
diff --git a/src/gallium/winsys/drm/radeon/core/radeon_buffer.c b/src/gallium/winsys/drm/radeon/core/radeon_buffer.c index 93748e22567..263f684a8e0 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_buffer.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_buffer.c @@ -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; diff --git a/src/gallium/winsys/drm/radeon/core/radeon_buffer.h b/src/gallium/winsys/drm/radeon/core/radeon_buffer.h index ca8bbb3c117..14c463d702c 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_buffer.h +++ b/src/gallium/winsys/drm/radeon/core/radeon_buffer.h @@ -48,11 +48,16 @@ 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; diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm.c b/src/gallium/winsys/drm/radeon/core/radeon_drm.c index 4cad96041f3..8561e124d0b 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_drm.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_drm.c @@ -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; } |