anv/GetQueryPoolResults: Actually implement the spec
The Vulkan spec is fairly clear about when we should and should not write query pool results. We're also supposed to return VK_NOT_READY if VK_QUERY_RESULT_PARTIAL_BIT is not set and we come across any queries which are not yet finished. This fixes rendering corruptions on The Talos Principle where geometry flickers in and out due to bogus query results being returned by the driver. These issues are most noticable on Sky Lake GT4 2hen running on "ultra" settings. Reviewed-By: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=100182 Cc: "17.0 13.0" <mesa-stable@lists.freedesktop.org>
This commit is contained in:
@@ -139,32 +139,52 @@ VkResult genX(GetQueryPoolResults)(
|
|||||||
MIN2(size, pool->bo.size - offset));
|
MIN2(size, pool->bo.size - offset));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VkResult status = VK_SUCCESS;
|
||||||
for (uint32_t i = 0; i < queryCount; i++) {
|
for (uint32_t i = 0; i < queryCount; i++) {
|
||||||
switch (pool->type) {
|
bool available = slot[firstQuery + i].available;
|
||||||
case VK_QUERY_TYPE_OCCLUSION: {
|
|
||||||
result = slot[firstQuery + i].end - slot[firstQuery + i].begin;
|
/* From the Vulkan 1.0.42 spec:
|
||||||
break;
|
*
|
||||||
}
|
* "If VK_QUERY_RESULT_WAIT_BIT and VK_QUERY_RESULT_PARTIAL_BIT are
|
||||||
case VK_QUERY_TYPE_PIPELINE_STATISTICS:
|
* both not set then no result values are written to pData for
|
||||||
unreachable("pipeline stats not supported");
|
* queries that are in the unavailable state at the time of the call,
|
||||||
case VK_QUERY_TYPE_TIMESTAMP: {
|
* and vkGetQueryPoolResults returns VK_NOT_READY. However,
|
||||||
result = slot[firstQuery + i].begin;
|
* availability state is still written to pData for those queries if
|
||||||
break;
|
* VK_QUERY_RESULT_WITH_AVAILABILITY_BIT is set."
|
||||||
}
|
*/
|
||||||
default:
|
bool write_results = available || (flags & VK_QUERY_RESULT_PARTIAL_BIT);
|
||||||
unreachable("invalid pool type");
|
|
||||||
|
if (write_results) {
|
||||||
|
switch (pool->type) {
|
||||||
|
case VK_QUERY_TYPE_OCCLUSION: {
|
||||||
|
result = slot[firstQuery + i].end - slot[firstQuery + i].begin;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case VK_QUERY_TYPE_PIPELINE_STATISTICS:
|
||||||
|
unreachable("pipeline stats not supported");
|
||||||
|
case VK_QUERY_TYPE_TIMESTAMP: {
|
||||||
|
result = slot[firstQuery + i].begin;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
unreachable("invalid pool type");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
status = VK_NOT_READY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & VK_QUERY_RESULT_64_BIT) {
|
if (flags & VK_QUERY_RESULT_64_BIT) {
|
||||||
uint64_t *dst = pData;
|
uint64_t *dst = pData;
|
||||||
dst[0] = result;
|
if (write_results)
|
||||||
|
dst[0] = result;
|
||||||
if (flags & VK_QUERY_RESULT_WITH_AVAILABILITY_BIT)
|
if (flags & VK_QUERY_RESULT_WITH_AVAILABILITY_BIT)
|
||||||
dst[1] = slot[firstQuery + i].available;
|
dst[1] = slot[firstQuery + i].available;
|
||||||
} else {
|
} else {
|
||||||
uint32_t *dst = pData;
|
uint32_t *dst = pData;
|
||||||
if (result > UINT32_MAX)
|
if (result > UINT32_MAX)
|
||||||
result = UINT32_MAX;
|
result = UINT32_MAX;
|
||||||
dst[0] = result;
|
if (write_results)
|
||||||
|
dst[0] = result;
|
||||||
if (flags & VK_QUERY_RESULT_WITH_AVAILABILITY_BIT)
|
if (flags & VK_QUERY_RESULT_WITH_AVAILABILITY_BIT)
|
||||||
dst[1] = slot[firstQuery + i].available;
|
dst[1] = slot[firstQuery + i].available;
|
||||||
}
|
}
|
||||||
@@ -174,7 +194,7 @@ VkResult genX(GetQueryPoolResults)(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return VK_SUCCESS;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Reference in New Issue
Block a user