v3dv: Add a condition variable for queries
In order to properly wait for a query to be complete, we need to first wait for the end query job to flush through on the queue. Since query end is always handled on the CPU, we can do this with a condition variable. The 2s timeout is taken from ANV. Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com> Reviewed-by: Iago Toral Quiroga <itoral@igalia.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15704>
This commit is contained in:
committed by
Marge Bot
parent
e5a0e2122f
commit
00b84fae2d
@@ -180,6 +180,8 @@ handle_reset_query_cpu_job(struct v3dv_job *job)
|
||||
static VkResult
|
||||
handle_end_query_cpu_job(struct v3dv_job *job)
|
||||
{
|
||||
mtx_lock(&job->device->query_mutex);
|
||||
|
||||
struct v3dv_end_query_cpu_job_info *info = &job->cpu.query_end;
|
||||
for (uint32_t i = 0; i < info->count; i++) {
|
||||
assert(info->query + i < info->pool->query_count);
|
||||
@@ -187,6 +189,9 @@ handle_end_query_cpu_job(struct v3dv_job *job)
|
||||
query->maybe_available = true;
|
||||
}
|
||||
|
||||
cnd_broadcast(&job->device->query_ended);
|
||||
mtx_unlock(&job->device->query_mutex);
|
||||
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -546,6 +551,8 @@ handle_timestamp_query_cpu_job(struct v3dv_job *job)
|
||||
/* Wait for completion of all work queued before the timestamp query */
|
||||
v3dv_QueueWaitIdle(v3dv_queue_to_handle(&job->device->queue));
|
||||
|
||||
mtx_lock(&job->device->query_mutex);
|
||||
|
||||
/* Compute timestamp */
|
||||
struct timespec t;
|
||||
clock_gettime(CLOCK_MONOTONIC, &t);
|
||||
@@ -558,6 +565,9 @@ handle_timestamp_query_cpu_job(struct v3dv_job *job)
|
||||
query->value = t.tv_sec * 1000000000ull + t.tv_nsec;
|
||||
}
|
||||
|
||||
cnd_broadcast(&job->device->query_ended);
|
||||
mtx_unlock(&job->device->query_mutex);
|
||||
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user