[vlc-commits] d3d11_fmt: move the forced check in D3D11_CreateDevice

Steve Lhomme git at videolan.org
Wed Feb 12 17:09:11 CET 2020


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Wed Feb 12 13:41:12 2020 +0100| [14a91cb6193469b2b7767f938abde916f9f1f373] | committer: Steve Lhomme

d3d11_fmt: move the forced check in D3D11_CreateDevice

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

 modules/hw/d3d11/d3d11_device.c         | 15 +--------------
 modules/video_chroma/d3d11_fmt.c        | 17 +++++++++++++----
 modules/video_chroma/d3d11_fmt.h        |  4 ++--
 modules/video_output/win32/direct3d11.c | 15 +--------------
 4 files changed, 17 insertions(+), 34 deletions(-)

diff --git a/modules/hw/d3d11/d3d11_device.c b/modules/hw/d3d11/d3d11_device.c
index d5777bc23d..5014716603 100644
--- a/modules/hw/d3d11/d3d11_device.c
+++ b/modules/hw/d3d11/d3d11_device.c
@@ -114,22 +114,9 @@ static int D3D11OpenDecoderDevice(vlc_decoder_device *device, bool forced, vout_
         else
         {
             /* internal decoder device */
-#if !VLC_WINSTORE_APP
-            if (!forced)
-            {
-                /* Allow using D3D11 automatically starting from Windows 8.1 */
-                bool isWin81OrGreater = false;
-                HMODULE hKernel32 = GetModuleHandle(TEXT("kernel32.dll"));
-                if (likely(hKernel32 != NULL))
-                    isWin81OrGreater = GetProcAddress(hKernel32, "IsProcessCritical") != NULL;
-                if (!isWin81OrGreater)
-                    goto error;
-            }
-#endif /* !VLC_WINSTORE_APP */
-
             hr = D3D11_CreateDevice( device, &sys->hd3d, NULL,
                                      true /* is_d3d11_opaque(chroma) */,
-                                     &sys->dec_device.d3d_dev );
+                                     forced, &sys->dec_device.d3d_dev );
         }
     }
 
diff --git a/modules/video_chroma/d3d11_fmt.c b/modules/video_chroma/d3d11_fmt.c
index f00c9a4a23..8c5da25aef 100644
--- a/modules/video_chroma/d3d11_fmt.c
+++ b/modules/video_chroma/d3d11_fmt.c
@@ -288,12 +288,21 @@ HRESULT D3D11_CreateDeviceExternal(vlc_object_t *obj, ID3D11DeviceContext *d3d11
     return S_OK;
 }
 
-#undef D3D11_CreateDevice
-HRESULT D3D11_CreateDevice(vlc_object_t *obj, d3d11_handle_t *hd3d,
-                           IDXGIAdapter *adapter,
-                           bool hw_decoding, d3d11_device_t *out)
+HRESULT (D3D11_CreateDevice)(vlc_object_t *obj, d3d11_handle_t *hd3d,
+                             IDXGIAdapter *adapter,
+                             bool hw_decoding, bool forced, d3d11_device_t *out)
 {
 #if !VLC_WINSTORE_APP
+    if (!forced)
+    {
+        /* Allow using D3D11 automatically starting from Windows 8.1 */
+        bool isWin81OrGreater = false;
+        HMODULE hKernel32 = GetModuleHandle(TEXT("kernel32.dll"));
+        if (likely(hKernel32 != NULL))
+            isWin81OrGreater = GetProcAddress(hKernel32, "IsProcessCritical") != NULL;
+        if (!isWin81OrGreater)
+            return E_FAIL;
+    }
 # define D3D11CreateDevice(args...)             pf_CreateDevice(args)
     /* */
     PFN_D3D11_CREATE_DEVICE pf_CreateDevice;
diff --git a/modules/video_chroma/d3d11_fmt.h b/modules/video_chroma/d3d11_fmt.h
index 6244418dac..b9ad54c549 100644
--- a/modules/video_chroma/d3d11_fmt.h
+++ b/modules/video_chroma/d3d11_fmt.h
@@ -148,8 +148,8 @@ int D3D11_AllocateResourceView(vlc_object_t *obj, ID3D11Device *d3ddevice,
 #define D3D11_AllocateResourceView(a,b,c,d,e,f)  D3D11_AllocateResourceView(VLC_OBJECT(a),b,c,d,e,f)
 
 HRESULT D3D11_CreateDevice(vlc_object_t *obj, d3d11_handle_t *, IDXGIAdapter *,
-                           bool hw_decoding, d3d11_device_t *out);
-#define D3D11_CreateDevice(a,b,c,d,e)  D3D11_CreateDevice( VLC_OBJECT(a), b, c, d, e )
+                           bool hw_decoding, bool forced, d3d11_device_t *out);
+#define D3D11_CreateDevice(a,b,c,d,e,f)  D3D11_CreateDevice( VLC_OBJECT(a), b, c, d, e, f )
 HRESULT D3D11_CreateDeviceExternal(vlc_object_t *obj, ID3D11DeviceContext *,
                                    bool hw_decoding, d3d11_device_t *out);
 #define D3D11_CreateDeviceExternal(a,b,c,d) \
diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index 0e3e0c8696..21c98231b4 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -291,19 +291,6 @@ static void UpdateSize(vout_display_t *vd)
 static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
                 video_format_t *fmtp, vlc_video_context *context)
 {
-#if !VLC_WINSTORE_APP
-    /* Allow using D3D11 automatically starting from Windows 8.1 */
-    if (!vd->obj.force)
-    {
-        bool isWin81OrGreater = false;
-        HMODULE hKernel32 = GetModuleHandle(TEXT("kernel32.dll"));
-        if (likely(hKernel32 != NULL))
-            isWin81OrGreater = GetProcAddress(hKernel32, "IsProcessCritical") != NULL;
-        if (!isWin81OrGreater)
-            return VLC_EGENERIC;
-    }
-#endif
-
     vout_display_sys_t *sys = vd->sys = vlc_obj_calloc(VLC_OBJECT(vd), 1, sizeof(vout_display_sys_t));
     if (!sys)
         return VLC_ENOMEM;
@@ -333,7 +320,7 @@ static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
     else
     {
         // No d3d11 device, we create one
-        HRESULT hr = D3D11_CreateDevice(vd, &sys->hd3d, NULL, false, &sys->local_d3d_dev);
+        HRESULT hr = D3D11_CreateDevice(vd, &sys->hd3d, NULL, false, vd->obj.force, &sys->local_d3d_dev);
         if (FAILED(hr)) {
             msg_Err(vd, "Could not Create the D3D11 device. (hr=0x%lX)", hr);
             goto error;



More information about the vlc-commits mailing list