Skip to content

Commit

Permalink
xrCore,xrCDB: replace cpu features on SDL
Browse files Browse the repository at this point in the history
  • Loading branch information
eagleivg committed Aug 2, 2018
1 parent bbf2b50 commit ac669b5
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/xrCDB/ISpatial_q_ray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ void ISpatial_DB::q_ray(
Stats.Query.Begin();
q_result = &R;
q_result->clear();
if (CPU::ID.hasFeature(CpuFeature::Sse))
if (SDL_HasSSE())
{
if (_o & O_ONLYFIRST)
{
Expand Down
2 changes: 1 addition & 1 deletion src/xrCDB/xrCDB_ray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ void COLLIDER::ray_query(const MODEL* m_def, const Fvector& r_start, const Fvect
const AABBNoLeafNode* N = T->GetNodes();
r_clear();

if (CPU::ID.hasFeature(CpuFeature::Sse))
if (SDL_HasSSE())
{
// SSE
// Binary dispatcher
Expand Down
33 changes: 14 additions & 19 deletions src/xrCore/_math.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <sys/time.h>
#include <sys/resource.h>
#include <chrono>
#include <thread>
#endif

typedef struct _PROCESSOR_POWER_INFORMATION
Expand Down Expand Up @@ -73,11 +74,13 @@ void QueryPerformanceCounter(PLARGE_INTEGER result)

DWORD timeGetTime()
{
std::chrono::time_point<std::chrono::high_resolution_clock> now = std::chrono::high_resolution_clock::now();
/* std::chrono::time_point<std::chrono::high_resolution_clock> now = std::chrono::high_resolution_clock::now();
auto nanosec = now.time_since_epoch();
return nanosec.count()/(1000000000.0 *60.0 *60.0);
*/
return SDL_GetTicks();
}

#endif
Expand Down Expand Up @@ -305,30 +308,22 @@ bool g_initialize_cpu_called = false;
//------------------------------------------------------------------------------------
void _initialize_cpu()
{
// General CPU identification
if (!query_processor_info(&CPU::ID))
FATAL("Can't detect CPU/FPU.");

CPU::Detect();

Msg("* Detected CPU: %s [%s], F%d/M%d/S%d, 'rdtsc'", CPU::ID.modelName,
+CPU::ID.vendor, CPU::ID.family, CPU::ID.model, CPU::ID.stepping);

string256 features;
xr_strcpy(features, sizeof(features), "RDTSC");
if (CPU::ID.hasFeature(CpuFeature::Mmx)) xr_strcat(features, ", MMX");
if (CPU::ID.hasFeature(CpuFeature::_3dNow)) xr_strcat(features, ", 3DNow!");
if (CPU::ID.hasFeature(CpuFeature::Sse)) xr_strcat(features, ", SSE");
if (CPU::ID.hasFeature(CpuFeature::Sse2)) xr_strcat(features, ", SSE2");
if (CPU::ID.hasFeature(CpuFeature::Sse3)) xr_strcat(features, ", SSE3");
if (CPU::ID.hasFeature(CpuFeature::MWait)) xr_strcat(features, ", MONITOR/MWAIT");
if (CPU::ID.hasFeature(CpuFeature::Ssse3)) xr_strcat(features, ", SSSE3");
if (CPU::ID.hasFeature(CpuFeature::Sse41)) xr_strcat(features, ", SSE4.1");
if (CPU::ID.hasFeature(CpuFeature::Sse42)) xr_strcat(features, ", SSE4.2");
if (CPU::ID.hasFeature(CpuFeature::HT)) xr_strcat(features, ", HTT");
if (SDL_HasMMX()) xr_strcat(features, ", MMX");
if (SDL_Has3DNow()) xr_strcat(features, ", 3DNow!");
if (SDL_HasSSE()) xr_strcat(features, ", SSE");
if (SDL_HasSSE2()) xr_strcat(features, ", SSE2");
if (SDL_HasSSE3()) xr_strcat(features, ", SSE3");
if (SDL_HasRDTSC()) xr_strcat(features, ", RDTSC");
if (SDL_HasSSE41()) xr_strcat(features, ", SSE4.1");
if (SDL_HasSSE42()) xr_strcat(features, ", SSE4.2");

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

#if defined(WINDOWS)
SYSTEM_INFO sysInfo;
Expand Down Expand Up @@ -378,7 +373,7 @@ void _initialize_cpu_thread()
else
FPU::m24r();

if (CPU::ID.hasFeature(CpuFeature::Sse))
if (SDL_HasSSE())
{
//_mm_setcsr ( _mm_getcsr() | (_MM_FLUSH_ZERO_ON+_MM_DENORMALS_ZERO_ON) );
_MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);
Expand Down
2 changes: 1 addition & 1 deletion src/xrCore/xrCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void xrCore::Initialize(pcstr _ApplicationName, LogCallback cb, bool init_fs, pc
Msg("%s %s build %d, %s\n", "OpenXRay", GetBuildConfiguration(), buildId, buildDate);
Msg("command line %s\n", Params);
_initialize_cpu();
R_ASSERT(CPU::ID.hasFeature(CpuFeature::Sse));
R_ASSERT(SDL_HasSSE());
ttapi.initialize();
XRay::Math::Initialize();
// xrDebug::Initialize ();
Expand Down

0 comments on commit ac669b5

Please sign in to comment.