From: Jacek Caban jacek@codeweavers.com
And use it for D3DKMTOpenAdapterFromGdiDisplayName.
Signed-off-by: Jacek Caban jacek@codeweavers.com Signed-off-by: Huw Davies huw@codeweavers.com --- dlls/gdi32/driver.c | 41 +++++++++++++++++++++++------------------ dlls/gdi32/gdi32.spec | 1 + include/ddk/d3dkmthk.h | 6 ++++++ include/ntgdi.h | 1 + 4 files changed, 31 insertions(+), 18 deletions(-)
diff --git a/dlls/gdi32/driver.c b/dlls/gdi32/driver.c index fba1f1cffea..3073f745f92 100644 --- a/dlls/gdi32/driver.c +++ b/dlls/gdi32/driver.c @@ -1257,13 +1257,11 @@ NTSTATUS WINAPI D3DKMTOpenAdapterFromGdiDisplayName( D3DKMT_OPENADAPTERFROMGDIDI WCHAR *end, key_nameW[MAX_PATH], bufferW[MAX_PATH]; HDEVINFO devinfo = INVALID_HANDLE_VALUE; NTSTATUS status = STATUS_UNSUCCESSFUL; - static D3DKMT_HANDLE handle_start = 0; - struct d3dkmt_adapter *adapter; + D3DKMT_OPENADAPTERFROMLUID luid_desc; SP_DEVINFO_DATA device_data; DWORD size, state_flags; DEVPROPTYPE type; HANDLE mutex; - LUID luid; int index;
TRACE("(%p)\n", desc); @@ -1279,10 +1277,6 @@ NTSTATUS WINAPI D3DKMTOpenAdapterFromGdiDisplayName( D3DKMT_OPENADAPTERFROMGDIDI if (*end) return STATUS_UNSUCCESSFUL;
- adapter = heap_alloc( sizeof( *adapter ) ); - if (!adapter) - return STATUS_NO_MEMORY; - /* Get adapter LUID from SetupAPI */ mutex = get_display_device_init_mutex();
@@ -1309,28 +1303,39 @@ NTSTATUS WINAPI D3DKMTOpenAdapterFromGdiDisplayName( D3DKMT_OPENADAPTERFROMGDIDI device_data.cbSize = sizeof( device_data ); SetupDiOpenDeviceInfoW( devinfo, bufferW, NULL, 0, &device_data ); if (!SetupDiGetDevicePropertyW( devinfo, &device_data, &DEVPROPKEY_GPU_LUID, &type, - (BYTE *)&luid, sizeof( luid ), NULL, 0)) + (BYTE *)&luid_desc.AdapterLuid, sizeof( luid_desc.AdapterLuid ), + NULL, 0)) goto done;
- EnterCriticalSection( &driver_section ); - /* D3DKMT_HANDLE is UINT, so we can't use pointer as handle */ - adapter->handle = ++handle_start; - list_add_tail( &d3dkmt_adapters, &adapter->entry ); - LeaveCriticalSection( &driver_section ); + if ((status = NtGdiDdDDIOpenAdapterFromLuid( &luid_desc ))) goto done;
- desc->hAdapter = handle_start; - desc->AdapterLuid = luid; + desc->hAdapter = luid_desc.hAdapter; + desc->AdapterLuid = luid_desc.AdapterLuid; desc->VidPnSourceId = index; - status = STATUS_SUCCESS;
done: SetupDiDestroyDeviceInfoList( devinfo ); release_display_device_init_mutex( mutex ); - if (status != STATUS_SUCCESS) - heap_free( adapter ); return status; }
+/****************************************************************************** + * NtGdiDdDDIOpenAdapterFromLuid (win32u.@) + */ +NTSTATUS WINAPI NtGdiDdDDIOpenAdapterFromLuid( D3DKMT_OPENADAPTERFROMLUID *desc ) +{ + static D3DKMT_HANDLE handle_start = 0; + struct d3dkmt_adapter *adapter; + + if (!(adapter = heap_alloc( sizeof( *adapter ) ))) return STATUS_NO_MEMORY; + + EnterCriticalSection( &driver_section ); + desc->hAdapter = adapter->handle = ++handle_start; + list_add_tail( &d3dkmt_adapters, &adapter->entry ); + LeaveCriticalSection( &driver_section ); + return STATUS_SUCCESS; +} + /****************************************************************************** * NtGdiDdDDICreateDevice (win32u.@) */ diff --git a/dlls/gdi32/gdi32.spec b/dlls/gdi32/gdi32.spec index 48ce04e3819..5bddcd26de6 100644 --- a/dlls/gdi32/gdi32.spec +++ b/dlls/gdi32/gdi32.spec @@ -89,6 +89,7 @@ @ stdcall D3DKMTEscape(ptr) NtGdiDdDDIEscape @ stdcall D3DKMTOpenAdapterFromGdiDisplayName(ptr) @ stdcall D3DKMTOpenAdapterFromHdc(ptr) NtGdiDdDDIOpenAdapterFromHdc +@ stdcall D3DKMTOpenAdapterFromLuid(ptr) NtGdiDdDDIOpenAdapterFromLuid @ stdcall D3DKMTQueryStatistics(ptr) NtGdiDdDDIQueryStatistics @ stdcall D3DKMTSetQueuedLimit(ptr) NtGdiDdDDISetQueuedLimit @ stdcall D3DKMTSetVidPnSourceOwner(ptr) NtGdiDdDDISetVidPnSourceOwner diff --git a/include/ddk/d3dkmthk.h b/include/ddk/d3dkmthk.h index dc53ea343c0..2ca3c4d7448 100644 --- a/include/ddk/d3dkmthk.h +++ b/include/ddk/d3dkmthk.h @@ -122,6 +122,12 @@ typedef struct _D3DKMT_OPENADAPTERFROMGDIDISPLAYNAME D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId; } D3DKMT_OPENADAPTERFROMGDIDISPLAYNAME;
+typedef struct _D3DKMT_OPENADAPTERFROMLUID +{ + LUID AdapterLuid; + D3DKMT_HANDLE hAdapter; +} D3DKMT_OPENADAPTERFROMLUID; + typedef struct _D3DKMT_SETVIDPNSOURCEOWNER { D3DKMT_HANDLE hDevice; diff --git a/include/ntgdi.h b/include/ntgdi.h index 7f3ecec8c64..ba4d2ff3556 100644 --- a/include/ntgdi.h +++ b/include/ntgdi.h @@ -333,6 +333,7 @@ NTSTATUS WINAPI NtGdiDdDDICreateDCFromMemory( D3DKMT_CREATEDCFROMMEMORY *desc ); NTSTATUS WINAPI NtGdiDdDDICreateDevice( D3DKMT_CREATEDEVICE *desc ); NTSTATUS WINAPI NtGdiDdDDIDestroyDCFromMemory( const D3DKMT_DESTROYDCFROMMEMORY *desc ); NTSTATUS WINAPI NtGdiDdDDIDestroyDevice( const D3DKMT_DESTROYDEVICE *desc ); +NTSTATUS WINAPI NtGdiDdDDIOpenAdapterFromLuid( D3DKMT_OPENADAPTERFROMLUID *desc ); NTSTATUS WINAPI NtGdiDdDDIQueryStatistics( D3DKMT_QUERYSTATISTICS *stats ); NTSTATUS WINAPI NtGdiDdDDISetQueuedLimit( D3DKMT_SETQUEUEDLIMIT *desc ); NTSTATUS WINAPI NtGdiDdDDISetVidPnSourceOwner( const D3DKMT_SETVIDPNSOURCEOWNER *desc );