From 49f1590e01ee2a1dfeed7b43b706a03cb1b82d02 Mon Sep 17 00:00:00 2001 From: samcake Date: Tue, 1 Nov 2016 16:51:57 -0700 Subject: [PATCH] Start detecting all the gpus --- libraries/shared/src/GPUIdent.cpp | 32 ++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/libraries/shared/src/GPUIdent.cpp b/libraries/shared/src/GPUIdent.cpp index 170d57fe4f..02ef4b64ab 100644 --- a/libraries/shared/src/GPUIdent.cpp +++ b/libraries/shared/src/GPUIdent.cpp @@ -65,7 +65,12 @@ GPUIdent* GPUIdent::ensureQuery(const QString& vendor, const QString& renderer) IDXGIFactory1* pFactory = nullptr; hr = CreateDXGIFactory1(__uuidof(IDXGIFactory1), (void**)(&pFactory) ); + if (hr != S_OK || pFactory == nullptr) { + qCDebug(shared) << "Unable to create DXGI"; + return this; + } + std::vector adapterDescs; // Select our adapter IDXGIAdapter1* capableAdapter = nullptr; { @@ -77,21 +82,21 @@ GPUIdent* GPUIdent::ensureQuery(const QString& vendor, const QString& renderer) break; } // query to see if there exists a corresponding compute device - - // if so, mark it as the one against which to create our d3d10 device - capableAdapter = pAdapter; - capableAdapter->AddRef(); - + DXGI_ADAPTER_DESC1 adapterDesc; + pAdapter->GetDesc1(&adapterDesc); pAdapter->Release(); + + qCDebug(shared) << "Found adapter: " << adapterDesc.Description; + + adapterDescs.push_back(adapterDesc); + } } - - DXGI_ADAPTER_DESC1 adapterDesc; - capableAdapter->GetDesc1(&adapterDesc); - - capableAdapter->Release(); pFactory->Release(); + + + // COM must be initialized already using CoInitialize. E.g., by the audio subsystem. CComPtr spLoc = NULL; hr = CoCreateInstance(CLSID_WbemLocator, 0, CLSCTX_SERVER, IID_IWbemLocator, (LPVOID *)&spLoc); @@ -189,9 +194,10 @@ GPUIdent* GPUIdent::ensureQuery(const QString& vendor, const QString& renderer) hr = spEnumInst->Next(WBEM_INFINITE, 1, &spInstance.p, &uNumOfInstances); } - const ULONGLONG BYTES_PER_MEGABYTE = 1024 * 1024; - _dedicatedMemoryMB = (uint64_t)(adapterDesc.DedicatedVideoMemory / BYTES_PER_MEGABYTE); - + if (adapterDescs.size()) { + const ULONGLONG BYTES_PER_MEGABYTE = 1024 * 1024; + _dedicatedMemoryMB = (uint64_t)(adapterDescs[0].DedicatedVideoMemory / BYTES_PER_MEGABYTE); + } #endif return this;