mirror of
https://github.com/lubosz/overte.git
synced 2025-08-08 03:08:00 +02:00
Fix stupid MSVC default indentation.
This commit is contained in:
parent
c12772e4c6
commit
cb137635db
3 changed files with 96 additions and 96 deletions
|
@ -20,90 +20,90 @@
|
||||||
GPUIdent GPUIdent::_instance {};
|
GPUIdent GPUIdent::_instance {};
|
||||||
|
|
||||||
GPUIdent* GPUIdent::ensureQuery() {
|
GPUIdent* GPUIdent::ensureQuery() {
|
||||||
if (_isQueried) {
|
if (_isQueried) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
_isQueried = true; // Don't try again, even if not _isValid;
|
_isQueried = true; // Don't try again, even if not _isValid;
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
// COM must be initialized already using CoInitialize. E.g., by the audio subsystem.
|
// COM must be initialized already using CoInitialize. E.g., by the audio subsystem.
|
||||||
CComPtr<IWbemLocator> spLoc = NULL;
|
CComPtr<IWbemLocator> spLoc = NULL;
|
||||||
HRESULT hr = CoCreateInstance(CLSID_WbemLocator, 0, CLSCTX_SERVER, IID_IWbemLocator, (LPVOID *)&spLoc);
|
HRESULT hr = CoCreateInstance(CLSID_WbemLocator, 0, CLSCTX_SERVER, IID_IWbemLocator, (LPVOID *)&spLoc);
|
||||||
if (hr != S_OK || spLoc == NULL) {
|
if (hr != S_OK || spLoc == NULL) {
|
||||||
qCDebug(shared) << "Unable to connect to WMI";
|
qCDebug(shared) << "Unable to connect to WMI";
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
CComBSTR bstrNamespace(_T("\\\\.\\root\\CIMV2"));
|
CComBSTR bstrNamespace(_T("\\\\.\\root\\CIMV2"));
|
||||||
CComPtr<IWbemServices> spServices;
|
CComPtr<IWbemServices> spServices;
|
||||||
|
|
||||||
// Connect to CIM
|
// Connect to CIM
|
||||||
hr = spLoc->ConnectServer(bstrNamespace, NULL, NULL, 0, NULL, 0, 0, &spServices);
|
hr = spLoc->ConnectServer(bstrNamespace, NULL, NULL, 0, NULL, 0, 0, &spServices);
|
||||||
if (hr != WBEM_S_NO_ERROR) {
|
if (hr != WBEM_S_NO_ERROR) {
|
||||||
qCDebug(shared) << "Unable to connect to CIM";
|
qCDebug(shared) << "Unable to connect to CIM";
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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_NONE*/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;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the vid controller
|
// Get the vid controller
|
||||||
CComPtr<IEnumWbemClassObject> spEnumInst = NULL;
|
CComPtr<IEnumWbemClassObject> spEnumInst = NULL;
|
||||||
hr = spServices->CreateInstanceEnum(CComBSTR("Win32_VideoController"), WBEM_FLAG_SHALLOW, NULL, &spEnumInst);
|
hr = spServices->CreateInstanceEnum(CComBSTR("Win32_VideoController"), WBEM_FLAG_SHALLOW, NULL, &spEnumInst);
|
||||||
if (hr != WBEM_S_NO_ERROR || spEnumInst == NULL) {
|
if (hr != WBEM_S_NO_ERROR || spEnumInst == NULL) {
|
||||||
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.
|
// alternative. We shouldn't need both this and the above.
|
||||||
IEnumWbemClassObject* pEnum;
|
IEnumWbemClassObject* pEnum;
|
||||||
hr = spServices->ExecQuery(CComBSTR("WQL"), CComBSTR("select * from Win32_VideoController"), WBEM_FLAG_FORWARD_ONLY, NULL, &pEnum);
|
hr = spServices->ExecQuery(CComBSTR("WQL"), CComBSTR("select * from Win32_VideoController"), WBEM_FLAG_FORWARD_ONLY, NULL, &pEnum);
|
||||||
if (hr != S_OK) {
|
if (hr != S_OK) {
|
||||||
qCDebug(shared) << "Unable to query video controller";
|
qCDebug(shared) << "Unable to query video controller";
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
if (hr == S_OK && spInstance) {
|
if (hr == S_OK && spInstance) {
|
||||||
// Get properties from the object
|
// Get properties from the object
|
||||||
CComVariant var;
|
CComVariant var;
|
||||||
CIMTYPE type;
|
CIMTYPE type;
|
||||||
|
|
||||||
hr = spInstance->Get(CComBSTR(_T("AdapterRAM")), 0, &var, 0, 0);
|
hr = spInstance->Get(CComBSTR(_T("AdapterRAM")), 0, &var, 0, 0);
|
||||||
if (hr == S_OK) {
|
if (hr == S_OK) {
|
||||||
var.ChangeType(CIM_UINT32); // We're going to receive some integral type, but it might not be uint.
|
var.ChangeType(CIM_UINT32); // We're going to receive some integral type, but it might not be uint.
|
||||||
_dedicatedMemoryMB = var.uintVal / (1024 * 1024);
|
_dedicatedMemoryMB = var.uintVal / (1024 * 1024);
|
||||||
} else {
|
} else {
|
||||||
qCDebug(shared) << "Unable to get video AdapterRAM";
|
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];
|
char sString[256];
|
||||||
WideCharToMultiByte(CP_ACP, 0, var.bstrVal, -1, sString, sizeof(sString), NULL, NULL);
|
WideCharToMultiByte(CP_ACP, 0, var.bstrVal, -1, sString, sizeof(sString), NULL, NULL);
|
||||||
_name = sString;
|
_name = sString;
|
||||||
} else {
|
} else {
|
||||||
qCDebug(shared) << "Unable to get video name";
|
qCDebug(shared) << "Unable to get video name";
|
||||||
}
|
}
|
||||||
|
|
||||||
hr = spInstance->Get(CComBSTR(_T("DriverVersion")), 0, &var, 0, 0);
|
hr = spInstance->Get(CComBSTR(_T("DriverVersion")), 0, &var, 0, 0);
|
||||||
if (hr == S_OK) {
|
if (hr == S_OK) {
|
||||||
char sString[256];
|
char sString[256];
|
||||||
WideCharToMultiByte(CP_ACP, 0, var.bstrVal, -1, sString, sizeof(sString), NULL, NULL);
|
WideCharToMultiByte(CP_ACP, 0, var.bstrVal, -1, sString, sizeof(sString), NULL, NULL);
|
||||||
_driver = sString;
|
_driver = sString;
|
||||||
} else {
|
} else {
|
||||||
qCDebug(shared) << "Unable to get video driver";
|
qCDebug(shared) << "Unable to get video driver";
|
||||||
}
|
}
|
||||||
|
|
||||||
_isValid = true;
|
_isValid = true;
|
||||||
} else {
|
} else {
|
||||||
qCDebug(shared) << "Unable to enerate video adapters";
|
qCDebug(shared) << "Unable to enerate video adapters";
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,20 +17,20 @@
|
||||||
class GPUIdent
|
class GPUIdent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
unsigned int getMemory() { return _dedicatedMemoryMB; }
|
unsigned int getMemory() { return _dedicatedMemoryMB; }
|
||||||
QString getName() { return _name; }
|
QString getName() { return _name; }
|
||||||
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() { return _instance.ensureQuery(); }
|
||||||
private:
|
private:
|
||||||
uint _dedicatedMemoryMB { 0 };
|
uint _dedicatedMemoryMB { 0 };
|
||||||
QString _name { "" };
|
QString _name { "" };
|
||||||
QString _driver { "" };
|
QString _driver { "" };
|
||||||
bool _isQueried { false };
|
bool _isQueried { false };
|
||||||
bool _isValid { false };
|
bool _isValid { false };
|
||||||
static GPUIdent _instance;
|
static GPUIdent _instance;
|
||||||
GPUIdent* ensureQuery();
|
GPUIdent* ensureQuery();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_GPUIdent_h
|
#endif // hifi_GPUIdent_h
|
||||||
|
|
|
@ -751,13 +751,13 @@ 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();
|
GPUIdent* gpu = GPUIdent::getInstance();
|
||||||
if (gpu->isValid()) {
|
if (gpu->isValid()) {
|
||||||
qDebug() << "GPU:";
|
qDebug() << "GPU:";
|
||||||
qDebug() << "\tcard:" << gpu->getName();
|
qDebug() << "\tcard:" << gpu->getName();
|
||||||
qDebug() << "\tdriver:" << gpu->getDriver();
|
qDebug() << "\tdriver:" << gpu->getDriver();
|
||||||
qDebug() << "\tdedicated memory:" << gpu->getMemory() << "MB";
|
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