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

Steve Lhomme git at videolan.org
Mon Aug 10 07:30:36 CEST 2020


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Wed Aug  5 09:25:31 2020 +0200| [cb15167c1c84597923bfb0a428217637d2f7dd82] | 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.

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

 modules/video_output/win32/direct3d11.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index 47eecf9582..b6c5fcd7b4 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -100,7 +100,7 @@ struct vout_display_sys_t
     d3d11_shaders_t          shaders;
     d3d_quad_t               picQuad;
 
-    ID3D11Query              *prepareWait;
+    ID3D11Asynchronous       *prepareWait;
 
     picture_sys_d3d11_t      stagingSys;
     plane_t                  stagingPlanes[PICTURE_PLANE_MAX];
@@ -521,8 +521,6 @@ static void PreparePicture(vout_display_t *vd, picture_t *picture, subpicture_t
 {
     vout_display_sys_t *sys = vd->sys;
 
-    d3d11_device_lock( sys->d3d_dev );
-
     if (sys->picQuad.textureFormat->formatTexture == DXGI_FORMAT_UNKNOWN)
     {
         D3D11_MAPPED_SUBRESOURCE mappedResource;
@@ -664,15 +662,17 @@ static void PreparePicture(vout_display_t *vd, picture_t *picture, subpicture_t
     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)
+        {
+            d3d11_device_unlock( sys->d3d_dev );
             SleepEx(2, TRUE);
+            d3d11_device_lock( sys->d3d_dev );
+        }
     }
-
-    d3d11_device_unlock( sys->d3d_dev );
 }
 
 static void Prepare(vout_display_t *vd, picture_t *picture,
@@ -1142,7 +1142,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