D3DKMTSetVidPnSourceOwner needs to be implemented in the graphics drivers because we need to maintain the VidPN source ownership information list in the graphics drivers. For example, the graphics drivers need to release the exclusive ownership when a new window is moved to a monitor which has been taken exclusive ownership.
Signed-off-by: Zhiyi Zhang zzhang@codeweavers.com --- .../api-ms-win-dx-d3dkmt-l1-1-0.spec | 4 +- dlls/d3d11/d3d11.spec | 3 +- dlls/gdi32/dibdrv/dc.c | 4 ++ dlls/gdi32/driver.c | 52 +++++++++++++++++++ dlls/gdi32/enhmfdrv/dc.c | 2 + dlls/gdi32/enhmfdrv/init.c | 2 + dlls/gdi32/freetype.c | 2 + dlls/gdi32/gdi32.spec | 2 + dlls/gdi32/mfdrv/init.c | 2 + dlls/gdi32/path.c | 2 + dlls/wineandroid.drv/init.c | 2 + dlls/winemac.drv/gdi.c | 2 + dlls/wineps.drv/init.c | 2 + dlls/winex11.drv/init.c | 2 + dlls/winex11.drv/xrender.c | 2 + include/ddk/d3dkmthk.h | 2 + include/wine/gdi_driver.h | 6 ++- 17 files changed, 89 insertions(+), 4 deletions(-)
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 a28fc5cfc5..d2fcc8fe45 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 @@ -5,7 +5,7 @@ @ stub D3DKMTCheckMonitorPowerState @ stub D3DKMTCheckOcclusion @ stub D3DKMTCheckSharedResourceAccess -@ stub D3DKMTCheckVidPnExclusiveOwnership +@ stdcall D3DKMTCheckVidPnExclusiveOwnership(ptr) gdi32.D3DKMTCheckVidPnExclusiveOwnership @ stdcall D3DKMTCloseAdapter(ptr) gdi32.D3DKMTCloseAdapter @ stub D3DKMTConfigureSharedResource @ stub D3DKMTCreateAllocation @@ -82,7 +82,7 @@ @ stub D3DKMTSetProcessSchedulingPriorityClass @ stub D3DKMTSetQueuedLimit @ stub D3DKMTSetStereoEnabled -@ stub D3DKMTSetVidPnSourceOwner +@ stdcall D3DKMTSetVidPnSourceOwner(ptr) gdi32.D3DKMTSetVidPnSourceOwner @ stub D3DKMTShareObjects @ stub D3DKMTSharedPrimaryLockNotification @ stub D3DKMTSharedPrimaryUnLockNotification diff --git a/dlls/d3d11/d3d11.spec b/dlls/d3d11/d3d11.spec index 01bc8bfebc..383ed6aa9c 100644 --- a/dlls/d3d11/d3d11.spec +++ b/dlls/d3d11/d3d11.spec @@ -5,6 +5,7 @@ @ stdcall D3D11CreateDevice(ptr long ptr long ptr long long ptr ptr ptr) @ stdcall D3D11CreateDeviceAndSwapChain(ptr long ptr long ptr long long ptr ptr ptr ptr ptr) @ stdcall D3D11On12CreateDevice(ptr long ptr long ptr long long ptr ptr ptr) +@ stdcall D3DKMTCheckVidPnExclusiveOwnership(ptr) gdi32.D3DKMTCheckVidPnExclusiveOwnership @ stdcall D3DKMTCloseAdapter(ptr) gdi32.D3DKMTCloseAdapter @ stub D3DKMTCreateAllocation @ stub D3DKMTCreateContext @@ -35,7 +36,7 @@ @ stub D3DKMTSetDisplayMode @ stub D3DKMTSetDisplayPrivateDriverFormat @ stub D3DKMTSetGammaRamp -@ stub D3DKMTSetVidPnSourceOwner +@ stdcall D3DKMTSetVidPnSourceOwner(ptr) gdi32.D3DKMTSetVidPnSourceOwner @ stub D3DKMTSignalSynchronizationObject @ stub D3DKMTUnlock @ stub D3DKMTWaitForSynchronizationObject diff --git a/dlls/gdi32/dibdrv/dc.c b/dlls/gdi32/dibdrv/dc.c index fb1683e8f1..f818aa0228 100644 --- a/dlls/gdi32/dibdrv/dc.c +++ b/dlls/gdi32/dibdrv/dc.c @@ -520,6 +520,8 @@ const struct gdi_dc_funcs dib_driver = dibdrv_StrokePath, /* pStrokePath */ NULL, /* pUnrealizePalette */ NULL, /* pWidenPath */ + NULL, /* pD3DKMTCheckVidPnExclusiveOwnership */ + NULL, /* pD3DKMTSetVidPnSourceOwner */ dibdrv_wine_get_wgl_driver, /* wine_get_wgl_driver */ NULL, /* wine_get_vulkan_driver */ GDI_PRIORITY_DIB_DRV /* priority */ @@ -1143,6 +1145,8 @@ static const struct gdi_dc_funcs window_driver = NULL, /* pStrokePath */ NULL, /* pUnrealizePalette */ NULL, /* pWidenPath */ + NULL, /* pD3DKMTCheckVidPnExclusiveOwnership */ + NULL, /* pD3DKMTSetVidPnSourceOwner */ windrv_wine_get_wgl_driver, /* wine_get_wgl_driver */ NULL, /* wine_get_vulkan_driver */ GDI_PRIORITY_DIB_DRV + 10 /* priority */ diff --git a/dlls/gdi32/driver.c b/dlls/gdi32/driver.c index eaf1cf7788..d84584da86 100644 --- a/dlls/gdi32/driver.c +++ b/dlls/gdi32/driver.c @@ -753,6 +753,16 @@ static BOOL CDECL nulldrv_UnrealizePalette( HPALETTE palette ) return FALSE; }
+static NTSTATUS CDECL nulldrv_D3DKMTCheckVidPnExclusiveOwnership( const D3DKMT_CHECKVIDPNEXCLUSIVEOWNERSHIP *desc ) +{ + return STATUS_PROCEDURE_NOT_FOUND; +} + +static NTSTATUS CDECL nulldrv_D3DKMTSetVidPnSourceOwner( const D3DKMT_SETVIDPNSOURCEOWNER *desc ) +{ + return STATUS_PROCEDURE_NOT_FOUND; +} + static struct opengl_funcs * CDECL nulldrv_wine_get_wgl_driver( PHYSDEV dev, UINT version ) { return (void *)-1; @@ -892,6 +902,8 @@ const struct gdi_dc_funcs null_driver = nulldrv_StrokePath, /* pStrokePath */ nulldrv_UnrealizePalette, /* pUnrealizePalette */ nulldrv_WidenPath, /* pWidenPath */ + nulldrv_D3DKMTCheckVidPnExclusiveOwnership, /* pD3DKMTCheckVidPnExclusiveOwnership */ + nulldrv_D3DKMTSetVidPnSourceOwner, /* pD3DKMTSetVidPnSourceOwner */ nulldrv_wine_get_wgl_driver, /* wine_get_wgl_driver */ nulldrv_wine_get_vulkan_driver, /* wine_get_vulkan_driver */
@@ -1422,6 +1434,7 @@ NTSTATUS WINAPI D3DKMTCreateDevice( D3DKMT_CREATEDEVICE *desc ) NTSTATUS WINAPI D3DKMTDestroyDevice( const D3DKMT_DESTROYDEVICE *desc ) { NTSTATUS status = STATUS_INVALID_PARAMETER; + D3DKMT_SETVIDPNSOURCEOWNER set_owner_desc; struct d3dkmt_device *device;
TRACE("(%p)\n", desc); @@ -1434,6 +1447,9 @@ NTSTATUS WINAPI D3DKMTDestroyDevice( const D3DKMT_DESTROYDEVICE *desc ) { if (device->handle == desc->hDevice) { + memset( &set_owner_desc, 0, sizeof(set_owner_desc) ); + set_owner_desc.hDevice = desc->hDevice; + D3DKMTSetVidPnSourceOwner( &set_owner_desc ); list_remove( &device->entry ); heap_free( device ); status = STATUS_SUCCESS; @@ -1453,3 +1469,39 @@ NTSTATUS WINAPI D3DKMTQueryStatistics(D3DKMT_QUERYSTATISTICS *stats) FIXME("(%p): stub\n", stats); return STATUS_SUCCESS; } + +/****************************************************************************** + * D3DKMTSetVidPnSourceOwner [GDI32.@] + */ +NTSTATUS WINAPI D3DKMTSetVidPnSourceOwner( const D3DKMT_SETVIDPNSOURCEOWNER *desc ) +{ + TRACE("(%p)\n", desc); + + if (!get_display_driver()->pD3DKMTSetVidPnSourceOwner) + return STATUS_PROCEDURE_NOT_FOUND; + + if (!desc || !desc->hDevice || (desc->VidPnSourceCount && (!desc->pType || !desc->pVidPnSourceId))) + return STATUS_INVALID_PARAMETER; + + /* Store the VidPN source ownership info in the graphics driver because + * the graphics driver needs to change ownership sometimes. For example, + * when a new window is moved to a VidPN source with an exclusive owner, + * such an exclusive owner will be released before showing the new window */ + return get_display_driver()->pD3DKMTSetVidPnSourceOwner( desc ); +} + +/****************************************************************************** + * D3DKMTCheckVidPnExclusiveOwnership [GDI32.@] + */ +NTSTATUS WINAPI D3DKMTCheckVidPnExclusiveOwnership( const D3DKMT_CHECKVIDPNEXCLUSIVEOWNERSHIP *desc ) +{ + TRACE("(%p)\n", desc); + + if (!get_display_driver()->pD3DKMTCheckVidPnExclusiveOwnership) + return STATUS_PROCEDURE_NOT_FOUND; + + if (!desc || !desc->hAdapter) + return STATUS_INVALID_PARAMETER; + + return get_display_driver()->pD3DKMTCheckVidPnExclusiveOwnership( desc ); +} diff --git a/dlls/gdi32/enhmfdrv/dc.c b/dlls/gdi32/enhmfdrv/dc.c index 18047b399c..804fef18f9 100644 --- a/dlls/gdi32/enhmfdrv/dc.c +++ b/dlls/gdi32/enhmfdrv/dc.c @@ -950,6 +950,8 @@ static const struct gdi_dc_funcs emfpath_driver = NULL, /* pStrokePath */ NULL, /* pUnrealizePalette */ NULL, /* pWidenPath */ + NULL, /* pD3DKMTCheckVidPnExclusiveOwnership */ + NULL, /* pD3DKMTSetVidPnSourceOwner */ NULL, /* wine_get_wgl_driver */ NULL, /* wine_get_vulkan_driver */ GDI_PRIORITY_PATH_DRV + 1 /* priority */ diff --git a/dlls/gdi32/enhmfdrv/init.c b/dlls/gdi32/enhmfdrv/init.c index 177b186057..4ff85fa5b3 100644 --- a/dlls/gdi32/enhmfdrv/init.c +++ b/dlls/gdi32/enhmfdrv/init.c @@ -163,6 +163,8 @@ static const struct gdi_dc_funcs emfdrv_driver = EMFDRV_StrokePath, /* pStrokePath */ NULL, /* pUnrealizePalette */ EMFDRV_WidenPath, /* pWidenPath */ + NULL, /* pD3DKMTCheckVidPnExclusiveOwnership */ + NULL, /* pD3DKMTSetVidPnSourceOwner */ NULL, /* wine_get_wgl_driver */ NULL, /* wine_get_vulkan_driver */ GDI_PRIORITY_GRAPHICS_DRV /* priority */ diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c index e3cff25b76..14807e1d14 100644 --- a/dlls/gdi32/freetype.c +++ b/dlls/gdi32/freetype.c @@ -9236,6 +9236,8 @@ static const struct gdi_dc_funcs freetype_funcs = NULL, /* pStrokePath */ NULL, /* pUnrealizePalette */ NULL, /* pWidenPath */ + NULL, /* pD3DKMTCheckVidPnExclusiveOwnership */ + NULL, /* pD3DKMTSetVidPnSourceOwner */ NULL, /* wine_get_wgl_driver */ NULL, /* wine_get_vulkan_driver */ GDI_PRIORITY_FONT_DRV /* priority */ diff --git a/dlls/gdi32/gdi32.spec b/dlls/gdi32/gdi32.spec index cc5d2c21a3..4e08e3494c 100644 --- a/dlls/gdi32/gdi32.spec +++ b/dlls/gdi32/gdi32.spec @@ -80,6 +80,7 @@ @ stdcall CreateScalableFontResourceA(long str str str) @ stdcall CreateScalableFontResourceW(long wstr wstr wstr) @ stdcall CreateSolidBrush(long) +@ stdcall D3DKMTCheckVidPnExclusiveOwnership(ptr) @ stdcall D3DKMTCloseAdapter(ptr) @ stdcall D3DKMTCreateDCFromMemory(ptr) @ stdcall D3DKMTCreateDevice(ptr) @@ -89,6 +90,7 @@ @ stdcall D3DKMTOpenAdapterFromGdiDisplayName(ptr) @ stdcall D3DKMTOpenAdapterFromHdc(ptr) @ stdcall D3DKMTQueryStatistics(ptr) +@ stdcall D3DKMTSetVidPnSourceOwner(ptr) @ stdcall DPtoLP(long ptr long) @ stdcall DeleteColorSpace(long) @ stdcall DeleteDC(long) diff --git a/dlls/gdi32/mfdrv/init.c b/dlls/gdi32/mfdrv/init.c index 5307310213..2a215b7090 100644 --- a/dlls/gdi32/mfdrv/init.c +++ b/dlls/gdi32/mfdrv/init.c @@ -226,6 +226,8 @@ static const struct gdi_dc_funcs MFDRV_Funcs = MFDRV_StrokePath, /* pStrokePath */ NULL, /* pUnrealizePalette */ MFDRV_WidenPath, /* pWidenPath */ + NULL, /* pD3DKMTCheckVidPnExclusiveOwnership */ + NULL, /* pD3DKMTSetVidPnSourceOwner */ NULL, /* wine_get_wgl_driver */ NULL, /* wine_get_vulkan_driver */ GDI_PRIORITY_GRAPHICS_DRV /* priority */ diff --git a/dlls/gdi32/path.c b/dlls/gdi32/path.c index d2d9ac90a9..7d51388a4e 100644 --- a/dlls/gdi32/path.c +++ b/dlls/gdi32/path.c @@ -2248,6 +2248,8 @@ const struct gdi_dc_funcs path_driver = NULL, /* pStrokePath */ NULL, /* pUnrealizePalette */ NULL, /* pWidenPath */ + NULL, /* pD3DKMTCheckVidPnExclusiveOwnership */ + NULL, /* pD3DKMTSetVidPnSourceOwner */ NULL, /* wine_get_wgl_driver */ NULL, /* wine_get_vulkan_driver */ GDI_PRIORITY_PATH_DRV /* priority */ diff --git a/dlls/wineandroid.drv/init.c b/dlls/wineandroid.drv/init.c index 10059928e5..97cdb515d5 100644 --- a/dlls/wineandroid.drv/init.c +++ b/dlls/wineandroid.drv/init.c @@ -411,6 +411,8 @@ static const struct gdi_dc_funcs android_drv_funcs = NULL, /* pStrokePath */ NULL, /* pUnrealizePalette */ NULL, /* pWidenPath */ + NULL, /* pD3DKMTCheckVidPnExclusiveOwnership */ + NULL, /* pD3DKMTSetVidPnSourceOwner */ ANDROID_wine_get_wgl_driver, /* wine_get_wgl_driver */ NULL, /* wine_get_vulkan_driver */ GDI_PRIORITY_GRAPHICS_DRV /* priority */ diff --git a/dlls/winemac.drv/gdi.c b/dlls/winemac.drv/gdi.c index b4d3e73d17..8073a875df 100644 --- a/dlls/winemac.drv/gdi.c +++ b/dlls/winemac.drv/gdi.c @@ -390,6 +390,8 @@ static const struct gdi_dc_funcs macdrv_funcs = NULL, /* pStrokePath */ NULL, /* pUnrealizePalette */ NULL, /* pWidenPath */ + NULL, /* pD3DKMTCheckVidPnExclusiveOwnership */ + NULL, /* pD3DKMTSetVidPnSourceOwner */ macdrv_wine_get_wgl_driver, /* wine_get_wgl_driver */ macdrv_wine_get_vulkan_driver, /* wine_get_vulkan_driver */ GDI_PRIORITY_GRAPHICS_DRV /* priority */ diff --git a/dlls/wineps.drv/init.c b/dlls/wineps.drv/init.c index 3ffdab956a..5c96986bb9 100644 --- a/dlls/wineps.drv/init.c +++ b/dlls/wineps.drv/init.c @@ -904,6 +904,8 @@ static const struct gdi_dc_funcs psdrv_funcs = PSDRV_StrokePath, /* pStrokePath */ NULL, /* pUnrealizePalette */ NULL, /* pWidenPath */ + NULL, /* pD3DKMTCheckVidPnExclusiveOwnership */ + NULL, /* pD3DKMTSetVidPnSourceOwner */ NULL, /* wine_get_wgl_driver */ NULL, /* wine_get_vulkan_driver */ GDI_PRIORITY_GRAPHICS_DRV /* priority */ diff --git a/dlls/winex11.drv/init.c b/dlls/winex11.drv/init.c index 28c81a2638..0040dbb430 100644 --- a/dlls/winex11.drv/init.c +++ b/dlls/winex11.drv/init.c @@ -471,6 +471,8 @@ static const struct gdi_dc_funcs x11drv_funcs = X11DRV_StrokePath, /* pStrokePath */ X11DRV_UnrealizePalette, /* pUnrealizePalette */ NULL, /* pWidenPath */ + NULL, /* pD3DKMTCheckVidPnExclusiveOwnership */ + NULL, /* pD3DKMTSetVidPnSourceOwner */ X11DRV_wine_get_wgl_driver, /* wine_get_wgl_driver */ X11DRV_wine_get_vulkan_driver, /* wine_get_vulkan_driver */ GDI_PRIORITY_GRAPHICS_DRV /* priority */ diff --git a/dlls/winex11.drv/xrender.c b/dlls/winex11.drv/xrender.c index 311ecb58b7..8bb7d56a77 100644 --- a/dlls/winex11.drv/xrender.c +++ b/dlls/winex11.drv/xrender.c @@ -2284,6 +2284,8 @@ static const struct gdi_dc_funcs xrender_funcs = NULL, /* pStrokePath */ NULL, /* pUnrealizePalette */ NULL, /* pWidenPath */ + NULL, /* pD3DKMTCheckVidPnExclusiveOwnership */ + NULL, /* pD3DKMTSetVidPnSourceOwner */ NULL, /* wine_get_wgl_driver */ NULL, /* wine_get_vulkan_driver */ GDI_PRIORITY_GRAPHICS_DRV + 10 /* priority */ diff --git a/include/ddk/d3dkmthk.h b/include/ddk/d3dkmthk.h index ea4df3a9e0..6d6a1d68cd 100644 --- a/include/ddk/d3dkmthk.h +++ b/include/ddk/d3dkmthk.h @@ -602,6 +602,7 @@ extern "C" { #endif /* __cplusplus */
+NTSTATUS WINAPI D3DKMTCheckVidPnExclusiveOwnership(const D3DKMT_CHECKVIDPNEXCLUSIVEOWNERSHIP *desc); NTSTATUS WINAPI D3DKMTCloseAdapter(const D3DKMT_CLOSEADAPTER *desc); NTSTATUS WINAPI D3DKMTCreateDevice(D3DKMT_CREATEDEVICE *desc); NTSTATUS WINAPI D3DKMTCreateDCFromMemory(D3DKMT_CREATEDCFROMMEMORY *desc); @@ -609,6 +610,7 @@ NTSTATUS WINAPI D3DKMTDestroyDCFromMemory(const D3DKMT_DESTROYDCFROMMEMORY *desc NTSTATUS WINAPI D3DKMTDestroyDevice(const D3DKMT_DESTROYDEVICE *desc); NTSTATUS WINAPI D3DKMTOpenAdapterFromGdiDisplayName(D3DKMT_OPENADAPTERFROMGDIDISPLAYNAME *desc); NTSTATUS WINAPI D3DKMTQueryStatistics(D3DKMT_QUERYSTATISTICS *stats); +NTSTATUS WINAPI D3DKMTSetVidPnSourceOwner(const D3DKMT_SETVIDPNSOURCEOWNER *desc);
#ifdef __cplusplus } diff --git a/include/wine/gdi_driver.h b/include/wine/gdi_driver.h index 53881b5932..971618e19a 100644 --- a/include/wine/gdi_driver.h +++ b/include/wine/gdi_driver.h @@ -21,6 +21,8 @@ #ifndef __WINE_WINE_GDI_DRIVER_H #define __WINE_WINE_GDI_DRIVER_H
+#include "winternl.h" +#include "ddk/d3dkmthk.h" #include "wine/list.h"
struct gdi_dc_funcs; @@ -192,6 +194,8 @@ struct gdi_dc_funcs BOOL (CDECL *pStrokePath)(PHYSDEV); BOOL (CDECL *pUnrealizePalette)(HPALETTE); BOOL (CDECL *pWidenPath)(PHYSDEV); + NTSTATUS (CDECL *pD3DKMTCheckVidPnExclusiveOwnership)(const D3DKMT_CHECKVIDPNEXCLUSIVEOWNERSHIP *); + NTSTATUS (CDECL *pD3DKMTSetVidPnSourceOwner)(const D3DKMT_SETVIDPNSOURCEOWNER *); struct opengl_funcs * (CDECL *wine_get_wgl_driver)(PHYSDEV,UINT); const struct vulkan_funcs * (CDECL *wine_get_vulkan_driver)(PHYSDEV,UINT);
@@ -200,7 +204,7 @@ struct gdi_dc_funcs };
/* increment this when you change the DC function table */ -#define WINE_GDI_DRIVER_VERSION 50 +#define WINE_GDI_DRIVER_VERSION 51
#define GDI_PRIORITY_NULL_DRV 0 /* null driver */ #define GDI_PRIORITY_FONT_DRV 100 /* any font driver */