freedreno: per-context fd_pipe
authorRob Clark <robdclark@gmail.com>
Thu, 24 Aug 2017 13:34:48 +0000 (09:34 -0400)
committerRob Clark <robdclark@gmail.com>
Tue, 24 Oct 2017 16:56:51 +0000 (12:56 -0400)
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@gmail.com>
src/gallium/drivers/freedreno/a5xx/fd5_draw.c
src/gallium/drivers/freedreno/freedreno_batch.c
src/gallium/drivers/freedreno/freedreno_context.c
src/gallium/drivers/freedreno/freedreno_context.h
src/gallium/drivers/freedreno/freedreno_fence.c
src/gallium/drivers/freedreno/freedreno_query_acc.c
src/gallium/drivers/freedreno/freedreno_query_hw.c
src/gallium/drivers/freedreno/freedreno_resource.c
src/gallium/drivers/freedreno/freedreno_screen.h

index d1f1d039b698d47de3df4c91e6d434c3aa80df93..1e9117a5b96dbf46e6bc1507934a5584e7c486d4 100644 (file)
@@ -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);
        }
 
index c2142b5a21458a506f799f0fc77713c83f3b5ab2..8f0f78861cf8d49e5dd737a702f67b9d1f3f3206 100644 (file)
@@ -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);
index e17dcf7b6849e0db54301438fd625f09dd44f22c..20480f4f8c1c62a830149babf702c5608fda0651 100644 (file)
@@ -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;
index 393b485a096db0d0a9f435b858dd7d945e48b204..f10f7ef4ea50b5ec2673a8aaf71e0911f5b8aa87 100644 (file)
@@ -156,6 +156,7 @@ struct fd_context {
 
        struct fd_device *dev;
        struct fd_screen *screen;
+       struct fd_pipe *pipe;
 
        struct util_queue flush_queue;
 
index f20c6ac120e21539d06a026486a36e03279c826a..e3d200aa3a1cc3910560b9293b089258e02b4711 100644 (file)
@@ -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;
index 96cee1aee84bb368aaff5030047bad89e802e13a..724ef69dc24daf3c4cd5c6e8316a34d3726e95d3 100644 (file)
@@ -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);
index 73c3691147122bcaf2d42c53330d342ae7257886..c92573ec93605088108a5f6b6a65d9355f88b6b3 100644 (file)
@@ -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);
 
index 5aa90ced69cf2de81781cd9be6aff15516606acb..266908c0bc4d247f34365ab514b56279b885c28f 100644 (file)
@@ -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;
                }
index c5018da4bc59b4013af10aedeca1d289583b112b..68518ef721b8260e4ef1b306fd8b8861e813413f 100644 (file)
@@ -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;