zink: split fence finish func

one part of this will be used to handle tc mechanics, the other part is for
internal use

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9885>
This commit is contained in:
Mike Blumenkrantz 2021-03-22 10:39:42 -04:00 committed by Marge Bot
parent 4a736677af
commit 0ebc13564a
3 changed files with 22 additions and 16 deletions

View File

@ -1890,7 +1890,7 @@ zink_flush(struct pipe_context *pctx,
* unknown at this time why this is the case
*/
if (!ctx->first_frame_done)
zink_fence_finish(zink_screen(pctx->screen), pctx, fence, PIPE_TIMEOUT_INFINITE);
zink_vkfence_wait(zink_screen(pctx->screen), fence, PIPE_TIMEOUT_INFINITE);
ctx->first_frame_done = true;
}
}
@ -1904,7 +1904,7 @@ zink_maybe_flush_or_stall(struct zink_context *ctx)
flush_batch(ctx);
if (ctx->resource_size >= screen->total_mem / 10 || _mesa_hash_table_num_entries(&ctx->batch_states) > 10) {
zink_fence_finish(zink_screen(ctx->base.screen), &ctx->base, ctx->last_fence, PIPE_TIMEOUT_INFINITE);
zink_vkfence_wait(zink_screen(ctx->base.screen), ctx->last_fence, PIPE_TIMEOUT_INFINITE);
zink_batch_reset_all(ctx);
}
}
@ -1917,7 +1917,7 @@ zink_fence_wait(struct pipe_context *pctx)
if (ctx->batch.has_work)
pctx->flush(pctx, NULL, PIPE_FLUSH_HINT_FINISH);
if (ctx->last_fence) {
zink_fence_finish(zink_screen(pctx->screen), pctx, ctx->last_fence, PIPE_TIMEOUT_INFINITE);
zink_vkfence_wait(zink_screen(pctx->screen), ctx->last_fence, PIPE_TIMEOUT_INFINITE);
zink_batch_reset_all(ctx);
}
}
@ -1987,7 +1987,7 @@ zink_check_batch_completion(struct zink_context *ctx, uint32_t batch_id)
}
simple_mtx_unlock(&ctx->batch_mtx);
assert(fence);
return ctx->base.screen->fence_finish(ctx->base.screen, &ctx->base, (struct pipe_fence_handle*)fence, 0);
return zink_vkfence_wait(zink_screen(ctx->base.screen), fence, 0);
}
static void

View File

@ -104,17 +104,11 @@ fence_reference(struct pipe_screen *pscreen,
}
bool
zink_fence_finish(struct zink_screen *screen, struct pipe_context *pctx, struct zink_fence *fence,
uint64_t timeout_ns)
zink_vkfence_wait(struct zink_screen *screen, struct zink_fence *fence, uint64_t timeout_ns)
{
if (pctx && fence->deferred_ctx == pctx) {
zink_context(pctx)->batch.has_work = true;
/* this must be the current batch */
pctx->flush(pctx, NULL, 0);
}
if (!fence->submitted)
return true;
bool success;
if (timeout_ns)
@ -129,6 +123,19 @@ zink_fence_finish(struct zink_screen *screen, struct pipe_context *pctx, struct
return success;
}
static bool
zink_fence_finish(struct zink_screen *screen, struct pipe_context *pctx, struct zink_fence *fence,
uint64_t timeout_ns)
{
if (pctx && fence->deferred_ctx == pctx) {
zink_context(pctx)->batch.has_work = true;
/* this must be the current batch */
pctx->flush(pctx, NULL, 0);
}
return zink_vkfence_wait(screen, fence, timeout_ns);
}
static bool
fence_finish(struct pipe_screen *pscreen, struct pipe_context *pctx,
struct pipe_fence_handle *pfence, uint64_t timeout_ns)

View File

@ -60,16 +60,15 @@ zink_fence_reference(struct zink_screen *screen,
struct zink_fence **ptr,
struct zink_fence *fence);
bool
zink_fence_finish(struct zink_screen *screen, struct pipe_context *pctx, struct zink_fence *fence,
uint64_t timeout_ns);
void
zink_fence_server_sync(struct pipe_context *pctx, struct pipe_fence_handle *pfence);
void
zink_screen_fence_init(struct pipe_screen *pscreen);
bool
zink_vkfence_wait(struct zink_screen *screen, struct zink_fence *fence, uint64_t timeout_ns);
void
zink_fence_clear_resources(struct zink_screen *screen, struct zink_fence *fence);
#endif