Commit af92ce50 authored by Brian Ho's avatar Brian Ho Committed by Marge Bot
Browse files

anv: Properly fetch partial results in vkGetQueryPoolResults

Currently, fetching the partial results (VK_QUERY_RESULT_PARTIAL_BIT)
of an unavailable occlusion query via vkGetQueryPoolResults can
return invalid values. anv returns slot.end - slot.begin, but in the
case of unavailable queries, slot.end is still at the initial value
of 0. If slot.begin is non-zero, the occlusion count underflows to
a value that is likely outside the acceptable range of the partial

This commit fixes vkGetQueryPoolResults by always returning 0 if the
query is unavailable and the VK_QUERY_RESULT_PARTIAL_BIT is set.

Cc: <>
Reviewed-by: Lionel Landwerlin's avatarLionel Landwerlin <>
Part-of: <mesa/mesa!3586>
parent 7edcf4a5
......@@ -308,8 +308,17 @@ VkResult genX(GetQueryPoolResults)(
switch (pool->type) {
uint64_t *slot = query_slot(pool, firstQuery + i);
if (write_results)
cpu_write_query_result(pData, flags, idx, slot[2] - slot[1]);
if (write_results) {
/* From the Vulkan 1.2.132 spec:
* VK_QUERY_RESULT_WAIT_BIT is not set, and the query’s status
* is unavailable, an intermediate result value between zero and
* the final result value is written to pData for that query."
uint64_t result = available ? slot[2] - slot[1] : 0;
cpu_write_query_result(pData, flags, idx, result);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment