mirror of
https://github.com/mpv-player/mpv
synced 2025-02-09 16:37:24 +00:00
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.
This commit is contained in:
parent
d941a57bd3
commit
8ff96f0216
@ -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 = {
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user