From f8d2770737add73ba41e424339b69421e336cda1 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Fri, 7 Jan 2022 09:44:34 -0500 Subject: [PATCH] zink: fix availability buffer sizing/copying for xfb queries xfb queries have 2 results, and the availability bit is a 3rd result, so the buffer size has to be at least that big and the copy offset has to reflect the number of xfb results in the src offset cc: mesa-stable Reviewed-by: Hoe Hao Cheng Part-of: --- src/gallium/drivers/zink/zink_query.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/gallium/drivers/zink/zink_query.c b/src/gallium/drivers/zink/zink_query.c index 924619adf85..894b68a20f9 100644 --- a/src/gallium/drivers/zink/zink_query.c +++ b/src/gallium/drivers/zink/zink_query.c @@ -1022,17 +1022,18 @@ zink_get_query_result_resource(struct pipe_context *pctx, */ VkQueryResultFlags flag = is_time_query(query) ? 0 : VK_QUERY_RESULT_PARTIAL_BIT; + unsigned src_offset = result_size * get_num_results(query->type); if (zink_batch_usage_check_completion(ctx, query->batch_id)) { - uint64_t u64[2] = {0}; - if (VKCTX(GetQueryPoolResults)(screen->dev, query->query_pool, query_id, 1, 2 * result_size, u64, + uint64_t u64[4] = {0}; + if (VKCTX(GetQueryPoolResults)(screen->dev, query->query_pool, query_id, 1, sizeof(u64), u64, 0, size_flags | VK_QUERY_RESULT_WITH_AVAILABILITY_BIT | flag) == VK_SUCCESS) { - pipe_buffer_write(pctx, pres, offset, result_size, (unsigned char*)u64 + result_size); + pipe_buffer_write(pctx, pres, offset, result_size, (unsigned char*)u64 + src_offset); return; } } - struct pipe_resource *staging = pipe_buffer_create(pctx->screen, 0, PIPE_USAGE_STAGING, result_size * 2); + struct pipe_resource *staging = pipe_buffer_create(pctx->screen, 0, PIPE_USAGE_STAGING, src_offset + result_size); copy_results_to_buffer(ctx, query, zink_resource(staging), 0, 1, size_flags | VK_QUERY_RESULT_WITH_AVAILABILITY_BIT | flag); - zink_copy_buffer(ctx, res, zink_resource(staging), offset, result_size, result_size); + zink_copy_buffer(ctx, res, zink_resource(staging), offset, result_size * get_num_results(query->type), result_size); pipe_resource_reference(&staging, NULL); return; }