Module: Mesa Branch: main Commit: b192b9c88a0c436ceed3c278ad292a2e677fb477 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b192b9c88a0c436ceed3c278ad292a2e677fb477
Author: Mike Blumenkrantz <[email protected]> Date: Thu Jul 15 08:33:23 2021 -0400 zink: implement PIPE_QUERY_GPU_FINISHED Reviewed-by: Dave Airlie <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12573> --- src/gallium/drivers/zink/zink_query.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/zink/zink_query.c b/src/gallium/drivers/zink/zink_query.c index cdfb15f3c50..4f1e9ddec37 100644 --- a/src/gallium/drivers/zink/zink_query.c +++ b/src/gallium/drivers/zink/zink_query.c @@ -49,7 +49,10 @@ struct zink_query { struct zink_batch_usage *batch_id; //batch that the query was started in struct list_head buffers; - struct zink_query_buffer *curr_qbo; + union { + struct zink_query_buffer *curr_qbo; + struct pipe_fence_handle *fence; //PIPE_QUERY_GPU_FINISHED + }; struct zink_resource *predicate; bool predicate_dirty; @@ -280,6 +283,8 @@ zink_create_query(struct pipe_context *pctx, query->index = index; query->type = query_type; + if (query->type == PIPE_QUERY_GPU_FINISHED) + return (struct pipe_query *)query; query->vkqtype = convert_query_type(query_type, &query->precise); if (query->vkqtype == -1) return NULL; @@ -759,6 +764,11 @@ zink_end_query(struct pipe_context *pctx, struct zink_query *query = (struct zink_query *)q; struct zink_batch *batch = &ctx->batch; + if (query->type == PIPE_QUERY_GPU_FINISHED) { + pctx->flush(pctx, &query->fence, PIPE_FLUSH_DEFERRED); + return true; + } + /* FIXME: this can be called from a thread, but it needs to write to the cmdbuf */ threaded_context_unwrap_sync(pctx); @@ -779,6 +789,14 @@ zink_get_query_result(struct pipe_context *pctx, struct zink_query *query = (void*)q; struct zink_context *ctx = zink_context(pctx); + if (query->type == PIPE_QUERY_GPU_FINISHED) { + struct pipe_screen *screen = pctx->screen; + + result->b = screen->fence_finish(screen, query->base.flushed ? NULL : pctx, + query->fence, wait ? PIPE_TIMEOUT_INFINITE : 0); + return result->b; + } + if (query->needs_update) update_qbo(ctx, query);
