v3dv: don't wait for idle on occlusion query pool resets

Instead, wait for the specific queries being reset to
not be in use by the GPU.

This takes query pool resets in the UE4 Shooter demo from
50-60ms down to 0.5-2ms.

Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8554>
This commit is contained in:
Iago Toral Quiroga 2020-12-18 12:51:08 +01:00
parent 15cf2ab642
commit e122c9f3c8

View file

@ -153,6 +153,9 @@ v3dv_QueueWaitIdle(VkQueue _queue)
static VkResult
handle_reset_query_cpu_job(struct v3dv_job *job)
{
struct v3dv_reset_query_cpu_job_info *info = &job->cpu.query_reset;
assert(info->pool);
/* We are about to reset query counters so we need to make sure that
* The GPU is not using them. The exception is timestamp queries, since
* we handle those in the CPU.
@ -160,21 +163,14 @@ handle_reset_query_cpu_job(struct v3dv_job *job)
* FIXME: we could avoid blocking the main thread for this if we use
* submission thread.
*/
struct v3dv_reset_query_cpu_job_info *info = &job->cpu.query_reset;
assert(info->pool);
if (info->pool->query_type == VK_QUERY_TYPE_OCCLUSION) {
VkResult result = gpu_queue_wait_idle(&job->device->queue);
if (result != VK_SUCCESS)
return result;
}
for (uint32_t i = info->first; i < info->first + info->count; i++) {
assert(i < info->pool->query_count);
struct v3dv_query *query = &info->pool->queries[i];
query->maybe_available = false;
switch (info->pool->query_type) {
case VK_QUERY_TYPE_OCCLUSION: {
const uint64_t infinite = 0xffffffffffffffffull;
v3dv_bo_wait(job->device, query->bo, infinite);
uint32_t *counter = (uint32_t *) query->bo->map;
*counter = 0;
break;