diff options
author | Brian Ho <brian@brkho.com> | 2020-01-26 15:12:11 -0800 |
---|---|---|
committer | Marge Bot <eric+marge@anholt.net> | 2020-01-28 15:17:21 +0000 |
commit | af92ce50a7e56d313f5623136d3f09e7c76475fa (patch) | |
tree | 99b234ab243bfd7eb9acec6e81e1409ccff333db /src/intel | |
parent | 7edcf4a59d060efb5ee7c31f9b8346f7c43a138d (diff) |
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
result.
This commit fixes vkGetQueryPoolResults by always returning 0 if the
query is unavailable and the VK_QUERY_RESULT_PARTIAL_BIT is set.
Cc: <mesa-stable@lists.freedesktop.org>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3586>
Diffstat (limited to 'src/intel')
-rw-r--r-- | src/intel/vulkan/genX_query.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/intel/vulkan/genX_query.c b/src/intel/vulkan/genX_query.c index 04c58871be9..c549b13960b 100644 --- a/src/intel/vulkan/genX_query.c +++ b/src/intel/vulkan/genX_query.c @@ -308,8 +308,17 @@ VkResult genX(GetQueryPoolResults)( switch (pool->type) { case VK_QUERY_TYPE_OCCLUSION: { 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: + * + * "If VK_QUERY_RESULT_PARTIAL_BIT is set, + * 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); + } idx++; break; } |