From 8ff96f0216884f9bd3c60857e629a25aaa8704de Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 24 May 2016 14:30:15 +0200 Subject: hwdec_d3d11egl: call ID3D11DeviceContext::Flush This must be called if a texture shared between D3D devices is updated. Often enough, the shared devices will be the same device, but ANGLE forces using shared surfaces. I suppose there is no guarantee the driver will do the expected thing. Internally, the driver could for example not insert the required barriers before the shared texture is used. --- video/out/opengl/hwdec_d3d11egl.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'video') diff --git a/video/out/opengl/hwdec_d3d11egl.c b/video/out/opengl/hwdec_d3d11egl.c index c257145470..1810105d5a 100644 --- a/video/out/opengl/hwdec_d3d11egl.c +++ b/video/out/opengl/hwdec_d3d11egl.c @@ -39,6 +39,7 @@ struct priv { struct mp_hwdec_ctx hwctx; ID3D11Device *d3d11_device; + ID3D11DeviceContext *device_ctx; ID3D11VideoDevice *video_dev; ID3D11VideoContext *video_ctx; @@ -142,6 +143,10 @@ static void destroy(struct gl_hwdec *hw) ID3D11VideoDevice_Release(p->video_dev); p->video_dev = NULL; + if (p->device_ctx) + ID3D11DeviceContext_Release(p->device_ctx); + p->device_ctx = NULL; + if (p->d3d11_device) ID3D11Device_Release(p->d3d11_device); p->d3d11_device = NULL; @@ -270,13 +275,11 @@ static int create(struct gl_hwdec *hw) if (FAILED(hr)) goto fail; - ID3D11DeviceContext *device_ctx; - ID3D11Device_GetImmediateContext(p->d3d11_device, &device_ctx); - if (!device_ctx) + ID3D11Device_GetImmediateContext(p->d3d11_device, &p->device_ctx); + if (!p->device_ctx) goto fail; - hr = ID3D11DeviceContext_QueryInterface(device_ctx, &IID_ID3D11VideoContext, + hr = ID3D11DeviceContext_QueryInterface(p->device_ctx, &IID_ID3D11VideoContext, (void **)&p->video_ctx); - ID3D11DeviceContext_Release(device_ctx); if (FAILED(hr)) goto fail; @@ -576,6 +579,11 @@ static int map_frame_video_proc(struct gl_hwdec *hw, ID3D11Texture2D *d3d_tex, return -1; } + // Make sure the texture is updated correctly on the shared context. + // I'm not sure if this is needed if the shared context is the same + // context. (ANGLE API does not allow not using sharing.) + ID3D11DeviceContext_Flush(p->device_ctx); + *out_frame = (struct gl_hwdec_frame){ .planes = { { -- cgit v1.2.3