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

2020-08-14 Thread Steve Lhomme
vlc/vlc-3.0 | branch: master | Steve Lhomme  | 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 

> 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( >d3d_dev );
-SleepEx(2, TRUE);
+msleep( render_wait );
 if (is_d3d11_opaque(picture->format.i_chroma))
 d3d11_device_lock( >d3d_dev );
 }

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


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

2020-08-10 Thread Steve Lhomme
vlc | branch: master | Steve Lhomme  | Mon Aug 10 12:13:39 
2020 +0200| [ba04276cae760f919a9a61c5dd5eb294e4d26cef] | 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.

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

 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 b6c5fcd7b4..3da8c32b23 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -661,15 +661,14 @@ static void PreparePicture(vout_display_t *vd, picture_t 
*picture, subpicture_t
 
 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 vlc_tick_t render_wait = VLC_TICK_FROM_MS(2);
 d3d11_device_unlock( sys->d3d_dev );
-SleepEx(2, TRUE);
+vlc_tick_sleep(render_wait);
 d3d11_device_lock( sys->d3d_dev );
 }
 }

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits