[Mesa-dev] [PATCH 3/6] winsys/radeon: allow mapping a user buffer by returning the same pointer
Marek Olšák
maraeo at gmail.com
Wed Feb 11 12:18:13 PST 2015
From: Marek Olšák <marek.olsak at amd.com>
OpenGL requires this.
---
src/gallium/winsys/radeon/drm/radeon_drm_bo.c | 5 +++++
src/gallium/winsys/radeon/drm/radeon_drm_bo.h | 1 +
src/gallium/winsys/radeon/drm/radeon_winsys.h | 4 ++--
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 2605ca6..8f4b135 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 1c00a13..b83ce16 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 d9fa1ab..3a6037c 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.
--
2.1.0
More information about the mesa-dev
mailing list