mirror of
https://github.com/lubosz/overte.git
synced 2025-08-08 03:08:00 +02:00
Match the gpu adapter names gainst the vendor and renderer names used by
the ogl we're using, so that we pick the right GPU to get info from.
This commit is contained in:
parent
b403dcb0d9
commit
904e87313e
4 changed files with 63 additions and 48 deletions
|
@ -14,6 +14,7 @@
|
||||||
#include <queue>
|
#include <queue>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <glm/gtc/type_ptr.hpp>
|
#include <glm/gtc/type_ptr.hpp>
|
||||||
|
#include <GPUIdent.h>
|
||||||
|
|
||||||
#if defined(NSIGHT_FOUND)
|
#if defined(NSIGHT_FOUND)
|
||||||
#include "nvToolsExt.h"
|
#include "nvToolsExt.h"
|
||||||
|
@ -86,10 +87,18 @@ GLBackend::CommandCall GLBackend::_commandCalls[Batch::NUM_COMMANDS] =
|
||||||
void GLBackend::init() {
|
void GLBackend::init() {
|
||||||
static std::once_flag once;
|
static std::once_flag once;
|
||||||
std::call_once(once, [] {
|
std::call_once(once, [] {
|
||||||
|
QString vendor{ (const char*)glGetString(GL_VENDOR) };
|
||||||
|
QString renderer{ (const char*)glGetString(GL_RENDERER) };
|
||||||
qCDebug(gpulogging) << "GL Version: " << QString((const char*) glGetString(GL_VERSION));
|
qCDebug(gpulogging) << "GL Version: " << QString((const char*) glGetString(GL_VERSION));
|
||||||
qCDebug(gpulogging) << "GL Shader Language Version: " << QString((const char*) glGetString(GL_SHADING_LANGUAGE_VERSION));
|
qCDebug(gpulogging) << "GL Shader Language Version: " << QString((const char*) glGetString(GL_SHADING_LANGUAGE_VERSION));
|
||||||
qCDebug(gpulogging) << "GL Vendor: " << QString((const char*) glGetString(GL_VENDOR));
|
qCDebug(gpulogging) << "GL Vendor: " << vendor;
|
||||||
qCDebug(gpulogging) << "GL Renderer: " << QString((const char*) glGetString(GL_RENDERER));
|
qCDebug(gpulogging) << "GL Renderer: " << renderer;
|
||||||
|
GPUIdent* gpu = GPUIdent::getInstance(vendor, renderer);
|
||||||
|
// From here on, GPUIdent::getInstance()->getMumble() should efficiently give the same answers.
|
||||||
|
qCDebug(gpulogging) << "GPU:";
|
||||||
|
qCDebug(gpulogging) << "\tcard:" << gpu->getName();
|
||||||
|
qCDebug(gpulogging) << "\tdriver:" << gpu->getDriver();
|
||||||
|
qCDebug(gpulogging) << "\tdedicated memory:" << gpu->getMemory() << "MB";
|
||||||
|
|
||||||
glewExperimental = true;
|
glewExperimental = true;
|
||||||
GLenum err = glewInit();
|
GLenum err = glewInit();
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
GPUIdent GPUIdent::_instance {};
|
GPUIdent GPUIdent::_instance {};
|
||||||
|
|
||||||
GPUIdent* GPUIdent::ensureQuery() {
|
GPUIdent* GPUIdent::ensureQuery(const QString& vendor, const QString& renderer) {
|
||||||
if (_isQueried) {
|
if (_isQueried) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ GPUIdent* GPUIdent::ensureQuery() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Switch the security level to IMPERSONATE so that provider will grant access to system-level objects.
|
// Switch the security level to IMPERSONATE so that provider will grant access to system-level objects.
|
||||||
hr = CoSetProxyBlanket(spServices, RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE, NULL, RPC_C_AUTHN_LEVEL_CALL, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, /*EOAC_NONE*/EOAC_DEFAULT);
|
hr = CoSetProxyBlanket(spServices, RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE, NULL, RPC_C_AUTHN_LEVEL_CALL, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_DEFAULT);
|
||||||
if (hr != S_OK) {
|
if (hr != S_OK) {
|
||||||
qCDebug(shared) << "Unable to authorize access to system objects.";
|
qCDebug(shared) << "Unable to authorize access to system objects.";
|
||||||
return this;
|
return this;
|
||||||
|
@ -57,52 +57,66 @@ GPUIdent* GPUIdent::ensureQuery() {
|
||||||
qCDebug(shared) << "Unable to reach video controller.";
|
qCDebug(shared) << "Unable to reach video controller.";
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
// alternative. We shouldn't need both this and the above.
|
|
||||||
IEnumWbemClassObject* pEnum;
|
// I'd love to find a better way to learn which graphics adapter is the one we're using.
|
||||||
hr = spServices->ExecQuery(CComBSTR("WQL"), CComBSTR("select * from Win32_VideoController"), WBEM_FLAG_FORWARD_ONLY, NULL, &pEnum);
|
// Alas, no combination of vendor, renderer, and adapter name seems to be a substring of the others.
|
||||||
if (hr != S_OK) {
|
// Here we get a list of words that we'll match adapter names against. Most matches wins.
|
||||||
qCDebug(shared) << "Unable to query video controller";
|
QRegExp wordMatcher{ "\\W" };
|
||||||
return this;
|
QStringList words;
|
||||||
}
|
words << vendor.toUpper().split(wordMatcher) << renderer.toUpper().split(wordMatcher);
|
||||||
|
words.removeAll("");
|
||||||
|
words.removeDuplicates();
|
||||||
|
int bestCount = 0;
|
||||||
|
|
||||||
ULONG uNumOfInstances = 0;
|
ULONG uNumOfInstances = 0;
|
||||||
CComPtr<IWbemClassObject> spInstance = NULL;
|
CComPtr<IWbemClassObject> spInstance = NULL;
|
||||||
hr = spEnumInst->Next(WBEM_INFINITE, 1, &spInstance, &uNumOfInstances);
|
hr = spEnumInst->Next(WBEM_INFINITE, 1, &spInstance, &uNumOfInstances);
|
||||||
|
while (hr == S_OK && spInstance && uNumOfInstances) {
|
||||||
if (hr == S_OK && spInstance) {
|
|
||||||
// Get properties from the object
|
// Get properties from the object
|
||||||
CComVariant var;
|
CComVariant var;
|
||||||
CIMTYPE type;
|
|
||||||
|
|
||||||
hr = spInstance->Get(CComBSTR(_T("AdapterRAM")), 0, &var, 0, 0);
|
|
||||||
if (hr == S_OK) {
|
|
||||||
var.ChangeType(CIM_UINT32); // We're going to receive some integral type, but it might not be uint.
|
|
||||||
_dedicatedMemoryMB = var.uintVal / (1024 * 1024);
|
|
||||||
} else {
|
|
||||||
qCDebug(shared) << "Unable to get video AdapterRAM";
|
|
||||||
}
|
|
||||||
|
|
||||||
hr = spInstance->Get(CComBSTR(_T("Name")), 0, &var, 0, 0);
|
hr = spInstance->Get(CComBSTR(_T("Name")), 0, &var, 0, 0);
|
||||||
if (hr == S_OK) {
|
if (hr != S_OK) {
|
||||||
char sString[256];
|
|
||||||
WideCharToMultiByte(CP_ACP, 0, var.bstrVal, -1, sString, sizeof(sString), NULL, NULL);
|
|
||||||
_name = sString;
|
|
||||||
} else {
|
|
||||||
qCDebug(shared) << "Unable to get video name";
|
qCDebug(shared) << "Unable to get video name";
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
char sString[256];
|
||||||
hr = spInstance->Get(CComBSTR(_T("DriverVersion")), 0, &var, 0, 0);
|
WideCharToMultiByte(CP_ACP, 0, var.bstrVal, -1, sString, sizeof(sString), NULL, NULL);
|
||||||
if (hr == S_OK) {
|
QStringList adapterWords = QString(sString).toUpper().split(wordMatcher);
|
||||||
char sString[256];
|
adapterWords.removeAll("");
|
||||||
WideCharToMultiByte(CP_ACP, 0, var.bstrVal, -1, sString, sizeof(sString), NULL, NULL);
|
adapterWords.removeDuplicates();
|
||||||
_driver = sString;
|
int count = 0;
|
||||||
} else {
|
for (const QString& adapterWord : adapterWords) {
|
||||||
qCDebug(shared) << "Unable to get video driver";
|
if (words.contains(adapterWord)) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if (count > bestCount) {
|
||||||
|
bestCount = count;
|
||||||
|
_name = sString;
|
||||||
|
|
||||||
_isValid = true;
|
hr = spInstance->Get(CComBSTR(_T("DriverVersion")), 0, &var, 0, 0);
|
||||||
} else {
|
if (hr == S_OK) {
|
||||||
qCDebug(shared) << "Unable to enerate video adapters";
|
char sString[256];
|
||||||
|
WideCharToMultiByte(CP_ACP, 0, var.bstrVal, -1, sString, sizeof(sString), NULL, NULL);
|
||||||
|
_driver = sString;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
qCDebug(shared) << "Unable to get video driver";
|
||||||
|
}
|
||||||
|
|
||||||
|
hr = spInstance->Get(CComBSTR(_T("AdapterRAM")), 0, &var, 0, 0);
|
||||||
|
if (hr == S_OK) {
|
||||||
|
var.ChangeType(CIM_UINT32); // We're going to receive some integral type, but it might not be uint.
|
||||||
|
_dedicatedMemoryMB = var.uintVal / (1024 * 1024);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
qCDebug(shared) << "Unable to get video AdapterRAM";
|
||||||
|
}
|
||||||
|
|
||||||
|
_isValid = true;
|
||||||
|
}
|
||||||
|
hr = spEnumInst->Next(WBEM_INFINITE, 1, &spInstance, &uNumOfInstances);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return this;
|
return this;
|
||||||
|
|
|
@ -22,7 +22,7 @@ public:
|
||||||
QString getDriver() { return _driver; }
|
QString getDriver() { return _driver; }
|
||||||
bool isValid() { return _isValid; }
|
bool isValid() { return _isValid; }
|
||||||
// E.g., GPUIdent::getInstance()->getMemory();
|
// E.g., GPUIdent::getInstance()->getMemory();
|
||||||
static GPUIdent* getInstance() { return _instance.ensureQuery(); }
|
static GPUIdent* getInstance(const QString& vendor = "", const QString& renderer = "") { return _instance.ensureQuery(vendor, renderer); }
|
||||||
private:
|
private:
|
||||||
uint _dedicatedMemoryMB { 0 };
|
uint _dedicatedMemoryMB { 0 };
|
||||||
QString _name { "" };
|
QString _name { "" };
|
||||||
|
@ -30,7 +30,7 @@ private:
|
||||||
bool _isQueried { false };
|
bool _isQueried { false };
|
||||||
bool _isValid { false };
|
bool _isValid { false };
|
||||||
static GPUIdent _instance;
|
static GPUIdent _instance;
|
||||||
GPUIdent* ensureQuery();
|
GPUIdent* ensureQuery(const QString& vendor, const QString& renderer);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_GPUIdent_h
|
#endif // hifi_GPUIdent_h
|
||||||
|
|
|
@ -751,14 +751,6 @@ void printSystemInformation() {
|
||||||
qDebug().nospace().noquote() << "\t[" << (feature.supported ? "x" : " ") << "] " << feature.name.c_str();
|
qDebug().nospace().noquote() << "\t[" << (feature.supported ? "x" : " ") << "] " << feature.name.c_str();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
GPUIdent* gpu = GPUIdent::getInstance();
|
|
||||||
/*if (gpu->isValid()) {
|
|
||||||
qDebug() << "GPU:";
|
|
||||||
qDebug() << "\tcard:" << gpu->getName();
|
|
||||||
qDebug() << "\tdriver:" << gpu->getDriver();
|
|
||||||
qDebug() << "\tdedicated memory:" << gpu->getMemory() << "MB";
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
qDebug() << "Environment Variables";
|
qDebug() << "Environment Variables";
|
||||||
// List of env variables to include in the log. For privacy reasons we don't send all env variables.
|
// List of env variables to include in the log. For privacy reasons we don't send all env variables.
|
||||||
|
|
Loading…
Reference in a new issue