Skip to content

Commit 7072cf2

Browse files
authored
Fix Windows enumeration for non-WDDM devices via HKR (#178)
* Fix non-WDDM enumeration Always try HKR enumeration irrespective of DXGK enumeration status. Currently, we fallback to HKR enumeration only if DXGK enumeration fails. For platforms with non-WDDM devices, DXGK fails to see WDDM adapters. If one platform with WDDM adapters is enumerated successfully via DXGK, the other platform with no WDDM adapters fails to get enumerated. Using HKR path unconditionally allows such platforms to be enumerated. While at it, also fix memory leak due to not freeing library handle in some cases. * Fix status and error messaging in enumeration. Fix status tracking and error messaging in Windows enumeration after recent change. * Bump up OpenCL ICD Loader version Bump up OpenCL ICD loader version to 3.0.3 after recent fix to Windows enumeration logic. * Fix status return for Windows enumeration. While trying to fix error trace prints, overall status returned changed to status of last enumeration. Use separate variable for individual status, but keep original logic to combine overall status and return the same.
1 parent 5b280f6 commit 7072cf2

2 files changed

Lines changed: 19 additions & 11 deletions

File tree

loader/windows/OpenCL.rc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
#define OPENCL_ICD_LOADER_VERSION_MAJOR 3
2222
#define OPENCL_ICD_LOADER_VERSION_MINOR 0
23-
#define OPENCL_ICD_LOADER_VERSION_REV 2
23+
#define OPENCL_ICD_LOADER_VERSION_REV 3
2424

2525
#ifdef RC_INVOKED
2626

loader/windows/icd_windows.c

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -108,25 +108,33 @@ void adapterFree(WinAdapter *pWinAdapter)
108108
BOOL CALLBACK khrIcdOsVendorsEnumerate(PINIT_ONCE InitOnce, PVOID Parameter, PVOID *lpContext)
109109
{
110110
LONG result;
111-
BOOL status = FALSE;
111+
BOOL status = FALSE, currentStatus = FALSE;
112112
const char* platformsName = "SOFTWARE\\Khronos\\OpenCL\\Vendors";
113113
HKEY platformsKey = NULL;
114114
DWORD dwIndex;
115115

116116
khrIcdVendorsEnumerateEnv();
117117

118-
status |= khrIcdOsVendorsEnumerateDXGK();
119-
if (!status)
118+
currentStatus = khrIcdOsVendorsEnumerateDXGK();
119+
status |= currentStatus;
120+
if (!currentStatus)
120121
{
121122
KHR_ICD_TRACE("Failed to load via DXGK interface on RS4, continuing\n");
122-
status |= khrIcdOsVendorsEnumerateHKR();
123-
if (!status)
124-
{
125-
KHR_ICD_TRACE("Failed to enumerate HKR entries, continuing\n");
126-
}
127123
}
128124

129-
status |= khrIcdOsVendorsEnumerateAppPackage();
125+
currentStatus = khrIcdOsVendorsEnumerateHKR();
126+
status |= currentStatus;
127+
if (!currentStatus)
128+
{
129+
KHR_ICD_TRACE("Failed to enumerate HKR entries, continuing\n");
130+
}
131+
132+
currentStatus = khrIcdOsVendorsEnumerateAppPackage();
133+
status |= currentStatus;
134+
if (!currentStatus)
135+
{
136+
KHR_ICD_TRACE("Failed to enumerate App package entry, continuing\n");
137+
}
130138

131139
KHR_ICD_TRACE("Opening key HKLM\\%s...\n", platformsName);
132140
result = RegOpenKeyExA(
@@ -218,8 +226,8 @@ BOOL CALLBACK khrIcdOsVendorsEnumerate(PINIT_ONCE InitOnce, PVOID Parameter, PVO
218226
}
219227
pFactory->lpVtbl->Release(pFactory);
220228
}
221-
FreeLibrary(hDXGI);
222229
}
230+
FreeLibrary(hDXGI);
223231
}
224232

225233
// Go through the list again, putting any remaining adapters at the end of the list in an undefined order

0 commit comments

Comments
 (0)