Commit Graph

364 Commits

Author SHA1 Message Date
Simon Ser 5c699f09cb Log drmGetDevices2 error code 2021-04-26 16:27:24 +02:00
Simon Ser af78ecb86b render: unconditionally read WLR_RENDERER
Prior to this commit, WLR_RENDERER was only looked up when the
backend returned a DRM FD.

Make it so WLR_RENDERER is always looked up, so that running wlroots
on a system without a GPU and with WLR_RENDERER=gles2 fails as
expected instead of falling back to the Pixman renderer.
2021-04-26 15:05:34 +02:00
Simon Zeni 8a27050b4e render/egl: fail on EGL_MESA_device_software 2021-04-26 09:02:52 +02:00
Simon Ser c314920a3d render: remove NULL checks in wlr_texture_impl.destroy
The NULL check already exists in wlr_texture_destroy, no need to
duplicate it in each impl
2021-04-22 15:44:49 +02:00
Simon Ser 8ca2b4cf49 render/pixman: destroy textures on renderer teardown 2021-04-22 15:44:49 +02:00
Simon Ser 661ba49564 render/gles2: destroy textures on renderer teardown 2021-04-22 15:44:49 +02:00
Simon Ser 9901d49fa5 render/pixman: cleanup when renderer is destroyed
We were leaking wlr_pixman_buffers and a wlr_drm_format_set.
2021-04-22 15:44:49 +02:00
Simon Ser 8e375ae340 render/gles2: log when creating renderer
Make it clear GLES2 is being used. Before this commit, various
GL-related information was printed, but not an easy-to-find line
about which renderer is being picked up.
2021-04-21 08:30:35 +02:00
Simon Zeni cdacf4f632 render: introduce WLR_RENDERER in wlr_renderer_autocreate_with_drm_fd
This env var forces the creation of a specific renderer. If no renderer
is specified, the function will try to create all of the renderers one
by one until one is created successfuly.
2021-04-20 21:14:27 +02:00
Simon Zeni 10c5199d85 render/gles2: introduce wlr_gles2_renderer_create_with_drm_fd 2021-04-20 21:14:27 +02:00
nyorain 572b5910bb render: Assert that texture dimensions are > 0 2021-04-20 18:10:48 +02:00
ayaka ed1924800d render: make GLES2 renderer optional
Allow selecting whether the GLES2 renderer gets enabled.

Co-authored-by: Simon Ser <contact@emersion.fr>
2021-04-17 16:39:40 +02:00
Simon Zeni 122d6c6988 renderer: create pixman renderer if getting drm fd failed 2021-04-17 09:54:39 +02:00
Simon Zeni 0d90dddfab render: introduce pixman renderer 2021-04-17 09:54:39 +02:00
Simon Ser c6b009ef85 render: introduce shared memory allocator
It allocates in local main memory via shm_open, and provides a FD
to allow sharing with other processes.

This is suitable for software rendering under the Wayland and X11
backends.
2021-04-17 09:54:39 +02:00
Simon Zeni 84dea55b20 render: rename get_dmabuf_render_formats into get_render_formats 2021-04-15 17:10:06 +02:00
Simon Ser 004cf887b7 render/gles2: prevent imported DMA-BUF textures from being mutated
The compositor shouldn't write to client buffers if the client
attaches a DMA-BUF to a wl_surface, then attaches a shm buffer.
Make gles2_texture_write_pixels return an error to prevent this
from happening.
2021-04-15 10:49:42 +02:00
Roman Gilg b36af22c94 backend: move get_drm_fd to public interface
The get_drm_fd was made available in an internal header with a53ab146f. Move it
now to the public header so consumers opting in to the unstable interfaces can
make use of it.
2021-04-12 11:43:56 +02:00
Stephan Hilb 9f012cac2f drm: check for PRIME support
PRIME support for buffer sharing has become mandatory since the renderer
rewrite. Make sure we check for the appropriate capabilities in backend,
allocator and renderer.

See also #2819.
2021-04-10 10:49:55 +02:00
Simon Ser a109a80dca render: drop support for ellipses
For anything more complicated than quads, compositors can easily
ship their own shaders.

Closes: https://github.com/swaywm/wlroots/issues/2759
2021-04-08 09:10:03 +02:00
Simon Ser 9ecfa4343a render: remove wlr_texture_to_dmabuf
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-08 09:09:50 +02:00
Simon Ser 1cdef8da57 render: drop wlr_renderer_blit_dmabuf
It can be replaced with wlr_renderer_bind_buffer. blit_dmabuf is
broken as-is (dies on an assertion).
2021-04-08 09:09:03 +02:00
zccrs 69e1997ebe render/egl: check "EGL_KHR_platform_gbm" for EGL gbm platform
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-07 15:38:35 +02:00
Simon Ser b514d4afe2 render/egl: stop relying on platform for high priority
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-04-06 14:57:54 +02:00
Simon Ser b89bcffea4 render/egl, backend/wayland: add workaround for split render/display setups
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-27 11:23:32 +01:00
Simon Zeni 78d21fa131 render/gles2: remove depth and bpp gles2_pixel_format, use drm pixel format 2021-03-25 10:55:54 +01:00
Simon Zeni 9b3f2e327f render/pixel_format: add XBGR8888 and ABGR8888 format 2021-03-25 10:55:54 +01:00
Simon Zeni 50d2985607 Move render/shm_format functions to render/pixel_format 2021-03-25 10:55:54 +01:00
Simon Zeni 5fd82c6f54 render/pixel_format: introduce pixel format info table 2021-03-25 10:55:54 +01:00
Simon Ser 2382684e94 render/egl: don't fail on EGL_MESA_device_software
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-03-15 15:14:33 +01:00
Simon Zeni 9601a2abf0 output: improve transform matrix calculation
Compute only the transform matrix in the output. The projection matrix
will be calculated inside the gles2 renderer when we start rendering.

The goal is to help the pixman rendering process.
2021-03-10 15:33:36 +01:00
Simon Ser 27fba3df43 render: use DRM formats in wlr_texture_from_pixels 2021-02-23 16:09:26 +01:00
Simon Ser b54ef3372d render: use DRM formats in wlr_renderer_read_pixels 2021-02-23 16:09:26 +01:00
Simon Ser 00bf6674b3 output: use DRM format in wlr_output_preferred_read_format 2021-02-23 16:09:26 +01:00
Simon Ser ddfee63055 render: use DRM formats in wlr_renderer_get_shm_texture_formats 2021-02-23 16:09:26 +01:00
Simon Ser 549435aee5 render/gles2: replace wlr_gles2_texture.wl_format with drm_format 2021-02-23 16:09:26 +01:00
Simon Ser fab396f149 render/gles2: convert format table to DRM formats 2021-02-23 16:09:26 +01:00
Simon Ser 5d6d76c61f render/shm_format: add wl_shm_format conversion helpers 2021-02-23 16:09:26 +01:00
Simon Ser bfd020047d render/gles2: remove current_buffer checks
All backends now use wlr_swapchain. This means the renderer is
guaranteed to have a current_buffer bound.

Remove the legacy code used for EGLSurface.
2021-02-19 23:36:00 +01:00
Simon Ser 6ca59519c9 render/gles2: check buffer stride when uploading texture
If the stride is too small, the driver could end up segfaulting
(e.g. radeonsi segfaults in __memmove_sse2_unaligned_erms).
2021-02-19 23:35:38 +01:00
Simon Ser 9396d8433a
render/gles2: remove YUV blocklist
Mesa provides YUV shaders, and can import multi-planar YUV DMA-BUFs
as a single EGLImage. Remove the arbitrary limitation.

If the driver doesn't support importing YUV as a single EGLImage,
the import will fail and the result will be the same anyways.
2021-02-05 15:56:29 +01:00
Simon Ser 3d7aa73867 render/dmabuf: make src arg const in wlr_dmabuf_attributes_copy 2021-02-02 19:53:16 +01:00
Simon Ser 7ac2ce25e3 render/dmabuf: cleanup on wlr_dmabuf_attributes_copy error 2021-02-02 19:52:20 +01:00
Quantum 975d14b799 render/wlr_texture: clamp texture coordinates to edge by default
Clamping texture coordinates prevents OpenGL from blending the left and
right edge (or top and bottom edge) when scaling textures with GL_LINEAR
filtering. This prevents visual artifacts like swaywm/sway#5809.

Per discussion on IRC, this behaviour is made default. Compositors that want
the wrapping behaviour (e.g. for tiled patterns) can override this by doing:

    struct wlr_gles2_texture_attribs attribs;
    wlr_gles2_texture_get_attribs(texture, &attribs);

    glBindTexture(attribs.target, attribs.tex);
    glTexParameteri(attribs.target, GL_TEXTURE_WRAP_S, GL_REPEAT);
    glTexParameteri(attribs.target, GL_TEXTURE_WRAP_T, GL_REPEAT);
    glBindTexture(attribs.target, 0);
2021-02-01 21:19:17 +01:00
Simon Ser 01d21cdd9f render/egl: log whether DMA-BUF modifiers are supported 2021-02-01 16:16:37 +01:00
Brandon Dowdy f1d37c54c8 render/egl: add check for EGL_KHR_surfaceless_context
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.
2021-02-01 09:31:44 +01:00
Brandon Dowdy 8aa38fe73e render/egl: remove *config_attribs and wlr_egl->config
Breaking changes:

Both "EGLint *config_attribs" and "wlr_egl->config" no longer exist.
2021-01-29 10:03:24 +01:00
Brandon Dowdy 705b3da7cb render/egl: remove wlr_egl_{create,destroy}_surface
Breaking changes:

wlr_egl_create_surface and wlr_egl_destroy_surface have been
removed and no longer exist.
2021-01-29 10:03:24 +01:00
Simon Ser a406f19479 render/egl: fix NULL dereference when using llvmpipe
Fixes: 6becc69ec9 ("render/egl: fail to create wlr_egl on software renderer")
2021-01-27 21:12:19 +01:00
Simon Zeni 6becc69ec9 render/egl: fail to create wlr_egl on software renderer
The creation of `wlr_egl` will fail is the device extension
EGL_MESA_device_software is defined. The creation process is allowed to
continue only if the environment variable `WLR_RENDERER_ALLOW_SOFTWARE`
is defined to the value 1.
2021-01-27 15:50:19 +01:00