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 d1f1d03..1e9117a 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 c2142b5..8f0f788 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 e17dcf7..20480f4 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 393b485..f10f7ef 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 f20c6ac..e3d200a 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 96cee1a..724ef69 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 73c3691..c92573e 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 5aa90ce..266908c 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 c5018da..68518ef 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;