summaryrefslogtreecommitdiffstats
path: root/src/gallium/winsys/radeon
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2015-02-10 16:41:53 +0100
committerMarek Olšák <[email protected]>2015-02-17 17:31:48 +0100
commite8d727a2b6b89f6c6c205fbe87acf30659a0bd39 (patch)
tree3273ac8e6415a0b419967c9ccbdf3eccee07a49d /src/gallium/winsys/radeon
parent8b587ee7011aee900fd84f6203467ba899f2ed01 (diff)
winsys/radeon: allow mapping a user buffer
OpenGL requires this. Reviewed-by: Christian König <[email protected]>
Diffstat (limited to 'src/gallium/winsys/radeon')
-rw-r--r--src/gallium/winsys/radeon/drm/radeon_drm_bo.c5
-rw-r--r--src/gallium/winsys/radeon/drm/radeon_drm_bo.h1
-rw-r--r--src/gallium/winsys/radeon/drm/radeon_winsys.h4
3 files changed, 8 insertions, 2 deletions
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
index 2605ca6238f..8f4b13576b9 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
@@ -345,6 +345,10 @@ void *radeon_bo_do_map(struct radeon_bo *bo)
struct drm_radeon_gem_mmap args = {0};
void *ptr;
+ /* If the buffer is created from user memory, return the user pointer. */
+ if (bo->user_ptr)
+ return bo->user_ptr;
+
/* Return the pointer if it's already mapped. */
if (bo->ptr)
return bo->ptr;
@@ -900,6 +904,7 @@ static struct pb_buffer *radeon_winsys_bo_from_ptr(struct radeon_winsys *rws,
bo->base.vtbl = &radeon_bo_vtbl;
bo->mgr = mgr;
bo->rws = mgr->rws;
+ bo->user_ptr = pointer;
bo->va = 0;
bo->initial_domain = RADEON_DOMAIN_GTT;
pipe_mutex_init(bo->map_mutex);
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_bo.h b/src/gallium/winsys/radeon/drm/radeon_drm_bo.h
index 1c00a13c1e0..b83ce168b4e 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_bo.h
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_bo.h
@@ -50,6 +50,7 @@ struct radeon_bo {
struct radeon_bomgr *mgr;
struct radeon_drm_winsys *rws;
+ void *user_ptr; /* from buffer_from_ptr */
void *ptr;
pipe_mutex map_mutex;
diff --git a/src/gallium/winsys/radeon/drm/radeon_winsys.h b/src/gallium/winsys/radeon/drm/radeon_winsys.h
index d9fa1ab7878..3a6037c0542 100644
--- a/src/gallium/winsys/radeon/drm/radeon_winsys.h
+++ b/src/gallium/winsys/radeon/drm/radeon_winsys.h
@@ -394,8 +394,8 @@ struct radeon_winsys {
unsigned *stride);
/**
- * Get a winsys buffer from a user pointer. The resulting buffer can't be
- * mapped or exported. Both pointer and size must be page aligned.
+ * Get a winsys buffer from a user pointer. The resulting buffer can't
+ * be exported. Both pointer and size must be page aligned.
*
* \param ws The winsys this function is called from.
* \param pointer User pointer to turn into a buffer object.