Commit Graph

72 Commits

Author SHA1 Message Date
Simon Ser 7f9bbaaa17 render/egl: explicit client extension handling
Prior to this commit, wlr_egl_init seemed to assume the extension string
queried via EGL_NO_DISPLAY was a subset of the extension string queried
via an initialized display. This isn't correct.

EGL_EXT_client_extensions [1] defines two types of extensions: client
extensions and display extensions. The set of supported client and
display extensions are disjoint (ie. an extension is either a client or
a display extension, not both). Client extensions are queried via
EGL_NO_DISPLAY, display extensions are queried via an initialized
display.

Rename the variables to make this clear. Remove the misleading comment.
Log both client and display extensions.

[1]: https://www.khronos.org/registry/EGL/extensions/EXT/EGL_EXT_client_extensions.txt
2020-06-10 14:55:29 +02:00
Andri Yngvason 11b598fe33 render: egl: Add utility functions for saving/restoring context 2020-06-08 20:49:41 +02:00
Simon Ser a3ba82885c render: choose DMA-BUF texture target via eglQueryDmaBufModifiersEXT
EGL_EXT_image_dma_buf_import_modifiers tells us whether we should use
GL_TEXTURE_2D or GL_TEXTURE_EXTERNAL_OES. Using the right texture target
can fix some failures and/or improve performance on some drivers.

This does the same as a Weston commit [1].

[1]: https://gitlab.freedesktop.org/wayland/weston/commit/40c519a3e613

Closes: https://github.com/swaywm/wlroots/issues/2173
2020-06-06 08:59:38 +02:00
Simon Ser e91417ea8d render: stop making EGL context current in wlr_egl_init
This leaves an EGL context current behind. wlr_gles2_renderer_create was
assuming the EGL context was already current because of this (because it
called a GL function right off the bat).
2020-06-02 14:23:24 -06:00
Simon Ser af2f69e6c1 render/egl: unset current context after swapping buffers
After swapping buffers, it doesn't make sense to perform more rendering
operations. Unset the context to reflect this.

This commit makes it so the context is always only current between
wlr_egl_make_current and wlr_egl_swap_buffers.

This is an alternative to [1].

[1]: https://github.com/swaywm/wlroots/pull/2212
2020-05-20 17:39:34 +02:00
Simon Ser 1edc42157b render/egl: introduce wlr_egl_unset_current
This function can be called after wlr_egl_make_current to cleanup the
EGL context. This avoids having lingering EGL contexts that make things
work by chance.

Closes: https://github.com/swaywm/wlroots/issues/2197
2020-05-19 14:56:20 +02:00
Simon Ser 6787ff521b render/egl: make config attribs const
wlr_egl_init is not allowed to mutate these attribs.
2020-04-09 00:15:25 +00:00
Simon Ser 2b04857343 render/egl: remove SURFACELESS_MESA special case
Users can just pass EGL_DEFAULT_DISPLAY themselves.
2020-01-12 10:10:09 -07:00
Simon Ser 01818ad2c8 render: fix EGL extensions not loaded
Some extensions are only advertised by the EGL implementation with a
non-zero EGLDisplay. That's the case when the extension can only be
enabled when the hardware/driver supports it for instance.

Instead of checking for all extensions without a display, check only for
EGL_EXT_platform_base and EGL_KHR_debug which are used before
eglGetDisplay. Check for all other extensions when we have a display.

Closes: https://github.com/swaywm/wlroots/issues/1955
2019-12-21 08:54:24 -05:00
Simon Ser 515679e4fe Refactor EGL/GL API loading
Remove glapi.sh code generation, replace it with hand-written loading
code that checks extension strings before calling eglGetProcAddress.

The GLES2 renderer still uses global state because of:

- {PUSH,POP}_GLES2_DEBUG macros
- wlr_gles2_texture_from_* taking a wlr_egl instead of the renderer
2019-12-20 01:03:34 +00:00
Simon Ser 51416738ea render/egl: prevent use-after-free when destroying current surface 2019-10-23 09:36:50 +00:00
Simon Ser 11bf87d678 render/egl: support formats with zero modifiers 2019-10-11 08:09:08 -04:00
Scott Anderson 06644575da render/egl: Change KHR_debug log to include error code 2019-09-15 10:06:34 +03:00
Simon Ser d6e250b389 render/egl: fix swapping with no damage
According to the spec:

> If <n_rects> is 0 then <rects> is ignored and the entire
> surface is implicitly damaged and the behaviour is equivalent
> to calling eglSwapBuffers.

When we want to swap with an empty damage region, set the damage to a single
empty rectangle.
2019-04-26 10:08:08 -06:00
Simon Ser f42816ce3f render/egl: fix zero-length VLA 2019-04-23 14:36:02 -06:00
Alyssa Ross 95b22619e0 Fix missing headers when building without X11
The deleted includes are redundant, because other headers will include
the necessary files. Additionally, they cause build failures, because
including EGL/egl.h or EGL/eglext.h directly, instead of through
wlr/render/egl.h or wlr/render/interface.h, will mean that
MESA_EGL_NO_X11_HEADERS will not have been defined, and so the EGL
headers will attempt to pull in unnecessary X11 headers that may not
exist on the system.

For the headers produced by glgen.sh, the includes couldn't simply be
deleted, because no other header would include the EGL headers. Neither
wlr/render/egl.h or wlr/render/interface.h felt appropriate to include,
so I opted instead to copy the MESA_EGL_NO_X11_HEADERS definition before
the EGL includes.
2019-04-22 00:04:08 +03:00
emersion e42178d03f
render: switch wlr_renderer to wlr_drm_format_set 2019-04-01 19:18:04 +03:00
emersion 1b9ebcf645
output: make wlr_egl flip the damage 2018-11-13 16:55:33 +01:00
emersion b42fc4f2b1
render: on Wayland, make eglSwapBuffers non-blocking 2018-10-28 09:58:20 +01:00
Scott Anderson 7ca3bc1d6f Fix libdrm includes
This removes any assumptions about how the libdrm headers are installed,
and uses the pkg-config include directories as we're "supposed to".
This only adds a partial dependency, since we don't actually need to
link against libdrm.
2018-10-15 11:39:35 +13:00
emersion 7daca85bcf
Merge pull request #1309 from swaywm/fix-headless-libinput
Fix headless backend
2018-10-14 08:33:25 +02:00
Cole Mickens 43d0ebfdac
Fix include path for (libdrm/)drm_fourcc.h
This PR broke a private nixpkgs definition I have for wlroots: https://github.com/swaywm/wlroots/pull/1304

It is fixed by changing `#include <drm_fourcc.h>` to `#include <libdrm/drm_fourcc.h>`, which follows what is already done in the dmabuf example.
2018-10-13 21:36:58 -07:00
Drew DeVault 63c69cee6e Fix headless backend
It was only working if you ran it underneath an already-working Wayland
compositor. Running with the headless backend on the API would break.
2018-10-13 23:39:38 -04:00
nyorain affbfb6a28 Support older wlr_linux_dmabuf_v1 clients
If a client uses an older version of the dmabuf protocol, use the
`formats` event instead of `modifiers` (since that didn't exist in older
versions).
With a bit of necessary guessing, support dmabuf importing even when
EGL_EXT_image_dma_buf_import_modifiers isn't present instead of
failing up front.
2018-10-12 23:07:45 +02:00
emersion 7cbef15206
util: add wlr_ prefix to log symbols 2018-07-09 22:49:54 +01:00
emersion 57548b557a
Merge branch 'master' into screencontent 2018-06-17 14:49:18 +01:00
Vincent Vanlaer f1a62a3200 Rename egl.exts to match the extension names 2018-06-09 19:11:51 +02:00
Vincent Vanlaer 5ec6d8230d Split eglSwapBuffersWithDamage feature detection
Detecting whether eglSwapBuffersWithDamageEXT or
eglSwapBuffersWithDamageKHR is used should be based on the extension
string, not only on the availability of the function.
2018-06-09 11:39:14 +02:00
Brian Ashworth 18bbe2d897 Fix atti assert in wlr_egl_init 2018-06-08 20:25:36 -04:00
emersion 457bfcab19
render/egl: only request high priority context on DRM 2018-06-08 00:17:45 +01:00
emersion d425edc96c
render/egl: consistent extension checking 2018-06-08 00:06:34 +01:00
emersion cbfe0e834a
Request a high priority EGL context 2018-06-08 00:06:34 +01:00
emersion 21928cbe61
Merge branch 'master' into screencontent 2018-05-31 12:33:27 +01:00
emersion 135721118a
render: remove wlr_renderer_check_import_dmabuf
It's possible to implement it outside the renderer, by creating a
texture and destroying it right away. This reduces the API surface
of the renderer.
2018-05-30 17:08:15 +01:00
emersion 28020ff577
Only allow one modifier per DMA-BUF, split attributes struct in render/ 2018-05-30 09:29:12 +01:00
emersion 5ba1a9af56
render: add wlr_texture_to_dmabuf 2018-05-29 18:47:17 +01:00
agr 4e89e0fc6c fix server exit: eglMakeCurrent Invalid display 2018-05-23 16:17:29 +02:00
Alain Greppin b2f8f00ae3 fix check of EGL_WL_bind_wayland_display presence 2018-05-13 15:17:17 +02:00
emersion 5a87712ca8
Log required extension name if unavailable 2018-04-26 11:11:28 +01:00
emersion 018b82c01e
render/egl: allow passing NULL to surface and image destructors 2018-04-25 08:28:48 +01:00
emersion eaed6bd03b
render/egl: add wlr_egl_destroy_surface 2018-04-24 23:44:43 +01:00
emersion 1588094b99
Remove a few local prefixed symbols 2018-04-21 10:20:33 +01:00
Guido Günther 6a05bd3886 egl: silence dmabuf error when extension is not present
This makes it match 4bf936360d.
2018-04-04 09:28:07 +02:00
emersion f3f61bed3e
Untie wlr_gles2_renderer and wlr_gles2_texture 2018-04-01 16:07:50 -04:00
emersion a7bb48b404
render/egl: add wlr_egl_create_image_from_wl_drm
This allows external renderers and potential future GL-based
renderers to re-use this function.
2018-03-31 23:20:00 -04:00
Tony Crisci 330ee08126
Merge pull request #744 from emersion/texture-redesign
Redesign wlr_texture
2018-03-28 00:14:57 -04:00
Drew DeVault 13edb19a6c Fix issue starting up client EGL on X11 backend 2018-03-27 18:51:38 -04:00
Drew DeVault f444a0d14c Implement layer surface damage 2018-03-27 18:50:32 -04:00
Drew DeVault 4bf936360d Arrange & render layer surfaces 2018-03-27 18:50:09 -04:00
emersion c42fd1018b
render: remove GL calls from wlr_egl 2018-03-27 17:02:48 -04:00