[vlc-commits] direct3d11: wait until the rendering is done before we leave Prepare()
Steve Lhomme
git at videolan.org
Wed Nov 28 12:40:19 CET 2018
vlc/vlc-3.0 | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Mon Nov 26 16:37:58 2018 +0100| [228e367ba02ef4e03bf193cd52ae639ee03a5c31] | 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.
(cherry picked from commit f389e8b0bb25d62550031ca62611ffe24ea9f953)
> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=228e367ba02ef4e03bf193cd52ae639ee03a5c31
---
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 4b29daab41..32d06caa00 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -98,6 +98,8 @@ struct vout_display_sys_t
d3d11_device_t d3d_dev;
d3d_quad_t picQuad;
+ ID3D11Query *prepareWait;
+
picture_sys_t stagingSys;
ID3D11RenderTargetView *d3drenderTargetView;
@@ -990,7 +992,16 @@ static void Prepare(vout_display_t *vd, picture_t *picture, subpicture_t *subpic
}
}
- 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 );
@@ -1543,6 +1554,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;
@@ -1745,6 +1760,11 @@ static void Direct3D11DestroyResources(vout_display_t *vd)
ID3D11PixelShader_Release(sys->picQuad.d3dpixelShader);
sys->picQuad.d3dpixelShader = 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