freedreno: some fence cleanup
authorRob Clark <robdclark@gmail.com>
Mon, 15 Aug 2016 17:41:04 +0000 (13:41 -0400)
committerRob Clark <robdclark@gmail.com>
Fri, 2 Dec 2016 01:16:31 +0000 (20:16 -0500)
Prep-work for next patch, mostly move to tracking last_fence as a
pipe_fence_handle (created now only in fd_gmem_render_tiles()), and a
bit of superficial renaming.

Signed-off-by: Rob Clark <robdclark@gmail.com>
src/gallium/drivers/freedreno/freedreno_batch.c
src/gallium/drivers/freedreno/freedreno_batch_cache.c
src/gallium/drivers/freedreno/freedreno_batch_cache.h
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_fence.h
src/gallium/drivers/freedreno/freedreno_gmem.c
src/gallium/drivers/freedreno/freedreno_screen.c

index ec6f1cd37e5ff665944a47c97dc463858bb44984..369b7e9cda443a598fb25460231b9d7108097442 100644 (file)
@@ -234,7 +234,6 @@ batch_flush_func(void *job, int id)
 
        fd_gmem_render_tiles(batch);
        batch_reset_resources(batch);
-       batch->ctx->last_fence = fd_ringbuffer_timestamp(batch->gmem);
 }
 
 static void
@@ -275,7 +274,6 @@ batch_flush(struct fd_batch *batch)
        } else {
                fd_gmem_render_tiles(batch);
                batch_reset_resources(batch);
-               batch->ctx->last_fence = fd_ringbuffer_timestamp(batch->gmem);
        }
 
        debug_assert(batch->reference.count > 0);
index df11eab254c927aeb6a15d1a497a1e66ffcbc13f..f3d5078d1c3b6f883a48212b4f60ea2d09de4a3e 100644 (file)
@@ -124,7 +124,7 @@ fd_bc_fini(struct fd_batch_cache *cache)
        _mesa_hash_table_destroy(cache->ht, NULL);
 }
 
-uint32_t
+void
 fd_bc_flush(struct fd_batch_cache *cache, struct fd_context *ctx)
 {
        struct hash_entry *entry;
@@ -150,8 +150,6 @@ fd_bc_flush(struct fd_batch_cache *cache, struct fd_context *ctx)
                fd_batch_sync(last_batch);
                fd_batch_reference(&last_batch, NULL);
        }
-
-       return ctx->last_fence;
 }
 
 void
index 1790e5cf46ea0453e30f8953ba3ad2d6e3657877..44c66b58f3b5037412720fa20a49ae15ee47ed22 100644 (file)
@@ -62,7 +62,7 @@ struct fd_batch_cache {
 void fd_bc_init(struct fd_batch_cache *cache);
 void fd_bc_fini(struct fd_batch_cache *cache);
 
-uint32_t fd_bc_flush(struct fd_batch_cache *cache, struct fd_context *ctx);
+void fd_bc_flush(struct fd_batch_cache *cache, struct fd_context *ctx);
 
 void fd_bc_invalidate_context(struct fd_context *ctx);
 void fd_bc_invalidate_batch(struct fd_batch *batch, bool destroy);
index 0b12409bac4db7902b9d4bc4260a1467710f7f98..70220f88deeda5d4275635bc32a2c59ae584f59b 100644 (file)
@@ -43,22 +43,15 @@ fd_context_flush(struct pipe_context *pctx, struct pipe_fence_handle **fence,
                unsigned flags)
 {
        struct fd_context *ctx = fd_context(pctx);
-       uint32_t timestamp;
 
        if (!ctx->screen->reorder) {
-               struct fd_batch *batch = NULL;
-               fd_batch_reference(&batch, ctx->batch);
-               fd_batch_flush(batch, true);
-               timestamp = fd_ringbuffer_timestamp(batch->gmem);
-               fd_batch_reference(&batch, NULL);
+               fd_batch_flush(ctx->batch, true);
        } else {
-               timestamp = fd_bc_flush(&ctx->screen->batch_cache, ctx);
+               fd_bc_flush(&ctx->screen->batch_cache, ctx);
        }
 
-       if (fence) {
-               fd_screen_fence_ref(pctx->screen, fence, NULL);
-               *fence = fd_fence_create(pctx, timestamp);
-       }
+       if (fence)
+               fd_fence_ref(pctx->screen, fence, ctx->last_fence);
 }
 
 /**
@@ -109,6 +102,8 @@ fd_context_destroy(struct pipe_context *pctx)
        fd_batch_reference(&ctx->batch, NULL);  /* unref current batch */
        fd_bc_invalidate_context(ctx);
 
+       fd_fence_ref(pctx->screen, &ctx->last_fence, NULL);
+
        fd_prog_fini(pctx);
        fd_hw_query_fini(pctx);
 
index e56fef9442295bd98f7b3321e918cb9b586c799a..e83b208ab86cb13a2a471b032f62ea92c796ceb6 100644 (file)
@@ -164,7 +164,7 @@ struct fd_context {
         */
        struct fd_batch *batch;
 
-       uint32_t last_fence;
+       struct pipe_fence_handle *last_fence;
 
        /* Are we in process of shadowing a resource? Used to detect recursion
         * in transfer_map, and skip unneeded synchronization.
index df4cf4dd56072fdab9e3ae63870ab0398226d56e..a5f717169f9fabca8fff47bd238e07b2e5e9c640 100644 (file)
@@ -40,7 +40,7 @@ struct pipe_fence_handle {
 };
 
 void
-fd_screen_fence_ref(struct pipe_screen *pscreen,
+fd_fence_ref(struct pipe_screen *pscreen,
                struct pipe_fence_handle **ptr,
                struct pipe_fence_handle *pfence)
 {
@@ -50,7 +50,7 @@ fd_screen_fence_ref(struct pipe_screen *pscreen,
        *ptr = pfence;
 }
 
-boolean fd_screen_fence_finish(struct pipe_screen *screen,
+boolean fd_fence_finish(struct pipe_screen *pscreen,
                struct pipe_context *ctx,
                struct pipe_fence_handle *fence,
                uint64_t timeout)
@@ -61,11 +61,10 @@ boolean fd_screen_fence_finish(struct pipe_screen *screen,
        return true;
 }
 
-struct pipe_fence_handle * fd_fence_create(struct pipe_context *pctx,
+struct pipe_fence_handle * fd_fence_create(struct fd_context *ctx,
                uint32_t timestamp)
 {
        struct pipe_fence_handle *fence;
-       struct fd_context *ctx = fd_context(pctx);
 
        fence = CALLOC_STRUCT(pipe_fence_handle);
        if (!fence)
index df7664bf8cd434a9b9ac559ee7e7829a586c3aa8..32bfacc7627f02d3682471dfe836f983fa181c5d 100644 (file)
 
 #include "pipe/p_context.h"
 
-void fd_screen_fence_ref(struct pipe_screen *pscreen,
+void fd_fence_ref(struct pipe_screen *pscreen,
                struct pipe_fence_handle **ptr,
                struct pipe_fence_handle *pfence);
-boolean fd_screen_fence_finish(struct pipe_screen *screen,
+boolean fd_fence_finish(struct pipe_screen *screen,
                struct pipe_context *ctx,
                struct pipe_fence_handle *pfence,
                uint64_t timeout);
-struct pipe_fence_handle * fd_fence_create(struct pipe_context *pctx,
+
+struct fd_context;
+struct pipe_fence_handle * fd_fence_create(struct fd_context *ctx,
                uint32_t timestamp);
 
 #endif /* FREEDRENO_FENCE_H_ */
index 3656538f26cfe23899e3a361289ddf6031e5ef10..6d243c6d1e2df958d96617712bee21354536a5ff 100644 (file)
@@ -34,6 +34,7 @@
 
 #include "freedreno_gmem.h"
 #include "freedreno_context.h"
+#include "freedreno_fence.h"
 #include "freedreno_resource.h"
 #include "freedreno_query_hw.h"
 #include "freedreno_util.h"
@@ -399,6 +400,9 @@ fd_gmem_render_tiles(struct fd_batch *batch)
        }
 
        fd_ringbuffer_flush(batch->gmem);
+
+       fd_fence_ref(&ctx->screen->base, &ctx->last_fence, NULL);
+       ctx->last_fence = fd_fence_create(ctx, fd_ringbuffer_timestamp(batch->gmem));
 }
 
 /* tile needs restore if it isn't completely contained within the
index 90060e219fe8e250d14686b41dd5ee66c6f6db13..07212dc0941936708618adeac320122151a8f4d7 100644 (file)
@@ -711,8 +711,8 @@ fd_screen_create(struct fd_device *dev)
 
        pscreen->get_timestamp = fd_screen_get_timestamp;
 
-       pscreen->fence_reference = fd_screen_fence_ref;
-       pscreen->fence_finish = fd_screen_fence_finish;
+       pscreen->fence_reference = fd_fence_ref;
+       pscreen->fence_finish = fd_fence_finish;
 
        slab_create_parent(&screen->transfer_pool, sizeof(struct fd_transfer), 16);