Mesa (master): freedreno: per-context fd_pipe

Rob Clark robclark at kemper.freedesktop.org
Tue Oct 24 17:01:53 UTC 2017


Module: Mesa
Branch: master
Commit: eed9685dd6619ec7598e8c3fd81117d36010510d
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=eed9685dd6619ec7598e8c3fd81117d36010510d

Author: Rob Clark <robdclark at gmail.com>
Date:   Thu Aug 24 09:34:48 2017 -0400

freedreno: per-context fd_pipe

To enable per-context priorities, we need to have per-context pipe's.
Unfortunately we still need to keep the global screen pipe, mostly just
for screen->get_timestamp().

Signed-off-by: Rob Clark <robdclark at gmail.com>

---

 src/gallium/drivers/freedreno/a5xx/fd5_draw.c       | 2 +-
 src/gallium/drivers/freedreno/freedreno_batch.c     | 6 +++---
 src/gallium/drivers/freedreno/freedreno_context.c   | 2 ++
 src/gallium/drivers/freedreno/freedreno_context.h   | 1 +
 src/gallium/drivers/freedreno/freedreno_fence.c     | 2 +-
 src/gallium/drivers/freedreno/freedreno_query_acc.c | 6 +++---
 src/gallium/drivers/freedreno/freedreno_query_hw.c  | 4 ++--
 src/gallium/drivers/freedreno/freedreno_resource.c  | 4 ++--
 src/gallium/drivers/freedreno/freedreno_screen.h    | 5 +++++
 9 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/src/gallium/drivers/freedreno/a5xx/fd5_draw.c b/src/gallium/drivers/freedreno/a5xx/fd5_draw.c
index d1f1d039b6..1e9117a5b9 100644
--- a/src/gallium/drivers/freedreno/a5xx/fd5_draw.c
+++ b/src/gallium/drivers/freedreno/a5xx/fd5_draw.c
@@ -194,7 +194,7 @@ fd5_clear_lrz(struct fd_batch *batch, struct fd_resource *zsbuf, double depth)
 	// draw
 
 	if (!batch->lrz_clear) {
-		batch->lrz_clear = fd_ringbuffer_new(batch->ctx->screen->pipe, 0x1000);
+		batch->lrz_clear = fd_ringbuffer_new(batch->ctx->pipe, 0x1000);
 		fd_ringbuffer_set_parent(batch->lrz_clear, batch->gmem);
 	}
 
diff --git a/src/gallium/drivers/freedreno/freedreno_batch.c b/src/gallium/drivers/freedreno/freedreno_batch.c
index c2142b5a21..8f0f78861c 100644
--- a/src/gallium/drivers/freedreno/freedreno_batch.c
+++ b/src/gallium/drivers/freedreno/freedreno_batch.c
@@ -53,9 +53,9 @@ batch_init(struct fd_batch *batch)
 		size = 0x100000;
 	}
 
-	batch->draw    = fd_ringbuffer_new(ctx->screen->pipe, size);
-	batch->binning = fd_ringbuffer_new(ctx->screen->pipe, size);
-	batch->gmem    = fd_ringbuffer_new(ctx->screen->pipe, size);
+	batch->draw    = fd_ringbuffer_new(ctx->pipe, size);
+	batch->binning = fd_ringbuffer_new(ctx->pipe, size);
+	batch->gmem    = fd_ringbuffer_new(ctx->pipe, size);
 
 	fd_ringbuffer_set_parent(batch->gmem, NULL);
 	fd_ringbuffer_set_parent(batch->draw, batch->gmem);
diff --git a/src/gallium/drivers/freedreno/freedreno_context.c b/src/gallium/drivers/freedreno/freedreno_context.c
index e17dcf7b68..20480f4f8c 100644
--- a/src/gallium/drivers/freedreno/freedreno_context.c
+++ b/src/gallium/drivers/freedreno/freedreno_context.c
@@ -144,6 +144,7 @@ fd_context_destroy(struct pipe_context *pctx)
 	}
 
 	fd_device_del(ctx->dev);
+	fd_pipe_del(ctx->pipe);
 
 	if (fd_mesa_debug & (FD_DBG_BSTAT | FD_DBG_MSGS)) {
 		printf("batch_total=%u, batch_sysmem=%u, batch_gmem=%u, batch_restore=%u\n",
@@ -251,6 +252,7 @@ fd_context_init(struct fd_context *ctx, struct pipe_screen *pscreen,
 	int i;
 
 	ctx->screen = screen;
+	ctx->pipe = fd_pipe_new(screen->dev, FD_PIPE_3D);
 
 	ctx->primtypes = primtypes;
 	ctx->primtype_mask = 0;
diff --git a/src/gallium/drivers/freedreno/freedreno_context.h b/src/gallium/drivers/freedreno/freedreno_context.h
index 393b485a09..f10f7ef4ea 100644
--- a/src/gallium/drivers/freedreno/freedreno_context.h
+++ b/src/gallium/drivers/freedreno/freedreno_context.h
@@ -156,6 +156,7 @@ struct fd_context {
 
 	struct fd_device *dev;
 	struct fd_screen *screen;
+	struct fd_pipe *pipe;
 
 	struct util_queue flush_queue;
 
diff --git a/src/gallium/drivers/freedreno/freedreno_fence.c b/src/gallium/drivers/freedreno/freedreno_fence.c
index f20c6ac120..e3d200aa3a 100644
--- a/src/gallium/drivers/freedreno/freedreno_fence.c
+++ b/src/gallium/drivers/freedreno/freedreno_fence.c
@@ -69,7 +69,7 @@ boolean fd_fence_finish(struct pipe_screen *pscreen,
 		return ret == 0;
 	}
 
-	if (fd_pipe_wait_timeout(fence->screen->pipe, fence->timestamp, timeout))
+	if (fd_pipe_wait_timeout(fence->ctx->pipe, fence->timestamp, timeout))
 		return false;
 
 	return true;
diff --git a/src/gallium/drivers/freedreno/freedreno_query_acc.c b/src/gallium/drivers/freedreno/freedreno_query_acc.c
index 96cee1aee8..724ef69dc2 100644
--- a/src/gallium/drivers/freedreno/freedreno_query_acc.c
+++ b/src/gallium/drivers/freedreno/freedreno_query_acc.c
@@ -66,7 +66,7 @@ realloc_query_bo(struct fd_context *ctx, struct fd_acc_query *aq)
 	/* don't assume the buffer is zero-initialized: */
 	rsc = fd_resource(aq->prsc);
 
-	fd_bo_cpu_prep(rsc->bo, ctx->screen->pipe, DRM_FREEDRENO_PREP_WRITE);
+	fd_bo_cpu_prep(rsc->bo, ctx->pipe, DRM_FREEDRENO_PREP_WRITE);
 
 	map = fd_bo_map(rsc->bo);
 	memset(map, 0, aq->provider->size);
@@ -142,7 +142,7 @@ fd_acc_get_query_result(struct fd_context *ctx, struct fd_query *q,
 			return false;
 		}
 
-		ret = fd_bo_cpu_prep(rsc->bo, ctx->screen->pipe,
+		ret = fd_bo_cpu_prep(rsc->bo, ctx->pipe,
 				DRM_FREEDRENO_PREP_READ | DRM_FREEDRENO_PREP_NOSYNC);
 		if (ret)
 			return false;
@@ -154,7 +154,7 @@ fd_acc_get_query_result(struct fd_context *ctx, struct fd_query *q,
 		fd_batch_flush(rsc->write_batch, true);
 
 	/* get the result: */
-	fd_bo_cpu_prep(rsc->bo, ctx->screen->pipe, DRM_FREEDRENO_PREP_READ);
+	fd_bo_cpu_prep(rsc->bo, ctx->pipe, DRM_FREEDRENO_PREP_READ);
 
 	void *ptr = fd_bo_map(rsc->bo);
 	p->result(ctx, ptr, result);
diff --git a/src/gallium/drivers/freedreno/freedreno_query_hw.c b/src/gallium/drivers/freedreno/freedreno_query_hw.c
index 73c3691147..c92573ec93 100644
--- a/src/gallium/drivers/freedreno/freedreno_query_hw.c
+++ b/src/gallium/drivers/freedreno/freedreno_query_hw.c
@@ -218,7 +218,7 @@ fd_hw_get_query_result(struct fd_context *ctx, struct fd_query *q,
 		if (!rsc->bo)
 			return false;
 
-		ret = fd_bo_cpu_prep(rsc->bo, ctx->screen->pipe,
+		ret = fd_bo_cpu_prep(rsc->bo, ctx->pipe,
 				DRM_FREEDRENO_PREP_READ | DRM_FREEDRENO_PREP_NOSYNC);
 		if (ret)
 			return false;
@@ -245,7 +245,7 @@ fd_hw_get_query_result(struct fd_context *ctx, struct fd_query *q,
 		if (!rsc->bo)
 			continue;
 
-		fd_bo_cpu_prep(rsc->bo, ctx->screen->pipe, DRM_FREEDRENO_PREP_READ);
+		fd_bo_cpu_prep(rsc->bo, ctx->pipe, DRM_FREEDRENO_PREP_READ);
 
 		void *ptr = fd_bo_map(rsc->bo);
 
diff --git a/src/gallium/drivers/freedreno/freedreno_resource.c b/src/gallium/drivers/freedreno/freedreno_resource.c
index 5aa90ced69..266908c0bc 100644
--- a/src/gallium/drivers/freedreno/freedreno_resource.c
+++ b/src/gallium/drivers/freedreno/freedreno_resource.c
@@ -512,7 +512,7 @@ fd_resource_transfer_map(struct pipe_context *pctx,
 		 */
 		bool needs_flush = pending(rsc, !!(usage & PIPE_TRANSFER_WRITE));
 		bool busy = needs_flush || (0 != fd_bo_cpu_prep(rsc->bo,
-				ctx->screen->pipe, op | DRM_FREEDRENO_PREP_NOSYNC));
+				ctx->pipe, op | DRM_FREEDRENO_PREP_NOSYNC));
 
 		/* if we need to flush/stall, see if we can make a shadow buffer
 		 * to avoid this:
@@ -553,7 +553,7 @@ fd_resource_transfer_map(struct pipe_context *pctx,
 		 * completed.
 		 */
 		if (busy) {
-			ret = fd_bo_cpu_prep(rsc->bo, ctx->screen->pipe, op);
+			ret = fd_bo_cpu_prep(rsc->bo, ctx->pipe, op);
 			if (ret)
 				goto fail;
 		}
diff --git a/src/gallium/drivers/freedreno/freedreno_screen.h b/src/gallium/drivers/freedreno/freedreno_screen.h
index c5018da4bc..68518ef721 100644
--- a/src/gallium/drivers/freedreno/freedreno_screen.h
+++ b/src/gallium/drivers/freedreno/freedreno_screen.h
@@ -72,6 +72,11 @@ struct fd_screen {
 	void *compiler;          /* currently unused for a2xx */
 
 	struct fd_device *dev;
+
+	/* NOTE: we still need a pipe associated with the screen in a few
+	 * places, like screen->get_timestamp().  For anything context
+	 * related, use ctx->pipe instead.
+	 */
 	struct fd_pipe *pipe;
 
 	int64_t cpu_gpu_time_delta;




More information about the mesa-commit mailing list