[vlc-commits] vout: direct3d11: clean the wait until all the commands are processed

Steve Lhomme git at videolan.org
Fri Aug 14 09:05:47 CEST 2020


vlc/vlc-3.0 | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Wed Aug  5 09:25:31 2020 +0200| [73e2eea5418be7e6e445975795b8aedd2e167a09] | committer: Steve Lhomme

vout: direct3d11: clean the wait until all the commands are processed

We need to unlock the device context while we wait until it's finished with our
commands. As it may block all decoder threads for 2ms or (a lot) more. The
decoder may have a chance to send some decoding commands and we may wait longer
when locking back the device context. This won't have much influence on when
the picture is finished rendering as it won't wait for potential new commands
that have been sent to the video context.

We don't need to lock the device context in PreparePicture, it's already locked.

Use a ID3D11Asynchronous pointer directly. We don't need to know the underlying
type, except when creating it.

(cherry picked from commit cb15167c1c84597923bfb0a428217637d2f7dd82) (edited)

edited:
- this branch uses a local d3d11_device_t instead of a pointer
- the locking is conditional in this branch
- there is no PreparePicture in this branch, just Prepare

Signed-off-by: Steve Lhomme <robux4 at ycbcr.xyz>

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

 modules/video_output/win32/direct3d11.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index af11e939a9..8404c96114 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -98,7 +98,7 @@ struct vout_display_sys_t
     d3d11_device_t           d3d_dev;
     d3d_quad_t               picQuad;
 
-    ID3D11Query              *prepareWait;
+    ID3D11Asynchronous       *prepareWait;
 
     picture_sys_t            stagingSys;
 
@@ -996,12 +996,18 @@ static void Prepare(vout_display_t *vd, picture_t *picture, subpicture_t *subpic
     if (sys->prepareWait)
     {
         int maxWait = 10;
-        ID3D11DeviceContext_End(sys->d3d_dev.d3dcontext, (ID3D11Asynchronous*)sys->prepareWait);
+        ID3D11DeviceContext_End(sys->d3d_dev.d3dcontext, sys->prepareWait);
 
         while (S_FALSE == ID3D11DeviceContext_GetData(sys->d3d_dev.d3dcontext,
-                                                      (ID3D11Asynchronous*)sys->prepareWait, NULL, 0, 0)
+                                                      sys->prepareWait, NULL, 0, 0)
                && --maxWait)
+        {
+            if (is_d3d11_opaque(picture->format.i_chroma))
+                d3d11_device_unlock( &sys->d3d_dev );
             SleepEx(2, TRUE);
+            if (is_d3d11_opaque(picture->format.i_chroma))
+                d3d11_device_lock( &sys->d3d_dev );
+        }
     }
 
     if (is_d3d11_opaque(picture->format.i_chroma))
@@ -1600,7 +1606,7 @@ static int Direct3D11CreateGenericResources(vout_display_t *vd)
 
     D3D11_QUERY_DESC query = { 0 };
     query.Query = D3D11_QUERY_EVENT;
-    hr = ID3D11Device_CreateQuery(sys->d3d_dev.d3ddevice, &query, &sys->prepareWait);
+    hr = ID3D11Device_CreateQuery(sys->d3d_dev.d3ddevice, &query, (ID3D11Query**)&sys->prepareWait);
 
     ID3D11BlendState *pSpuBlendState;
     D3D11_BLEND_DESC spuBlendDesc = { 0 };



More information about the vlc-commits mailing list