Skip to content

Commit ac669b5

Browse files
committed
xrCore,xrCDB: replace cpu features on SDL
1 parent bbf2b50 commit ac669b5

File tree

4 files changed

+17
-22
lines changed

4 files changed

+17
-22
lines changed

src/xrCDB/ISpatial_q_ray.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ void ISpatial_DB::q_ray(
335335
Stats.Query.Begin();
336336
q_result = &R;
337337
q_result->clear();
338-
if (CPU::ID.hasFeature(CpuFeature::Sse))
338+
if (SDL_HasSSE())
339339
{
340340
if (_o & O_ONLYFIRST)
341341
{

src/xrCDB/xrCDB_ray.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ void COLLIDER::ray_query(const MODEL* m_def, const Fvector& r_start, const Fvect
424424
const AABBNoLeafNode* N = T->GetNodes();
425425
r_clear();
426426

427-
if (CPU::ID.hasFeature(CpuFeature::Sse))
427+
if (SDL_HasSSE())
428428
{
429429
// SSE
430430
// Binary dispatcher

src/xrCore/_math.cpp

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <sys/time.h>
2424
#include <sys/resource.h>
2525
#include <chrono>
26+
#include <thread>
2627
#endif
2728

2829
typedef struct _PROCESSOR_POWER_INFORMATION
@@ -73,11 +74,13 @@ void QueryPerformanceCounter(PLARGE_INTEGER result)
7374

7475
DWORD timeGetTime()
7576
{
76-
std::chrono::time_point<std::chrono::high_resolution_clock> now = std::chrono::high_resolution_clock::now();
77+
/* std::chrono::time_point<std::chrono::high_resolution_clock> now = std::chrono::high_resolution_clock::now();
7778
7879
auto nanosec = now.time_since_epoch();
7980
8081
return nanosec.count()/(1000000000.0 *60.0 *60.0);
82+
*/
83+
return SDL_GetTicks();
8184
}
8285

8386
#endif
@@ -305,30 +308,22 @@ bool g_initialize_cpu_called = false;
305308
//------------------------------------------------------------------------------------
306309
void _initialize_cpu()
307310
{
308-
// General CPU identification
309-
if (!query_processor_info(&CPU::ID))
310-
FATAL("Can't detect CPU/FPU.");
311311

312312
CPU::Detect();
313313

314-
Msg("* Detected CPU: %s [%s], F%d/M%d/S%d, 'rdtsc'", CPU::ID.modelName,
315-
+CPU::ID.vendor, CPU::ID.family, CPU::ID.model, CPU::ID.stepping);
316-
317314
string256 features;
318315
xr_strcpy(features, sizeof(features), "RDTSC");
319-
if (CPU::ID.hasFeature(CpuFeature::Mmx)) xr_strcat(features, ", MMX");
320-
if (CPU::ID.hasFeature(CpuFeature::_3dNow)) xr_strcat(features, ", 3DNow!");
321-
if (CPU::ID.hasFeature(CpuFeature::Sse)) xr_strcat(features, ", SSE");
322-
if (CPU::ID.hasFeature(CpuFeature::Sse2)) xr_strcat(features, ", SSE2");
323-
if (CPU::ID.hasFeature(CpuFeature::Sse3)) xr_strcat(features, ", SSE3");
324-
if (CPU::ID.hasFeature(CpuFeature::MWait)) xr_strcat(features, ", MONITOR/MWAIT");
325-
if (CPU::ID.hasFeature(CpuFeature::Ssse3)) xr_strcat(features, ", SSSE3");
326-
if (CPU::ID.hasFeature(CpuFeature::Sse41)) xr_strcat(features, ", SSE4.1");
327-
if (CPU::ID.hasFeature(CpuFeature::Sse42)) xr_strcat(features, ", SSE4.2");
328-
if (CPU::ID.hasFeature(CpuFeature::HT)) xr_strcat(features, ", HTT");
316+
if (SDL_HasMMX()) xr_strcat(features, ", MMX");
317+
if (SDL_Has3DNow()) xr_strcat(features, ", 3DNow!");
318+
if (SDL_HasSSE()) xr_strcat(features, ", SSE");
319+
if (SDL_HasSSE2()) xr_strcat(features, ", SSE2");
320+
if (SDL_HasSSE3()) xr_strcat(features, ", SSE3");
321+
if (SDL_HasRDTSC()) xr_strcat(features, ", RDTSC");
322+
if (SDL_HasSSE41()) xr_strcat(features, ", SSE4.1");
323+
if (SDL_HasSSE42()) xr_strcat(features, ", SSE4.2");
329324

330325
Msg("* CPU features: %s", features);
331-
Msg("* CPU cores/threads: %d/%d", CPU::ID.n_cores, CPU::ID.n_threads);
326+
Msg("* CPU cores/threads: %d/%d", std::thread::hardware_concurrency(), SDL_GetCPUCount());
332327

333328
#if defined(WINDOWS)
334329
SYSTEM_INFO sysInfo;
@@ -378,7 +373,7 @@ void _initialize_cpu_thread()
378373
else
379374
FPU::m24r();
380375

381-
if (CPU::ID.hasFeature(CpuFeature::Sse))
376+
if (SDL_HasSSE())
382377
{
383378
//_mm_setcsr ( _mm_getcsr() | (_MM_FLUSH_ZERO_ON+_MM_DENORMALS_ZERO_ON) );
384379
_MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);

src/xrCore/xrCore.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ void xrCore::Initialize(pcstr _ApplicationName, LogCallback cb, bool init_fs, pc
7575
Msg("%s %s build %d, %s\n", "OpenXRay", GetBuildConfiguration(), buildId, buildDate);
7676
Msg("command line %s\n", Params);
7777
_initialize_cpu();
78-
R_ASSERT(CPU::ID.hasFeature(CpuFeature::Sse));
78+
R_ASSERT(SDL_HasSSE());
7979
ttapi.initialize();
8080
XRay::Math::Initialize();
8181
// xrDebug::Initialize ();

0 commit comments

Comments
 (0)