Mesa (master): zink: unify all occurrences of waiting on a fence
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Sep 29 20:55:59 UTC 2020
Module: Mesa
Branch: master
Commit: 6a20c630b93b1519c71a0a90185aebe30054be9d
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6a20c630b93b1519c71a0a90185aebe30054be9d
Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date: Mon Jun 29 14:04:22 2020 -0400
zink: unify all occurrences of waiting on a fence
this was duplicated in a few places
Reviewed-by: Erik Faye-Lund <erik.faye-lund at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6922>
---
src/gallium/drivers/zink/zink_context.c | 12 ++++++++++++
src/gallium/drivers/zink/zink_context.h | 3 +++
src/gallium/drivers/zink/zink_query.c | 19 ++-----------------
src/gallium/drivers/zink/zink_resource.c | 16 ++--------------
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
@@ -153,6 +153,9 @@ zink_batch_rp(struct zink_context *ctx);
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
@@ -100,19 +100,6 @@ zink_create_query(struct pipe_context *pctx,
return (struct pipe_query *)query;
}
-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)
{
@@ -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,
More information about the mesa-commit
mailing list