mpv icon indicating copy to clipboard operation
mpv copied to clipboard

OSD stuck while paused when using dxinterop

Open quilloss opened this issue 9 years ago • 6 comments

mpv version and platform

fdd75f90a Window 10

Reproduction steps

  1. Set opengl-backend=dxinterop
  2. Open any audio file with force-window (a paused video or image also works)
  3. Trigger an OSD message or OSC display

Expected behavior

OSD/OSC eventually fades out.

Actual behavior

OSD/OSC does not fade out.

Log file

http://sprunge.us/RRiU

The issue seems to only occur when there is no video frame being rendered.

quilloss avatar Jun 04 '17 08:06 quilloss

Doesn't have to do with the backend. It's how the OSD/OSC are implemented that depend too much on the mouse moving on the screen if there's no video.

wiiaboo avatar Jun 04 '17 09:06 wiiaboo

It works fine with opengl-backend=win and vo=direct3d though.

quilloss avatar Jun 04 '17 09:06 quilloss

I think the issue might not be due to the OSD/OSC implementation.

Toggling fullscreen on and off with a still image causes issues with dxinterop. The windowed display is squashed while the fullscreen display is stretched. The presented image seems to be a single frame late.

Moving the DXLockObjectsNV call to after IDirect3DDevice9Ex_PresentEx in context_dxinterop.c fixes the issue for me. It might be be due to the IDirect3DDevice9Ex_StretchRect call not being flushed before the render target was locked.

quilloss avatar Jun 10 '17 08:06 quilloss

Hmm, I also have Nvidia on Windows 10, but I can't repro this.

Moving the DXLockObjectsNV call to after IDirect3DDevice9Ex_PresentEx in context_dxinterop.c fixes the issue for me. It might be be due to the IDirect3DDevice9Ex_StretchRect call not being flushed before the render target was locked.

This looks reasonable though. I assumed that DXLockObjectsNV did the appropriate synchronisation because it seemed to block under some conditions, but maybe it doesn't. I tested this change on my machine and there doesn't seem to be any impact on performance, so I'm okay with it.

rossy avatar Jun 10 '17 14:06 rossy

https://www.khronos.org/registry/OpenGL/extensions/NV/WGL_NV_DX_interop.txt

DISCUSSION: The Lock/Unlock calls serve as synchronization points between OpenGL and DirectX. They ensure that any rendering operations that affect the resource on one driver are complete before the other driver takes ownership of it.

It should provide synchronization according to the spec. Maybe it is a bug with the latest Nvidia drivers. We might also be running different versions of Windows 10 as I have not been updated to the Creators Update.

quilloss avatar Jun 11 '17 02:06 quilloss

Yeah, it seems like no GPU vendor implements the DX_interop spec correctly, though it's more surprising to see a bug with Nvidia, since they wrote the spec. Our dxinterop code contains some workarounds for Intel bugs, so this should be fine too.

rossy avatar Jun 17 '17 13:06 rossy