[vlc-commits] d3d11: use D3D11_Create and D3D11_Destroy

Steve Lhomme git at videolan.org
Mon Nov 20 19:14:05 CET 2017


vlc | branch: master | Steve Lhomme <robUx4 at videolabs.io> | Sat Nov 18 14:29:23 2017 +0100| [d54b3f1440ada4d3317e3c0797b30ae08279fcbb] | committer: Jean-Baptiste Kempf

d3d11: use D3D11_Create and D3D11_Destroy

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 modules/codec/avcodec/d3d11va.c         |  9 ++++++++-
 modules/video_output/win32/direct3d11.c | 24 ++----------------------
 2 files changed, 10 insertions(+), 23 deletions(-)

diff --git a/modules/codec/avcodec/d3d11va.c b/modules/codec/avcodec/d3d11va.c
index e94b4287e0..0fcc7b6ab1 100644
--- a/modules/codec/avcodec/d3d11va.c
+++ b/modules/codec/avcodec/d3d11va.c
@@ -109,6 +109,7 @@ struct vlc_va_sys_t
     unsigned                     textureWidth;
     unsigned                     textureHeight;
 
+    d3d11_handle_t               hd3d;
     d3d11_device_t               d3d_dev;
 
 #if !defined(NDEBUG) && defined(HAVE_DXGIDEBUG_H)
@@ -311,6 +312,8 @@ static void Close(vlc_va_t *va, void **ctx)
 
     directx_va_Close(va, &sys->dx_sys);
 
+    D3D11_Destroy( &sys->hd3d );
+
 #if !defined(NDEBUG) && defined(HAVE_DXGIDEBUG_H)
     if (sys->dxgidebug_dll)
         FreeLibrary(sys->dxgidebug_dll);
@@ -390,6 +393,10 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt,
         va->sys->textureHeight = fmt->video.i_height;
     }
 
+    err = D3D11_Create( va, &sys->hd3d );
+    if (err != VLC_SUCCESS)
+        goto error;
+
 #if VLC_WINSTORE_APP
     err = directx_va_Open(va, &sys->dx_sys, false);
 #else
@@ -431,7 +438,7 @@ static int D3dCreateDevice(vlc_va_t *va)
     }
 
     /* */
-    hr = D3D11_CreateDevice(va, dx_sys->hdecoder_dll, true, &sys->d3d_dev);
+    hr = D3D11_CreateDevice(va, &sys->hd3d, true, &sys->d3d_dev);
     if (FAILED(hr)) {
         msg_Err(va, "D3D11CreateDevice failed. (hr=0x%lX)", hr);
         return VLC_EGENERIC;
diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index ceb4d34c4c..85eeb643fe 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -139,9 +139,6 @@ struct vout_display_sys_t
     HINSTANCE                hdxgi_dll;        /* handle of the opened dxgi dll */
     d3d11_handle_t           hd3d;
     HINSTANCE                hd3dcompiler_dll; /* handle of the opened d3dcompiler dll */
-    /* We should find a better way to store this or atleast a shorter name */
-    PFN_D3D11_CREATE_DEVICE_AND_SWAP_CHAIN OurD3D11CreateDeviceAndSwapChain;
-    PFN_D3D11_CREATE_DEVICE                OurD3D11CreateDevice;
     pD3DCompile                            OurD3DCompile;
 #endif
 #if defined(HAVE_ID3D11VIDEODECODER)
@@ -418,11 +415,8 @@ static int OpenHwnd(vout_display_t *vd)
     if (!sys)
         return VLC_ENOMEM;
 
-    sys->hd3d.hdll = LoadLibrary(TEXT("D3D11.DLL"));
-    if (!sys->hd3d.hdll) {
-        msg_Warn(vd, "cannot load d3d11.dll, aborting");
+    if (D3D11_Create(vd, &sys->hd3d) != VLC_SUCCESS)
         return VLC_EGENERIC;
-    }
 
     sys->hd3dcompiler_dll = Direct3D11LoadShaderLibrary();
     if (!sys->hd3dcompiler_dll) {
@@ -437,14 +431,6 @@ static int OpenHwnd(vout_display_t *vd)
         Direct3D11Destroy(vd);
         return VLC_EGENERIC;
     }
-
-    sys->OurD3D11CreateDevice =
-        (void *)GetProcAddress(sys->hd3d.hdll, "D3D11CreateDevice");
-    if (!sys->OurD3D11CreateDevice) {
-        msg_Err(vd, "Cannot locate reference to D3D11CreateDevice in d3d11 DLL");
-        Direct3D11Destroy(vd);
-        return VLC_EGENERIC;
-    }
     return VLC_SUCCESS;
 }
 #else
@@ -1242,20 +1228,14 @@ static void Direct3D11Destroy(vout_display_t *vd)
 #if !VLC_WINSTORE_APP
     vout_display_sys_t *sys = vd->sys;
 
-    if (sys->hd3d.hdll)
-        FreeLibrary(sys->hd3d.hdll);
     if (sys->hd3dcompiler_dll)
         FreeLibrary(sys->hd3dcompiler_dll);
 
-    sys->OurD3D11CreateDevice = NULL;
-    sys->OurD3D11CreateDeviceAndSwapChain = NULL;
     sys->OurD3DCompile = NULL;
     sys->hdxgi_dll = NULL;
-    sys->hd3d.hdll = NULL;
     sys->hd3dcompiler_dll = NULL;
-#else
-    VLC_UNUSED(vd);
 #endif
+    D3D11_Destroy( &vd->sys->hd3d );
 }
 
 #if !VLC_WINSTORE_APP



More information about the vlc-commits mailing list