Mesa (master): freedreno/batch: split out helper for rb alloc

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Aug 28 22:37:29 UTC 2020


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

Author: Rob Clark <robdclark at chromium.org>
Date:   Wed Aug 26 10:25:16 2020 -0700

freedreno/batch: split out helper for rb alloc

Going to want to re-use this in next patch.

Signed-off-by: Rob Clark <robdclark at chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6475>

---

 src/gallium/drivers/freedreno/freedreno_batch.c | 39 +++++++++++++------------
 1 file changed, 21 insertions(+), 18 deletions(-)

diff --git a/src/gallium/drivers/freedreno/freedreno_batch.c b/src/gallium/drivers/freedreno/freedreno_batch.c
index 4ad10aeb35a..86e8b5b7834 100644
--- a/src/gallium/drivers/freedreno/freedreno_batch.c
+++ b/src/gallium/drivers/freedreno/freedreno_batch.c
@@ -35,40 +35,43 @@
 #include "freedreno_resource.h"
 #include "freedreno_query_hw.h"
 
-static void
-batch_init(struct fd_batch *batch)
+static struct fd_ringbuffer *
+alloc_ring(struct fd_batch *batch, unsigned sz, enum fd_ringbuffer_flags flags)
 {
 	struct fd_context *ctx = batch->ctx;
-	enum fd_ringbuffer_flags flags = 0;
-	unsigned size = 0;
 
 	/* if kernel is too old to support unlimited # of cmd buffers, we
 	 * have no option but to allocate large worst-case sizes so that
 	 * we don't need to grow the ringbuffer.  Performance is likely to
 	 * suffer, but there is no good alternative.
 	 *
-	 * XXX I think we can just require new enough kernel for this?
+	 * Otherwise if supported, allocate a growable ring with initial
+	 * size of zero.
 	 */
-	if ((fd_device_version(ctx->screen->dev) < FD_VERSION_UNLIMITED_CMDS) ||
-			(fd_mesa_debug & FD_DBG_NOGROW)){
-		size = 0x100000;
-	} else {
-		flags = FD_RINGBUFFER_GROWABLE;
+	if ((fd_device_version(ctx->screen->dev) >= FD_VERSION_UNLIMITED_CMDS) &&
+			!(fd_mesa_debug & FD_DBG_NOGROW)){
+		flags |= FD_RINGBUFFER_GROWABLE;
+		sz = 0;
 	}
 
+	return fd_submit_new_ringbuffer(batch->submit, sz, flags);
+}
+
+static void
+batch_init(struct fd_batch *batch)
+{
+	struct fd_context *ctx = batch->ctx;
+
 	batch->submit = fd_submit_new(ctx->pipe);
 	if (batch->nondraw) {
-		batch->draw = fd_submit_new_ringbuffer(batch->submit, size,
-				FD_RINGBUFFER_PRIMARY | flags);
+		batch->draw = alloc_ring(batch, 0x100000, FD_RINGBUFFER_PRIMARY);
 	} else {
-		batch->gmem = fd_submit_new_ringbuffer(batch->submit, size,
-				FD_RINGBUFFER_PRIMARY | flags);
-		batch->draw = fd_submit_new_ringbuffer(batch->submit, size,
-				flags);
+		batch->gmem = alloc_ring(batch, 0x100000, FD_RINGBUFFER_PRIMARY);
+		batch->draw = alloc_ring(batch, 0x100000, 0);
 
+		/* a6xx+ re-uses draw rb for both draw and binning pass: */
 		if (ctx->screen->gpu_id < 600) {
-			batch->binning = fd_submit_new_ringbuffer(batch->submit,
-					size, flags);
+			batch->binning = alloc_ring(batch, 0x100000, 0);
 		}
 	}
 



More information about the mesa-commit mailing list