From 47a612b195dc038118dc3d3eb71c422edb4eeeca Mon Sep 17 00:00:00 2001 From: amerhifi Date: Tue, 21 May 2019 07:46:02 -0700 Subject: [PATCH] testing gpu ident changes --- libraries/platform/src/LinuxPlatform.cpp | 2 +- libraries/shared/src/GPUIdent.cpp | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/libraries/platform/src/LinuxPlatform.cpp b/libraries/platform/src/LinuxPlatform.cpp index 03952a8655..20034a4340 100644 --- a/libraries/platform/src/LinuxPlatform.cpp +++ b/libraries/platform/src/LinuxPlatform.cpp @@ -15,7 +15,7 @@ using namespace platform; static void getLCpuId( uint32_t* p, uint32_t ax ) { -#if Q_OS_LINUX +#ifdef Q_OS_LINUX __asm __volatile ( "movl %%ebx, %%esi\n\t" "cpuid\n\t" diff --git a/libraries/shared/src/GPUIdent.cpp b/libraries/shared/src/GPUIdent.cpp index 773e40aaee..16c95ff9ce 100644 --- a/libraries/shared/src/GPUIdent.cpp +++ b/libraries/shared/src/GPUIdent.cpp @@ -28,6 +28,7 @@ #endif +#include #include #include "SharedLogging.h" @@ -83,7 +84,26 @@ GPUIdent* GPUIdent::ensureQuery(const QString& vendor, const QString& renderer) _dedicatedMemoryMB = bestVRAM; CGLDestroyRendererInfo(rendererInfo); - +#elif defined(Q_OS_LINUX) +//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]; + } + } #elif defined(Q_OS_WIN) struct ConvertLargeIntegerToQString {