diff options
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/drivers/r600/r600.h | 3 | ||||
-rw-r--r-- | src/gallium/drivers/r600/r600_texture.c | 14 | ||||
-rw-r--r-- | src/gallium/winsys/r600/drm/r600_bo.c | 28 | ||||
-rw-r--r-- | src/gallium/winsys/r600/drm/r600_priv.h | 3 | ||||
-rw-r--r-- | src/gallium/winsys/r600/drm/radeon_bo.c | 16 |
5 files changed, 62 insertions, 2 deletions
diff --git a/src/gallium/drivers/r600/r600.h b/src/gallium/drivers/r600/r600.h index 5ec607bbd85..17858b2d381 100644 --- a/src/gallium/drivers/r600/r600.h +++ b/src/gallium/drivers/r600/r600.h @@ -43,6 +43,7 @@ typedef uint16_t u16; typedef uint8_t u8; struct radeon; +struct winsys_handle; enum radeon_family { CHIP_UNKNOWN, @@ -120,6 +121,8 @@ void *r600_bo_map(struct radeon *radeon, struct r600_bo *bo, unsigned usage, voi void r600_bo_unmap(struct radeon *radeon, struct r600_bo *bo); void r600_bo_reference(struct radeon *radeon, struct r600_bo **dst, struct r600_bo *src); +boolean r600_bo_get_winsys_handle(struct radeon *radeon, struct r600_bo *pb_bo, + unsigned stride, struct winsys_handle *whandle); static INLINE unsigned r600_bo_offset(struct r600_bo *bo) { return 0; diff --git a/src/gallium/drivers/r600/r600_texture.c b/src/gallium/drivers/r600/r600_texture.c index a63990fbffe..0c9b9993756 100644 --- a/src/gallium/drivers/r600/r600_texture.c +++ b/src/gallium/drivers/r600/r600_texture.c @@ -341,6 +341,18 @@ static void r600_texture_destroy(struct pipe_screen *screen, FREE(rtex); } +static boolean r600_texture_get_handle(struct pipe_screen* screen, + struct pipe_resource *ptex, + struct winsys_handle *whandle) +{ + struct r600_resource_texture *rtex = (struct r600_resource_texture*)ptex; + struct r600_resource *resource = &rtex->resource; + struct radeon *radeon = (struct radeon *)screen->winsys; + + return r600_bo_get_winsys_handle(radeon, resource->bo, + rtex->pitch_in_bytes[0], whandle); +} + static struct pipe_surface *r600_get_tex_surface(struct pipe_screen *screen, struct pipe_resource *texture, unsigned face, unsigned level, @@ -655,7 +667,7 @@ void r600_texture_transfer_unmap(struct pipe_context *ctx, struct u_resource_vtbl r600_texture_vtbl = { - u_default_resource_get_handle, /* get_handle */ + r600_texture_get_handle, /* get_handle */ r600_texture_destroy, /* resource_destroy */ r600_texture_is_referenced, /* is_resource_referenced */ r600_texture_get_transfer, /* get_transfer */ diff --git a/src/gallium/winsys/r600/drm/r600_bo.c b/src/gallium/winsys/r600/drm/r600_bo.c index 9b9aec5f64c..251f009a6b0 100644 --- a/src/gallium/winsys/r600/drm/r600_bo.c +++ b/src/gallium/winsys/r600/drm/r600_bo.c @@ -26,9 +26,10 @@ #include <pipe/p_compiler.h> #include <pipe/p_screen.h> #include <pipebuffer/pb_bufmgr.h> -#include "radeon_drm.h" +#include "state_tracker/drm_driver.h" #include "r600_priv.h" #include "r600d.h" +#include "drm.h" #include "radeon_drm.h" struct r600_bo *r600_bo(struct radeon *radeon, @@ -154,3 +155,28 @@ unsigned r600_bo_get_size(struct r600_bo *pb_bo) return bo->size; } + +boolean r600_bo_get_winsys_handle(struct radeon *radeon, struct r600_bo *pb_bo, + unsigned stride, struct winsys_handle *whandle) +{ + struct radeon_bo *bo; + + bo = radeon_bo_pb_get_bo(pb_bo->pb); + if (!bo) + return FALSE; + + whandle->stride = stride; + switch(whandle->type) { + case DRM_API_HANDLE_TYPE_KMS: + whandle->handle = r600_bo_get_handle(pb_bo); + break; + case DRM_API_HANDLE_TYPE_SHARED: + if (radeon_bo_get_name(radeon, bo, &whandle->handle)) + return FALSE; + break; + default: + return FALSE; + } + + return TRUE; +} diff --git a/src/gallium/winsys/r600/drm/r600_priv.h b/src/gallium/winsys/r600/drm/r600_priv.h index 97c582397a7..9fd77b71c77 100644 --- a/src/gallium/winsys/r600/drm/r600_priv.h +++ b/src/gallium/winsys/r600/drm/r600_priv.h @@ -102,6 +102,9 @@ int radeon_bo_get_tiling_flags(struct radeon *radeon, struct radeon_bo *bo, uint32_t *tiling_flags, uint32_t *pitch); +int radeon_bo_get_name(struct radeon *radeon, + struct radeon_bo *bo, + uint32_t *name); /* radeon_bo_pb.c */ struct radeon_bo *radeon_bo_pb_get_bo(struct pb_buffer *_buf); diff --git a/src/gallium/winsys/r600/drm/radeon_bo.c b/src/gallium/winsys/r600/drm/radeon_bo.c index dcee00de864..3054782838b 100644 --- a/src/gallium/winsys/r600/drm/radeon_bo.c +++ b/src/gallium/winsys/r600/drm/radeon_bo.c @@ -216,3 +216,19 @@ int radeon_bo_get_tiling_flags(struct radeon *radeon, *pitch = args.pitch; return ret; } + +int radeon_bo_get_name(struct radeon *radeon, + struct radeon_bo *bo, + uint32_t *name) +{ + struct drm_gem_flink flink; + int ret; + + flink.handle = bo->handle; + ret = drmIoctl(radeon->fd, DRM_IOCTL_GEM_FLINK, &flink); + if (ret) + return ret; + + *name = flink.name; + return ret; +} |