zink: reorder availability handling for (user) qbos

if the shortcut method without a staging buffer fails, falling back
to the staging buffer is more sane than silently failing

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9811>
This commit is contained in:
Mike Blumenkrantz 2021-03-14 19:39:24 -04:00 committed by Marge Bot
parent 3b5f345e9b
commit 726e2eb8f9

View file

@ -926,20 +926,18 @@ zink_get_query_result_resource(struct pipe_context *pctx,
*/
VkQueryResultFlags flag = is_time_query(query) ? 0 : VK_QUERY_RESULT_PARTIAL_BIT;
if (fences) {
struct pipe_resource *staging = pipe_buffer_create(pctx->screen, 0, PIPE_USAGE_STAGING, result_size * 2);
copy_results_to_buffer(ctx, query, zink_resource(staging), 0, 1, size_flags | VK_QUERY_RESULT_WITH_AVAILABILITY_BIT | flag);
zink_copy_buffer(ctx, &ctx->batch, res, zink_resource(staging), offset, result_size, result_size);
pipe_resource_reference(&staging, NULL);
} else {
if (!fences) {
uint64_t u64[2] = {0};
if (vkGetQueryPoolResults(screen->dev, query->query_pool, query_id, 1, 2 * result_size, u64,
0, size_flags | VK_QUERY_RESULT_WITH_AVAILABILITY_BIT | flag) != VK_SUCCESS) {
debug_printf("zink: getting query result failed\n");
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);
return;
}
pipe_buffer_write(pctx, pres, offset, result_size, (unsigned char*)u64 + result_size);
}
struct pipe_resource *staging = pipe_buffer_create(pctx->screen, 0, PIPE_USAGE_STAGING, result_size * 2);
copy_results_to_buffer(ctx, query, zink_resource(staging), 0, 1, size_flags | VK_QUERY_RESULT_WITH_AVAILABILITY_BIT | flag);
zink_copy_buffer(ctx, &ctx->batch, res, zink_resource(staging), offset, result_size, result_size);
pipe_resource_reference(&staging, NULL);
return;
}