summaryrefslogtreecommitdiffstats
path: root/video/out/opengl/egl_helpers.c
Commit message (Collapse)AuthorAgeFilesLines
* vo_gpu: EGL: fix transparency on X11/EGL/Mesawm42020-08-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Transparent windows on X11/EGL/native Mesa GL didn't work for various reasons. From what I remember, the current code did work with nvidia at least. Mesa has made attempts to fix this, but they never really made it in. But it turns out you can make EGL/Mesa list the EGLConfigs that use X11 RGBA visuals, and context_x11egl.c contains code that explicitly selects them if alpha is requested (see pick_xrgba_config()). The reason EGL/Mesa did not list them (and thus breaking transparency) is because we requested a EGL_ALPHA_SIZE != 0 if alpha is requested. But the transparent EGLConfigs use EGL_ALPHA_SIZE == 0. That's because EGL doesn't actually support the concept of transparent windows; the alpha size parameter is something else (memory rendering without FBOs or something, I don't care enough to look up the real reasons). This still won't work on Wayland. Every EGL backend needs platform specific code. (Good job, EGL, such an awesome platform independent standard.) Fixes: #6590
* vo_gpu: EGL: slightly better debug logging of EGL configswm42020-08-271-1/+2
|
* egl_helpers: add typedef for EGLAttrib (#7314)Jan Palus2020-04-231-0/+1
| | | | part of EGL 1.5 which is not present ie on Raspberry Pi
* vo_gpu: opengl: make it work with EGL 1.4wm42019-12-161-0/+69
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This tries to deal with the crazy EGL situation. The summary is: - using eglGetDisplay() with multiple windowing platforms doesn't really work, but Mesa had an awful hack for it - this hack can be disabled at build time, and some distros sometimes accidentally or intentionally do so - Mesa will probably eventually disable it by default - we switched to eglGetPlatformDisplay(), but this requires EGL 1.5 - the very regrettable graphics company (also known as Nvidia) ships drivers (for old hardware I think) that are EGL 1.4 only - that means even though we "require" EGL 1.5 and link against it, the runtime EGL may be 1.4 - trying to run mpv there crashes in the dynamic linker - so we have to go through some more awful compatibility hacks This commit tries to do it "properly", but using EGL 1.4 as base. The plaform selection mechanism is a messy extension there, which got elevated to core API in 1.5 (but OF COURSE in incompatible ways). I'm not sure whether the EGL 1.5 code path (by parsing the EGL_VERSION) is really needed, but if you ask me, it feels slightly saner not to rely on an EGL 1.4 kludge forever. But maybe this is just an instance of self-harm, since they will most likely never drop or not provide this API. Also, unlike before, we actually check the extension string for the individual platform extensions, because who knows, some EGL implementations might curse us if we pass unknown platform parameters. (But actually, the more I think about this, the more bullshit it is.) X11 and Wayland were the only ones trying to call eglGetPlatformDisplay, so they're the only ones which are adjusted in this commit. Unfortunately, correct function of this commit is unconfirmed. It's possible that it crashes with the old drivers mentioned above. Why didn't they solve it like this: struct native_display { int platform_type; void *native_display; }; Could have kept eglGetDisplay() without all the obnoxious extension BS.
* egl_helpers: change minimum framebuffer size to 8 bit per componentwm42018-04-291-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | This is for working around bugs in certain Android devices. At least one device fails to sort EGLConfigs by size, so eglChooseConfig() ends up choosing a config with 5/6/5 bits per r/g/b component. The other attributes in the affected EGLConfigs did not look like they should affect the sorting process as specified by the EGL 1.4 standard. The device was reported as: Sony Xperia Z3 Tablet Compact Firmware 6.0.1 build number 23.5.A.1.291 GL_VERSION='OpenGL ES 3.0 V@140.0 AU@ (GIT@I741a3d36ca)' GL_VENDOR='Qualcomm' GL_RENDERER='Adreno (TM) 330' Other Qualcom/Adreno devices have been reported as unaffected by this (including some with same GL_RENDERER string). "Fix" this by always requiring at least 8 bit. This means it would fail on devices which cannot provide this. We're fine with this. mpv-android/mpv-android#112
* egl_helpers: log certain EGL attributeswm42018-04-291-0/+38
| | | | Might be helpful with broken EGL implementations.
* opengl: include details in EGL context errorsAman Gupta2018-04-121-3/+3
|
* egl_helpers: mpegl_cb can now signal an error conditionAnton Kindestam2018-02-261-0/+5
| | | | | This can be used by client code that needs to fail when it cannot find a suitable EGLConfig.
* vo_gpu: EGL: provide SwapInterval to generic codewm42017-12-271-0/+10
| | | | | | | This means that we now explicitly set an interval of 1. Although that should be the EGL default, some drivers could possibly ignore this (unconfirmed). In any case, this commit also allows disabling vsync, for users who want it.
* vo_opengl: refactor into vo_gpuNiklas Haas2017-09-211-60/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is done in several steps: 1. refactor MPGLContext -> struct ra_ctx 2. move GL-specific stuff in vo_opengl into opengl/context.c 3. generalize context creation to support other APIs, and add --gpu-api 4. rename all of the --opengl- options that are no longer opengl-specific 5. move all of the stuff from opengl/* that isn't GL-specific into gpu/ (note: opengl/gl_utils.h became opengl/utils.h) 6. rename vo_opengl to vo_gpu 7. to handle window screenshots, the short-term approach was to just add it to ra_swchain_fns. Long term (and for vulkan) this has to be moved to ra itself (and vo_gpu altered to compensate), but this was a stop-gap measure to prevent this commit from getting too big 8. move ra->fns->flush to ra_gl_ctx instead 9. some other minor changes that I've probably already forgotten Note: This is one half of a major refactor, the other half of which is provided by rossy's following commit. This commit enables support for all linux platforms, while his version enables support for all non-linux platforms. Note 2: vo_opengl_cb.c also re-uses ra_gl_ctx so it benefits from the --opengl- options like --opengl-early-flush, --opengl-finish etc. Should be a strict superset of the old functionality. Disclaimer: Since I have no way of compiling mpv on all platforms, some of these ports were done blindly. Specifically, the blind ports included context_mali_fbdev.c and context_rpi.c. Since they're both based on egl_helpers, the port should have gone smoothly without any major changes required. But if somebody complains about a compile error on those platforms (assuming anybody actually uses them), you know where to complain.
* vo_opengl: add a generic EGL function loader functionwm42017-04-061-0/+31
| | | | | | | This is pretty trivial, but also quite annoying due to details like mismatching eglGetProcAddress() function signature (most callers just cast the function pointer), and ARM/Linux hacks. So move them all to one place.
* vo_opengl: add a --opengl-es=force2 optionwm42017-03-201-1/+3
| | | | | | | Useful for testing. Unfortunately, the nVidia EGL driver ignores this, and returns a GLES 3.2 context anyway (which it is allowed to do). Might still be useable with ANGLE, which will really give you a GLES 2 context if you ask for it.
* vo_opengl: egl_helpers: fix for non-WindowsJames Ross-Gowan2017-02-081-1/+1
| | | | Whoops. Fixes #4119
* vo_opengl: angle: rewrite with custom swap chainJames Ross-Gowan2017-02-071-0/+6
| | | | | | | | | | | | | This replaces the old backend that exclusively used EGL windowing with one that can also use ANGLE's ability to render to directly to a texture. The advantage of this is that it allows mpv to create the swap chain itself and this allows mpv to use a flip-mode swap chain on a HWND (which avoids problems with DirectComposition) and to use a longer swap chain that has six backbuffers by default (which reportedly fixes problems with rendering 24fps video on 24Hz monitors.) Also, "screenshot window" should now work on DXGI 1.2 and up (Windows 8 and up.)
* vo_opengl: egl_helpers: fix variable namewm42017-01-261-3/+3
| | | | | | It was basically inverted. Not sure how this even happened. Hopefully it's more an "I don't know what I was doing" instead of an "I don't know what I am doing" case.
* vo_opengl: egl: handle potential eglChooseConfig failureswm42016-12-311-11/+10
| | | | | | | | | | | | | | | This is actually a pretty important fix. eglChooseConfig() might be the first thing that fails when porobing for desktop GL / ES2 / ES3 support, because EGL_RENDERABLE_TYPE is set values specific to the underlying APIs. Not sure how the hell this worked before. EGL 1.4 implementations certainly could fail the call with EGL_BAD_ATTRIBUTE if EGL_RENDERABLE_TYPE has EGL_OPENGL_ES3_BIT set. It's quite possible that many EGL implementations tolerate invalid EGLConfig values steming from uininitialized EGLConfig values (and eglCreateWindowSurface() even is specified to return EGL_BAD_CONFIG error code for "not valid" EGLConfigs).
* vo_opengl: egl: fix depth size parameterwm42016-12-301-1/+0
| | | | | | This was accidentally flipped from 0 to 1 in a previous commit. Actually simply remove it, because 0 is the default value for this parameter anyway.
* vo_opengl: egl_helpers: add a way to override config selectionwm42016-12-301-2/+14
| | | | | | | Preparation for the following commits. Since at least theoretically the config selection depends on the context type (EGL_RENDERABLE_TYPE has separate bits for ES 2, ES 3, and desktop GL), doing it any other way would be too painful.
* vo_opengl: egl_helpers: add a way to pass more optionswm42016-12-301-16/+26
| | | | | | | | | | For X11 garbage we have to pass some annoying parameters to EGL context creation. Add some sort of extensible API, so that adding a new parameter doesn't break all callers. We still want to keep it as a single function, because it's so nice isolating all the EGL nonsense API boilerplate like this. (Did I mention yet that X11 and EGL are garbage?) Also somewhat simplifies the vo_flags mess in the helper internals.
* vo_opengl: egl: print EGL errors only if not probingwm42016-09-301-6/+9
| | | | | Avoids printing an error when trying to create a GLES 3.x context on a device which can do GLES 2.0 only.
* vo_opengl: EGL: dump some version infowm42016-09-141-0/+8
|
* vo_opengl: EGL: better desktop-GL context creationwm42016-09-141-19/+65
| | | | | | | | | | | | Stops Mesa from restricting us to OpenGL 3.0. It also tries to create GLES 3 contexts for drivers which do not just return a higher context when requesting GLES 2. I don't know whether this code is a good or bad idea. A not-so-good aspect is that we don't check for EGL 1.5 (or 1.4 extensions) for some of the more advanced context attributes. But EGL implementations should be able to tolerate it and return an error, and then we'd use the fallback.
* vo_opengl: EGL: silence eglBindAPI() error messagewm42016-09-131-1/+1
| | | | | It's not helpful and will be printed with EGL implementations that don't support OpenGL at all. Just shut it up.
* vo_opengl: factor some EGL context creation codewm42016-09-131-0/+96
| | | | | | | Add a function to egl_helpers.c for creating an EGL context and make context_x11egl.c use it. This is meant to be generic, and should work with other windowing APIs as well. The other EGL-using code in mpv can be switched to it.
* vo_opengl: use standard functions to retrieve display depthwm42016-06-141-10/+0
| | | | | | | | | | | | | Until now, we've used system-specific API (GLX, EGL, etc.) to retrieve the depth of the default framebuffer. (We equal this to display depth and use the determined depth for dithering.) We can actually retrieve this value through standard GL API, and it works everywhere (except GLES 2 of course). This simplifies everything a great deal. egl_helpers.c is empty now. But I expect that some EGL boilerplate will be moved to it, so don't remove it yet.
* Change GPL/LGPL dual-licensed files to LGPLwm42016-01-191-12/+7
| | | | | | | | | | | Do this to make the license situation less confusing. This change should be of no consequence, since LGPL is compatible with GPL anyway, and making it LGPL-only does not restrict the use with GPL code. Additionally, the wording implies that this is allowed, and that we can just remove the GPL part.
* vo_opengl: x11egl: retrieve framebuffer depthwm42015-12-191-0/+35
This is used for dithering, although I'm not aware of anyone who got higher than 8 bit depth support to work on Linux. Also put this into egl_helpers.c. Since EGL is pseudo-portable at best I have no hope that the EGL context creation code in all the backends can be fully shared. But some self-contained functionality can definitely be shared.