From c1c2efc71dbc392311a0acf3ecc1179bd5cc3b9c Mon Sep 17 00:00:00 2001 From: amerhifi Date: Thu, 16 May 2019 15:47:03 -0700 Subject: [PATCH] getting gpu name via profiler parsing --- libraries/shared/src/GPUIdent.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/libraries/shared/src/GPUIdent.cpp b/libraries/shared/src/GPUIdent.cpp index 658f68a689..773e40aaee 100644 --- a/libraries/shared/src/GPUIdent.cpp +++ b/libraries/shared/src/GPUIdent.cpp @@ -22,7 +22,10 @@ #elif defined(Q_OS_MAC) #include -#include +#include +#include +#include + #endif #include @@ -57,6 +60,26 @@ 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; CGLDestroyRendererInfo(rendererInfo);