Commit Graph

222 Commits

Author SHA1 Message Date
Drew DeVault 4c9423278a Introduce wlr_renderer_get_egl 2019-11-11 19:10:10 +01:00
Simon Ser 447835afc1 render/gles2: provide public API to access GL texture
Prior to this commit, compositors needed to render the texture to an
intermediate off-screen buffer using wlr_renderer APIs if they wanted to
use a custom rendering path (e.g. render to a 3D scene).

A new wlr_gles2_texture_get_attribs exposes the GL texture target and ID
so that compositors can render wlr_textures with their own shaders. An
example of a compositor doing so is available at [1].

[1]: 3db905b784/src/render.c (L227)
2019-11-07 14:24:03 -05:00
Scott Anderson 85a2ee6d30 render/gles: Simplify textures a bit
We don't need our own enum for types. Instead we just use
GL_TEXTURE_{2D,EXTERNAL_OES}, which already describes usage.

Also fixes a situation where we were using GL_TEXTURE_2D in a situation
we should not have. wl_drm buffers are always GL_TEXTURE_EXTERNAL_OES,
no matter if they're RGB or any other format.
2019-11-06 09:46:01 +01:00
Simon Ser 51416738ea render/egl: prevent use-after-free when destroying current surface 2019-10-23 09:36:50 +00:00
Simon Ser 6bb7639a0f render/gles2: don't unset the current EGL surface when destroying texture
When a texture is destroyed between wlr_egl_make_current and
wlr_egl_swap_buffers, it resets the current EGL surface to NULL. This
makes wlr_egl_swap_buffers fail.

If the EGL context is already current, there's no need to reset it.
2019-10-16 09:40:26 -04: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
Filip Sandborg 734c64a6cc render/gles2: fix calculation for partial gles2 pixel read (#1809) 2019-08-31 23:00:52 +03:00
Drew DeVault 540e23d102 Revert "render/drm: keep old drm_format if realloc fails"
This reverts commit c1be9b6945.
2019-08-12 19:53:39 +09:00
Antonin Décimo c1be9b6945 render/drm: keep old drm_format if realloc fails 2019-08-12 09:37:21 +09:00
Simon Ser 6dbdf5db34 render/dmabuf: add wlr_dmabuf_attributes_copy 2019-06-07 09:06:11 -04:00
Simon Ser e516ea4c79 backend/drm: check format when scanning out DMA-BUF 2019-06-07 09:06:11 -04:00
Simon Ser 107a1789ea render/gles2: print GL_RENDERER
This is often the name of the GPU and can help debugging graphics issues.
2019-05-07 10:51:52 -06: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
Scott Anderson c01b81c99c
render: introduce wlr_drm_format_set
This types adds a container for formats + modifiers.

A list that is of [format [modifier]] was chosen instead of
[format modifer] because that is how GBM accepts them.

Co-Authored-By: emersion <contact@emersion.fr>
2019-04-01 19:15:56 +03:00
emersion 5445d8aad0 meson: enable more compiler warnings 2019-03-01 09:20:23 +01:00
emersion 75371d2c88
Require libdrm >= 2.4.95 2019-01-29 19:33:38 +01:00
Timidger 9af0c5338f
Standardize the wlr_box input paramaters
Fixes #1094
2018-12-21 13:56:10 -05:00
Ilia Bozhinov fb5691b6cc output: add wlr_output_preferred_read_format()
The read format is dependent on the output, so we first need to make it
current. This fixes a race condition in wlr-screencopy-v1 where a dmabuf
client would cause EGL_NO_SURFACE to be bound at the time when
screencopy needs to query for the preferred format, causing GL errors.
2018-11-24 10:54:25 +01:00
emersion 1b9ebcf645
output: make wlr_egl flip the damage 2018-11-13 16:55:33 +01:00
emersion 09550032b7
render: correctly set EGL_RENDERABLE_TYPE
This should be set to EGL_OPENGL_ES2_BIT.

Also fixes EGL config attributes in the headless and X11 backends.
2018-11-10 13:20:54 +01:00
emersion d592dcdedd
render/gles2: check for GL_OES_EGL_image_external 2018-11-04 09:00:55 +01:00
emersion 62d646f2b8
render/gles2: remove assumptions about supported formats
We were assuming GL_BGRA_EXT was always supported.

We now check that it's supported for rendering. We fail if it isn't because
this format is specified as "always supported" by the Wayland protocol.

We also check if it's supported for reading pixels. A new preferred_read_format
function returns the preferred format that can be used to read pixels. This is
used by the screencopy protocol.
2018-11-04 09:00:51 +01:00
emersion b42fc4f2b1
render: on Wayland, make eglSwapBuffers non-blocking 2018-10-28 09:58:20 +01:00
nyorain cb03a41a3b Use enum wl_shm_format for gles2 texture formats
Also rephrase the write_pixels comment.
2018-10-16 09:35:28 +02:00
nyorain cd28637187 Remove fmt parameter from wlr_texture_write_pixels
It's not allowed to change the format of a texture so remove
the confusing parameter.
2018-10-15 23:56:56 +02:00
Cole Mickens 7297348736 render: fix meson including libdrm 2018-10-15 13:34:23 -07: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 2f0815838d Init dmabuf global in renderer 2018-09-02 08:50:43 +02:00
Scott Anderson dc37194291 Change how glgen.sh outputs files
This fixes building wlroots as a subproject.
2018-08-24 19:35:21 +12:00
Scott Anderson fd3fa760d3 Revert "Revert "Merge pull request #1194 from ascent12/meson_feature""
This reverts commit 9c886f20b9.
2018-08-24 19:35:02 +12:00
Drew DeVault 9c886f20b9 Revert "Merge pull request #1194 from ascent12/meson_feature"
This breaks wlroots when used as a meson subproject.

This reverts commit dea311992e, reversing
changes made to 6db9c4b746.
2018-08-23 21:00:58 -04:00
Scott Anderson a2bbf2c1f7 Make style more consistent 2018-08-22 21:16:16 +12:00
Mariusz Bialonczyk ad406db21c gles2: change context when it is not current
Texture functions, that create and manipulate textures should switch
the current context if necessary.

thanks to: @emersion

Fixes #934
2018-08-03 07:43:22 +02:00
Drew DeVault b902c2bd7c Revert "Move side-effect out of assert statement"
This reverts commit a0afedcd8f.
2018-07-13 15:46:54 -04:00
Drew DeVault a0afedcd8f Move side-effect out of assert statement 2018-07-13 13:54:09 -04:00
emersion c4915d1492 render: add wlr_texture_is_opaque 2018-07-12 23:35:33 +01:00
emersion 7cbef15206
util: add wlr_ prefix to log symbols 2018-07-09 22:49:54 +01:00
emersion cc9b198f9e
render/gles2: ditch extra parens 2018-06-30 23:19:02 +01:00
emersion bf7560b7cd
screencopy: add capture_output_region support 2018-06-30 22:18:04 +01:00
emersion 2b9cbaddf3
screencopy: add support for frame flags 2018-06-30 22:18:03 +01:00
Dominique Martinet 4cc4412481 wlr_renderer_destroy: fix renderer NULL check
renderer is checked for NULL, but was dereferenced before that.

Found through static analysis
2018-06-30 11:38:21 +09:00
emersion 57548b557a
Merge branch 'master' into screencontent 2018-06-17 14:49:18 +01:00