[Mesa-dev] [PATCH 2/4] freedreno: add fd_transfer to wrap around pipe_transfer

Ilia Mirkin imirkin at alum.mit.edu
Sat Apr 25 12:00:23 PDT 2015


Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
---
 src/gallium/drivers/freedreno/freedreno_context.c  |  2 +-
 src/gallium/drivers/freedreno/freedreno_resource.c |  4 +++-
 src/gallium/drivers/freedreno/freedreno_resource.h | 11 +++++++++++
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/freedreno/freedreno_context.c b/src/gallium/drivers/freedreno/freedreno_context.c
index 5fca57c..5d92da4 100644
--- a/src/gallium/drivers/freedreno/freedreno_context.c
+++ b/src/gallium/drivers/freedreno/freedreno_context.c
@@ -222,7 +222,7 @@ fd_context_init(struct fd_context *ctx, struct pipe_screen *pscreen,
 
 	util_dynarray_init(&ctx->draw_patches);
 
-	util_slab_create(&ctx->transfer_pool, sizeof(struct pipe_transfer),
+	util_slab_create(&ctx->transfer_pool, sizeof(struct fd_transfer),
 			16, UTIL_SLAB_SINGLETHREADED);
 
 	fd_draw_init(pctx);
diff --git a/src/gallium/drivers/freedreno/freedreno_resource.c b/src/gallium/drivers/freedreno/freedreno_resource.c
index 985b663..e8da68e 100644
--- a/src/gallium/drivers/freedreno/freedreno_resource.c
+++ b/src/gallium/drivers/freedreno/freedreno_resource.c
@@ -140,6 +140,7 @@ fd_resource_transfer_map(struct pipe_context *pctx,
 	struct fd_context *ctx = fd_context(pctx);
 	struct fd_resource *rsc = fd_resource(prsc);
 	struct fd_resource_slice *slice = fd_resource_slice(rsc, level);
+	struct fd_transfer *trans;
 	struct pipe_transfer *ptrans;
 	enum pipe_format format = prsc->format;
 	uint32_t op = 0;
@@ -154,7 +155,8 @@ fd_resource_transfer_map(struct pipe_context *pctx,
 		return NULL;
 
 	/* util_slab_alloc() doesn't zero: */
-	memset(ptrans, 0, sizeof(*ptrans));
+	trans = fd_transfer(ptrans);
+	memset(trans, 0, sizeof(*trans));
 
 	pipe_resource_reference(&ptrans->resource, prsc);
 	ptrans->level = level;
diff --git a/src/gallium/drivers/freedreno/freedreno_resource.h b/src/gallium/drivers/freedreno/freedreno_resource.h
index a2a540c..f80acb1 100644
--- a/src/gallium/drivers/freedreno/freedreno_resource.h
+++ b/src/gallium/drivers/freedreno/freedreno_resource.h
@@ -81,6 +81,17 @@ fd_resource(struct pipe_resource *ptex)
 	return (struct fd_resource *)ptex;
 }
 
+struct fd_transfer {
+	struct pipe_transfer base;
+	void *staging;
+};
+
+static INLINE struct fd_transfer *
+fd_transfer(struct pipe_transfer *ptrans)
+{
+	return (struct fd_transfer *)ptrans;
+}
+
 static INLINE struct fd_resource_slice *
 fd_resource_slice(struct fd_resource *rsc, unsigned level)
 {
-- 
2.0.5



More information about the mesa-dev mailing list