From a122118c14a3cc9da22b94174cae7ee8d8445dfa Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Mon, 3 Sep 2018 16:07:17 -0400 Subject: [PATCH] freedreno: add fd_context_batch() accessor For cases in which (after the following commit) ctx->batch may be null. Prep work for following commit. Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/a4xx/fd4_query.c | 3 ++- src/gallium/drivers/freedreno/freedreno_batch_cache.c | 5 +++-- src/gallium/drivers/freedreno/freedreno_context.c | 3 +++ src/gallium/drivers/freedreno/freedreno_context.h | 6 ++++++ src/gallium/drivers/freedreno/freedreno_draw.c | 4 ++-- src/gallium/drivers/freedreno/freedreno_fence.c | 2 +- src/gallium/drivers/freedreno/freedreno_query_acc.c | 4 ++-- src/gallium/drivers/freedreno/freedreno_query_hw.c | 4 ++-- 8 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_query.c b/src/gallium/drivers/freedreno/a4xx/fd4_query.c index 0cd9ab31f6a..1a693aa3e12 100644 --- a/src/gallium/drivers/freedreno/a4xx/fd4_query.c +++ b/src/gallium/drivers/freedreno/a4xx/fd4_query.c @@ -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); } diff --git a/src/gallium/drivers/freedreno/freedreno_batch_cache.c b/src/gallium/drivers/freedreno/freedreno_batch_cache.c index 1bf656cf208..9d046f205bc 100644 --- a/src/gallium/drivers/freedreno/freedreno_batch_cache.c +++ b/src/gallium/drivers/freedreno/freedreno_batch_cache.c @@ -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]); } } diff --git a/src/gallium/drivers/freedreno/freedreno_context.c b/src/gallium/drivers/freedreno/freedreno_context.c index 2eeb85e315e..1d91b079f60 100644 --- a/src/gallium/drivers/freedreno/freedreno_context.c +++ b/src/gallium/drivers/freedreno/freedreno_context.c @@ -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); diff --git a/src/gallium/drivers/freedreno/freedreno_context.h b/src/gallium/drivers/freedreno/freedreno_context.h index a93561ef033..c8eb4f8c010 100644 --- a/src/gallium/drivers/freedreno/freedreno_context.h +++ b/src/gallium/drivers/freedreno/freedreno_context.h @@ -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) { diff --git a/src/gallium/drivers/freedreno/freedreno_draw.c b/src/gallium/drivers/freedreno/freedreno_draw.c index 3bcda342fb8..78bdc375e35 100644 --- a/src/gallium/drivers/freedreno/freedreno_draw.c +++ b/src/gallium/drivers/freedreno/freedreno_draw.c @@ -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; diff --git a/src/gallium/drivers/freedreno/freedreno_fence.c b/src/gallium/drivers/freedreno/freedreno_fence.c index e2602cb4112..489c8a3049c 100644 --- a/src/gallium/drivers/freedreno/freedreno_fence.c +++ b/src/gallium/drivers/freedreno/freedreno_fence.c @@ -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); diff --git a/src/gallium/drivers/freedreno/freedreno_query_acc.c b/src/gallium/drivers/freedreno/freedreno_query_acc.c index a7420d695f0..d7e1404fff8 100644 --- a/src/gallium/drivers/freedreno/freedreno_query_acc.c +++ b/src/gallium/drivers/freedreno/freedreno_query_acc.c @@ -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; diff --git a/src/gallium/drivers/freedreno/freedreno_query_hw.c b/src/gallium/drivers/freedreno/freedreno_query_hw.c index 86a46faa730..a321db3e937 100644 --- a/src/gallium/drivers/freedreno/freedreno_query_hw.c +++ b/src/gallium/drivers/freedreno/freedreno_query_hw.c @@ -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); -- 2.30.2