[Mesa-dev] [PATCH 09/21] gallium: add user_ptr in pipe_resource

Marek Olšák maraeo at gmail.com
Wed Apr 11 08:38:43 PDT 2012


I need to access the pointer in st/mesa when I only have pipe_resource.
---
 src/gallium/drivers/i915/i915_resource_buffer.c |    1 +
 src/gallium/drivers/llvmpipe/lp_texture.c       |    1 +
 src/gallium/drivers/nouveau/nouveau_buffer.c    |    1 +
 src/gallium/drivers/nvfx/nvfx_buffer.c          |    1 +
 src/gallium/drivers/r300/r300_screen_buffer.c   |    2 ++
 src/gallium/drivers/r600/r600_buffer.c          |    2 ++
 src/gallium/drivers/softpipe/sp_texture.c       |    1 +
 src/gallium/drivers/svga/svga_resource_buffer.c |    1 +
 src/gallium/include/pipe/p_state.h              |    3 +++
 9 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_resource_buffer.c b/src/gallium/drivers/i915/i915_resource_buffer.c
index 77c0345..6718948 100644
--- a/src/gallium/drivers/i915/i915_resource_buffer.c
+++ b/src/gallium/drivers/i915/i915_resource_buffer.c
@@ -183,6 +183,7 @@ i915_user_buffer_create(struct pipe_screen *screen,
    buf->b.b.height0 = 1;
    buf->b.b.depth0 = 1;
    buf->b.b.array_size = 1;
+   buf->b.b.user_ptr = ptr;
 
    buf->data = ptr;
    buf->free_on_destroy = FALSE;
diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c
index 28e5aa9..f6a1ec2 100644
--- a/src/gallium/drivers/llvmpipe/lp_texture.c
+++ b/src/gallium/drivers/llvmpipe/lp_texture.c
@@ -770,6 +770,7 @@ llvmpipe_user_buffer_create(struct pipe_screen *screen,
    buffer->base.height0 = 1;
    buffer->base.depth0 = 1;
    buffer->base.array_size = 1;
+   buffer->base.user_ptr = ptr;
    buffer->userBuffer = TRUE;
    buffer->data = ptr;
 
diff --git a/src/gallium/drivers/nouveau/nouveau_buffer.c b/src/gallium/drivers/nouveau/nouveau_buffer.c
index f822625..016c0d3 100644
--- a/src/gallium/drivers/nouveau/nouveau_buffer.c
+++ b/src/gallium/drivers/nouveau/nouveau_buffer.c
@@ -383,6 +383,7 @@ nouveau_user_buffer_create(struct pipe_screen *pscreen, void *ptr,
    buffer->base.width0 = bytes;
    buffer->base.height0 = 1;
    buffer->base.depth0 = 1;
+   buffer->base.user_ptr = ptr;
 
    buffer->data = ptr;
    buffer->status = NOUVEAU_BUFFER_STATUS_USER_MEMORY;
diff --git a/src/gallium/drivers/nvfx/nvfx_buffer.c b/src/gallium/drivers/nvfx/nvfx_buffer.c
index 76b7f45..3b84809 100644
--- a/src/gallium/drivers/nvfx/nvfx_buffer.c
+++ b/src/gallium/drivers/nvfx/nvfx_buffer.c
@@ -66,6 +66,7 @@ nvfx_user_buffer_create(struct pipe_screen *pscreen,
 	buffer->base.base.height0 = 1;
 	buffer->base.base.depth0 = 1;
 	buffer->base.base.array_size = 1;
+	buffer->base.base.user_ptr = ptr;
 	buffer->data = ptr;
 	buffer->size = bytes;
 	buffer->bytes_to_draw_until_static = bytes * screen->static_reuse_threshold;
diff --git a/src/gallium/drivers/r300/r300_screen_buffer.c b/src/gallium/drivers/r300/r300_screen_buffer.c
index 37f6e8d..fba17a2 100644
--- a/src/gallium/drivers/r300/r300_screen_buffer.c
+++ b/src/gallium/drivers/r300/r300_screen_buffer.c
@@ -193,6 +193,7 @@ struct pipe_resource *r300_buffer_create(struct pipe_screen *screen,
     rbuf->b.b.vtbl = &r300_buffer_vtbl;
     pipe_reference_init(&rbuf->b.b.b.reference, 1);
     rbuf->b.b.b.screen = screen;
+    rbuf->b.b.b.user_ptr = NULL;
     rbuf->b.user_ptr = NULL;
     rbuf->domain = RADEON_DOMAIN_GTT;
     rbuf->buf = NULL;
@@ -239,6 +240,7 @@ struct pipe_resource *r300_user_buffer_create(struct pipe_screen *screen,
     rbuf->b.b.b.depth0 = 1;
     rbuf->b.b.b.array_size = 1;
     rbuf->b.b.b.flags = 0;
+    rbuf->b.b.b.user_ptr = ptr;
     rbuf->b.b.vtbl = &r300_buffer_vtbl;
     rbuf->b.user_ptr = ptr;
     rbuf->domain = RADEON_DOMAIN_GTT;
diff --git a/src/gallium/drivers/r600/r600_buffer.c b/src/gallium/drivers/r600/r600_buffer.c
index 4708d01..440af56 100644
--- a/src/gallium/drivers/r600/r600_buffer.c
+++ b/src/gallium/drivers/r600/r600_buffer.c
@@ -222,6 +222,7 @@ struct pipe_resource *r600_buffer_create(struct pipe_screen *screen,
 	rbuffer->b.b.b = *templ;
 	pipe_reference_init(&rbuffer->b.b.b.reference, 1);
 	rbuffer->b.b.b.screen = screen;
+	rbuffer->b.b.b.user_ptr = NULL;
 	rbuffer->b.b.vtbl = &r600_buffer_vtbl;
 	rbuffer->b.user_ptr = NULL;
 
@@ -253,6 +254,7 @@ struct pipe_resource *r600_user_buffer_create(struct pipe_screen *screen,
 	rbuffer->b.b.b.depth0 = 1;
 	rbuffer->b.b.b.array_size = 1;
 	rbuffer->b.b.b.flags = 0;
+	rbuffer->b.b.b.user_ptr = ptr;
 	rbuffer->b.user_ptr = ptr;
 	rbuffer->buf = NULL;
 	return &rbuffer->b.b.b;
diff --git a/src/gallium/drivers/softpipe/sp_texture.c b/src/gallium/drivers/softpipe/sp_texture.c
index 95374c3..f5c6f56 100644
--- a/src/gallium/drivers/softpipe/sp_texture.c
+++ b/src/gallium/drivers/softpipe/sp_texture.c
@@ -476,6 +476,7 @@ softpipe_user_buffer_create(struct pipe_screen *screen,
    spr->base.height0 = 1;
    spr->base.depth0 = 1;
    spr->base.array_size = 1;
+   spr->base.user_ptr = ptr;
    spr->userBuffer = TRUE;
    spr->data = ptr;
 
diff --git a/src/gallium/drivers/svga/svga_resource_buffer.c b/src/gallium/drivers/svga/svga_resource_buffer.c
index fa713ee..ff53b82 100644
--- a/src/gallium/drivers/svga/svga_resource_buffer.c
+++ b/src/gallium/drivers/svga/svga_resource_buffer.c
@@ -394,6 +394,7 @@ svga_user_buffer_create(struct pipe_screen *screen,
    sbuf->b.b.height0 = 1;
    sbuf->b.b.depth0 = 1;
    sbuf->b.b.array_size = 1;
+   sbuf->b.b.user_ptr = ptr;
 
    sbuf->swbuf = ptr;
    sbuf->user = TRUE;
diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h
index 72ec04a..a459a56 100644
--- a/src/gallium/include/pipe/p_state.h
+++ b/src/gallium/include/pipe/p_state.h
@@ -415,6 +415,9 @@ struct pipe_resource
 
    unsigned bind;            /**< bitmask of PIPE_BIND_x */
    unsigned flags;           /**< bitmask of PIPE_RESOURCE_FLAG_x */
+
+   /* XXX this is only temporary and will be removed once it's not needed */
+   uint8_t *user_ptr;        /**< user buffer pointer */
 };
 
 
-- 
1.7.5.4



More information about the mesa-dev mailing list