[vlc-commits] direct3d11: set the HWND to use for the internal Swapchain

Steve Lhomme git at videolan.org
Tue Apr 30 16:24:11 CEST 2019


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Thu Apr 18 16:40:57 2019 +0200| [e98c9e26081c21ed20b5b6b6affb6851be9d0ad8] | committer: Steve Lhomme

direct3d11: set the HWND to use for the internal Swapchain

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e98c9e26081c21ed20b5b6b6affb6851be9d0ad8
---

 modules/video_output/win32/direct3d11.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index 72ad84ba74..d8b890045c 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -91,6 +91,7 @@ struct d3d11_local_swapchain
 {
     vlc_object_t           *obj;
 
+    HWND                   swapchainHwnd;
     IDXGISwapChain1        *dxgiswapChain;   /* DXGI 1.2 swap chain */
     IDXGISwapChain4        *dxgiswapChain4;  /* DXGI 1.5 for HDR metadata */
 
@@ -320,6 +321,13 @@ static void FillSwapChainDesc(vout_display_t *vd, DXGI_SWAP_CHAIN_DESC1 *out)
 static int SetupWindowedOutput(vout_display_t *vd)
 {
     vout_display_sys_t *sys = vd->sys;
+
+    if (sys->internal_swapchain.swapchainHwnd == NULL)
+    {
+        msg_Err(vd, "missing a HWND to create the swapchain");
+        return VLC_EGENERIC;
+    }
+
     DXGI_SWAP_CHAIN_DESC1 scd;
     HRESULT hr;
 
@@ -338,9 +346,6 @@ static int SetupWindowedOutput(vout_display_t *vd)
         return VLC_EGENERIC;
     }
 
-    if (sys->sys.hvideownd == 0)
-        return VLC_EGENERIC;
-
     FillSwapChainDesc(vd, &scd);
 
     IDXGIAdapter *dxgiadapter = D3D11DeviceAdapter(sys->d3d_dev.d3ddevice);
@@ -357,13 +362,15 @@ static int SetupWindowedOutput(vout_display_t *vd)
     }
 
     hr = IDXGIFactory2_CreateSwapChainForHwnd(dxgifactory, (IUnknown *)sys->d3d_dev.d3ddevice,
-                                              sys->sys.hvideownd, &scd, NULL, NULL, &sys->internal_swapchain.dxgiswapChain);
+                                              sys->internal_swapchain.swapchainHwnd, &scd,
+                                              NULL, NULL, &sys->internal_swapchain.dxgiswapChain);
     if (hr == DXGI_ERROR_INVALID_CALL && scd.Format == DXGI_FORMAT_R10G10B10A2_UNORM)
     {
         msg_Warn(vd, "10 bits swapchain failed, try 8 bits");
         scd.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
         hr = IDXGIFactory2_CreateSwapChainForHwnd(dxgifactory, (IUnknown *)sys->d3d_dev.d3ddevice,
-                                                  sys->sys.hvideownd, &scd, NULL, NULL, &sys->internal_swapchain.dxgiswapChain);
+                                                  sys->internal_swapchain.swapchainHwnd, &scd,
+                                                  NULL, NULL, &sys->internal_swapchain.dxgiswapChain);
     }
     IDXGIFactory2_Release(dxgifactory);
     if (FAILED(hr)) {
@@ -462,6 +469,7 @@ static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
         if (CommonInit(VLC_OBJECT(vd), &sys->area, &sys->sys,
                        vd->source.projection_mode != PROJECTION_MODE_RECTANGULAR))
             goto error;
+        sys->internal_swapchain.swapchainHwnd = sys->sys.hvideownd;
 #endif /* !VLC_WINSTORE_APP */
     }
 



More information about the vlc-commits mailing list