[Mesa-dev] [PATCH 2/4] gallium/u_queue: add util_queue_get_thread_time_nano

Marek Olšák maraeo at gmail.com
Sat Feb 11 19:58:57 UTC 2017


From: Marek Olšák <marek.olsak at amd.com>

---
 src/gallium/auxiliary/util/u_queue.c | 10 ++++++++++
 src/gallium/auxiliary/util/u_queue.h |  2 ++
 2 files changed, 12 insertions(+)

diff --git a/src/gallium/auxiliary/util/u_queue.c b/src/gallium/auxiliary/util/u_queue.c
index 838464f..4da5d8e 100644
--- a/src/gallium/auxiliary/util/u_queue.c
+++ b/src/gallium/auxiliary/util/u_queue.c
@@ -235,10 +235,20 @@ util_queue_add_job(struct util_queue *queue,
    ptr->job = job;
    ptr->fence = fence;
    ptr->execute = execute;
    ptr->cleanup = cleanup;
    queue->write_idx = (queue->write_idx + 1) % queue->max_jobs;
 
    queue->num_queued++;
    pipe_condvar_signal(queue->has_queued_cond);
    pipe_mutex_unlock(queue->lock);
 }
+
+int64_t
+util_queue_get_thread_time_nano(struct util_queue *queue, unsigned thread_index)
+{
+   /* Allow some flexibility by not raising an error. */
+   if (thread_index >= queue->num_threads)
+      return 0;
+
+   return pipe_thread_get_time_nano(queue->threads[thread_index]);
+}
diff --git a/src/gallium/auxiliary/util/u_queue.h b/src/gallium/auxiliary/util/u_queue.h
index 59646cc..351315c 100644
--- a/src/gallium/auxiliary/util/u_queue.h
+++ b/src/gallium/auxiliary/util/u_queue.h
@@ -77,20 +77,22 @@ void util_queue_fence_init(struct util_queue_fence *fence);
 void util_queue_fence_destroy(struct util_queue_fence *fence);
 
 /* optional cleanup callback is called after fence is signaled: */
 void util_queue_add_job(struct util_queue *queue,
                         void *job,
                         struct util_queue_fence *fence,
                         util_queue_execute_func execute,
                         util_queue_execute_func cleanup);
 
 void util_queue_job_wait(struct util_queue_fence *fence);
+int64_t util_queue_get_thread_time_nano(struct util_queue *queue,
+                                        unsigned thread_index);
 
 /* util_queue needs to be cleared to zeroes for this to work */
 static inline bool
 util_queue_is_initialized(struct util_queue *queue)
 {
    return queue->threads != NULL;
 }
 
 static inline bool
 util_queue_fence_is_signalled(struct util_queue_fence *fence)
-- 
2.7.4



More information about the mesa-dev mailing list