From 7a1426db6607632c37b20238c19bce8c6fa3e31a Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Tue, 8 Feb 2022 17:26:40 +1000 Subject: [PATCH] lavapipe: fix pipeline statistic query results with availability. The availability is meant to be the last integer value written, but for pipeline stats this was being done wrong. calculate the availability position properly. With the old non-overlapping execution model queries never were unavailable. Reviewed-by: Mike Blumenkrantz Reviewed-by: Roland Scheidegger Part-of: --- src/gallium/frontends/lavapipe/lvp_execute.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/gallium/frontends/lavapipe/lvp_execute.c b/src/gallium/frontends/lavapipe/lvp_execute.c index b0e52776bb4..ea57df9f876 100644 --- a/src/gallium/frontends/lavapipe/lvp_execute.c +++ b/src/gallium/frontends/lavapipe/lvp_execute.c @@ -2988,21 +2988,26 @@ static void handle_copy_query_pool_results(struct vk_cmd_queue_entry *cmd, struct vk_cmd_copy_query_pool_results *copycmd = &cmd->u.copy_query_pool_results; LVP_FROM_HANDLE(lvp_query_pool, pool, copycmd->query_pool); enum pipe_query_flags flags = (copycmd->flags & VK_QUERY_RESULT_WAIT_BIT) ? PIPE_QUERY_WAIT : 0; - + unsigned result_size = copycmd->flags & VK_QUERY_RESULT_64_BIT ? 8 : 4; for (unsigned i = copycmd->first_query; i < copycmd->first_query + copycmd->query_count; i++) { unsigned offset = copycmd->dst_offset + lvp_buffer_from_handle(copycmd->dst_buffer)->offset + (copycmd->stride * (i - copycmd->first_query)); if (pool->queries[i]) { - if (copycmd->flags & VK_QUERY_RESULT_WITH_AVAILABILITY_BIT) + unsigned num_results = 0; + if (copycmd->flags & VK_QUERY_RESULT_WITH_AVAILABILITY_BIT) { + if (pool->type == VK_QUERY_TYPE_PIPELINE_STATISTICS) { + num_results = util_bitcount(pool->pipeline_stats); + } else + num_results = 1; state->pctx->get_query_result_resource(state->pctx, pool->queries[i], flags, copycmd->flags & VK_QUERY_RESULT_64_BIT ? PIPE_QUERY_TYPE_U64 : PIPE_QUERY_TYPE_U32, -1, lvp_buffer_from_handle(copycmd->dst_buffer)->bo, - offset + (copycmd->flags & VK_QUERY_RESULT_64_BIT ? 8 : 4)); + offset + num_results * result_size); + } if (pool->type == VK_QUERY_TYPE_PIPELINE_STATISTICS) { - unsigned num_results = 0; - unsigned result_size = copycmd->flags & VK_QUERY_RESULT_64_BIT ? 8 : 4; + num_results = 0; u_foreach_bit(bit, pool->pipeline_stats) state->pctx->get_query_result_resource(state->pctx, pool->queries[i],