mirror of
https://github.com/lubosz/overte.git
synced 2025-08-12 17:44:14 +02:00
Merge pull request #15575 from amerhifi/feature/platform
case BUGZ-57: Populate macos gpu _name
This commit is contained in:
commit
4e9852f9f9
14 changed files with 89 additions and 25 deletions
|
@ -8,9 +8,8 @@
|
||||||
|
|
||||||
#include "AndroidPlatform.h"
|
#include "AndroidPlatform.h"
|
||||||
#include "platformJsonKeys.h"
|
#include "platformJsonKeys.h"
|
||||||
|
|
||||||
#include <GPUIdent.h>
|
#include <GPUIdent.h>
|
||||||
#include <string>
|
|
||||||
using namespace platform;
|
using namespace platform;
|
||||||
|
|
||||||
void AndroidInstance::enumerateCpu() {
|
void AndroidInstance::enumerateCpu() {
|
||||||
|
@ -35,6 +34,11 @@ void AndroidInstance::enumerateGpu() {
|
||||||
|
|
||||||
void AndroidInstance::enumerateMemory() {
|
void AndroidInstance::enumerateMemory() {
|
||||||
json ram = {};
|
json ram = {};
|
||||||
|
ram["totalMemory"]="";
|
||||||
_memory.push_back(ram);
|
_memory.push_back(ram);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AndroidInstance::enumerateComputer(){
|
||||||
|
//no implememntation at this time
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ namespace platform {
|
||||||
void enumerateCpu() override;
|
void enumerateCpu() override;
|
||||||
void enumerateMemory() override;
|
void enumerateMemory() override;
|
||||||
void enumerateGpu() override;
|
void enumerateGpu() override;
|
||||||
|
void enumerateComputer () override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace platform
|
} // namespace platform
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
#include "LinuxPlatform.h"
|
#include "LinuxPlatform.h"
|
||||||
#include "platformJsonKeys.h"
|
#include "platformJsonKeys.h"
|
||||||
#include <GPUIdent.h>
|
#include <GPUIdent.h>
|
||||||
#include <string>
|
|
||||||
|
|
||||||
using namespace platform;
|
using namespace platform;
|
||||||
void LinuxInstance::enumerateCpu() {
|
void LinuxInstance::enumerateCpu() {
|
||||||
|
@ -36,7 +35,12 @@ void LinuxInstance::enumerateGpu() {
|
||||||
|
|
||||||
void LinuxInstance::enumerateMemory() {
|
void LinuxInstance::enumerateMemory() {
|
||||||
json ram = {};
|
json ram = {};
|
||||||
|
ram["totalMemory"]="";
|
||||||
|
|
||||||
_memory.push_back(ram);
|
_memory.push_back(ram);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LinuxInstance::enumerateComputer(){
|
||||||
|
//no implememntation at this time
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ namespace platform {
|
||||||
void enumerateCpu() override;
|
void enumerateCpu() override;
|
||||||
void enumerateMemory() override;
|
void enumerateMemory() override;
|
||||||
void enumerateGpu() override;
|
void enumerateGpu() override;
|
||||||
|
void enumerateComputer () override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace platform
|
} // namespace platform
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
#include "MACOSPlatform.h"
|
#include "MACOSPlatform.h"
|
||||||
#include "platformJsonKeys.h"
|
#include "platformJsonKeys.h"
|
||||||
|
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <GPUIdent.h>
|
#include <GPUIdent.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -15,6 +16,7 @@
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <cpuid.h>
|
#include <cpuid.h>
|
||||||
|
#include <sys/sysctl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using namespace platform;
|
using namespace platform;
|
||||||
|
@ -33,6 +35,7 @@ static void getCpuId( uint32_t* p, uint32_t ax )
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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};
|
||||||
|
@ -72,6 +75,7 @@ void MACOSInstance::enumerateGpu() {
|
||||||
|
|
||||||
_gpu.push_back(gpu);
|
_gpu.push_back(gpu);
|
||||||
_display = ident->getOutput();
|
_display = ident->getOutput();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MACOSInstance::enumerateMemory() {
|
void MACOSInstance::enumerateMemory() {
|
||||||
|
@ -84,3 +88,20 @@ void MACOSInstance::enumerateMemory() {
|
||||||
#endif
|
#endif
|
||||||
_memory.push_back(ram);
|
_memory.push_back(ram);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MACOSInstance::enumerateComputer(){
|
||||||
|
#ifdef Q_OS_MAC
|
||||||
|
|
||||||
|
//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);
|
||||||
|
|
||||||
|
_computer["computerModel"]=std::string(model);
|
||||||
|
|
||||||
|
free(model);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,9 @@ namespace platform {
|
||||||
void enumerateCpu() override;
|
void enumerateCpu() override;
|
||||||
void enumerateMemory() override;
|
void enumerateMemory() override;
|
||||||
void enumerateGpu() override;
|
void enumerateGpu() override;
|
||||||
|
void enumerateComputer () override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace platform
|
} // namespace platform
|
||||||
|
|
||||||
#endif //hifi_winplatform_h
|
#endif //hifi_macosplatform_h
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
#include "WINPlatform.h"
|
#include "WINPlatform.h"
|
||||||
#include "platformJsonKeys.h"
|
#include "platformJsonKeys.h"
|
||||||
|
|
||||||
#ifdef Q_OS_WINDOWS
|
#ifdef Q_OS_WINDOWS
|
||||||
#include <intrin.h>
|
#include <intrin.h>
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
@ -76,7 +77,12 @@ void WINInstance::enumerateMemory() {
|
||||||
statex.dwLength = sizeof(statex);
|
statex.dwLength = sizeof(statex);
|
||||||
GlobalMemoryStatusEx(&statex);
|
GlobalMemoryStatusEx(&statex);
|
||||||
int totalRam = statex.ullTotalPhys / 1024 / 1024;
|
int totalRam = statex.ullTotalPhys / 1024 / 1024;
|
||||||
ram[jsonKeys::totalMemory] = totalRam;
|
ram["totalMemory"] = totalRam;
|
||||||
#endif
|
#endif
|
||||||
_memory.push_back(ram);
|
_memory.push_back(ram);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WINInstance::enumerateComputer(){
|
||||||
|
//no implememntation at this time
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace platform {
|
||||||
void enumerateCpu() override;
|
void enumerateCpu() override;
|
||||||
void enumerateMemory() override;
|
void enumerateMemory() override;
|
||||||
void enumerateGpu() override;
|
void enumerateGpu() override;
|
||||||
|
void enumerateComputer () override;
|
||||||
};
|
};
|
||||||
} // namespace platform
|
} // namespace platform
|
||||||
|
|
||||||
|
|
|
@ -77,3 +77,7 @@ int platform::getNumMemory() {
|
||||||
json platform::getMemory(int index) {
|
json platform::getMemory(int index) {
|
||||||
return _instance->getMemory(index);
|
return _instance->getMemory(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
json platform::getComputer(){
|
||||||
|
return _instance->getComputer();
|
||||||
|
}
|
||||||
|
|
|
@ -9,8 +9,7 @@
|
||||||
#ifndef hifi_Platform_h
|
#ifndef hifi_Platform_h
|
||||||
#define hifi_Platform_h
|
#define hifi_Platform_h
|
||||||
|
|
||||||
#include "platformInstance.h"
|
|
||||||
#include <vector>
|
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
namespace platform {
|
namespace platform {
|
||||||
|
@ -32,6 +31,8 @@ json getDisplay(int index);
|
||||||
int getNumMemory();
|
int getNumMemory();
|
||||||
json getMemory(int index);
|
json getMemory(int index);
|
||||||
|
|
||||||
|
json getComputer();
|
||||||
|
|
||||||
} // namespace platform
|
} // namespace platform
|
||||||
|
|
||||||
#endif // hifi_platform_h
|
#endif // hifi_platform_h
|
||||||
|
|
|
@ -7,24 +7,13 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
#include "platform.h"
|
#include "platformInstance.h"
|
||||||
|
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
#include "WINPlatform.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef Q_OS_MACOS
|
|
||||||
#include "MACOSPlatform.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef Q_OS_LINUX
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using namespace platform;
|
using namespace platform;
|
||||||
|
|
||||||
bool Instance::enumeratePlatform() {
|
bool Instance::enumeratePlatform() {
|
||||||
|
enumerateComputer();
|
||||||
enumerateCpu();
|
enumerateCpu();
|
||||||
enumerateGpu();
|
enumerateGpu();
|
||||||
enumerateMemory();
|
enumerateMemory();
|
||||||
|
@ -75,7 +64,6 @@ Instance::~Instance() {
|
||||||
_memory.clear();
|
_memory.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (_gpu.size() > 0) {
|
if (_gpu.size() > 0) {
|
||||||
_gpu.clear();
|
_gpu.clear();
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,9 +31,13 @@ public:
|
||||||
int getNumDisplay() { return (int)_display.size(); }
|
int getNumDisplay() { return (int)_display.size(); }
|
||||||
json getDisplay(int index);
|
json getDisplay(int index);
|
||||||
|
|
||||||
|
|
||||||
|
json getComputer() {return _computer;}
|
||||||
|
|
||||||
void virtual enumerateCpu()=0;
|
void virtual enumerateCpu()=0;
|
||||||
void virtual enumerateMemory()=0;
|
void virtual enumerateMemory()=0;
|
||||||
void virtual enumerateGpu()=0;
|
void virtual enumerateGpu()=0;
|
||||||
|
void virtual enumerateComputer()=0;
|
||||||
|
|
||||||
virtual ~Instance();
|
virtual ~Instance();
|
||||||
|
|
||||||
|
@ -42,6 +46,7 @@ protected:
|
||||||
std::vector<json> _memory;
|
std::vector<json> _memory;
|
||||||
std::vector<json> _gpu;
|
std::vector<json> _gpu;
|
||||||
std::vector<json> _display;
|
std::vector<json> _display;
|
||||||
|
json _computer;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace platform
|
} // namespace platform
|
||||||
|
|
|
@ -26,9 +26,12 @@ namespace platform {
|
||||||
static const char* displayCoordsRight { "coordinatesright"};
|
static const char* displayCoordsRight { "coordinatesright"};
|
||||||
static const char* displayCoordsTop { "coordinatestop"};
|
static const char* displayCoordsTop { "coordinatestop"};
|
||||||
static const char* displayCoordsBottom { "coordinatesbottom"};
|
static const char* displayCoordsBottom { "coordinatesbottom"};
|
||||||
|
static const char* computerModel { "computerModel"};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace platform
|
} // namespace plaform::jsonKeys
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -22,6 +22,10 @@
|
||||||
|
|
||||||
#elif defined(Q_OS_MAC)
|
#elif defined(Q_OS_MAC)
|
||||||
#include <OpenGL/OpenGL.h>
|
#include <OpenGL/OpenGL.h>
|
||||||
|
#include <sstream>
|
||||||
|
#include <QString>
|
||||||
|
#include <qstringlist.h>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <QtCore/QtGlobal>
|
#include <QtCore/QtGlobal>
|
||||||
|
@ -56,6 +60,27 @@ GPUIdent* GPUIdent::ensureQuery(const QString& vendor, const QString& renderer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//get gpu name
|
||||||
|
FILE* stream = popen("system_profiler SPDisplaysDataType | grep Chipset", "r");
|
||||||
|
|
||||||
|
std::ostringstream hostStream;
|
||||||
|
while (!feof(stream) && !ferror(stream)) {
|
||||||
|
char buf[128];
|
||||||
|
int bytesRead = fread(buf, 1, 128, stream);
|
||||||
|
hostStream.write(buf, bytesRead);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString result = QString::fromStdString(hostStream.str());
|
||||||
|
QStringList parts = result.split('\n');
|
||||||
|
std::string name;
|
||||||
|
|
||||||
|
for (int i = 0; i < parts.size(); ++i) {
|
||||||
|
if (parts[i].toLower().contains("radeon") || parts[i].toLower().contains("nvidia")) {
|
||||||
|
_name=parts[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_dedicatedMemoryMB = bestVRAM;
|
_dedicatedMemoryMB = bestVRAM;
|
||||||
CGLDestroyRendererInfo(rendererInfo);
|
CGLDestroyRendererInfo(rendererInfo);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue