adding computer model to platform for macos

This commit is contained in:
amerhifi 2019-05-16 14:30:11 -07:00
parent 6595f86985
commit 9e00920884
5 changed files with 23 additions and 0 deletions

View file

@ -16,6 +16,7 @@
#ifdef Q_OS_MAC
#include <unistd.h>
#include <cpuid.h>
#include <sys/sysctl.h>
#endif
using namespace platform;
@ -34,6 +35,7 @@ static void getCpuId( uint32_t* p, uint32_t ax )
#endif
}
void MACOSInstance::enumerateCpu() {
json cpu = {};
uint32_t cpuInfo[4]={0,0,0,0};
@ -62,6 +64,16 @@ void MACOSInstance::enumerateCpu() {
cpu[jsonKeys::cpuNumCores] = std::thread::hardware_concurrency();
_cpu.push_back(cpu);
//get system name
size_t len=0;
sysctlbyname("hw.model",NULL, &len, NULL, 0);
char* model = (char *) malloc(sizeof(char)*len+1);
sysctlbyname("hw.model", model, &len, NULL,0);
_computerModel=std::string(model);
free(model);
}
void MACOSInstance::enumerateGpu() {
@ -73,6 +85,7 @@ void MACOSInstance::enumerateGpu() {
_gpu.push_back(gpu);
_display = ident->getOutput();
}
void MACOSInstance::enumerateMemory() {

View file

@ -77,3 +77,7 @@ int platform::getNumMemory() {
json platform::getMemory(int index) {
return _instance->getMemory(index);
}
std::string platform::getComputerModel(){
return _instance->getComputerModel();
}

View file

@ -32,6 +32,7 @@ json getDisplay(int index);
int getNumMemory();
json getMemory(int index);
std::string getComputerModel();
} // namespace platform
#endif // hifi_platform_h

View file

@ -31,6 +31,8 @@ public:
int getNumDisplay() { return (int)_display.size(); }
json getDisplay(int index);
std::string getComputerModel(){return _computerModel;}
void virtual enumerateCpu()=0;
void virtual enumerateMemory()=0;
void virtual enumerateGpu()=0;
@ -42,6 +44,7 @@ protected:
std::vector<json> _memory;
std::vector<json> _gpu;
std::vector<json> _display;
std::string _computerModel;
};
} // namespace platform

View file

@ -22,6 +22,7 @@
#elif defined(Q_OS_MAC)
#include <OpenGL/OpenGL.h>
#include<sys/sysctl.h>
#endif
#include <QtCore/QtGlobal>
@ -56,6 +57,7 @@ GPUIdent* GPUIdent::ensureQuery(const QString& vendor, const QString& renderer)
}
}
}
_dedicatedMemoryMB = bestVRAM;
CGLDestroyRendererInfo(rendererInfo);