vo_opengl/angle_dynamic: accept EGL_-prefixed exports - #18325
Conversation
angle_load() resolves the EGL entry points with GetProcAddress() using their unprefixed names, and gives up on the first one that is missing. Some ANGLE builds export those entry points under the EGL_-prefixed spelling instead - EGL_QueryString rather than eglQueryString - which is what Chromium uses, and which applications embedding such a build inherit. On those builds angle_load() returns false, so every ANGLE-based hwdec (d3d11-egl, dxva2-egl) is refused at its second gate, before any device, capability or extension is examined. mpv logs only "Loading failed.", which is hard to distinguish from a machine that genuinely lacks the interop. Try the prefixed spelling as a fallback. This costs one extra GetProcAddress() per entry point on builds that export the plain names, and nothing on the builds that need it. Found while embedding libmpv in an Avalonia application on Windows. Avalonia ships ANGLE as a single combined binary that exports only the prefixed names, so eglGetCurrentDisplay, eglGetCurrentContext and eglQueryString were all absent under the names angle_load() looks up. With this change, and with the EGL_EXT_device_query fix from issue mpv-player#10212, hwdec on that setup goes from d3d11va-copy to d3d11va.
|
The actual interesting question here is why do "some"(?) ANGLE DLLs export their symbols under different names? |
|
these names are defined by the standard: https://registry.khronos.org/EGL/sdk/docs/man/ I'm suspecting |
Correct. We should be going through |
I was wrong about that, sorry. Should've phrased it better. The DLL here is ANGLE's libGLESv2, not libEGL. I dumped the exports from the one Avalonia ships ( The normal
Yeah, my bad. I tested it. Same DLL, all 22 entry points from
However if you do that, you can't get I can redo it so it bootstraps Or close it if you want, that's fine too. If the take is that a host should ship a proper ANGLE deployment instead of one library renamed to another's filename, that's fair and I'll fix it on my end. Either way the export dump seemed worth leaving here. I didn't work out the why myself until I looked at the table. |
No it's not. mpv loads libEGL explicitly. mpv/video/out/opengl/angle_dynamic.c Line 24 in 74356c0
So, why do you ever though it's an mpv issue to be fixed here? mpv links to
You are welcome to provide any patches you want, but you have to ensure they meet some quality standard. I will not spend time prompting your LLM. It's not my job as a reviewer/maintainer to do the work for you. If you are unable to provide or even recognize that your patch is a hack and nothing more, it's not our job to educate you. |
angle_load()resolves the EGL entry points withGetProcAddress()using their unprefixed names, and gives up on the first one that is missing:Some ANGLE builds export those entry points under the
EGL_-prefixed spelling instead —EGL_QueryStringrather thaneglQueryString— which is what Chromium uses, and which applications embedding such a build inherit.On those builds
angle_load()returns false, so every ANGLE-based hwdec is refused at its second gate, before any device, capability or extension is examined.hwdec_d3d11egl.candhwdec_dxva2egl.cboth start with:Because every gate in those functions is a bare
return -1, mpv logs only:which is hard to tell apart from a machine that genuinely lacks the interop. That is what made this expensive to diagnose — it took a local build with a log line at each gate to find out which one it was.
How it was found
Embedding libmpv in an Avalonia application on Windows. Avalonia ships ANGLE as a single combined binary that exports only the prefixed names, so
eglGetCurrentDisplay,eglGetCurrentContextandeglQueryStringare all absent under the namesangle_load()looks up, whileEGL_GetCurrentDisplay,EGL_GetCurrentContextandEGL_QueryStringare present.Measured on ANGLE 2.1.1 (git
1c89805903c1), Windows 11, RTX 3080, with libmpv's OpenGL render API on an ES 3.0 context.Result
With this change, plus the
EGL_EXT_device_queryfix from #10212 (that extension is a client extension queried againstEGL_NO_DISPLAY, andhwdec_d3d11egl.ctests the display string),d3d11-eglinitialises andhwdecgoes fromd3d11va-copytod3d11vaon that setup. Frame render time in the host dropped from ~14–19 ms to ~0.7 ms at 4K HEVC, since the per-frame GPU→RAM→GPU round trip is gone.The two are independent and both are needed — either alone still ends in
d3d11va-copy. This PR is only theangle_load()half, since #10212 already has #11142 open against it.Cost
One extra
GetProcAddress()per entry point on builds that export the plain names, once per process, and nothing at all on the builds that need it. Behaviour is unchanged wherever the plain names resolve.<string.h>is added explicitly forstrlen/memcpy— it currently arrives only transitively viawindows.hon MinGW.Compile-tested on MSYS2 MINGW64 (gcc 16.1.0, meson 1.11.2) and runtime-tested as described above.