vlc | branch: master | Steve Lhomme <[email protected]> | Thu Nov 30 14:20:47 2017 +0100| [717daca1c62f298902db807ae6eee82a32d6890d] | committer: Steve Lhomme
d3d11_fmt: add helpers to lock/unlock the D3D11VideoContext > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=717daca1c62f298902db807ae6eee82a32d6890d --- modules/hw/d3d11/d3d11_deinterlace.c | 6 ++---- modules/hw/d3d11/d3d11_filters.c | 8 +++----- modules/video_chroma/d3d11_fmt.h | 12 ++++++++++++ modules/video_output/win32/direct3d11.c | 29 +++++++---------------------- 4 files changed, 24 insertions(+), 31 deletions(-) diff --git a/modules/hw/d3d11/d3d11_deinterlace.c b/modules/hw/d3d11/d3d11_deinterlace.c index f0ede6d8b8..e385f8213c 100644 --- a/modules/hw/d3d11/d3d11_deinterlace.c +++ b/modules/hw/d3d11/d3d11_deinterlace.c @@ -228,13 +228,11 @@ static picture_t *Deinterlace(filter_t *p_filter, picture_t *p_pic) { filter_sys_t *p_sys = p_filter->p_sys; - if( p_sys->d3d_dev.context_mutex != INVALID_HANDLE_VALUE ) - WaitForSingleObjectEx( p_sys->d3d_dev.context_mutex, INFINITE, FALSE ); + d3d11_device_lock( &p_sys->d3d_dev ); picture_t *res = DoDeinterlacing( p_filter, &p_sys->context, p_pic ); - if( p_sys->d3d_dev.context_mutex != INVALID_HANDLE_VALUE ) - ReleaseMutex( p_sys->d3d_dev.context_mutex ); + d3d11_device_unlock( &p_sys->d3d_dev ); return res; } diff --git a/modules/hw/d3d11/d3d11_filters.c b/modules/hw/d3d11/d3d11_filters.c index dca642baac..369a624520 100644 --- a/modules/hw/d3d11/d3d11_filters.c +++ b/modules/hw/d3d11/d3d11_filters.c @@ -246,9 +246,6 @@ static picture_t *Filter(filter_t *p_filter, picture_t *p_pic) picture_CopyProperties( p_outpic, p_pic ); - 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, p_sys->procInput[0], @@ -263,6 +260,8 @@ static picture_t *Filter(filter_t *p_filter, picture_t *p_pic) p_sys->procOutput[1] }; + d3d11_device_lock( &p_sys->d3d_dev ); + size_t idx = 0, count = 0; /* contrast */ if ( ApplyFilter( p_sys, @@ -318,8 +317,7 @@ static picture_t *Filter(filter_t *p_filter, picture_t *p_pic) NULL); } - if( p_sys->d3d_dev.context_mutex != INVALID_HANDLE_VALUE ) - ReleaseMutex( p_sys->d3d_dev.context_mutex ); + d3d11_device_unlock( &p_sys->d3d_dev ); picture_Release( p_pic ); return p_outpic; diff --git a/modules/video_chroma/d3d11_fmt.h b/modules/video_chroma/d3d11_fmt.h index fd998b9571..ba10ddfb81 100644 --- a/modules/video_chroma/d3d11_fmt.h +++ b/modules/video_chroma/d3d11_fmt.h @@ -141,4 +141,16 @@ void D3D11_LogProcessorSupport(vlc_object_t*, ID3D11VideoProcessorEnumerator*); #define D3D11_LogProcessorSupport(a,b) D3D11_LogProcessorSupport( VLC_OBJECT(a), b ) #endif +static inline void d3d11_device_lock(d3d11_device_t *d3d_dev) +{ + if( d3d_dev->context_mutex != INVALID_HANDLE_VALUE ) + WaitForSingleObjectEx( d3d_dev->context_mutex, INFINITE, FALSE ); +} + +static inline void d3d11_device_unlock(d3d11_device_t *d3d_dev) +{ + if( d3d_dev->context_mutex != INVALID_HANDLE_VALUE ) + ReleaseMutex( d3d_dev->context_mutex ); +} + #endif /* include-guard */ diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c index 04794620cd..3319f703f9 100644 --- a/modules/video_output/win32/direct3d11.c +++ b/modules/video_output/win32/direct3d11.c @@ -983,24 +983,14 @@ static void UpdateSize(vout_display_t *vd) UpdateBackBuffer(vd); -#if defined(HAVE_ID3D11VIDEODECODER) - if( sys->d3d_dev.context_mutex != INVALID_HANDLE_VALUE ) - { - WaitForSingleObjectEx( sys->d3d_dev.context_mutex, INFINITE, FALSE ); - } -#endif + d3d11_device_lock( &sys->d3d_dev ); UpdatePicQuadPosition(vd); UpdateQuadPosition(vd, &sys->picQuad, &sys->sys.rect_src_clipped, vd->fmt.orientation); -#if defined(HAVE_ID3D11VIDEODECODER) - if( sys->d3d_dev.context_mutex != INVALID_HANDLE_VALUE ) - { - ReleaseMutex( sys->d3d_dev.context_mutex ); - } -#endif + d3d11_device_unlock( &sys->d3d_dev ); } static inline bool RectEquals(const RECT *r1, const RECT *r2) @@ -1191,10 +1181,9 @@ static void Prepare(vout_display_t *vd, picture_t *picture, { picture_sys_t *p_sys = ActivePictureSys(picture); -#if defined(HAVE_ID3D11VIDEODECODER) - 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)) + d3d11_device_lock( &sys->d3d_dev ); + if (!is_d3d11_opaque(picture->format.i_chroma) || sys->legacy_shader) { D3D11_TEXTURE2D_DESC srcDesc,texDesc; if (!is_d3d11_opaque(picture->format.i_chroma)) @@ -1298,12 +1287,8 @@ static void Prepare(vout_display_t *vd, picture_t *picture, } } -#if defined(HAVE_ID3D11VIDEODECODER) - if (sys->d3d_dev.context_mutex != INVALID_HANDLE_VALUE && is_d3d11_opaque(picture->format.i_chroma)) - { - ReleaseMutex( sys->d3d_dev.context_mutex ); - } -#endif + if (is_d3d11_opaque(picture->format.i_chroma)) + d3d11_device_unlock( &sys->d3d_dev ); ID3D11DeviceContext_Flush(sys->d3d_dev.d3dcontext); } _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
