aboutsummaryrefslogtreecommitdiff
path: root/render/egl.c
AgeCommit message (Collapse)Author
2024-02-15Define _POSIX_C_SOURCE globallySimon Ser
Stop trying to maintain a per-file _POSIX_C_SOURCE. Instead, require POSIX.1-2008 globally. A lot of core source files depend on that already. Some care must be taken on a few select files where we need a bit more than POSIX. Some files need XSI extensions (_XOPEN_SOURCE) and some files need BSD extensions (_DEFAULT_SOURCE). In both cases, these feature test macros imply _POSIX_C_SOURCE. Make sure to not define both these macros and _POSIX_C_SOURCE explicitly to avoid POSIX requirement conflicts (e.g. _POSIX_C_SOURCE says POSIX.1-2001 but _XOPEN_SOURCE says POSIX.1-2008). Additionally, there is one special case in render/vulkan/vulkan.c. That file needs major()/minor(), and these are system-specific. On FreeBSD, _POSIX_C_SOURCE hides system-specific symbols so we need to make sure it's not defined for this file. On Linux, we can explicitly include <sys/sysmacros.h> and ensure that apart from symbols defined there the file only uses POSIX toys.
2023-11-28render/egl: fallback to GBM FD if EGLDevice is not availableSimon Ser
It's possible that we don't have an EGLDevice if we created the EGL context from a GBM device. Let's ensure all GPU-accelerated renderers always have a DRM FD to return by falling back to GBM's FD.
2023-10-03treewide: Migrate from sizeof(struct) to sizeof(*pointer) where practicalAlexander Orzechowski
2023-08-21egl: Don't assume display is owned when KHR_display_reference is unsupportedAlexander Orzechowski
We could potentially leak a display here, but not really because the display acts as a singleton that will be returned next time a renderer of the same device is created.
2023-08-21egl: Remove dead codeAlexander Orzechowski
Display is always NULL here since egl_init is always last to be called.
2023-05-24render/egl: check for EGL_EXT_device_query in get_egl_device_from_drm_fd()Simon Ser
We use eglQueryDeviceStringEXT() later on, which is optional and requires support for the EGL_EXT_device_query extension.
2023-02-18Revert "render/egl: skip incompatible EGL devices"Simon Zeni
Reverts commit c73e20628ad3cf8a38fc1cebd061a49da8708394. This caused a regression in the GLES2 renderer because `egl->exts.EXT_device_drm` is set in `egl_init_display()`, which is invoked after `get_egl_device_from_drm_fd()`. So the function will always return `EGL_NO_DEVICE_EXT`.
2023-02-16render/egl: skip incompatible EGL devicesEric Engestrom
Without EGL_EXT_device_drm, eglQueryDeviceStringEXT(EGL_DRM_DEVICE_FILE_EXT) further below is invalid.
2022-12-13render/egl: stop advertising render support for external-only formatsSimon Ser
Some formats like YUV are only supported by Mesa for sampling, not for rendering. However we always unconditionally added the INVALID modifier to the list of render formats. Check whether all modifiers are external-only, in that case, don't add INVALID to the list of render formats.
2022-12-12egl: consistently use EGLint for DMA-BUF formatSimon Ser
EGL_EXT_image_dma_buf_import_modifiers [1] uses EGLint to carry formats. We were casting it to int (which may not be the same width) and uint32_t (which may change the value). Instead, use EGLint everywhere. [1]: https://registry.khronos.org/EGL/extensions/EXT/EGL_EXT_image_dma_buf_import_modifiers.txt
2022-11-15render/egl: enable EGL_LOSE_CONTEXT_ON_RESETSimon Ser
This allows the GLES2 renderer to figure out when a GPU reset happens.
2022-11-11render/egl: fix uninitialized pointers in init_dmabuf_formatsSimon Zeni
`modifiers` and `external_only` are never initialized, and free'd later. This commit explicitly initializes them to NULL to prevent segfaults on `free()`
2022-10-21egl: add WLR_EGL_NO_MODIFIERSSimon Ser
Same as WLR_DRM_NO_MODIFIERS but for EGL. For debugging purposes mostly. References: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3451
2022-09-19render/egl: add support for EGL_KHR_display_referenceSimon Ser
See the spec at [1]. tl;dr EGL has terrible defaults: eglTerminate() may have side-effects on completely unrelated EGLDisplay objects. This extension allows us to opt-in to get the sane behavior: eglTerminate() only free's our own EGLDisplay without affecting others. [1]: https://registry.khronos.org/EGL/extensions/KHR/EGL_KHR_display_reference.txt
2022-09-14render/egl: improve DMA-BUF format/modifier loggingSimon Ser
For each format and modifier, log supported usage. Log a human-readable format/modifier string.
2022-09-07egl: modify egl_init_display function definitionfakechen
I think the second parameter of the function should be void* instead of void **, because we use it as a right value in the function. Signed-off-by: fakechen <chenzigui@kylinos.cn> Signed-off-by: sunzg <sunzhigang1@kylinos.cn>
2022-08-22Use env helpersAlexander Orzechowski
2022-06-12render/egl: don't leak memory on error returnbi4k8
2022-05-25render/egl: add wlr_egl_get_{context,display}Simon Ser
This allows compositors to integrate with the wlroots GLES2 renderer, if they need to perform custom GL rendering.
2022-03-14Free drmDevice in get_egl_device_from_drm_fd()Dean
2021-12-02render/egl: improve modifier support detectionSimon Ser
Support for EXT_image_dma_buf_import_modifiers doesn't necessarily indicate support for modifiers. For instance, Mesa will advertise EXT_image_dma_buf_import_modifiers for all drivers. This is a trick to allow EGL clients to enumerate supported formats (something EXT_image_dma_buf_import is missing). For more information, see [1]. Add a new wlr_egl.has_modifiers flag which indicates whether modifiers are supported. It's set to true if any eglQueryDmaBufModifiersEXT query returned a non-empty list. Use that flag to figure out whether the buffer modifier should be passed to the EGL implementation on import. [1]: https://github.com/KhronosGroup/EGL-Registry/issues/142
2021-12-01render/egl: add wlr_egl_create_with_contextSimon Ser
This allows creating a wlr_egl from an already-existing EGL display and context. This is useful to allow compositors to choose the exact EGL initialization parameters.
2021-12-01render/egl: store IMG_context_priority in wlr_eglSimon Ser
The next commit will split extension lookup and context initialization.
2021-11-26render/egl: always add LINEAR to supported modifiersSimon Ser
2021-11-26Require INVALID for implicit format modifiersSimon Ser
See [1] for the motivation. [1]: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/75
2021-11-09egl: use alts for EGL_EXT_device_enum, if missingCole Mickens
2021-10-27render/egl.c: Fix memory leaks in egl_createHaelwenn (lanodan) Monnier
calloc is moved to right before egl is called to avoid requiring to free() unused memory. Found via scan-build
2021-10-01Revert "Require INVALID for implicit format modifiers"Simon Ser
This reverts commit ea7357b70366588069c83f158e6a4eb2d3a702b3.
2021-10-01Revert "render/egl: always add LINEAR to supported modifiers"Simon Ser
This reverts commit 780052d4da0c93f9210dd87d2100b116af7ff308.
2021-10-01render/egl: always add LINEAR to supported modifiersSimon Ser
2021-10-01Require INVALID for implicit format modifiersSimon Ser
See [1] for the motivation. [1]: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/75
2021-08-25render/egl: reopen DRM node for GBMSimon Ser
This will be necessary for the next patch, to avoid messing up BO handles shared between the GL implementation and the DRM backend.
2021-07-27render/egl: initialize wlr_egl with EGL_PLATFORM_DEVICE_EXTSimon Zeni
Uses the EXT_device_query extension to get the EGL device matching the requested DRM file descriptor. If the extension is not supported or no device is found, the EGL device will be retrieved using GBM. Depends on the EGL_EXT_device_enumeration to get the list of EGL devices.
2021-07-27render/egl: fix typoyuiiio
2021-07-26render/egl: add support for EGL_EXT_device_drm_render_nodeSimon Ser
This EGL extension has been added in [1]. The upsides are: - We directly get a render node, instead of having to convert the primary node name to a render node name. - If EGL_DRM_RENDER_NODE_FILE_EXT returns NULL, that means there is no render node being used by the driver. [1]: https://github.com/KhronosGroup/EGL-Registry/pull/127
2021-07-23render/egl: set EGL_IMAGE_PRESERVED_KHRSimon Ser
Without setting this the EGL implementation is allowed to perform destructive actions on the buffer when imported: its contents become undefined. This is mostly a pedantic change, because Mesa processes the attrib and does absolutely nothing with it.
2021-07-12render/egl: rename wlr_egl.exts to better match KhronosSimon Ser
Khronos refers to extensions with their namespace as a prefix in uppercase. Change our naming to align with Khronos conventions. This also makes grepping easier.
2021-07-05render/egl: remove EGL_WL_bind_wayland_display supportSimon Ser
Our GLES2 renderer doesn't use it anymore, so we can drop it.
2021-06-30render/egl: replace wlr_egl_create with wlr_egl_create_with_drm_fdSimon Ser
We never create an EGL context with the platform set to something other than EGL_PLATFORM_GBM_KHR. Let's simplify wlr_egl_create by taking a DRM FD instead of a (platform, remote_display) tuple. This hides the internal details of creating an EGL context for a specific device. This will allow us to transparently use the device platform [1] when the time comes. [1]: https://github.com/swaywm/wlroots/pull/2671
2021-06-24render/egl: make most functions privateSimon Ser
The wlr_egl functions are mostly used internally by the GLES2 renderer. Let's reduce our API surface a bit by hiding them. If there are good use-cases for one of these, we can always make them public again. The functions mutating the current EGL context are not made private because e.g. Wayfire uses them.
2021-05-11render/egl: query and display EGL driver nameSimon Ser
GL_RENDERER typically displays a human-readable string for the name of the GPU, and EGL_VENDOR typically displays a human-readable string for the GPU manufacturer. EGL_DRIVER_NAME_EXT should give the name of the driver in use. References: https://github.com/KhronosGroup/EGL-Registry/commit/e8baa0bf39120803505c6e360e1e33af0d9b9745
2021-04-26Log drmGetDevices2 error codeSimon Ser
2021-04-26render/egl: fail on EGL_MESA_device_softwareSimon Zeni
2021-04-08render: remove wlr_texture_to_dmabufSimon Ser
This is unused in wlroots, and the use-cases for compositors are pretty niche since they can access the original DMA-BUF via the wlr_buffer.
2021-04-07render/egl: check "EGL_KHR_platform_gbm" for EGL gbm platformzccrs
See the https://www.khronos.org/registry/EGL/extensions/KHR/EGL_KHR_platform_gbm.txt example code. On EGL_PLATFORM_GBM_KHR platform, we should be check the "EGL_KHR_platform_gbm" extension. Change-Id: Icf11c07c2949841a80b10527fb09987257fbd63b
2021-04-06render/egl: stop relying on platform for high prioritySimon Ser
All backends use the GBM platform. We can't use it to figure out whether the DRM backend is used anymore. Let's just try to always request a high-priority EGL context. Failing to do so is not fatal.
2021-03-27render/egl, backend/wayland: add workaround for split render/display setupsSimon Ser
Split render/display setups have two separate devices: one display-only with a primary node, and one render-only with a render node. However in these cases the EGL implementation and the Wayland compositor will advertise the display device instead of the render device [1]. The EGL implementation will magically open the render device when the display device is passed in. So just pass the display device as if it were a render device. Maybe in the future Mesa will advertise the render device instead and we'll be able to remove this workaround. [1]: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4178
2021-03-15render/egl: don't fail on EGL_MESA_device_softwareSimon Ser
Mesa may advertise EGL_MESA_device_software even when hardware drivers are in use [1]. Demote the error to a warning until the Mesa bug is fixed. [1]: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4178 References: https://github.com/swaywm/wlroots/pull/2689
2021-02-01render/egl: log whether DMA-BUF modifiers are supportedSimon Ser
2021-02-01render/egl: add check for EGL_KHR_surfaceless_contextBrandon Dowdy
As surfaces are no longer going to be used for wlr_egl, I may as well just go and add this check as it is needed for safety whenever surface-less rendering is being used.