Skip to content

Commit c289fee

Browse files
committed
xrCore: obtaining CPU information was rewritten to C++ instead of ASM
From commit Im-dex/xray-162@ddf2598
1 parent 46c5c0d commit c289fee

File tree

9 files changed

+190
-461
lines changed

9 files changed

+190
-461
lines changed

src/xrCDB/ISpatial_q_ray.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ void ISpatial_DB::q_ray(
340340
Stats.Query.Begin();
341341
q_result = &R;
342342
q_result->clear_not_free();
343-
if (CPU::ID.feature & _CPU_FEATURE_SSE)
343+
if (CPU::ID.hasFeature(CpuFeature::Sse))
344344
{
345345
if (_o & O_ONLYFIRST)
346346
{

src/xrCDB/xrCDB_ray.cpp

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

431-
if (CPU::ID.feature & _CPU_FEATURE_SSE)
431+
if (CPU::ID.hasFeature(CpuFeature::Sse))
432432
{
433433
// SSE
434434
// Binary dispatcher

src/xrCore/Threading/ttapi.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ void SetThreadName(DWORD dwThreadID, LPCSTR szThreadName)
105105
}
106106
}
107107

108-
int ttapi_Init(const _processor_info& pi)
108+
int ttapi_Init(const processor_info& pi)
109109
{
110110
if (ttapi_initialized)
111111
return ttapi_worker_count;

src/xrCore/Threading/ttapi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ using TTAPIWorkerFunc = void (*)(void* lpWorkerParameters);
66

77
// Initializes subsystem
88
// Returns zero for error, and number of workers on success
9-
int XRCORE_API ttapi_Init(const _processor_info& pi);
9+
int XRCORE_API ttapi_Init(const processor_info& pi);
1010

1111
// Destroys subsystem
1212
void XRCORE_API ttapi_Done();

src/xrCore/_math.cpp

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ XRCORE_API u64 qpc_freq = 0;
143143
XRCORE_API u64 qpc_overhead = 0;
144144
XRCORE_API u32 qpc_counter = 0;
145145

146-
XRCORE_API _processor_info ID;
146+
XRCORE_API processor_info ID;
147147

148148
XRCORE_API u64 QPC()
149149
{
@@ -164,7 +164,7 @@ u64 __fastcall GetCLK(void)
164164
void Detect()
165165
{
166166
// General CPU identification
167-
if (!_cpuid(&ID))
167+
if (!query_processor_info(&ID))
168168
{
169169
// Core.Fatal ("Fatal error: can't detect CPU/FPU.");
170170
abort();
@@ -234,44 +234,36 @@ bool g_initialize_cpu_called = false;
234234
//------------------------------------------------------------------------------------
235235
void _initialize_cpu(void)
236236
{
237-
Msg("* Detected CPU: %s [%s], F%d/M%d/S%d, %.2f mhz, %d-clk 'rdtsc'", CPU::ID.model_name, CPU::ID.v_name,
237+
Msg("* Detected CPU: %s [%s], F%d/M%d/S%d, %.2f mhz, %d-clk 'rdtsc'", CPU::ID.modelName, CPU::ID.vendor,
238238
CPU::ID.family, CPU::ID.model, CPU::ID.stepping, float(CPU::clk_per_second / u64(1000000)),
239239
u32(CPU::clk_overhead));
240240

241241
// DUMP_PHASE;
242242

243243
if (strstr(Core.Params, "-x86"))
244244
{
245-
CPU::ID.feature &= ~_CPU_FEATURE_MMX;
246-
CPU::ID.feature &= ~_CPU_FEATURE_3DNOW;
247-
CPU::ID.feature &= ~_CPU_FEATURE_SSE;
248-
CPU::ID.feature &= ~_CPU_FEATURE_SSE2;
249-
CPU::ID.feature &= ~_CPU_FEATURE_SSE3;
250-
CPU::ID.feature &= ~_CPU_FEATURE_SSSE3;
251-
CPU::ID.feature &= ~_CPU_FEATURE_SSE4_1;
252-
CPU::ID.feature &= ~_CPU_FEATURE_SSE4_2;
245+
CPU::ID.hasFeature(CpuFeature::Mmx);
246+
CPU::ID.hasFeature(CpuFeature::_3dNow);
247+
CPU::ID.hasFeature(CpuFeature::Sse);
248+
CPU::ID.hasFeature(CpuFeature::Sse2);
249+
CPU::ID.hasFeature(CpuFeature::Sse3);
250+
CPU::ID.hasFeature(CpuFeature::Ssse3);
251+
CPU::ID.hasFeature(CpuFeature::Sse41);
252+
CPU::ID.hasFeature(CpuFeature::Sse42);
253253
};
254254

255255
string256 features;
256256
xr_strcpy(features, sizeof(features), "RDTSC");
257-
if (CPU::ID.feature & _CPU_FEATURE_MMX)
258-
xr_strcat(features, ", MMX");
259-
if (CPU::ID.feature & _CPU_FEATURE_3DNOW)
260-
xr_strcat(features, ", 3DNow!");
261-
if (CPU::ID.feature & _CPU_FEATURE_SSE)
262-
xr_strcat(features, ", SSE");
263-
if (CPU::ID.feature & _CPU_FEATURE_SSE2)
264-
xr_strcat(features, ", SSE2");
265-
if (CPU::ID.feature & _CPU_FEATURE_SSE3)
266-
xr_strcat(features, ", SSE3");
267-
if (CPU::ID.feature & _CPU_FEATURE_SSSE3)
268-
xr_strcat(features, ", SSSE3");
269-
if (CPU::ID.feature & _CPU_FEATURE_SSE4_1)
270-
xr_strcat(features, ", SSE4.1");
271-
if (CPU::ID.feature & _CPU_FEATURE_SSE4_2)
272-
xr_strcat(features, ", SSE4.2");
273-
if (CPU::ID.feature & _CPU_FEATURE_HTT)
274-
xr_strcat(features, ", HTT");
257+
if (CPU::ID.hasFeature(CpuFeature::Mmx)) xr_strcat(features, ", MMX");
258+
if (CPU::ID.hasFeature(CpuFeature::_3dNow)) xr_strcat(features, ", 3DNow!");
259+
if (CPU::ID.hasFeature(CpuFeature::Sse)) xr_strcat(features, ", SSE");
260+
if (CPU::ID.hasFeature(CpuFeature::Sse2)) xr_strcat(features, ", SSE2");
261+
if (CPU::ID.hasFeature(CpuFeature::Sse3)) xr_strcat(features, ", SSE3");
262+
if (CPU::ID.hasFeature(CpuFeature::MWait)) xr_strcat(features, ", MONITOR/MWAIT");
263+
if (CPU::ID.hasFeature(CpuFeature::Ssse3)) xr_strcat(features, ", SSSE3");
264+
if (CPU::ID.hasFeature(CpuFeature::Sse41)) xr_strcat(features, ", SSE4.1");
265+
if (CPU::ID.hasFeature(CpuFeature::Sse42)) xr_strcat(features, ", SSE4.2");
266+
if (CPU::ID.hasFeature(CpuFeature::HT)) xr_strcat(features, ", HTT");
275267

276268
Msg("* CPU features: %s", features);
277269
Msg("* CPU cores/threads: %d/%d\n", CPU::ID.n_cores, CPU::ID.n_threads);
@@ -304,7 +296,7 @@ void _initialize_cpu_thread()
304296
xrDebug::OnThreadSpawn();
305297
if (!Core.PluginMode)
306298
FPU::m24r();
307-
if (CPU::ID.feature & _CPU_FEATURE_SSE)
299+
if (CPU::ID.hasFeature(CpuFeature::Sse))
308300
{
309301
//_mm_setcsr ( _mm_getcsr() | (_MM_FLUSH_ZERO_ON+_MM_DENORMALS_ZERO_ON) );
310302
_MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);

src/xrCore/_math.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ XRCORE_API extern u64 qpc_freq;
2626
XRCORE_API extern u64 qpc_overhead;
2727
XRCORE_API extern u32 qpc_counter;
2828

29-
XRCORE_API extern _processor_info ID;
29+
XRCORE_API extern processor_info ID;
3030
XRCORE_API extern u64 QPC();
3131

3232
#ifdef M_VISUAL

0 commit comments

Comments
 (0)