77
88#include " shared/source/helpers/get_info.h"
99#include " shared/source/helpers/hw_info.h"
10+ #include " shared/source/os_interface/windows/os_interface.h"
1011#include " shared/source/utilities/api_intercept.h"
1112
1213#include " opencl/source/api/api.h"
2223
2324using namespace NEO ;
2425
26+ ClDevice *pickDeviceWithAdapterLuid (Platform *platform, LUID adapterLuid) {
27+ ClDevice *deviceToReturn = nullptr ;
28+ for (auto i = 0u ; i < platform->getNumDevices (); i++) {
29+ auto device = platform->getClDevice (i);
30+ if (device->getRootDeviceEnvironment ().osInterface ->get ()->getWddm ()->verifyAdapterLuid (adapterLuid)) {
31+ deviceToReturn = device;
32+ break ;
33+ }
34+ }
35+ return deviceToReturn;
36+ }
37+
2538void NEO::MemObj::getOsSpecificMemObjectInfo (const cl_mem_info ¶mName, size_t *srcParamSize, void **srcParam) {
2639 switch (paramName) {
2740 case CL_MEM_D3D10_RESOURCE_KHR:
@@ -295,6 +308,7 @@ cl_int CL_API_CALL clGetDeviceIDsFromD3D10KHR(cl_platform_id platform, cl_d3d10_
295308 cl_int retCode = CL_SUCCESS;
296309
297310 Platform *platformInternal = nullptr ;
311+ ClDevice *device = nullptr ;
298312 auto retVal = validateObjects (WithCastToInternal (platform, &platformInternal));
299313 API_ENTER (&retVal);
300314 DBG_LOG_INPUTS (" platform" , platform,
@@ -312,8 +326,6 @@ cl_int CL_API_CALL clGetDeviceIDsFromD3D10KHR(cl_platform_id platform, cl_d3d10_
312326 sharingFcns.getDxgiDescFcn = (D3DSharingFunctions<D3DTypesHelper::D3D10>::GetDxgiDescFcn)DebugManager.injectFcn ;
313327 }
314328
315- ClDevice *device = platformInternal->getClDevice (0 );
316-
317329 switch (d3dDeviceSource) {
318330 case CL_D3D10_DEVICE_KHR:
319331 d3dDevice = (ID3D10Device *)d3dObject;
@@ -328,7 +340,7 @@ cl_int CL_API_CALL clGetDeviceIDsFromD3D10KHR(cl_platform_id platform, cl_d3d10_
328340 }
329341
330342 sharingFcns.getDxgiDescFcn (&dxgiDesc, dxgiAdapter, d3dDevice);
331- if (dxgiDesc.VendorId != INTEL_VENDOR_ID || dxgiDesc. DeviceId != device-> getHardwareInfo (). platform . usDeviceID ) {
343+ if (dxgiDesc.VendorId != INTEL_VENDOR_ID) {
332344 GetInfoHelper::set (numDevices, localNumDevices);
333345 retVal = CL_DEVICE_NOT_FOUND;
334346 return retVal;
@@ -337,8 +349,13 @@ cl_int CL_API_CALL clGetDeviceIDsFromD3D10KHR(cl_platform_id platform, cl_d3d10_
337349 switch (d3dDeviceSet) {
338350 case CL_PREFERRED_DEVICES_FOR_D3D10_KHR:
339351 case CL_ALL_DEVICES_FOR_D3D10_KHR:
340- GetInfoHelper::set (devices, static_cast <cl_device_id>(device));
341- localNumDevices = 1 ;
352+ device = pickDeviceWithAdapterLuid (platformInternal, dxgiDesc.AdapterLuid );
353+ if (device) {
354+ GetInfoHelper::set (devices, static_cast <cl_device_id>(device));
355+ localNumDevices = 1 ;
356+ } else {
357+ retCode = CL_DEVICE_NOT_FOUND;
358+ }
342359 break ;
343360 default :
344361 retCode = CL_INVALID_VALUE;
@@ -502,6 +519,7 @@ cl_int CL_API_CALL clGetDeviceIDsFromD3D11KHR(cl_platform_id platform, cl_d3d11_
502519 cl_uint localNumDevices = 0 ;
503520
504521 Platform *platformInternal = nullptr ;
522+ ClDevice *device = nullptr ;
505523 auto retVal = validateObjects (WithCastToInternal (platform, &platformInternal));
506524 API_ENTER (&retVal);
507525 DBG_LOG_INPUTS (" platform" , platform,
@@ -519,8 +537,6 @@ cl_int CL_API_CALL clGetDeviceIDsFromD3D11KHR(cl_platform_id platform, cl_d3d11_
519537 sharingFcns.getDxgiDescFcn = (D3DSharingFunctions<D3DTypesHelper::D3D11>::GetDxgiDescFcn)DebugManager.injectFcn ;
520538 }
521539
522- ClDevice *device = platformInternal->getClDevice (0 );
523-
524540 switch (d3dDeviceSource) {
525541 case CL_D3D11_DEVICE_KHR:
526542 d3dDevice = (ID3D11Device *)d3dObject;
@@ -536,7 +552,7 @@ cl_int CL_API_CALL clGetDeviceIDsFromD3D11KHR(cl_platform_id platform, cl_d3d11_
536552 }
537553
538554 sharingFcns.getDxgiDescFcn (&dxgiDesc, dxgiAdapter, d3dDevice);
539- if (dxgiDesc.VendorId != INTEL_VENDOR_ID || dxgiDesc. DeviceId != device-> getHardwareInfo (). platform . usDeviceID ) {
555+ if (dxgiDesc.VendorId != INTEL_VENDOR_ID) {
540556 GetInfoHelper::set (numDevices, localNumDevices);
541557 retVal = CL_DEVICE_NOT_FOUND;
542558 return retVal;
@@ -545,8 +561,13 @@ cl_int CL_API_CALL clGetDeviceIDsFromD3D11KHR(cl_platform_id platform, cl_d3d11_
545561 switch (d3dDeviceSet) {
546562 case CL_PREFERRED_DEVICES_FOR_D3D11_KHR:
547563 case CL_ALL_DEVICES_FOR_D3D11_KHR:
548- GetInfoHelper::set (devices, static_cast <cl_device_id>(device));
549- localNumDevices = 1 ;
564+ device = pickDeviceWithAdapterLuid (platformInternal, dxgiDesc.AdapterLuid );
565+ if (device) {
566+ GetInfoHelper::set (devices, static_cast <cl_device_id>(device));
567+ localNumDevices = 1 ;
568+ } else {
569+ retVal = CL_DEVICE_NOT_FOUND;
570+ }
550571 break ;
551572 default :
552573 retVal = CL_INVALID_VALUE;
0 commit comments