[vlc-commits] direct3d11: wait until the rendering is done before we leave Prepare()

Steve Lhomme git at videolan.org
Mon Nov 26 16:39:20 CET 2018


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Mon Nov 26 16:37:58 2018 +0100| [f389e8b0bb25d62550031ca62611ffe24ea9f953] | committer: Steve Lhomme

direct3d11: wait until the rendering is done before we leave Prepare()

And don't Flush() the device context. It's considered harmful.

This will improve the Display() call timing.

It also improves lags with Intel on high bitrate sources in multithread.

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

 modules/video_output/win32/direct3d11.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index 69f20bc52f..c8e383e042 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -97,6 +97,8 @@ struct vout_display_sys_t
     d3d11_device_t           d3d_dev;
     d3d_quad_t               picQuad;
 
+    ID3D11Query              *prepareWait;
+
     picture_sys_t            stagingSys;
 
     ID3D11RenderTargetView   *swapchainTargetView[D3D11_MAX_SHADER_VIEW];
@@ -931,7 +933,16 @@ static void PreparePicture(vout_display_t *vd, picture_t *picture, subpicture_t
         }
     }
 
-    ID3D11DeviceContext_Flush(sys->d3d_dev.d3dcontext);
+    if (sys->prepareWait)
+    {
+        int maxWait = 10;
+        ID3D11DeviceContext_End(sys->d3d_dev.d3dcontext, (ID3D11Asynchronous*)sys->prepareWait);
+
+        while (S_FALSE == ID3D11DeviceContext_GetData(sys->d3d_dev.d3dcontext,
+                                                      (ID3D11Asynchronous*)sys->prepareWait, NULL, 0, 0)
+               && --maxWait)
+            SleepEx(2, TRUE);
+    }
 
     if (is_d3d11_opaque(picture->format.i_chroma))
         d3d11_device_unlock( &sys->d3d_dev );
@@ -1510,6 +1521,10 @@ static int Direct3D11CreateGenericResources(vout_display_t *vd)
     vout_display_sys_t *sys = vd->sys;
     HRESULT hr;
 
+    D3D11_QUERY_DESC query = { 0 };
+    query.Query = D3D11_QUERY_EVENT;
+    hr = ID3D11Device_CreateQuery(sys->d3d_dev.d3ddevice, &query, &sys->prepareWait);
+
     ID3D11BlendState *pSpuBlendState;
     D3D11_BLEND_DESC spuBlendDesc = { 0 };
     spuBlendDesc.RenderTarget[0].BlendEnable = TRUE;
@@ -1616,6 +1631,11 @@ static void Direct3D11DestroyResources(vout_display_t *vd)
             sys->swapchainTargetView[i] = NULL;
         }
     }
+    if (sys->prepareWait)
+    {
+        ID3D11Query_Release(sys->prepareWait);
+        sys->prepareWait = NULL;
+    }
 
     msg_Dbg(vd, "Direct3D11 resources destroyed");
 }



More information about the vlc-commits mailing list