diff --git a/dlls/api-ms-win-dx-d3dkmt-l1-1-0/api-ms-win-dx-d3dkmt-l1-1-0.spec b/dlls/api-ms-win-dx-d3dkmt-l1-1-0/api-ms-win-dx-d3dkmt-l1-1-0.spec index 43186e8fcc3..cb7935bbbc3 100644 --- a/dlls/api-ms-win-dx-d3dkmt-l1-1-0/api-ms-win-dx-d3dkmt-l1-1-0.spec +++ b/dlls/api-ms-win-dx-d3dkmt-l1-1-0/api-ms-win-dx-d3dkmt-l1-1-0.spec @@ -12,7 +12,7 @@ @ stub D3DKMTCreateAllocation2 @ stub D3DKMTCreateContext @ stdcall D3DKMTCreateDCFromMemory(ptr) gdi32.D3DKMTCreateDCFromMemory -@ stub D3DKMTCreateDevice +@ stdcall D3DKMTCreateDevice(ptr) gdi32.D3DKMTCreateDevice @ stub D3DKMTCreateKeyedMutex @ stub D3DKMTCreateKeyedMutex2 @ stub D3DKMTCreateOutputDupl diff --git a/dlls/d3d11/d3d11.spec b/dlls/d3d11/d3d11.spec index 87304b7c132..e4692ace9cd 100644 --- a/dlls/d3d11/d3d11.spec +++ b/dlls/d3d11/d3d11.spec @@ -8,7 +8,7 @@ @ stdcall D3DKMTCloseAdapter(ptr) gdi32.D3DKMTCloseAdapter @ stub D3DKMTCreateAllocation @ stub D3DKMTCreateContext -@ stub D3DKMTCreateDevice +@ stdcall D3DKMTCreateDevice(ptr) gdi32.D3DKMTCreateDevice @ stub D3DKMTCreateSynchronizationObject @ stub D3DKMTDestroyAllocation @ stub D3DKMTDestroyContext diff --git a/dlls/gdi32/driver.c b/dlls/gdi32/driver.c index da3aad9e7ce..f57dd1231f1 100644 --- a/dlls/gdi32/driver.c +++ b/dlls/gdi32/driver.c @@ -59,10 +59,17 @@ struct d3dkmt_adapter struct list entry; /* List entry */ }; +struct d3dkmt_device +{ + D3DKMT_HANDLE handle; /* Kernel mode graphics device handle*/ + struct list entry; /* List entry */ +}; + static struct list drivers = LIST_INIT( drivers ); static struct graphics_driver *display_driver; static struct list d3dkmt_adapters = LIST_INIT( d3dkmt_adapters ); +static struct list d3dkmt_devices = LIST_INIT( d3dkmt_devices ); const struct gdi_dc_funcs *font_driver = NULL; @@ -1342,3 +1349,48 @@ NTSTATUS WINAPI D3DKMTOpenAdapterFromGdiDisplayName( D3DKMT_OPENADAPTERFROMGDIDI desc->VidPnSourceId = 0; return STATUS_SUCCESS; } + +/****************************************************************************** + * D3DKMTCreateDevice [GDI32.@] + */ +NTSTATUS WINAPI D3DKMTCreateDevice( D3DKMT_CREATEDEVICE *desc ) +{ + static D3DKMT_HANDLE handle_start = 0; + struct d3dkmt_adapter *adapter; + struct d3dkmt_device *device; + BOOL found = FALSE; + + TRACE("(%p)\n", desc); + + if (!desc) + return STATUS_INVALID_PARAMETER; + + EnterCriticalSection( &driver_section ); + LIST_FOR_EACH_ENTRY( adapter, &d3dkmt_adapters, struct d3dkmt_adapter, entry ) + { + if (adapter->handle == desc->hAdapter) + { + found = TRUE; + break; + } + } + LeaveCriticalSection( &driver_section ); + + if (!found) + return STATUS_INVALID_PARAMETER; + + if (desc->Flags.LegacyMode || desc->Flags.RequestVSync || desc->Flags.DisableGpuTimeout) + FIXME("Flags unsupported.\n"); + + device = heap_alloc_zero( sizeof( *device ) ); + if (!device) + return STATUS_NO_MEMORY; + + EnterCriticalSection( &driver_section ); + device->handle = ++handle_start; + list_add_tail( &d3dkmt_devices, &device->entry ); + LeaveCriticalSection( &driver_section ); + + desc->hDevice = device->handle; + return STATUS_SUCCESS; +} diff --git a/dlls/gdi32/gdi32.spec b/dlls/gdi32/gdi32.spec index 5c17ed9ee80..88fe846eb83 100644 --- a/dlls/gdi32/gdi32.spec +++ b/dlls/gdi32/gdi32.spec @@ -82,6 +82,7 @@ @ stdcall CreateSolidBrush(long) @ stdcall D3DKMTCloseAdapter(ptr) @ stdcall D3DKMTCreateDCFromMemory(ptr) +@ stdcall D3DKMTCreateDevice(ptr) @ stdcall D3DKMTDestroyDCFromMemory(ptr) @ stdcall D3DKMTEscape(ptr) @ stdcall D3DKMTOpenAdapterFromGdiDisplayName(ptr) diff --git a/dlls/gdi32/tests/driver.c b/dlls/gdi32/tests/driver.c index caded27aefd..f5c23dad763 100644 --- a/dlls/gdi32/tests/driver.c +++ b/dlls/gdi32/tests/driver.c @@ -194,7 +194,7 @@ static void test_D3DKMTCreateDevice(void) D3DKMT_DESTROYDEVICE destroy_device_desc; NTSTATUS status; - if (!pD3DKMTCreateDevice || pD3DKMTCreateDevice(NULL) == STATUS_PROCEDURE_NOT_FOUND) + if (!pD3DKMTCreateDevice || pD3DKMTCreateDevice(NULL) == STATUS_PROCEDURE_NOT_FOUND || !pD3DKMTDestroyDevice) { skip("D3DKMTCreateDevice() or D3DKMTDestroyDevice() is unavailable.\n"); return; diff --git a/include/ddk/d3dkmthk.h b/include/ddk/d3dkmthk.h index 5436cb66122..90bf907e306 100644 --- a/include/ddk/d3dkmthk.h +++ b/include/ddk/d3dkmthk.h @@ -166,6 +166,7 @@ extern "C" #endif /* __cplusplus */ NTSTATUS WINAPI D3DKMTCloseAdapter(const D3DKMT_CLOSEADAPTER *desc); +NTSTATUS WINAPI D3DKMTCreateDevice(D3DKMT_CREATEDEVICE *desc); NTSTATUS WINAPI D3DKMTCreateDCFromMemory(D3DKMT_CREATEDCFROMMEMORY *desc); NTSTATUS WINAPI D3DKMTDestroyDCFromMemory(const D3DKMT_DESTROYDCFROMMEMORY *desc); NTSTATUS WINAPI D3DKMTOpenAdapterFromGdiDisplayName(D3DKMT_OPENADAPTERFROMGDIDISPLAYNAME *desc);