summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Ho <brian@brkho.com>2020-01-26 15:12:11 -0800
committerDylan Baker <dylan@pnwbakers.com>2020-02-03 08:31:30 -0800
commitd203c0add7efaca44544ffb463ef0dc73b13baab (patch)
treeb703f8dc4b8267640bb6dff87a8cf2bd190a79ff
parentf585257cb0367fccd42a544a149b793be4b03210 (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> (cherry picked from commit af92ce50a7e56d313f5623136d3f09e7c76475fa)
-rw-r--r--.pick_status.json2
-rw-r--r--src/intel/vulkan/genX_query.c13
2 files changed, 12 insertions, 3 deletions
diff --git a/.pick_status.json b/.pick_status.json
index 70241ea0134..cf211be7868 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -58,7 +58,7 @@
"description": "anv: Properly fetch partial results in vkGetQueryPoolResults",
"nominated": true,
"nomination_type": 0,
- "resolution": 0,
+ "resolution": 1,
"master_sha": null,
"because_sha": null
},
diff --git a/src/intel/vulkan/genX_query.c b/src/intel/vulkan/genX_query.c
index cf95bead2b9..74f7e37550e 100644
--- a/src/intel/vulkan/genX_query.c
+++ b/src/intel/vulkan/genX_query.c
@@ -338,8 +338,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;
}