freedreno: add fd_context_batch() accessor
authorRob Clark <robdclark@gmail.com>
Mon, 3 Sep 2018 20:07:17 +0000 (16:07 -0400)
committerRob Clark <robdclark@gmail.com>
Wed, 5 Sep 2018 17:38:43 +0000 (13:38 -0400)
For cases in which (after the following commit) ctx->batch may be null.
Prep work for following commit.

Signed-off-by: Rob Clark <robdclark@gmail.com>
src/gallium/drivers/freedreno/a4xx/fd4_query.c
src/gallium/drivers/freedreno/freedreno_batch_cache.c
src/gallium/drivers/freedreno/freedreno_context.c
src/gallium/drivers/freedreno/freedreno_context.h
src/gallium/drivers/freedreno/freedreno_draw.c
src/gallium/drivers/freedreno/freedreno_fence.c
src/gallium/drivers/freedreno/freedreno_query_acc.c
src/gallium/drivers/freedreno/freedreno_query_hw.c

index 0cd9ab3..1a693aa 100644 (file)
@@ -117,7 +117,8 @@ time_elapsed_enable(struct fd_context *ctx, struct fd_ringbuffer *ring)
         * just hard coded.  If we start exposing more countables than we
         * have counters, we will need to be more clever.
         */
-       fd_wfi(ctx->batch, ring);
+       struct fd_batch *batch = fd_context_batch(ctx);
+       fd_wfi(batch, ring);
        OUT_PKT0(ring, REG_A4XX_CP_PERFCTR_CP_SEL_0, 1);
        OUT_RING(ring, CP_ALWAYS_COUNT);
 }
index 1bf656c..9d046f2 100644 (file)
@@ -144,10 +144,11 @@ bc_flush(struct fd_batch_cache *cache, struct fd_context *ctx, bool deferred)
        }
 
        if (deferred) {
-               struct fd_batch *current_batch = ctx->batch;
+               struct fd_batch *current_batch = fd_context_batch(ctx);
 
                for (unsigned i = 0; i < n; i++) {
-                       if (batches[i] != current_batch) {
+                       if (batches[i] && (batches[i]->ctx == ctx) &&
+                                       (batches[i] != current_batch)) {
                                fd_batch_add_dep(current_batch, batches[i]);
                        }
                }
index 2eeb85e..1d91b07 100644 (file)
@@ -49,6 +49,9 @@ fd_context_flush(struct pipe_context *pctx, struct pipe_fence_handle **fencep,
 
        DBG("%p: flush: flags=%x\n", ctx->batch, flags);
 
+       if (!ctx->batch)
+               return;
+
        /* Take a ref to the batch's fence (batch can be unref'd when flushed: */
        fd_fence_ref(pctx->screen, &fence, ctx->batch->fence);
 
index a93561e..c8eb4f8 100644 (file)
@@ -428,6 +428,12 @@ fd_supported_prim(struct fd_context *ctx, unsigned prim)
        return (1 << prim) & ctx->primtype_mask;
 }
 
+static inline struct fd_batch *
+fd_context_batch(struct fd_context *ctx)
+{
+       return ctx->batch;
+}
+
 static inline void
 fd_batch_set_stage(struct fd_batch *batch, enum fd_render_stage stage)
 {
index 3bcda34..78bdc37 100644 (file)
@@ -62,7 +62,7 @@ static void
 fd_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info)
 {
        struct fd_context *ctx = fd_context(pctx);
-       struct fd_batch *batch = ctx->batch;
+       struct fd_batch *batch = fd_context_batch(ctx);
        struct pipe_framebuffer_state *pfb = &batch->framebuffer;
        struct pipe_scissor_state *scissor = fd_context_get_scissor(ctx);
        unsigned i, prims, buffers = 0, restore_buffers = 0;
@@ -346,7 +346,7 @@ fd_clear(struct pipe_context *pctx, unsigned buffers,
                const union pipe_color_union *color, double depth, unsigned stencil)
 {
        struct fd_context *ctx = fd_context(pctx);
-       struct fd_batch *batch = ctx->batch;
+       struct fd_batch *batch = fd_context_batch(ctx);
        struct pipe_framebuffer_state *pfb = &batch->framebuffer;
        struct pipe_scissor_state *scissor = fd_context_get_scissor(ctx);
        unsigned cleared_buffers;
index e2602cb..489c8a3 100644 (file)
@@ -132,7 +132,7 @@ void fd_fence_server_sync(struct pipe_context *pctx,
                struct pipe_fence_handle *fence)
 {
        struct fd_context *ctx = fd_context(pctx);
-       struct fd_batch *batch = ctx->batch;
+       struct fd_batch *batch = fd_context_batch(ctx);
 
        fence_flush(fence);
 
index a7420d6..d7e1404 100644 (file)
@@ -77,7 +77,7 @@ realloc_query_bo(struct fd_context *ctx, struct fd_acc_query *aq)
 static boolean
 fd_acc_begin_query(struct fd_context *ctx, struct fd_query *q)
 {
-       struct fd_batch *batch = ctx->batch;
+       struct fd_batch *batch = fd_context_batch(ctx);
        struct fd_acc_query *aq = fd_acc_query(q);
        const struct fd_acc_sample_provider *p = aq->provider;
 
@@ -100,7 +100,7 @@ fd_acc_begin_query(struct fd_context *ctx, struct fd_query *q)
 static void
 fd_acc_end_query(struct fd_context *ctx, struct fd_query *q)
 {
-       struct fd_batch *batch = ctx->batch;
+       struct fd_batch *batch = fd_context_batch(ctx);
        struct fd_acc_query *aq = fd_acc_query(q);
        const struct fd_acc_sample_provider *p = aq->provider;
 
index 86a46fa..a321db3 100644 (file)
@@ -137,7 +137,7 @@ fd_hw_destroy_query(struct fd_context *ctx, struct fd_query *q)
 static boolean
 fd_hw_begin_query(struct fd_context *ctx, struct fd_query *q)
 {
-       struct fd_batch *batch = ctx->batch;
+       struct fd_batch *batch = fd_context_batch(ctx);
        struct fd_hw_query *hq = fd_hw_query(q);
 
        DBG("%p: active=%d", q, q->active);
@@ -158,7 +158,7 @@ fd_hw_begin_query(struct fd_context *ctx, struct fd_query *q)
 static void
 fd_hw_end_query(struct fd_context *ctx, struct fd_query *q)
 {
-       struct fd_batch *batch = ctx->batch;
+       struct fd_batch *batch = fd_context_batch(ctx);
        struct fd_hw_query *hq = fd_hw_query(q);
 
        DBG("%p: active=%d", q, q->active);