mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 18:41:10 +02:00
fixed a bunch of pr comments
This commit is contained in:
parent
9652d412ac
commit
804d171102
7 changed files with 54 additions and 63 deletions
|
@ -41,7 +41,7 @@ static void getCpuId( uint32_t* p, uint32_t ax )
|
||||||
}
|
}
|
||||||
|
|
||||||
void MACOSInstance::enumerateCpu() {
|
void MACOSInstance::enumerateCpu() {
|
||||||
json cpu = {};
|
json cpu = {};
|
||||||
uint32_t cpuInfo[4]={0,0,0,0};
|
uint32_t cpuInfo[4]={0,0,0,0};
|
||||||
char CPUBrandString[16];
|
char CPUBrandString[16];
|
||||||
char CPUModelString[16];
|
char CPUModelString[16];
|
||||||
|
@ -75,10 +75,8 @@ unsigned int MACOSInstance::getNumLogicalCores() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MACOSInstance::enumerateGpu() {
|
void MACOSInstance::enumerateGpu() {
|
||||||
|
GPUIdent* ident = GPUIdent::getInstance();
|
||||||
GPUIdent* ident = GPUIdent::getInstance();
|
json gpu = {};
|
||||||
|
|
||||||
json gpu = {};
|
|
||||||
gpu["name"] = ident->getName().toUtf8().constData();
|
gpu["name"] = ident->getName().toUtf8().constData();
|
||||||
gpu["memory"] = ident->getMemory();
|
gpu["memory"] = ident->getMemory();
|
||||||
gpu["driver"] = ident->getDriver().toUtf8().constData();
|
gpu["driver"] = ident->getDriver().toUtf8().constData();
|
||||||
|
@ -88,11 +86,11 @@ void MACOSInstance::enumerateGpu() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MACOSInstance::enumerateRam() {
|
void MACOSInstance::enumerateRam() {
|
||||||
json ram = {};
|
json ram = {};
|
||||||
|
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
long pages = sysconf(_SC_PHYS_PAGES);
|
long pages = sysconf(_SC_PHYS_PAGES);
|
||||||
long page_size = sysconf(_SC_PAGE_SIZE);
|
long page_size = sysconf(_SC_PAGE_SIZE);
|
||||||
|
|
||||||
ram["totalMem"] = pages * page_size;;
|
ram["totalMem"] = pages * page_size;;
|
||||||
#endif
|
#endif
|
||||||
_memory.push_back(ram);
|
_memory.push_back(ram);
|
||||||
|
|
|
@ -28,8 +28,7 @@ bool WINInstance::enumeratePlatform() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void WINInstance::enumerateCpu() {
|
void WINInstance::enumerateCpu() {
|
||||||
json cpu = {};
|
json cpu = {};
|
||||||
|
|
||||||
|
|
||||||
#ifdef Q_OS_WINDOWS
|
#ifdef Q_OS_WINDOWS
|
||||||
int CPUInfo[4] = { -1 };
|
int CPUInfo[4] = { -1 };
|
||||||
|
@ -59,6 +58,7 @@ void WINInstance::enumerateCpu() {
|
||||||
cpu["clockSpeed"] = CPUClockString;
|
cpu["clockSpeed"] = CPUClockString;
|
||||||
cpu["numCores"] = getNumLogicalCores();
|
cpu["numCores"] = getNumLogicalCores();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_cpu.push_back(cpu);
|
_cpu.push_back(cpu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,9 +68,9 @@ unsigned int WINInstance::getNumLogicalCores() {
|
||||||
|
|
||||||
void WINInstance::enumerateGpu() {
|
void WINInstance::enumerateGpu() {
|
||||||
|
|
||||||
GPUIdent* ident = GPUIdent::getInstance();
|
GPUIdent* ident = GPUIdent::getInstance();
|
||||||
|
|
||||||
json gpu = {};
|
json gpu = {};
|
||||||
gpu["name"] = ident->getName().toUtf8().constData();
|
gpu["name"] = ident->getName().toUtf8().constData();
|
||||||
gpu["memory"] = ident->getMemory();
|
gpu["memory"] = ident->getMemory();
|
||||||
gpu["driver"] = ident->getDriver().toUtf8().constData();
|
gpu["driver"] = ident->getDriver().toUtf8().constData();
|
||||||
|
@ -80,7 +80,7 @@ void WINInstance::enumerateGpu() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void WINInstance::enumerateRam() {
|
void WINInstance::enumerateRam() {
|
||||||
json ram = {};
|
json ram = {};
|
||||||
#ifdef Q_OS_WINDOWS
|
#ifdef Q_OS_WINDOWS
|
||||||
MEMORYSTATUSEX statex;
|
MEMORYSTATUSEX statex;
|
||||||
statex.dwLength = sizeof(statex);
|
statex.dwLength = sizeof(statex);
|
||||||
|
@ -88,5 +88,6 @@ void WINInstance::enumerateRam() {
|
||||||
int totalRam = statex.ullTotalPhys / 1024 / 1024;
|
int totalRam = statex.ullTotalPhys / 1024 / 1024;
|
||||||
ram["totalMem"] = totalRam;
|
ram["totalMem"] = totalRam;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_memory.push_back(ram);
|
_memory.push_back(ram);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,6 @@ namespace platform {
|
||||||
void enumerateRam();
|
void enumerateRam();
|
||||||
void enumerateGpu();
|
void enumerateGpu();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace platform
|
} // namespace platform
|
||||||
|
|
||||||
#endif //hifi_winplatform_h
|
#endif //hifi_winplatform_h
|
||||||
|
|
|
@ -42,10 +42,10 @@ void platform::destroy() {
|
||||||
delete _instance;
|
delete _instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
json Instance::getCPU(int index) {
|
json Instance::getCPU(int index) {
|
||||||
assert(index <(int) _cpu.size());
|
assert(index <(int) _cpu.size());
|
||||||
if (index >= (int)_cpu.size())
|
if (index >= (int)_cpu.size())
|
||||||
return NULL;
|
return json();
|
||||||
|
|
||||||
return _cpu.at(index);
|
return _cpu.at(index);
|
||||||
}
|
}
|
||||||
|
@ -55,74 +55,74 @@ void platform::destroy() {
|
||||||
json Instance::getMemory(int index) {
|
json Instance::getMemory(int index) {
|
||||||
assert(index <(int) _memory.size());
|
assert(index <(int) _memory.size());
|
||||||
if(index >= (int)_memory.size())
|
if(index >= (int)_memory.size())
|
||||||
return NULL;
|
return json();
|
||||||
|
|
||||||
return _memory.at(index);
|
return _memory.at(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
json Instance::getGPU(int index) {
|
json Instance::getGPU(int index) {
|
||||||
assert(index <(int) _gpu.size());
|
assert(index <(int) _gpu.size());
|
||||||
if (index >=(int) _gpu.size())
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
|
if (index >=(int) _gpu.size())
|
||||||
|
return json();
|
||||||
|
|
||||||
return _gpu.at(index);
|
return _gpu.at(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
json Instance::getDisplay(int index) {
|
json Instance::getDisplay(int index) {
|
||||||
assert(index <(int) _display.size());
|
assert(index <(int) _display.size());
|
||||||
|
|
||||||
if (index >=(int) _display.size())
|
if (index >=(int) _display.size())
|
||||||
return NULL;
|
return json();
|
||||||
|
|
||||||
return _display.at(index);
|
return _display.at(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
Instance::~Instance() {
|
Instance::~Instance() {
|
||||||
if (_cpu.size() > 0) {
|
if (_cpu.size() > 0) {
|
||||||
|
_cpu.clear();
|
||||||
|
}
|
||||||
|
|
||||||
_cpu.clear();
|
if (_memory.size() > 0) {
|
||||||
}
|
_memory.clear();
|
||||||
|
}
|
||||||
if (_memory.size() > 0) {
|
|
||||||
_memory.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (_gpu.size() > 0) {
|
if (_gpu.size() > 0) {
|
||||||
_gpu.clear();
|
_gpu.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_display.size() > 0) {
|
if (_display.size() > 0) {
|
||||||
_display.clear();
|
_display.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool platform::enumeratePlatform() {
|
bool platform::enumeratePlatform() {
|
||||||
return _instance->enumeratePlatform();
|
return _instance->enumeratePlatform();
|
||||||
}
|
}
|
||||||
|
|
||||||
int platform::getNumProcessor() {
|
int platform::getNumCPU() {
|
||||||
return _instance->getNumCPU();
|
return _instance->getNumCPU();
|
||||||
}
|
}
|
||||||
|
|
||||||
json platform::getProcessor(int index) {
|
json platform::getCPU(int index) {
|
||||||
return _instance->getCPU(index);
|
return _instance->getCPU(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
int platform::getNumGraphics() {
|
int platform::getNumGPU() {
|
||||||
return _instance->getNumGPU();
|
return _instance->getNumGPU();
|
||||||
}
|
}
|
||||||
|
|
||||||
json platform::getGraphics(int index) {
|
json platform::getGPU(int index) {
|
||||||
return _instance->getGPU(index);
|
return _instance->getGPU(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
int platform::getNumDisplay() {
|
int platform::getNumDisplay() {
|
||||||
return _instance->getNumDisplay();
|
return _instance->getNumDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
json platform::getDisplay(int index) {
|
json platform::getDisplay(int index) {
|
||||||
return _instance->getDisplay(index);
|
return _instance->getDisplay(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
int platform::getNumMemory() {
|
int platform::getNumMemory() {
|
||||||
|
@ -132,6 +132,3 @@ int platform::getNumMemory() {
|
||||||
json platform::getMemory(int index) {
|
json platform::getMemory(int index) {
|
||||||
return _instance->getMemory(index);
|
return _instance->getMemory(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ protected:
|
||||||
std::vector<json> _cpu;
|
std::vector<json> _cpu;
|
||||||
std::vector<json> _memory;
|
std::vector<json> _memory;
|
||||||
std::vector<json> _gpu;
|
std::vector<json> _gpu;
|
||||||
std::vector<json> _display;
|
std::vector<json> _display;
|
||||||
};
|
};
|
||||||
|
|
||||||
//Platform level functions
|
//Platform level functions
|
||||||
|
@ -46,16 +46,15 @@ void destroy();
|
||||||
|
|
||||||
bool enumeratePlatform();
|
bool enumeratePlatform();
|
||||||
|
|
||||||
int getNumProcessor();
|
int getNumCPU();
|
||||||
json getProcessor(int index);
|
json getCPU(int index);
|
||||||
|
|
||||||
int getNumGraphics();
|
int getNumGPU();
|
||||||
json getGraphics(int index);
|
json getGPU(int index);
|
||||||
|
|
||||||
int getNumDisplay();
|
int getNumDisplay();
|
||||||
json getDisplay(int index);
|
json getDisplay(int index);
|
||||||
|
|
||||||
|
|
||||||
int getNumMemory();
|
int getNumMemory();
|
||||||
json getMemory(int index);
|
json getMemory(int index);
|
||||||
|
|
||||||
|
|
|
@ -251,15 +251,12 @@ GPUIdent* GPUIdent::ensureQuery(const QString& vendor, const QString& renderer)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!validAdapterList.empty()) {
|
if (!validAdapterList.empty()) {
|
||||||
|
for (auto outy = adapterToOutputs.begin(); outy != adapterToOutputs.end(); outy++) {
|
||||||
|
|
||||||
for (auto outy = adapterToOutputs.begin(); outy != adapterToOutputs.end(); outy++) {
|
|
||||||
|
|
||||||
AdapterEntry entry = *outy;
|
AdapterEntry entry = *outy;
|
||||||
|
for (auto test = entry.second.begin(); test != entry.second.end(); ++test) {
|
||||||
entry.first.first.Description;
|
|
||||||
for (auto test = entry.second.begin(); test != entry.second.end(); test++) {
|
nlohmann::json output = {};
|
||||||
nlohmann::json output = {};
|
|
||||||
|
|
||||||
output["description"] = entry.first.first.Description;
|
output["description"] = entry.first.first.Description;
|
||||||
output["deviceName"]= test->DeviceName;
|
output["deviceName"]= test->DeviceName;
|
||||||
output["coordinatesleft"] = test->DesktopCoordinates.left;
|
output["coordinatesleft"] = test->DesktopCoordinates.left;
|
||||||
|
@ -267,8 +264,8 @@ GPUIdent* GPUIdent::ensureQuery(const QString& vendor, const QString& renderer)
|
||||||
output["coordinatestop"] = test->DesktopCoordinates.top;
|
output["coordinatestop"] = test->DesktopCoordinates.top;
|
||||||
output["coordinatesbottom"] = test->DesktopCoordinates.bottom;
|
output["coordinatesbottom"] = test->DesktopCoordinates.bottom;
|
||||||
_output.push_back(output);
|
_output.push_back(output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto& adapterEntry = adapterToOutputs[validAdapterList.front()];
|
auto& adapterEntry = adapterToOutputs[validAdapterList.front()];
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ public:
|
||||||
QString getName() { return _name; }
|
QString getName() { return _name; }
|
||||||
QString getDriver() { return _driver; }
|
QString getDriver() { return _driver; }
|
||||||
bool isValid() { return _isValid; }
|
bool isValid() { return _isValid; }
|
||||||
std::vector<nlohmann::json> getOutput() { return _output; }
|
const std::vector<nlohmann::json>& getOutput() { return _output; }
|
||||||
|
|
||||||
// E.g., GPUIdent::getInstance()->getMemory();
|
// E.g., GPUIdent::getInstance()->getMemory();
|
||||||
static GPUIdent* getInstance(const QString& vendor = "", const QString& renderer = "") { return _instance.ensureQuery(vendor, renderer); }
|
static GPUIdent* getInstance(const QString& vendor = "", const QString& renderer = "") { return _instance.ensureQuery(vendor, renderer); }
|
||||||
|
|
Loading…
Reference in a new issue