From ed1402cbd33808c4186945f5efac3ac4ca905b55 Mon Sep 17 00:00:00 2001 From: XXTH Date: Fri, 12 May 2023 13:47:55 +0200 Subject: [PATCH] better cpu count guess --- Engine/source/platformSDL/sdlCPUInfo.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/Engine/source/platformSDL/sdlCPUInfo.cpp b/Engine/source/platformSDL/sdlCPUInfo.cpp index a02b5149c..b7c480a05 100644 --- a/Engine/source/platformSDL/sdlCPUInfo.cpp +++ b/Engine/source/platformSDL/sdlCPUInfo.cpp @@ -29,22 +29,28 @@ #include "platform/platformCPUCount.h" #include "console/console.h" +#include Platform::SystemInfo_struct Platform::SystemInfo; - - - void Processor::init() { S32 lCpuCount = SDL_GetCPUCount(); Platform::SystemInfo.processor.numLogicalProcessors = lCpuCount; //sdl dont have logical/physical CPU count so ... time to guess - Platform::SystemInfo.processor.numPhysicalProcessors = 1; // :/ lCpuCount; - Platform::SystemInfo.processor.isMultiCore = lCpuCount > 1; - //modern CPU should have isHyperThreaded - Platform::SystemInfo.processor.isHyperThreaded = true; + if (lCpuCount > 1) + { + Platform::SystemInfo.processor.numPhysicalProcessors = mFloor(lCpuCount / 2); // guessing ; + Platform::SystemInfo.processor.isMultiCore = true; + //modern CPU should have isHyperThreaded + Platform::SystemInfo.processor.isHyperThreaded = true; + } + else { + Platform::SystemInfo.processor.numPhysicalProcessors = lCpuCount; // guessing ; + Platform::SystemInfo.processor.isMultiCore = false; + Platform::SystemInfo.processor.isHyperThreaded = false; + } //hackfest Platform::SystemInfo.processor.mhz = 2666; @@ -139,5 +145,4 @@ namespace CPUInfo } }; // namespace CPUInfo - -#endif +#endif // defined( __FreeBSD__ )