Commit 6b2ded87 by Maxime Grégoire

Revert timers implementation for Windows

Change-Id: I54e0607b060d42da60efa1057f114730d13f390c Reviewed-on: https://swiftshader-review.googlesource.com/3709Reviewed-by: 's avatarMaxime Grégoire <mgregoire@google.com> Tested-by: 's avatarMaxime Grégoire <mgregoire@google.com>
parent 157ccecf
...@@ -528,68 +528,6 @@ void Event::setDeviceData(void *data) ...@@ -528,68 +528,6 @@ void Event::setDeviceData(void *data)
p_device_data = data; p_device_data = data;
} }
LARGE_INTEGER
getFILETIMEoffset()
{
SYSTEMTIME s;
FILETIME f;
LARGE_INTEGER t;
s.wYear = 1970;
s.wMonth = 1;
s.wDay = 1;
s.wHour = 0;
s.wMinute = 0;
s.wSecond = 0;
s.wMilliseconds = 0;
SystemTimeToFileTime(&s, &f);
t.QuadPart = f.dwHighDateTime;
t.QuadPart <<= 32;
t.QuadPart |= f.dwLowDateTime;
return (t);
}
int
clock_gettime(int X, timeval *tv)
{
LARGE_INTEGER t;
FILETIME f;
double microseconds;
static LARGE_INTEGER offset;
static double frequencyToMicroseconds;
static int initialized = 0;
static BOOL usePerformanceCounter = 0;
if(!initialized) {
LARGE_INTEGER performanceFrequency;
initialized = 1;
usePerformanceCounter = QueryPerformanceFrequency(&performanceFrequency);
if(usePerformanceCounter) {
QueryPerformanceCounter(&offset);
frequencyToMicroseconds = (double)performanceFrequency.QuadPart / 1000000.;
}
else {
offset = getFILETIMEoffset();
frequencyToMicroseconds = 10.;
}
}
if(usePerformanceCounter) QueryPerformanceCounter(&t);
else {
GetSystemTimeAsFileTime(&f);
t.QuadPart = f.dwHighDateTime;
t.QuadPart <<= 32;
t.QuadPart |= f.dwLowDateTime;
}
t.QuadPart -= offset.QuadPart;
microseconds = (double)t.QuadPart / frequencyToMicroseconds;
t.QuadPart = microseconds;
tv->tv_sec = t.QuadPart / 1000000;
tv->tv_usec = t.QuadPart % 1000000;
return (0);
}
void Event::updateTiming(Timing timing) void Event::updateTiming(Timing timing)
{ {
if(timing >= Max) if(timing >= Max)
...@@ -604,18 +542,14 @@ void Event::updateTiming(Timing timing) ...@@ -604,18 +542,14 @@ void Event::updateTiming(Timing timing)
return; return;
} }
struct timeval tp; struct timespec tp;
//struct timespec tp;
cl_ulong rs; cl_ulong rs;
//TODO if(clock_gettime(CLOCK_MONOTONIC, &tp) != 0)
if(clock_gettime(0, &tp) != 0) clock_gettime(CLOCK_REALTIME, &tp);
clock_gettime(0, &tp);
rs = tp.tv_usec;// *1000; rs = tp.tv_nsec;
rs += tp.tv_sec * 1000000; rs += tp.tv_sec * 1000000;
/*rs = tp.tv_nsec;
rs += tp.tv_sec * 1000000;*/
p_timing[timing] = rs; p_timing[timing] = rs;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment