From c3fc8d8695245ee422ea56467d795b3b20cc0070 Mon Sep 17 00:00:00 2001 From: Mateusz Jablonski Date: Wed, 2 Oct 2019 14:49:33 +0200 Subject: [PATCH] Load proper KMD adapter Related-To: NEO-3007 Change-Id: I6555caf4351f30677983cef86df48c88d0927ebc Signed-off-by: Mateusz Jablonski --- runtime/os_interface/windows/wddm/wddm.cpp | 32 +++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/runtime/os_interface/windows/wddm/wddm.cpp b/runtime/os_interface/windows/wddm/wddm.cpp index 170a11efbf..714bd61ed1 100644 --- a/runtime/os_interface/windows/wddm/wddm.cpp +++ b/runtime/os_interface/windows/wddm/wddm.cpp @@ -30,6 +30,24 @@ #include "gmm_memory.h" +std::wstring getIgdrclPath() { + std::wstring returnValue; + WCHAR path[255]; + HMODULE handle = NULL; + + auto status = GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | + GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, + (LPCWSTR)(&clGetPlatformIDs), &handle); + if (status != 0) { + + status = GetModuleFileName(handle, path, sizeof(path)); + if (status != 0) { + returnValue.append(path); + } + } + return returnValue; +} + namespace NEO { extern Wddm::CreateDXGIFactoryFcn getCreateDxgiFactory(); extern Wddm::GetSystemInfoFcn getGetSystemInfo(); @@ -231,6 +249,8 @@ bool Wddm::openAdapter() { IDXGIAdapter1 *pAdapter = nullptr; DWORD iDevNum = 0; + auto igdrclPath = getIgdrclPath(); + HRESULT hr = Wddm::createDxgiFactory(__uuidof(IDXGIFactory), (void **)(&pFactory)); if ((hr != S_OK) || (pFactory == nullptr)) { return false; @@ -243,7 +263,17 @@ bool Wddm::openAdapter() { // be virtualizing one of our adapters) in the description if ((wcsstr(OpenAdapterDesc.Description, L"Intel") != 0) || (wcsstr(OpenAdapterDesc.Description, L"Citrix") != 0)) { - break; + if (wcsstr(OpenAdapterDesc.Description, L"DCH-D") != 0) { + if (wcsstr(igdrclPath.c_str(), L"_dch_d.inf") != 0) { + break; + } + } else if (wcsstr(OpenAdapterDesc.Description, L"DCH-I") != 0) { + if (wcsstr(igdrclPath.c_str(), L"_dch_i.inf") != 0) { + break; + } + } else { + break; + } } } // Release all the non-Intel adapters