Commit fbd39cd8 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

gdi32: Implement NtGdiDdDDIOpenAdapterFromLuid.

And use it for D3DKMTOpenAdapterFromGdiDisplayName. Signed-off-by: 's avatarJacek Caban <jacek@codeweavers.com> Signed-off-by: 's avatarHuw Davies <huw@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent d127a14a
...@@ -1257,13 +1257,11 @@ NTSTATUS WINAPI D3DKMTOpenAdapterFromGdiDisplayName( D3DKMT_OPENADAPTERFROMGDIDI ...@@ -1257,13 +1257,11 @@ NTSTATUS WINAPI D3DKMTOpenAdapterFromGdiDisplayName( D3DKMT_OPENADAPTERFROMGDIDI
WCHAR *end, key_nameW[MAX_PATH], bufferW[MAX_PATH]; WCHAR *end, key_nameW[MAX_PATH], bufferW[MAX_PATH];
HDEVINFO devinfo = INVALID_HANDLE_VALUE; HDEVINFO devinfo = INVALID_HANDLE_VALUE;
NTSTATUS status = STATUS_UNSUCCESSFUL; NTSTATUS status = STATUS_UNSUCCESSFUL;
static D3DKMT_HANDLE handle_start = 0; D3DKMT_OPENADAPTERFROMLUID luid_desc;
struct d3dkmt_adapter *adapter;
SP_DEVINFO_DATA device_data; SP_DEVINFO_DATA device_data;
DWORD size, state_flags; DWORD size, state_flags;
DEVPROPTYPE type; DEVPROPTYPE type;
HANDLE mutex; HANDLE mutex;
LUID luid;
int index; int index;
TRACE("(%p)\n", desc); TRACE("(%p)\n", desc);
...@@ -1279,10 +1277,6 @@ NTSTATUS WINAPI D3DKMTOpenAdapterFromGdiDisplayName( D3DKMT_OPENADAPTERFROMGDIDI ...@@ -1279,10 +1277,6 @@ NTSTATUS WINAPI D3DKMTOpenAdapterFromGdiDisplayName( D3DKMT_OPENADAPTERFROMGDIDI
if (*end) if (*end)
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
adapter = heap_alloc( sizeof( *adapter ) );
if (!adapter)
return STATUS_NO_MEMORY;
/* Get adapter LUID from SetupAPI */ /* Get adapter LUID from SetupAPI */
mutex = get_display_device_init_mutex(); mutex = get_display_device_init_mutex();
...@@ -1309,29 +1303,40 @@ NTSTATUS WINAPI D3DKMTOpenAdapterFromGdiDisplayName( D3DKMT_OPENADAPTERFROMGDIDI ...@@ -1309,29 +1303,40 @@ NTSTATUS WINAPI D3DKMTOpenAdapterFromGdiDisplayName( D3DKMT_OPENADAPTERFROMGDIDI
device_data.cbSize = sizeof( device_data ); device_data.cbSize = sizeof( device_data );
SetupDiOpenDeviceInfoW( devinfo, bufferW, NULL, 0, &device_data ); SetupDiOpenDeviceInfoW( devinfo, bufferW, NULL, 0, &device_data );
if (!SetupDiGetDevicePropertyW( devinfo, &device_data, &DEVPROPKEY_GPU_LUID, &type, 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; goto done;
EnterCriticalSection( &driver_section ); if ((status = NtGdiDdDDIOpenAdapterFromLuid( &luid_desc ))) goto done;
/* 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 );
desc->hAdapter = handle_start; desc->hAdapter = luid_desc.hAdapter;
desc->AdapterLuid = luid; desc->AdapterLuid = luid_desc.AdapterLuid;
desc->VidPnSourceId = index; desc->VidPnSourceId = index;
status = STATUS_SUCCESS;
done: done:
SetupDiDestroyDeviceInfoList( devinfo ); SetupDiDestroyDeviceInfoList( devinfo );
release_display_device_init_mutex( mutex ); release_display_device_init_mutex( mutex );
if (status != STATUS_SUCCESS)
heap_free( adapter );
return status; 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.@) * NtGdiDdDDICreateDevice (win32u.@)
*/ */
NTSTATUS WINAPI NtGdiDdDDICreateDevice( D3DKMT_CREATEDEVICE *desc ) NTSTATUS WINAPI NtGdiDdDDICreateDevice( D3DKMT_CREATEDEVICE *desc )
......
...@@ -89,6 +89,7 @@ ...@@ -89,6 +89,7 @@
@ stdcall D3DKMTEscape(ptr) NtGdiDdDDIEscape @ stdcall D3DKMTEscape(ptr) NtGdiDdDDIEscape
@ stdcall D3DKMTOpenAdapterFromGdiDisplayName(ptr) @ stdcall D3DKMTOpenAdapterFromGdiDisplayName(ptr)
@ stdcall D3DKMTOpenAdapterFromHdc(ptr) NtGdiDdDDIOpenAdapterFromHdc @ stdcall D3DKMTOpenAdapterFromHdc(ptr) NtGdiDdDDIOpenAdapterFromHdc
@ stdcall D3DKMTOpenAdapterFromLuid(ptr) NtGdiDdDDIOpenAdapterFromLuid
@ stdcall D3DKMTQueryStatistics(ptr) NtGdiDdDDIQueryStatistics @ stdcall D3DKMTQueryStatistics(ptr) NtGdiDdDDIQueryStatistics
@ stdcall D3DKMTSetQueuedLimit(ptr) NtGdiDdDDISetQueuedLimit @ stdcall D3DKMTSetQueuedLimit(ptr) NtGdiDdDDISetQueuedLimit
@ stdcall D3DKMTSetVidPnSourceOwner(ptr) NtGdiDdDDISetVidPnSourceOwner @ stdcall D3DKMTSetVidPnSourceOwner(ptr) NtGdiDdDDISetVidPnSourceOwner
......
...@@ -122,6 +122,12 @@ typedef struct _D3DKMT_OPENADAPTERFROMGDIDISPLAYNAME ...@@ -122,6 +122,12 @@ typedef struct _D3DKMT_OPENADAPTERFROMGDIDISPLAYNAME
D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId; D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId;
} D3DKMT_OPENADAPTERFROMGDIDISPLAYNAME; } D3DKMT_OPENADAPTERFROMGDIDISPLAYNAME;
typedef struct _D3DKMT_OPENADAPTERFROMLUID
{
LUID AdapterLuid;
D3DKMT_HANDLE hAdapter;
} D3DKMT_OPENADAPTERFROMLUID;
typedef struct _D3DKMT_SETVIDPNSOURCEOWNER typedef struct _D3DKMT_SETVIDPNSOURCEOWNER
{ {
D3DKMT_HANDLE hDevice; D3DKMT_HANDLE hDevice;
......
...@@ -333,6 +333,7 @@ NTSTATUS WINAPI NtGdiDdDDICreateDCFromMemory( D3DKMT_CREATEDCFROMMEMORY *desc ); ...@@ -333,6 +333,7 @@ NTSTATUS WINAPI NtGdiDdDDICreateDCFromMemory( D3DKMT_CREATEDCFROMMEMORY *desc );
NTSTATUS WINAPI NtGdiDdDDICreateDevice( D3DKMT_CREATEDEVICE *desc ); NTSTATUS WINAPI NtGdiDdDDICreateDevice( D3DKMT_CREATEDEVICE *desc );
NTSTATUS WINAPI NtGdiDdDDIDestroyDCFromMemory( const D3DKMT_DESTROYDCFROMMEMORY *desc ); NTSTATUS WINAPI NtGdiDdDDIDestroyDCFromMemory( const D3DKMT_DESTROYDCFROMMEMORY *desc );
NTSTATUS WINAPI NtGdiDdDDIDestroyDevice( const D3DKMT_DESTROYDEVICE *desc ); NTSTATUS WINAPI NtGdiDdDDIDestroyDevice( const D3DKMT_DESTROYDEVICE *desc );
NTSTATUS WINAPI NtGdiDdDDIOpenAdapterFromLuid( D3DKMT_OPENADAPTERFROMLUID *desc );
NTSTATUS WINAPI NtGdiDdDDIQueryStatistics( D3DKMT_QUERYSTATISTICS *stats ); NTSTATUS WINAPI NtGdiDdDDIQueryStatistics( D3DKMT_QUERYSTATISTICS *stats );
NTSTATUS WINAPI NtGdiDdDDISetQueuedLimit( D3DKMT_SETQUEUEDLIMIT *desc ); NTSTATUS WINAPI NtGdiDdDDISetQueuedLimit( D3DKMT_SETQUEUEDLIMIT *desc );
NTSTATUS WINAPI NtGdiDdDDISetVidPnSourceOwner( const D3DKMT_SETVIDPNSOURCEOWNER *desc ); NTSTATUS WINAPI NtGdiDdDDISetVidPnSourceOwner( const D3DKMT_SETVIDPNSOURCEOWNER *desc );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment