Module: Mesa
Branch: master
Commit: 16f6ceaca9e25f86bcdc509fc0abb48e2d51c3fa
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=16f6ceaca9e25f86bcdc509fc0abb48e2d51c3fa

Author: Rob Clark <robdcl...@gmail.com>
Date:   Mon Aug 15 13:41:04 2016 -0400

freedreno: some fence cleanup

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 <robdcl...@gmail.com>

---

 src/gallium/drivers/freedreno/freedreno_batch.c       |  2 --
 src/gallium/drivers/freedreno/freedreno_batch_cache.c |  4 +---
 src/gallium/drivers/freedreno/freedreno_batch_cache.h |  2 +-
 src/gallium/drivers/freedreno/freedreno_context.c     | 17 ++++++-----------
 src/gallium/drivers/freedreno/freedreno_context.h     |  2 +-
 src/gallium/drivers/freedreno/freedreno_fence.c       |  7 +++----
 src/gallium/drivers/freedreno/freedreno_fence.h       |  8 +++++---
 src/gallium/drivers/freedreno/freedreno_gmem.c        |  4 ++++
 src/gallium/drivers/freedreno/freedreno_screen.c      |  4 ++--
 9 files changed, 23 insertions(+), 27 deletions(-)

diff --git a/src/gallium/drivers/freedreno/freedreno_batch.c 
b/src/gallium/drivers/freedreno/freedreno_batch.c
index ec6f1cd..369b7e9 100644
--- a/src/gallium/drivers/freedreno/freedreno_batch.c
+++ b/src/gallium/drivers/freedreno/freedreno_batch.c
@@ -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);
diff --git a/src/gallium/drivers/freedreno/freedreno_batch_cache.c 
b/src/gallium/drivers/freedreno/freedreno_batch_cache.c
index df11eab..f3d5078 100644
--- a/src/gallium/drivers/freedreno/freedreno_batch_cache.c
+++ b/src/gallium/drivers/freedreno/freedreno_batch_cache.c
@@ -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
diff --git a/src/gallium/drivers/freedreno/freedreno_batch_cache.h 
b/src/gallium/drivers/freedreno/freedreno_batch_cache.h
index 1790e5c..44c66b5 100644
--- a/src/gallium/drivers/freedreno/freedreno_batch_cache.h
+++ b/src/gallium/drivers/freedreno/freedreno_batch_cache.h
@@ -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);
diff --git a/src/gallium/drivers/freedreno/freedreno_context.c 
b/src/gallium/drivers/freedreno/freedreno_context.c
index 0b12409..70220f8 100644
--- a/src/gallium/drivers/freedreno/freedreno_context.c
+++ b/src/gallium/drivers/freedreno/freedreno_context.c
@@ -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);
 
diff --git a/src/gallium/drivers/freedreno/freedreno_context.h 
b/src/gallium/drivers/freedreno/freedreno_context.h
index e56fef9..e83b208 100644
--- a/src/gallium/drivers/freedreno/freedreno_context.h
+++ b/src/gallium/drivers/freedreno/freedreno_context.h
@@ -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.
diff --git a/src/gallium/drivers/freedreno/freedreno_fence.c 
b/src/gallium/drivers/freedreno/freedreno_fence.c
index df4cf4d..a5f7171 100644
--- a/src/gallium/drivers/freedreno/freedreno_fence.c
+++ b/src/gallium/drivers/freedreno/freedreno_fence.c
@@ -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)
diff --git a/src/gallium/drivers/freedreno/freedreno_fence.h 
b/src/gallium/drivers/freedreno/freedreno_fence.h
index df7664b..32bfacc 100644
--- a/src/gallium/drivers/freedreno/freedreno_fence.h
+++ b/src/gallium/drivers/freedreno/freedreno_fence.h
@@ -31,14 +31,16 @@
 
 #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_ */
diff --git a/src/gallium/drivers/freedreno/freedreno_gmem.c 
b/src/gallium/drivers/freedreno/freedreno_gmem.c
index 3656538..6d243c6 100644
--- a/src/gallium/drivers/freedreno/freedreno_gmem.c
+++ b/src/gallium/drivers/freedreno/freedreno_gmem.c
@@ -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
diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c 
b/src/gallium/drivers/freedreno/freedreno_screen.c
index 90060e2..07212dc 100644
--- a/src/gallium/drivers/freedreno/freedreno_screen.c
+++ b/src/gallium/drivers/freedreno/freedreno_screen.c
@@ -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);
 

_______________________________________________
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to