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>
This commit is contained in:
Mike Blumenkrantz 2020-06-29 14:04:22 -04:00 committed by Marge Bot
parent e31381ac26
commit 6a20c630b9
4 changed files with 19 additions and 31 deletions

View File

@ -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)

View File

@ -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);

View File

@ -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);

View File

@ -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,