mirror of
https://github.com/lubosz/overte.git
synced 2025-04-19 12:24:01 +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::ensureQuery() {
|
||||
if (_isQueried) {
|
||||
return this;
|
||||
}
|
||||
_isQueried = true; // Don't try again, even if not _isValid;
|
||||
if (_isQueried) {
|
||||
return this;
|
||||
}
|
||||
_isQueried = true; // Don't try again, even if not _isValid;
|
||||
#ifdef Q_OS_WIN
|
||||
// COM must be initialized already using CoInitialize. E.g., by the audio subsystem.
|
||||
CComPtr<IWbemLocator> spLoc = NULL;
|
||||
HRESULT hr = CoCreateInstance(CLSID_WbemLocator, 0, CLSCTX_SERVER, IID_IWbemLocator, (LPVOID *)&spLoc);
|
||||
if (hr != S_OK || spLoc == NULL) {
|
||||
qCDebug(shared) << "Unable to connect to WMI";
|
||||
return this;
|
||||
}
|
||||
// COM must be initialized already using CoInitialize. E.g., by the audio subsystem.
|
||||
CComPtr<IWbemLocator> spLoc = NULL;
|
||||
HRESULT hr = CoCreateInstance(CLSID_WbemLocator, 0, CLSCTX_SERVER, IID_IWbemLocator, (LPVOID *)&spLoc);
|
||||
if (hr != S_OK || spLoc == NULL) {
|
||||
qCDebug(shared) << "Unable to connect to WMI";
|
||||
return this;
|
||||
}
|
||||
|
||||
CComBSTR bstrNamespace(_T("\\\\.\\root\\CIMV2"));
|
||||
CComPtr<IWbemServices> spServices;
|
||||
CComBSTR bstrNamespace(_T("\\\\.\\root\\CIMV2"));
|
||||
CComPtr<IWbemServices> spServices;
|
||||
|
||||
// Connect to CIM
|
||||
hr = spLoc->ConnectServer(bstrNamespace, NULL, NULL, 0, NULL, 0, 0, &spServices);
|
||||
if (hr != WBEM_S_NO_ERROR) {
|
||||
qCDebug(shared) << "Unable to connect to CIM";
|
||||
return this;
|
||||
}
|
||||
// Connect to CIM
|
||||
hr = spLoc->ConnectServer(bstrNamespace, NULL, NULL, 0, NULL, 0, 0, &spServices);
|
||||
if (hr != WBEM_S_NO_ERROR) {
|
||||
qCDebug(shared) << "Unable to connect to CIM";
|
||||
return this;
|
||||
}
|
||||
|
||||
// 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);
|
||||
if (hr != S_OK) {
|
||||
qCDebug(shared) << "Unable to authorize access to system objects.";
|
||||
return this;
|
||||
}
|
||||
// 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);
|
||||
if (hr != S_OK) {
|
||||
qCDebug(shared) << "Unable to authorize access to system objects.";
|
||||
return this;
|
||||
}
|
||||
|
||||
// Get the vid controller
|
||||
CComPtr<IEnumWbemClassObject> spEnumInst = NULL;
|
||||
hr = spServices->CreateInstanceEnum(CComBSTR("Win32_VideoController"), WBEM_FLAG_SHALLOW, NULL, &spEnumInst);
|
||||
if (hr != WBEM_S_NO_ERROR || spEnumInst == NULL) {
|
||||
qCDebug(shared) << "Unable to reach video controller.";
|
||||
return this;
|
||||
}
|
||||
// alternative. We shouldn't need both this and the above.
|
||||
IEnumWbemClassObject* pEnum;
|
||||
hr = spServices->ExecQuery(CComBSTR("WQL"), CComBSTR("select * from Win32_VideoController"), WBEM_FLAG_FORWARD_ONLY, NULL, &pEnum);
|
||||
if (hr != S_OK) {
|
||||
qCDebug(shared) << "Unable to query video controller";
|
||||
return this;
|
||||
}
|
||||
// Get the vid controller
|
||||
CComPtr<IEnumWbemClassObject> spEnumInst = NULL;
|
||||
hr = spServices->CreateInstanceEnum(CComBSTR("Win32_VideoController"), WBEM_FLAG_SHALLOW, NULL, &spEnumInst);
|
||||
if (hr != WBEM_S_NO_ERROR || spEnumInst == NULL) {
|
||||
qCDebug(shared) << "Unable to reach video controller.";
|
||||
return this;
|
||||
}
|
||||
// alternative. We shouldn't need both this and the above.
|
||||
IEnumWbemClassObject* pEnum;
|
||||
hr = spServices->ExecQuery(CComBSTR("WQL"), CComBSTR("select * from Win32_VideoController"), WBEM_FLAG_FORWARD_ONLY, NULL, &pEnum);
|
||||
if (hr != S_OK) {
|
||||
qCDebug(shared) << "Unable to query video controller";
|
||||
return this;
|
||||
}
|
||||
|
||||
ULONG uNumOfInstances = 0;
|
||||
CComPtr<IWbemClassObject> spInstance = NULL;
|
||||
hr = spEnumInst->Next(WBEM_INFINITE, 1, &spInstance, &uNumOfInstances);
|
||||
ULONG uNumOfInstances = 0;
|
||||
CComPtr<IWbemClassObject> spInstance = NULL;
|
||||
hr = spEnumInst->Next(WBEM_INFINITE, 1, &spInstance, &uNumOfInstances);
|
||||
|
||||
if (hr == S_OK && spInstance) {
|
||||
// Get properties from the object
|
||||
CComVariant var;
|
||||
CIMTYPE type;
|
||||
if (hr == S_OK && spInstance) {
|
||||
// Get properties from the object
|
||||
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("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);
|
||||
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";
|
||||
}
|
||||
hr = spInstance->Get(CComBSTR(_T("Name")), 0, &var, 0, 0);
|
||||
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";
|
||||
}
|
||||
|
||||
hr = spInstance->Get(CComBSTR(_T("DriverVersion")), 0, &var, 0, 0);
|
||||
if (hr == S_OK) {
|
||||
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("DriverVersion")), 0, &var, 0, 0);
|
||||
if (hr == S_OK) {
|
||||
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";
|
||||
}
|
||||
|
||||
_isValid = true;
|
||||
} else {
|
||||
qCDebug(shared) << "Unable to enerate video adapters";
|
||||
}
|
||||
_isValid = true;
|
||||
} else {
|
||||
qCDebug(shared) << "Unable to enerate video adapters";
|
||||
}
|
||||
#endif
|
||||
return this;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -17,20 +17,20 @@
|
|||
class GPUIdent
|
||||
{
|
||||
public:
|
||||
unsigned int getMemory() { return _dedicatedMemoryMB; }
|
||||
QString getName() { return _name; }
|
||||
QString getDriver() { return _driver; }
|
||||
bool isValid() { return _isValid; }
|
||||
// E.g., GPUIdent::getInstance()->getMemory();
|
||||
static GPUIdent* getInstance() { return _instance.ensureQuery(); }
|
||||
unsigned int getMemory() { return _dedicatedMemoryMB; }
|
||||
QString getName() { return _name; }
|
||||
QString getDriver() { return _driver; }
|
||||
bool isValid() { return _isValid; }
|
||||
// E.g., GPUIdent::getInstance()->getMemory();
|
||||
static GPUIdent* getInstance() { return _instance.ensureQuery(); }
|
||||
private:
|
||||
uint _dedicatedMemoryMB { 0 };
|
||||
QString _name { "" };
|
||||
QString _driver { "" };
|
||||
bool _isQueried { false };
|
||||
bool _isValid { false };
|
||||
static GPUIdent _instance;
|
||||
GPUIdent* ensureQuery();
|
||||
uint _dedicatedMemoryMB { 0 };
|
||||
QString _name { "" };
|
||||
QString _driver { "" };
|
||||
bool _isQueried { false };
|
||||
bool _isValid { false };
|
||||
static GPUIdent _instance;
|
||||
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();
|
||||
}
|
||||
#endif
|
||||
GPUIdent* gpu = GPUIdent::getInstance();
|
||||
if (gpu->isValid()) {
|
||||
qDebug() << "GPU:";
|
||||
qDebug() << "\tcard:" << gpu->getName();
|
||||
qDebug() << "\tdriver:" << gpu->getDriver();
|
||||
qDebug() << "\tdedicated memory:" << gpu->getMemory() << "MB";
|
||||
}
|
||||
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";
|
||||
// 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