Module: Mesa
Branch: main
Commit: dc7a61aa17e786ceeadf5eb6f854372630456267
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=dc7a61aa17e786ceeadf5eb6f854372630456267

Author: Yonggang Luo <[email protected]>
Date:   Wed Mar 30 04:32:39 2022 +0800

util: Implement util_thread_get_time_nano on win32

Signed-off-by: Yonggang Luo <[email protected]>
Reviewed-by: Jesse Natalie <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18001>

---

 src/util/u_thread.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/util/u_thread.h b/src/util/u_thread.h
index c25067930b2..f2187e551dd 100644
--- a/src/util/u_thread.h
+++ b/src/util/u_thread.h
@@ -240,6 +240,13 @@ util_thread_get_time_nano(thrd_t thread)
    pthread_getcpuclockid(thread, &cid);
    clock_gettime(cid, &ts);
    return (int64_t)ts.tv_sec * 1000000000 + ts.tv_nsec;
+#elif defined(_WIN32)
+   union {
+      FILETIME time;
+      ULONGLONG value;
+   } kernel_time, user_time;
+   GetThreadTimes((HANDLE)thread.handle, NULL, NULL, &kernel_time.time, 
&user_time.time);
+   return (kernel_time.value + user_time.value) * 100;
 #else
    (void)thread;
    return 0;

Reply via email to