summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRob Clark <robdclark@gmail.com>2016-08-15 13:41:04 -0400
committerRob Clark <robdclark@gmail.com>2016-12-01 20:16:31 -0500
commit16f6ceaca9e25f86bcdc509fc0abb48e2d51c3fa (patch)
treefc9bd0f2e41d5094abe0d994c8daf2f3805d568c /src
parent026a7223a6c9dcd7c59b95dbaf5e64b7258f8700 (diff)
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 <robdclark@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/freedreno/freedreno_batch.c2
-rw-r--r--src/gallium/drivers/freedreno/freedreno_batch_cache.c4
-rw-r--r--src/gallium/drivers/freedreno/freedreno_batch_cache.h2
-rw-r--r--src/gallium/drivers/freedreno/freedreno_context.c17
-rw-r--r--src/gallium/drivers/freedreno/freedreno_context.h2
-rw-r--r--src/gallium/drivers/freedreno/freedreno_fence.c7
-rw-r--r--src/gallium/drivers/freedreno/freedreno_fence.h8
-rw-r--r--src/gallium/drivers/freedreno/freedreno_gmem.c4
-rw-r--r--src/gallium/drivers/freedreno/freedreno_screen.c4
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 ec6f1cd37e5..369b7e9cda4 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 df11eab254c..f3d5078d1c3 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 1790e5cf46e..44c66b58f3b 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 0b12409bac4..70220f88dee 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 e56fef94422..e83b208ab86 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 df4cf4dd560..a5f717169f9 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 df7664bf8cd..32bfacc7627 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 3656538f26c..6d243c6d1e2 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 90060e219fe..07212dc0941 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);