[vlc-commits] d3d11: move the D3D11DeviceContext mutex storage in d3d11_device_t

Steve Lhomme git at videolan.org
Mon May 28 13:24:48 CEST 2018


vlc | branch: master | Steve Lhomme <robux4 at videolabs.io> | Thu Nov 30 11:22:06 2017 +0100| [369cf77c1fffe86f0e8e99404f1990dd8c4c1869] | committer: Steve Lhomme

d3d11: move the D3D11DeviceContext mutex storage in d3d11_device_t

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

 modules/codec/avcodec/d3d11va.c         |  6 ++----
 modules/hw/d3d11/d3d11_deinterlace.c    | 11 +++++------
 modules/hw/d3d11/d3d11_filters.c        | 11 +++++------
 modules/video_chroma/d3d11_fmt.h        |  1 +
 modules/video_output/win32/direct3d11.c | 31 ++++++++++++++-----------------
 5 files changed, 27 insertions(+), 33 deletions(-)

diff --git a/modules/codec/avcodec/d3d11va.c b/modules/codec/avcodec/d3d11va.c
index 7201b599bf..feea28ab0b 100644
--- a/modules/codec/avcodec/d3d11va.c
+++ b/modules/codec/avcodec/d3d11va.c
@@ -111,8 +111,6 @@ struct vlc_va_sys_t
     ID3D11VideoContext           *d3dvidctx;
     DXGI_FORMAT                  render;
 
-    HANDLE                       context_mutex;
-
     /* pool */
     picture_t                    *extern_pics[MAX_SURFACE_COUNT];
 
@@ -150,7 +148,7 @@ void SetupAVCodecContext(vlc_va_t *va)
     sys->hw.cfg = &sys->cfg;
     sys->hw.surface_count = dx_sys->va_pool.surface_count;
     sys->hw.surface = dx_sys->hw_surface;
-    sys->hw.context_mutex = sys->context_mutex;
+    sys->hw.context_mutex = sys->d3d_dev.context_mutex;
 
     if (IsEqualGUID(&dx_sys->input, &DXVA_Intel_H264_NoFGT_ClearVideo))
         sys->hw.workaround |= FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO;
@@ -354,7 +352,7 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt,
             hr = ID3D11Device_GetPrivateData(sys->d3d_dev.d3ddevice, &GUID_CONTEXT_MUTEX, &dataSize, &context_lock);
             if (FAILED(hr))
                 msg_Warn(va, "No mutex found to lock the decoder");
-            sys->context_mutex = context_lock;
+            sys->d3d_dev.context_mutex = context_lock;
 
             sys->d3d_dev.d3dcontext = p_sys->context;
             sys->d3d_dev.owner = false;
diff --git a/modules/hw/d3d11/d3d11_deinterlace.c b/modules/hw/d3d11/d3d11_deinterlace.c
index 6e3de6f8aa..f0ede6d8b8 100644
--- a/modules/hw/d3d11/d3d11_deinterlace.c
+++ b/modules/hw/d3d11/d3d11_deinterlace.c
@@ -58,7 +58,6 @@ typedef struct
     ID3D11VideoProcessor           *videoProcessor;
     ID3D11VideoProcessorEnumerator *procEnumerator;
 
-    HANDLE                         context_mutex;
     union {
         ID3D11Texture2D            *outTexture;
         ID3D11Resource             *outResource;
@@ -229,13 +228,13 @@ static picture_t *Deinterlace(filter_t *p_filter, picture_t *p_pic)
 {
     filter_sys_t *p_sys = p_filter->p_sys;
 
-    if( p_sys->context_mutex != INVALID_HANDLE_VALUE )
-        WaitForSingleObjectEx( p_sys->context_mutex, INFINITE, FALSE );
+    if( p_sys->d3d_dev.context_mutex != INVALID_HANDLE_VALUE )
+        WaitForSingleObjectEx( p_sys->d3d_dev.context_mutex, INFINITE, FALSE );
 
     picture_t *res = DoDeinterlacing( p_filter, &p_sys->context, p_pic );
 
-    if( p_sys->context_mutex  != INVALID_HANDLE_VALUE )
-        ReleaseMutex( p_sys->context_mutex );
+    if( p_sys->d3d_dev.context_mutex  != INVALID_HANDLE_VALUE )
+        ReleaseMutex( p_sys->d3d_dev.context_mutex );
 
     return res;
 }
@@ -390,7 +389,7 @@ int D3D11OpenDeinterlace(vlc_object_t *obj)
     hr = ID3D11Device_GetPrivateData(sys->d3d_dev.d3ddevice, &GUID_CONTEXT_MUTEX, &dataSize, &context_lock);
     if (FAILED(hr))
         msg_Warn(filter, "No mutex found to lock the decoder");
-    sys->context_mutex = context_lock;
+    sys->d3d_dev.context_mutex = context_lock;
 
     const video_format_t *fmt = &filter->fmt_out.video;
 
diff --git a/modules/hw/d3d11/d3d11_filters.c b/modules/hw/d3d11/d3d11_filters.c
index d400cabd6a..dca642baac 100644
--- a/modules/hw/d3d11/d3d11_filters.c
+++ b/modules/hw/d3d11/d3d11_filters.c
@@ -75,7 +75,6 @@ typedef struct
     ID3D11VideoProcessor           *videoProcessor;
     ID3D11VideoProcessorEnumerator *procEnumerator;
 
-    HANDLE                         context_mutex;
     union {
         ID3D11Texture2D            *texture;
         ID3D11Resource             *resource;
@@ -247,8 +246,8 @@ static picture_t *Filter(filter_t *p_filter, picture_t *p_pic)
 
     picture_CopyProperties( p_outpic, p_pic );
 
-    if( p_sys->context_mutex != INVALID_HANDLE_VALUE )
-        WaitForSingleObjectEx( p_sys->context_mutex, INFINITE, FALSE );
+    if( p_sys->d3d_dev.context_mutex != INVALID_HANDLE_VALUE )
+        WaitForSingleObjectEx( p_sys->d3d_dev.context_mutex, INFINITE, FALSE );
 
     ID3D11VideoProcessorInputView *inputs[4] = {
         p_src_sys->processorInput,
@@ -319,8 +318,8 @@ static picture_t *Filter(filter_t *p_filter, picture_t *p_pic)
                                                   NULL);
     }
 
-    if( p_sys->context_mutex  != INVALID_HANDLE_VALUE )
-        ReleaseMutex( p_sys->context_mutex );
+    if( p_sys->d3d_dev.context_mutex  != INVALID_HANDLE_VALUE )
+        ReleaseMutex( p_sys->d3d_dev.context_mutex );
 
     picture_Release( p_pic );
     return p_outpic;
@@ -387,7 +386,7 @@ static int D3D11OpenAdjust(vlc_object_t *obj)
     hr = ID3D11Device_GetPrivateData(sys->d3d_dev.d3ddevice, &GUID_CONTEXT_MUTEX, &dataSize, &context_lock);
     if (FAILED(hr))
         msg_Warn(filter, "No mutex found to lock the decoder");
-    sys->context_mutex = context_lock;
+    sys->d3d_dev.context_mutex = context_lock;
 
     const video_format_t *fmt = &filter->fmt_out.video;
 
diff --git a/modules/video_chroma/d3d11_fmt.h b/modules/video_chroma/d3d11_fmt.h
index 26e6acbd0f..fd998b9571 100644
--- a/modules/video_chroma/d3d11_fmt.h
+++ b/modules/video_chroma/d3d11_fmt.h
@@ -40,6 +40,7 @@ typedef struct
     ID3D11Device             *d3ddevice;       /* D3D device */
     ID3D11DeviceContext      *d3dcontext;      /* D3D context */
     bool                     owner;
+    HANDLE                   context_mutex;
     struct wddm_version      WDDM;
     D3D_FEATURE_LEVEL        feature_level;
 } d3d11_device_t;
diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index 3a88ea5706..04794620cd 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -151,10 +151,6 @@ struct vout_display_sys_t
     HINSTANCE                hd3dcompiler_dll; /* handle of the opened d3dcompiler dll */
     pD3DCompile                            OurD3DCompile;
 #endif
-#if defined(HAVE_ID3D11VIDEODECODER)
-    HANDLE                   context_lock;     /* D3D11 Context lock necessary
-                                                  for hw decoding */
-#endif
     IDXGISwapChain1          *dxgiswapChain;   /* DXGI 1.2 swap chain */
     IDXGISwapChain4          *dxgiswapChain4;  /* DXGI 1.5 for HDR */
     d3d11_device_t           d3d_dev;
@@ -988,9 +984,9 @@ static void UpdateSize(vout_display_t *vd)
     UpdateBackBuffer(vd);
 
 #if defined(HAVE_ID3D11VIDEODECODER)
-    if( sys->context_lock != INVALID_HANDLE_VALUE )
+    if( sys->d3d_dev.context_mutex != INVALID_HANDLE_VALUE )
     {
-        WaitForSingleObjectEx( sys->context_lock, INFINITE, FALSE );
+        WaitForSingleObjectEx( sys->d3d_dev.context_mutex, INFINITE, FALSE );
     }
 #endif
 
@@ -1000,9 +996,9 @@ static void UpdateSize(vout_display_t *vd)
                        vd->fmt.orientation);
 
 #if defined(HAVE_ID3D11VIDEODECODER)
-    if( sys->context_lock != INVALID_HANDLE_VALUE )
+    if( sys->d3d_dev.context_mutex != INVALID_HANDLE_VALUE )
     {
-        ReleaseMutex( sys->context_lock );
+        ReleaseMutex( sys->d3d_dev.context_mutex );
     }
 #endif
 }
@@ -1196,8 +1192,8 @@ static void Prepare(vout_display_t *vd, picture_t *picture,
         picture_sys_t *p_sys = ActivePictureSys(picture);
 
 #if defined(HAVE_ID3D11VIDEODECODER)
-        if (sys->context_lock != INVALID_HANDLE_VALUE && is_d3d11_opaque(picture->format.i_chroma))
-            WaitForSingleObjectEx( sys->context_lock, INFINITE, FALSE );
+        if (sys->d3d_dev.context_mutex != INVALID_HANDLE_VALUE && is_d3d11_opaque(picture->format.i_chroma))
+            WaitForSingleObjectEx( sys->d3d_dev.context_mutex, INFINITE, FALSE );
 #endif
         if (!is_d3d11_opaque(picture->format.i_chroma) || sys->legacy_shader) {
             D3D11_TEXTURE2D_DESC srcDesc,texDesc;
@@ -1303,9 +1299,9 @@ static void Prepare(vout_display_t *vd, picture_t *picture,
     }
 
 #if defined(HAVE_ID3D11VIDEODECODER)
-    if (sys->context_lock != INVALID_HANDLE_VALUE && is_d3d11_opaque(picture->format.i_chroma))
+    if (sys->d3d_dev.context_mutex != INVALID_HANDLE_VALUE && is_d3d11_opaque(picture->format.i_chroma))
     {
-        ReleaseMutex( sys->context_lock );
+        ReleaseMutex( sys->d3d_dev.context_mutex );
     }
 #endif
 
@@ -2151,8 +2147,9 @@ static int Direct3D11CreateGenericResources(vout_display_t *vd)
     HRESULT hr;
 
 #if defined(HAVE_ID3D11VIDEODECODER)
-    sys->context_lock = CreateMutexEx( NULL, NULL, 0, SYNCHRONIZE );
-    ID3D11Device_SetPrivateData( sys->d3d_dev.d3ddevice, &GUID_CONTEXT_MUTEX, sizeof( sys->context_lock ), &sys->context_lock );
+    sys->d3d_dev.context_mutex = CreateMutexEx( NULL, NULL, 0, SYNCHRONIZE );
+    ID3D11Device_SetPrivateData( sys->d3d_dev.d3ddevice, &GUID_CONTEXT_MUTEX,
+                                 sizeof( sys->d3d_dev.context_mutex ), &sys->d3d_dev.context_mutex );
 #endif
 
     ID3D11BlendState *pSpuBlendState;
@@ -3036,10 +3033,10 @@ static void Direct3D11DestroyResources(vout_display_t *vd)
         sys->picQuadPixelShader = NULL;
     }
 #if defined(HAVE_ID3D11VIDEODECODER)
-    if( sys->context_lock != INVALID_HANDLE_VALUE )
+    if( sys->d3d_dev.context_mutex != INVALID_HANDLE_VALUE )
     {
-        CloseHandle( sys->context_lock );
-        sys->context_lock = INVALID_HANDLE_VALUE;
+        CloseHandle( sys->d3d_dev.context_mutex );
+        sys->d3d_dev.context_mutex = INVALID_HANDLE_VALUE;
     }
 #endif
 



More information about the vlc-commits mailing list