summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>2020-06-29 14:04:22 -0400
committerMarge Bot <eric+marge@anholt.net>2020-09-29 20:49:15 +0000
commit6a20c630b93b1519c71a0a90185aebe30054be9d (patch)
tree62870f40efe54d6e837dda0286e5a773b2764925
parente31381ac2609ef06dfa5a230c38e7044009f5526 (diff)
zink: unify all occurrences of waiting on a fence
this was duplicated in a few places Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6922>
-rw-r--r--src/gallium/drivers/zink/zink_context.c12
-rw-r--r--src/gallium/drivers/zink/zink_context.h3
-rw-r--r--src/gallium/drivers/zink/zink_query.c19
-rw-r--r--src/gallium/drivers/zink/zink_resource.c16
4 files changed, 19 insertions, 31 deletions
diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c
index e05556ca0a6..669fb52ec02 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -897,6 +897,18 @@ zink_flush(struct pipe_context *pctx,
PIPE_TIMEOUT_INFINITE);
}
+void
+zink_fence_wait(struct pipe_context *pctx)
+{
+ struct pipe_fence_handle *fence = NULL;
+ pctx->flush(pctx, &fence, PIPE_FLUSH_HINT_FINISH);
+ if (fence) {
+ pctx->screen->fence_finish(pctx->screen, NULL, fence,
+ PIPE_TIMEOUT_INFINITE);
+ pctx->screen->fence_reference(pctx->screen, &fence, NULL);
+ }
+}
+
static void
zink_flush_resource(struct pipe_context *pipe,
struct pipe_resource *resource)
diff --git a/src/gallium/drivers/zink/zink_context.h b/src/gallium/drivers/zink/zink_context.h
index 9dd80040368..e76e256b102 100644
--- a/src/gallium/drivers/zink/zink_context.h
+++ b/src/gallium/drivers/zink/zink_context.h
@@ -154,6 +154,9 @@ struct zink_batch *
zink_batch_no_rp(struct zink_context *ctx);
void
+zink_fence_wait(struct pipe_context *ctx);
+
+void
zink_resource_barrier(VkCommandBuffer cmdbuf, struct zink_resource *res,
VkImageAspectFlags aspect, VkImageLayout new_layout);
diff --git a/src/gallium/drivers/zink/zink_query.c b/src/gallium/drivers/zink/zink_query.c
index 0d0c4fe53d0..2a0e5520d47 100644
--- a/src/gallium/drivers/zink/zink_query.c
+++ b/src/gallium/drivers/zink/zink_query.c
@@ -101,19 +101,6 @@ zink_create_query(struct pipe_context *pctx,
}
static void
-wait_query(struct pipe_context *pctx, struct zink_query *query)
-{
- struct pipe_fence_handle *fence = NULL;
-
- pctx->flush(pctx, &fence, PIPE_FLUSH_HINT_FINISH);
- if (fence) {
- pctx->screen->fence_finish(pctx->screen, NULL, fence,
- PIPE_TIMEOUT_INFINITE);
- pctx->screen->fence_reference(pctx->screen, &fence, NULL);
- }
-}
-
-static void
destroy_query(struct zink_screen *screen, struct zink_query *query)
{
assert(!p_atomic_read(&query->fences));
@@ -131,7 +118,7 @@ zink_destroy_query(struct pipe_context *pctx,
p_atomic_set(&query->dead, true);
if (p_atomic_read(&query->fences)) {
if (query->xfb_running)
- wait_query(pctx, query);
+ zink_fence_wait(pctx);
return;
}
@@ -345,10 +332,8 @@ zink_get_query_result(struct pipe_context *pctx,
bool wait,
union pipe_query_result *result)
{
- struct zink_query *query = (struct zink_query *)q;
-
if (wait) {
- wait_query(pctx, query);
+ zink_fence_wait(pctx);
} else
pctx->flush(pctx, NULL, 0);
return get_query_result(pctx, q, wait, result);
diff --git a/src/gallium/drivers/zink/zink_resource.c b/src/gallium/drivers/zink/zink_resource.c
index 89b9ca12239..561afeaf590 100644
--- a/src/gallium/drivers/zink/zink_resource.c
+++ b/src/gallium/drivers/zink/zink_resource.c
@@ -456,13 +456,7 @@ zink_transfer_map(struct pipe_context *pctx,
* TODO: optimize/fix this to be much less obtrusive
* mesa/mesa#2966
*/
- struct pipe_fence_handle *fence = NULL;
- pctx->flush(pctx, &fence, PIPE_FLUSH_HINT_FINISH);
- if (fence) {
- pctx->screen->fence_finish(pctx->screen, NULL, fence,
- PIPE_TIMEOUT_INFINITE);
- pctx->screen->fence_reference(pctx->screen, &fence, NULL);
- }
+ zink_fence_wait(pctx);
}
@@ -511,13 +505,7 @@ zink_transfer_map(struct pipe_context *pctx,
return NULL;
/* need to wait for rendering to finish */
- struct pipe_fence_handle *fence = NULL;
- pctx->flush(pctx, &fence, PIPE_FLUSH_HINT_FINISH);
- if (fence) {
- pctx->screen->fence_finish(pctx->screen, NULL, fence,
- PIPE_TIMEOUT_INFINITE);
- pctx->screen->fence_reference(pctx->screen, &fence, NULL);
- }
+ zink_fence_wait(pctx);
}
VkResult result = vkMapMemory(screen->dev, staging_res->mem,