[vlc-commits] direct3d11: wait indefinitely for the rendering to be done

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


vlc/vlc-3.0 | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Mon Aug 10 12:13:39 2020 +0200| [ef7ec7dad887da5cba637a05f741a92897859039] | committer: Steve Lhomme

direct3d11: wait indefinitely for the rendering to be done

If we don't, D3D11 complains that we didn't wait for the finished result
matching a ID3D11DeviceContext::End() call.
As long as GetData() returns S_FALSE we can safely wait. Any other value will
exit the loop.

We want the rendering time seen by the vout to be as accurate as possible
rather than stop waiting after some time and pretend the rendering happened
when it didn't.
The granularity of the wait should be as small as possible to have the
rendering time stats as accurate as possible.

(cherry picked from commit ba04276cae760f919a9a61c5dd5eb294e4d26cef) (edited)

edited:
- this branch doesn't have vlc_tick_sleep() but msleep()

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

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

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

diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index 8404c96114..f5973c4de3 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -995,16 +995,15 @@ 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, sys->prepareWait);
 
         while (S_FALSE == ID3D11DeviceContext_GetData(sys->d3d_dev.d3dcontext,
-                                                      sys->prepareWait, NULL, 0, 0)
-               && --maxWait)
+                                                      sys->prepareWait, NULL, 0, 0))
         {
+            const mtime_t render_wait = CLOCK_FREQ / 500; // 2ms
             if (is_d3d11_opaque(picture->format.i_chroma))
                 d3d11_device_unlock( &sys->d3d_dev );
-            SleepEx(2, TRUE);
+            msleep( render_wait );
             if (is_d3d11_opaque(picture->format.i_chroma))
                 d3d11_device_lock( &sys->d3d_dev );
         }



More information about the vlc-commits mailing list