Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=102241
Cc: mesa-stable@lists.freedesktop.org
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
static LARGE_INTEGER frequency;
LARGE_INTEGER counter;
+ int64_t secs, nanosecs;
if(!frequency.QuadPart)
QueryPerformanceFrequency(&frequency);
QueryPerformanceCounter(&counter);
- return counter.QuadPart*INT64_C(1000000000)/frequency.QuadPart;
+ /* Compute seconds and nanoseconds parts separately to
+ * reduce severity of precision loss.
+ */
+ secs = counter.QuadPart / frequency.QuadPart;
+ nanosecs = (counter.QuadPart % frequency.QuadPart) * INT64_C(1000000000)
+ / frequency.QuadPart;
+ return secs*INT64_C(1000000000) + nanosecs;
#else