@@ -43,47 +43,10 @@ XRCORE_API Dmatrix Didentity;
43
43
XRCORE_API CRandom Random;
44
44
45
45
#if defined(LINUX)
46
- #define nsec_per_sec 1000 *1000 *1000
47
- /* *
48
- * From https://stackoverflow.com/questions/12468331/queryperformancecounter-linux-equivalent
49
- * @return
50
- */
51
- void QueryPerformanceCounter (PLARGE_INTEGER result)
52
- {
53
- u64 nsec_count, nsec_per_tick;
54
- /*
55
- * clock_gettime() returns the number of secs. We translate that to number of nanosecs.
56
- * clock_getres() returns number of seconds per tick. We translate that to number of nanosecs per tick.
57
- * Number of nanosecs divided by number of nanosecs per tick - will give the number of ticks.
58
- */
59
- struct timespec ts1, ts2;
60
-
61
- if (clock_gettime (CLOCK_MONOTONIC, &ts1) != 0 ) {
62
- return ;
63
- }
64
-
65
- nsec_count = ts1.tv_nsec + ts1.tv_sec * nsec_per_sec;
66
-
67
- if (clock_getres (CLOCK_MONOTONIC, &ts2) != 0 ) {
68
- return ;
69
- }
70
-
71
- nsec_per_tick = ts2.tv_nsec + ts2.tv_sec * nsec_per_sec;
72
-
73
- *result = (nsec_count / nsec_per_tick);
74
- }
75
-
76
46
DWORD timeGetTime ()
77
47
{
78
- /* std::chrono::time_point<std::chrono::high_resolution_clock> now = std::chrono::high_resolution_clock::now();
79
-
80
- auto nanosec = now.time_since_epoch();
81
-
82
- return nanosec.count()/(1000000000.0 *60.0 *60.0);
83
- */
84
48
return SDL_GetTicks ();
85
49
}
86
-
87
50
#endif
88
51
89
52
/*
@@ -220,8 +183,7 @@ XRCORE_API processor_info ID;
220
183
221
184
XRCORE_API u64 QPC () noexcept
222
185
{
223
- u64 _dest;
224
- QueryPerformanceCounter ((PLARGE_INTEGER)&_dest);
186
+ u64 _dest = SDL_GetPerformanceCounter ();
225
187
qpc_counter++;
226
188
return _dest;
227
189
}
@@ -269,9 +231,10 @@ void _initialize_cpu()
269
231
Msg (" * CPU%zu current freq: %lu MHz, max freq: %lu MHz" ,
270
232
i, cpuInfo.CurrentMhz , cpuInfo.MaxMhz );
271
233
}
272
-
273
- Log ( " " );
234
+ # else
235
+ Msg ( " * CPU current freq: %lu MHz " , CPU::qpc_freq );
274
236
#endif
237
+ Log (" " );
275
238
Fidentity.identity (); // Identity matrix
276
239
Didentity.identity (); // Identity matrix
277
240
pvInitializeStatics (); // Lookup table for compressed normals
@@ -306,9 +269,9 @@ void _initialize_cpu_thread()
306
269
{
307
270
// _mm_setcsr ( _mm_getcsr() | (_MM_FLUSH_ZERO_ON+_MM_DENORMALS_ZERO_ON) );
308
271
_MM_SET_FLUSH_ZERO_MODE (_MM_FLUSH_ZERO_ON);
309
- #if defined(WINDOWS)
310
272
if (_denormals_are_zero_supported)
311
273
{
274
+ #if defined(WINDOWS)
312
275
__try
313
276
{
314
277
_MM_SET_DENORMALS_ZERO_MODE (_MM_DENORMALS_ZERO_ON);
@@ -317,8 +280,18 @@ void _initialize_cpu_thread()
317
280
{
318
281
_denormals_are_zero_supported = FALSE ;
319
282
}
320
- }
283
+ #else
284
+ try
285
+ {
286
+ _MM_SET_DENORMALS_ZERO_MODE (_MM_DENORMALS_ZERO_ON);
287
+ }
288
+ catch (...)
289
+ {
290
+ _denormals_are_zero_supported = FALSE ;
291
+ }
321
292
#endif
293
+ }
294
+
322
295
}
323
296
}
324
297
0 commit comments