Commit Graph

799 Commits

Author SHA1 Message Date
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
Simon Ser 4f06ce2550 render/gbm_allocator: avoid drmPrimeHandleToFD
Some drivers (e.g. nouveau) need to do some book-keeping when exporting
a BO handle to a DMA-BUF [1]. Using drmPrimeHandleToFD directly hides
the export from the user-space drivers and causes some ref'counting
issues.

So we can't properly handle BOs with a different handle for each plane
until [2] lands.

[1]: https://gitlab.freedesktop.org/drm/nouveau/-/issues/43#note_772661
[2]: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5442

Suggested-by: Ilia Mirkin <imirkin@alum.mit.edu>
2021-01-23 16:41:54 +01:00
Simon Ser 7c995b78b2 Revert "render: add wlr_egl_create_from_drm_fd function"
This reverts commit ee31be167b.
2021-01-20 21:32:50 +01:00
Simon Ser 54e5ef39c0 Revert "render/egl: remove unused gbm_device member"
This reverts commit 306cf11d87.
2021-01-20 21:32:50 +01:00
Simon Zeni 306cf11d87 render/egl: remove unused gbm_device member 2021-01-20 15:29:00 +01:00
Simon Zeni ee31be167b render: add wlr_egl_create_from_drm_fd function 2021-01-20 15:29:00 +01:00
Simon Ser bf86110fc5 render/gbm_allocator: set modifier to INVALID if implicit
When gbm_bo_create is used and the GBM implementation does support
modifiers, gbm_bo_get_modifier may return something other than
DRM_FORMAT_MOD_INVALID. This can cause issues with the rest of the
stack (e.g. EGL or KMS) in case these don't support modifiers.

Instead, force the modifier to INVALID, to make sure no one uses
modifiers.
2021-01-17 10:27:46 +01:00
Simon Ser b5cefada92 render/gbm_allocator: export to DMA-BUF on init
Instead of lazily exporting BOs to DMA-BUFs, do it on init. This is
the only way to use the buffer, so there's no point in deferring
that work.

This is preparatory work for the next commit.
2021-01-17 10:27:46 +01:00
Simon Ser 2f11914613 render: introduce private wlr_renderer_autocreate_with_drm_fd 2021-01-16 22:52:26 +01:00
Simon Ser 32c30481d3
render/egl: fix gbm_device use-after-free
The GBM device needs to be destroyed after the EGL display.

    ==50931==ERROR: AddressSanitizer: SEGV on unknown address 0x7fe40a000049 (pc 0x7fe446121d30 bp 0x60400001bbd0 sp 0x7ffc99c774d0 T0)
    ==50931==The signal is caused by a READ memory access.
        #0 0x7fe446121d30  (/usr/lib/dri/radeonsi_dri.so+0x5f0d30)
        #1 0x7fe4474717bd  (/usr/lib/../lib/libEGL_mesa.so.0+0x177bd)
        #2 0x7fe4474677d9  (/usr/lib/../lib/libEGL_mesa.so.0+0xd7d9)
        #3 0x7fe44cca7b6f in wlr_egl_destroy ../subprojects/wlroots/render/egl.c:379
        #4 0x7fe44ccc2626 in gles2_destroy ../subprojects/wlroots/render/gles2/renderer.c:705
        #5 0x7fe44ccb5041 in wlr_renderer_destroy ../subprojects/wlroots/render/wlr_renderer.c:37
        #6 0x7fe44cd17850 in backend_destroy ../subprojects/wlroots/backend/wayland/backend.c:296
        #7 0x7fe44ccca4de in wlr_backend_destroy ../subprojects/wlroots/backend/backend.c:48
        #8 0x7fe44cd11b21 in multi_backend_destroy ../subprojects/wlroots/backend/multi/backend.c:58
        #9 0x7fe44cd125b0 in handle_display_destroy ../subprojects/wlroots/backend/multi/backend.c:125
        #10 0x7fe44c315e0e  (/usr/lib/libwayland-server.so.0+0x8e0e)
        #11 0x7fe44c3165a6 in wl_display_destroy (/usr/lib/libwayland-server.so.0+0x95a6)
        #12 0x55a2c8870683 in server_fini ../sway/server.c:203
        #13 0x55a2c886cbf2 in main ../sway/main.c:436
        #14 0x7fe44b77c151 in __libc_start_main (/usr/lib/libc.so.6+0x28151)
        #15 0x55a2c883172d in _start (/home/simon/src/sway/build/sway/sway+0x33472d)
2021-01-16 09:07:56 +01:00
Simon Ser afdf4dc890 render/gles2: make EGL context current in bind_buffer
Instead of requiring callers to manually make the EGL context current
before binding a buffer and unsetting it after unbinding a buffer, do
it inside wlr_renderer_bind_buffer.

This hides renderer-specific implementation details inside the
wlr_renderer interface. Non-GLES2 renderers may not use EGL.
This removes all EGL dependencies from the backends.

References: https://github.com/swaywm/wlroots/issues/2618
References: https://github.com/swaywm/wlroots/pull/2615#issuecomment-756687006
2021-01-16 09:06:17 +01:00
Simon Zeni e128e6c08d render: drop egl parameters from wlr_renderer_autocreate 2021-01-16 08:57:42 +01:00
Simon Ser 87293d1b15
render: extract gles2 build files to subdir
This will make it easier to toggle when we make our GLES2 renderer
optional.
2021-01-15 22:13:04 +01:00
Simon Ser c73a8cde83 render/gbm_allocator: fix gbm_device use-after-free
We need to destroy any gbm_bo we've created before gbm_device_destroy.

Closes: https://github.com/swaywm/wlroots/issues/2601
2021-01-15 19:27:49 +01:00
Simon Ser f0303978e3
render/gbm_allocator: log GBM backend name 2021-01-15 11:18:17 +01:00
Simon Ser 642b349e94 render/gles2: restore EGL context after texture operations
It can be surprising and unexpected that texture operations (such as
texture upload and import) change the current EGL context, especially
when it's done under-the-hood by wlroots in response to wl_surface
requests.

To prevent surprises, save and restore the previous EGL context.
2021-01-15 10:19:31 +01:00
Simon Ser 02a086599c
render/gles2: save/restore EGL context in destroy_buffer
It can be surprising that destroying a buffer changes the EGL context,
especially since this can be triggered from anywhere wlr_buffer_unlock
is called.

Prevent this from happening by saving and restoring the EGL context.
2021-01-14 12:00:06 +01:00
Simon Ser 3f7e0cf5f0 render/egl: remove surface and buffer age args from make_current
These aren't used anymore.
2021-01-12 11:31:04 +01:00
Simon Ser 1d461687d2 render/egl: replace init/finish with create/destroy
This ensures wlr_gles2_renderer can properly take ownership of the
wlr_egl.

Closes: https://github.com/swaywm/wlroots/issues/2612
2021-01-12 11:31:04 +01:00
Simon Ser 50b120927d render/egl: remove wlr_egl_swap_buffers 2021-01-12 11:31:04 +01:00
Simon Ser 76ed2255ef render/egl: remove support for EGL_NATIVE_VISUAL_ID
Nobody uses it anymore.
2021-01-12 11:31:04 +01:00
Simon Ser 2585f322cb
render/gles2: fix EGL use-after-free
The wlr_egl was cleaned up too early.

While at it, also fix a memory leak.

Fixes: b899a412e3 ("backend: remove wlr_egl from all backends")
2021-01-12 10:45:14 +01:00
Simon Zeni b899a412e3 backend: remove wlr_egl from all backends 2021-01-07 17:11:22 +01:00
Simon Ser 07d75c99db render: remove EGL config and visual from wlr_renderer_autocreate
This isn't used anymore by any backend.

Some examples still provide an EGL config to wlr_egl_init, so we can't
drop it yet there.
2021-01-06 12:05:51 +01:00
Simon Ser c4635c68d2 render/drm_format_set: add special case for LINEAR-only formats
Our wlr_format_set structs don't hold GBM usage flags. Instead, users
who want to get a LINEAR buffer can use the DRM_FORMAT_MOD_LINEAR
modifier even if the kernel driver doesn't support modifiers.

Add a special case to wlr_drm_format_intersect to properly handle this
situation.
2020-12-30 11:17:43 +01:00
Simon Ser b9460ab724
Stop using wlr_texture_get_size
Just use wlr_texture.{width,height} directly.
2020-12-25 12:21:29 +01:00
Simon Ser d37214cb16 render/drm_format_set: add wlr_drm_format_{create,add} 2020-12-18 09:41:12 +01:00
Simon Ser bdf26f87d5
render/allocator: ignore NULL in wlr_allocator_destroy 2020-12-17 20:34:19 +01:00
Simon Ser 3fd8098881
render/gles2: require GL_EXT_unpack_subimage
We implicitly depended on this extension.
2020-12-15 14:55:18 +01:00
Ilia Bozhinov 12ede67c62 egl: fix memory leak
I have noticed this with LeakSanitizer, I hope these are all occurrences.
2020-12-10 23:29:59 +01:00
Simon Ser f91e89fd9f render/gles2: query alpha size from render buffer
If we're using a render buffer, query the alpha size from it.

Closes: https://github.com/swaywm/wlroots/issues/2527
2020-12-09 21:45:28 +01:00
Simon Ser be8403e73d render/gles2: don't eglGetConfigAttrib on EGL_NO_CONFIG_KHR
If we don't have an EGL config, don't try to query anything from it.
2020-12-09 21:45:28 +01:00
Simon Ser 8a6930c138
render/drm_format_set: assert len <= cap when duplicating 2020-12-08 23:35:05 +01:00
Simon Ser 29da97c185
render/drm_format_set: allocate using cap when duplicating
In wlr_drm_format_dup, allocate the new wlr_drm_format using cap instead
of len. This makes it so the cap field is up-to-date and the chunk of
memory isn't too small if we append new modifiers (we don't allow this
yet but might in the future).
2020-12-08 16:02:44 +01:00
Simon Ser 037710b1d4 render/egl: support config-less wlr_egl
When using wlr_swapchain, there's no need to select an EGLConfig. Add
support for creating config-less EGL contexts.
2020-12-07 11:40:45 +01:00
Simon Ser 82443ea46b render/drm_format_set: introduce wlr_drm_format_intersect
Intersects modifiers from two wlr_drm_format structs. If either format
doesn't support modifiers, the resulting format won't support modifiers.
2020-12-03 10:52:25 +01:00
Simon Ser 83a5d03bf3 render/egl: remove wlr_egl.external_only_dmabuf_formats
Replace it with wlr_egl.dmabuf_render_formats.
2020-11-30 11:08:44 +01:00
Simon Ser 1f15dd093d render: assert {X,A}RGB8888 are supported
The Wayland protocol requires those to be supported.
2020-11-30 11:08:44 +01:00
Simon Ser c94ab99ae2 render: rename wlr_renderer_get_formats
Rename wlr_renderer_get_formats to wlr_renderer_get_shm_texture_formats.
This makes it clear those formats are only suitable for shm import.
2020-11-30 11:08:44 +01:00
Simon Ser 49115e9d5d render: rename wlr_renderer_get_dmabuf_formats
Rename wlr_renderer_get_dmabuf_formats to
wlr_renderer_get_dmabuf_texture_formats. This makes it clear the formats
are only suitable for creating wlr_textures.
2020-11-30 11:08:44 +01:00
Simon Ser 5d008d9030 render: introduce wlr_renderer_get_dmabuf_render_formats
It describes which DMA-BUF formats can be used to render.
2020-11-30 11:08:44 +01:00
Simon Ser 61612ecb36 render: remove wlr_renderer_format_supported
Instead, callers can just use wlr_renderer_get_formats and iterate over
the list.

This function was unused in wlroots.
2020-11-30 11:08:44 +01:00
Simon Ser 44cea53e72 render/egl: don't rely on being able to open primary node
On some setups (e.g. remote access via SSH) the current user won't have
the permission to open the primary node at all. It's still possible to
use drmGetDevices to match the primary node name returned by EGL.

Closes: https://github.com/swaywm/wlroots/issues/2488
2020-11-28 19:21:36 +01:00
Ronan Pigott dc7c6c4860 render/egl: recognize EGL_BAD_DEVICE_EXT error 2020-11-19 00:42:37 +01:00
Simon Ser eb8360bda3 render: introduce wlr_renderer_get_drm_fd 2020-11-15 22:54:07 +01:00
Simon Ser c8d95acc37 render/egl: introduce wlr_egl_dup_drm_fd 2020-11-15 22:54:07 +01:00
Simon Ser c11c6c4568 render/swapchain: add support for buffer age 2020-11-15 22:48:42 +01:00
Simon Ser 1245730ea2 render/gles2: fix y-inverted output when rendering to buffer 2020-11-15 22:48:42 +01:00
Simon Ser 6136fe87d1 render/gles2: implement wlr_renderer_bind_buffer 2020-11-15 22:48:42 +01:00
Simon Ser c88c54fb38 render: introduce wlr_renderer_bind_buffer 2020-11-15 22:48:42 +01:00
Simon Ser b0a663d39d render: introduce wlr_swapchain
The swapchain maximum capacity is set to 4, so that we have enough room
for:

- A buffer currently displayed on screen
- A buffer queued for display (e.g. to KMS)
- A pending buffer that'll be queued next commit
- An additional pending buffer in case we want to invalidate the
  currently pending one
2020-11-15 22:48:42 +01:00
Simon Ser 7c6212a0f7 render/drm_format_set: introduce wlr_drm_format_dup 2020-11-15 22:48:42 +01:00
Simon Ser 5913040110 render: introduce wlr_gbm_allocator 2020-11-15 22:48:42 +01:00
Simon Ser f47445f142 render: introduce wlr_allocator 2020-11-15 22:48:42 +01:00
Isaac Freund 0724b3c453 Use uint32_t in wlr_renderer_begin signature
This matches the signature of wlr_renderer_impl.begin
2020-11-11 11:01:46 +01:00
Guido Cella 6949d0fd38 render: Don't crash on 0 dimensions
Don't force compositors to check when an empty shape is being renderered.
References #2282. This was motivated by dwl crashing when setting window
borders to 0 (djpohly/dwl#51).
2020-08-27 17:39:31 +02:00
Simon Ser 1dbcfdaf81 render/gles2: remove gles2_procs
Move the global into wlr_gles2_renderer. This removes global state and
allows us to have multiple renderers with different GL loaders.
2020-07-28 06:59:07 -06:00
Simon Ser 62da61716f render/gles2: make push/pop debug functions take a wlr_renderer 2020-07-28 06:59:07 -06:00
Simon Ser e8872d9ed7 render/gles2: keep ref to wlr_gles2_renderer in wlr_gles2_texture 2020-07-28 06:59:07 -06:00
Simon Ser 26af316b3b render/gles2: make wlr_gles2_texture_from_* private
These functions are unused by compositors (see e.g. [1]) and prevent
wlr_gles2_texture from accessing wlr_gles2_renderer state. This is an
issue for proper teardown [2] and for accessing GLES2 extensions.

[1]: https://github.com/swaywm/wlroots/pull/1962#issuecomment-569511830
[2]: https://github.com/swaywm/wlroots/pull/1962
2020-07-28 06:59:07 -06:00
Andri Yngvason 6ef5d18757 render: egl: Use current display to restore NULL context
eglGetCurrentDisplay() returns EGL_NO_DISPLAY when there is no context current
and eglMakeCurrent() needs a display argument.

Fixes #2327
2020-07-14 19:55:20 +02:00
Andri Yngvason e05a85327f render: gles2: Fix y-inversion in gles2_blit_dmabuf() 2020-07-01 11:43:02 +02:00
Simon Zeni 4a4da256dd render/gles2: use glGetAttribLocation instead of hardcoded indices 2020-06-24 20:01:19 +02:00
Simon Ser 58df3eda9f render/egl: print error name
Allows for easier debugging.
2020-06-18 07:56:05 -06:00
Simon Ser 315bf08733 render: add wlr_render_subtexture_with_matrix
This renders only a subset of the texture, instead of the full texture.
2020-06-17 09:10:54 -06:00
Simon Ser 5118189a2b render/gles2: use .x/.y instead of .s/.t
texcoord is a vector of coordinates, with the first member being the X
axis value and the second member being the Y axis value. It makes more
sense to use the accessors with the same names.
2020-06-17 09:10:54 -06:00
Rouven Czerwinski d3d1bac1c2 render: assert sane values for box functions
Width and height should always be > 0 for render functions which take a
wlr_box.

References https://github.com/swaywm/wlroots/issues/2281
2020-06-16 15:16:02 +02:00
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 78d6eed6b3 render: Fix blit_dmabuf() breakage due to API change 2020-06-08 21:37:32 +02:00
Andri Yngvason b64a8a7f98 render: Add wlr_renderer_blit_dmabuf() 2020-06-08 20:49:41 +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 05803511db render/texture: make write_pixels optional 2020-04-28 21:45:14 +02:00
Simon Ser 06f4c3945d render/texture: add width and height fields
Instead of requiring compositors to call wlr_texture_get_size each time
they want to access the texture's size, expose this information as
wlr_texture fields.
2020-04-28 21:45:14 +02:00
Simon Ser 5dc3a9c754 render/gles2: add wlr_gles2_renderer_check_ext 2020-04-22 22:40:54 +02:00
Simon Ser 01d4506253 render/drm_format_set: disallow DRM_FORMAT_INVALID
It doesn't make sense to add DRM_FORMAT_INVALID to a format set. Adding
an assertion allows us to safely query the format set with
DRM_FORMAT_INVALID. See [1].

[1]: https://github.com/swaywm/wlroots/pull/2021#discussion_r385839668
2020-04-22 22:14:44 +02:00
Simon Ser d10f8a98ec render: only expose linux-dmabuf if EGL extension is supported
Only expose linux-dmabuf extension if EGL_EXT_image_dmabuf_import_ext is
supported.

Closes: https://github.com/swaywm/wlroots/issues/2076
2020-04-09 00:16:03 +00:00
Simon Ser 4a1015faff render/gles2: only call wlr_egl_bind_display if supported
This allows us to hard-fail if the extension is advertised but we fail
to enable it.
2020-04-09 00:16:03 +00: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
Isaac Freund c682d97841 Return failure of wlr_renderer_init_wl_display()
This makes it easier for the user of this library to properly handle
failure of this function.

The signature of wlr_renderer_impl.init_wl_display was also modified to
allow for proper error propagation.
2020-03-23 15:19:16 +01:00
Simon Ser a71649dde9 render/gles2: remove duplicated format list 2020-03-09 15:26:28 +01:00
Simon Ser 6d3f3b9300 render/gles2: unbind textures after use
Keeping textures bound results in hard-to-debug situations where some GL
operations incorrectly affect the texture.
2020-01-13 07:52:30 -07: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 346b43e937 render: guard rendering operations between begin() and end()
Add a wlr_renderer.rendering bool, set it to true between
wlr_renderer_begin() and wlr_renderer_end(). Assert we're rendering when
calling functions that render.
2019-12-31 08:07:44 -07:00
Scott Anderson cff1c2f740 meson: Various improvements
Bumps minimum version to 0.51.0

- Remove all intermediate static libraries.
  They serve no purpose and are just add a bunch of boilerplate for
  managing dependencies and options. It's now managed as a list of
  files which are compiled into libwlroots directly.

- Use install_subdir instead of installing headers individually.
  I've changed my mind since I did that. Listing them out is annoying as
  hell, and it's easy to forget to do it.

- Add not_found_message for all of our optional dependencies that have a
  meson option. It gives some hints about what option to pass and what
  the optional dependency is for.

- Move all backend subdirectories into their own meson.build. This
keeps some of the backend-specific build logic (especially rdp and
session) more neatly separated off.

- Don't overlink example clients with code they're not using.
  This was done by merging the protocol dictionaries and setting some
  variables containing the code and client header file.
  Example clients now explicitly mention what extension protocols they
  want to link to.

- Split compositor example logic from client example logic.

- Minor formatting changes
2019-12-23 07:48:29 -05: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
Ronan Pigott 5df606d8ab render/gles2: do not set GL_TEXTURE_MAG_FILTER 2019-11-26 09:42:10 -05:00
Simon Ser bcd5f7d259 render: remove return in wlr_texture_get_size
Otherwise this error happens:

    ../subprojects/wlroots/render/wlr_texture.c: In function ‘wlr_texture_get_size’:
    ../subprojects/wlroots/render/wlr_texture.c:47:9: error: ISO C forbids ‘return’ with expression, in function returning void [-Werror=pedantic]
       47 |  return texture->impl->get_size(texture, width, height);
          |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ../subprojects/wlroots/render/wlr_texture.c:45:6: note: declared here
       45 | void wlr_texture_get_size(struct wlr_texture *texture, int *width,
          |      ^~~~~~~~~~~~~~~~~~~~
2019-11-25 08:54:04 -05:00
Simon Ser 16e5e9541b Add -Wmissing-prototypes
This requires functions without a prototype definition to be static.
This allows to detect dead code, export less symbols and put shared
functions in headers.
2019-11-20 02:05:03 +00:00
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
emersion d643361c48
Merge pull request #1047 from NotKit/gles2fix
Fix GLES2 renderer to use glGetUniformLocations locations
2018-06-13 15:37:16 +01:00
NeKit 6f29db1044 gles2 renderer: introduce struct wlr_gles2_tex_shader 2018-06-13 13:43:01 +03: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
NeKit de91c55ea9 Fix GLES2 renderer to use glGetUniformLocations locations
This is needed as uniform locations are driver implementation-specific.
2018-06-07 18:06:31 +03:00
emersion 6b7a55aa3d
Merge pull request #1020 from emersion/remove-check-dmabuf
render: remove wlr_renderer_check_import_dmabuf
2018-05-31 21:49:57 +01:00
emersion 21928cbe61
Merge branch 'master' into screencontent 2018-05-31 12:33:27 +01:00
Genki Sky d1cf9acbd5 cleanup: Use void for zero-parameter functions
Signed-off-by: Genki Sky <sky@genki.is>
2018-05-30 20:19:16 -04: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
emersion 6eb4b5b54d
Merge pull request #993 from emersion/bind-wl-drm-in-renderer
render: bind wl_drm in renderer
2018-05-25 13:54:16 +01:00
Ilia Bozhinov 24cf70ae96 backends: implement custom EGL and renderer initialization
Compositors now have more control over how the backend creates its
renderer. Currently all backends create an EGL/GLES2 renderer, so
the necessary attributes for creating the context are passed to a
user-provided callback function. It is responsible for initializing
provided wlr_egl and to return a renderer. On fail, return 0.

Fixes #987
2018-05-25 14:56:52 +03:00
agr 4e89e0fc6c fix server exit: eglMakeCurrent Invalid display 2018-05-23 16:17:29 +02:00
emersion 41130fe54b
render: bind wl_drm in renderer 2018-05-21 19:07:08 +01:00
Ilia Bozhinov 47ffd0e184 gles2: pre-multiply alpha and fix blending function 2018-05-18 20:34:36 +03:00
Brian Ashworth 35e83800d4 Fix alpha for src_rgba and src_rgbx 2018-05-15 22:29:36 -04: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
Drew DeVault fecb971518
Merge pull request #902 from emersion/various-memory-leaks
Various memory leaks
2018-04-26 11:34:49 +02:00
emersion 449f06556a
Destroy wlr_surface with wlr_renderer 2018-04-26 00:11:36 +01:00
emersion 71ca45e2c0
Make sure we don't use others' prefixes 2018-04-25 23:24:58 +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
Rostislav Pehlivanov 12298ce88c Do not advertize *RGB8888 as supported shm formats
They're always available and supported, and are added automatically.
Adding them again just duplicates them.
2018-04-21 14:58:25 +01:00
Drew DeVault b116414bd5
Merge pull request #880 from emersion/advertize-renderer-formats
Advertize supported renderer formats
2018-04-21 14:45:09 +02:00
emersion 1588094b99
Remove a few local prefixed symbols 2018-04-21 10:20:33 +01:00
emersion 70d820be25
Add wlr_renderer_init_wl_shm to advertize supported renderer formats 2018-04-20 23:58:30 +01:00
emersion 1b802d9251
Make wlr_renderer_scissor take normal coords instead of upside-down ones 2018-04-12 19:38:33 -04:00
emersion d2ebbd103c
backend: remove wlr_backend_get_egl 2018-04-08 11:00:56 -04: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
emersion 33a2eb4b77
Untie wlr_backend from wlr_renderer 2018-03-31 18:49:43 -04:00
Drew DeVault 23d357e371 Downgrade gles2 messages to L_DEBUG
L_INFO is for stuff that's useful to the user
2018-03-31 00:27:30 -04:00
Orestis Floros c9ed6fed59
Fix build error with -O2
../render/gles2/renderer.c: In function ‘gles2_render_texture_with_matrix’:
../render/gles2/renderer.c:140:2: error: ‘target’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  glBindTexture(target, tex_id);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../render/gles2/renderer.c:145:2: error: ‘prog’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  glUseProgram(prog);
2018-03-31 01:05:33 +03: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
emersion adf4fb08dd
Merge branch 'master' into texture-redesign 2018-03-26 19:13:13 -04:00
emersion 793c3b3047
render: add simple functions to render rectangles and ellipses 2018-03-26 12:41:51 -04:00
emersion c63d94483b
Redesign wlr_texture
- Textures are now immutable (apart from those created from raw
  pixels), no more invalid textures
- Move all wl_drm stuff in wlr_renderer
- Most of wlr_texture fields are now private
- Remove some duplicated DMA-BUF code in the DRM backend
- Add more assertions
- Stride is now always given as bytes rather than pixels
- Drop wl_shm functions

Fun fact: this patch has been written 10,000 meters up in the air.
2018-03-24 23:48:32 -04:00
Guido Günther b1852096c5 linux-dmabuf: Support multi plane formats like NV12 2018-03-23 09:03:31 +01:00
emersion a854c2f246
Merge branch 'master' into gles2-renderer-redesign 2018-03-23 00:55:55 +01:00
emersion b1f93bc5cc
render/egl: use EGL_KHR_debug 2018-03-21 10:42:43 +01:00
emersion 8207f0f081
render/gles2: use gles2_pixel_format::has_alpha for shader selection 2018-03-21 08:53:36 +01:00
emersion cc5ef1d2ff
render/gles2: move list of supported WL formats to pixel_format.c 2018-03-21 08:50:59 +01:00
emersion 3581573bdc
render/gles2: make wlr_renderer_begin take viewport size
This allows raw GL calls outside wlr_renderer to be removed.
2018-03-21 07:37:09 +01:00
emersion 95e86e675a
render/gles2: remove global state, use OpenGL debug extension 2018-03-20 19:14:33 +01:00
Guido Günther 2d01663b25 gles2: Honor alpha in fragment_src_external
By using the same vertex shader and adding alpha to the fragment shader
for external textures we can:

  - use alpha blending
  - have wlr_gles2_render_texture_with_matrix work with
    the GL_TEXTURE_EXTERNAL_OES. So far this failed
    since we passed in alpha which was unknown by fragment_src_external
2018-03-20 14:30:30 +01:00
Guido Günther 13e4ba4867 gles2_texture_bind: use texture's target type
Hardcoding GL_TEXTURE_2D leads to rendering errors when using
GL_TEXTURE_EXTERNAL_OES textures.
2018-03-20 14:30:30 +01:00
Guido Günther b3cb5a36c7 gles2: allow to specify texture target type
Allow to set the texture target type when generating/binding the
texture.  This allows us to attach the texture type to the texture so we
don't have to keep the logic elsewhere.
2018-03-20 14:30:30 +01:00
emersion c41de2d1be
render: split render.h into wlr_renderer.h and wlr_texture.h 2018-03-19 23:16:29 +01:00
emersion 6ecb0eefcb
render/gles2: transpose matrices before binding them
Setting glUniformMatrix3fv's transpose parameter to GL_TRUE is
not allowed for OpenGL ES 2.

This adds a wlr_matrix_transpose function.
2018-03-19 20:21:02 +01:00
Drew DeVault 1956d3cedb
Merge pull request #722 from emersion/matrix-redesign
Matrix redesign
2018-03-17 15:22:00 -04:00
Guido Günther 7fd7dff26f egl: print supported dmabuf formats
Useful for debugging dmabuf related problems e.g. when a client requests
a certain and we fail to support it.
2018-03-16 09:47:21 +01:00
emersion f1cbbac636
render/gles2: remove matrix transposition in shaders 2018-03-15 21:30:31 +01:00
emersion 876f07e9f1
renderer: replace wlr_texture_get_matrix by wlr_render_texture 2018-03-15 19:31:02 +01:00
emersion 0e253e0615
render/gles2: don't set inverted_y when EGL_WAYLAND_Y_INVERTED_WL is unsupported 2018-03-15 15:51:15 +01:00
emersion 8b58e1a3ad
Merge branch 'master' into matrix-redesign 2018-03-15 15:48:09 +01:00
emersion 824a95ad19
matrix: use 2D matrices 2018-03-15 15:33:58 +01:00
Guido Günther 653bc282a7 Indent GLSL by two spaces
since this is the most established indentation
2018-03-15 12:40:18 +01:00
Guido Günther 14cdb6153f Add initial linux_dmabuf protocol support
Tested with

    ./weston-simple-dmabuf-drm
    ./weston-simple-dmabuf-drm --import-immediate=1
    ./weston-simple-dmabuf-drm --y-inverted=1
    (and combinations)

Supports only single plane XRGB dmabufs for now.
2018-03-15 12:40:18 +01:00
emersion d26b67cb06
matrix: unify API, don't use array pointers 2018-03-15 11:10:56 +01:00
emersion b6a3f240c7
matrix: move to types/ 2018-03-15 09:11:27 +01:00
Guido Günther 2d0db16942 render: Flip textures in case of inverted_y 2018-03-11 19:02:05 +01:00
emersion d9571f27e6
Merge pull request #691 from agx/egl_ext_match
Avoid false positives on egl extension matching
2018-02-28 21:22:00 +01:00
Guido Günther d9f2e90df6 Avoid false positives on egl extension matching
Due to the strstr prefix match EGL_EXT_foo would be incorrectly matched
if EGL_EXT_foobar would be available but not foo.

This doesn't matter for the currently checked extensions but will matter
for EGL_EXT_image_dma_buf_import_modifiers vs
EGL_EXT_image_dma_buf_import

Code borrowed from weston
2018-02-28 20:03:06 +01:00
Guido Günther 2dc8a35db2 textures: tell us which texture format is unsupported 2018-02-28 18:36:32 +01:00
Guido Günther d928ddc36c wlr_egl_create_image: return NULL when function is missing
This matches the return value of elgCreateImage in case of error.
2018-02-28 08:44:00 +01:00
Guido Günther d08792bfff Add alpha to wlr_render_with_matrix
so we can use the alpha channel to e.g. blend in textures
2018-02-25 13:47:48 +01:00
Drew DeVault 1d9be89e2d
Revert "ELF Visibility" 2018-02-19 18:01:27 -05:00
Scott Anderson 86269052eb Explicitly export EFL symbols 2018-02-19 14:26:40 +13:00
Guido Günther 4d496802dd Log GL and EGL vendor
useful for debugging
2018-02-15 10:40:19 +01:00
Rodrigo Lourenço 168e26489a Add missing dependencies 2018-02-14 18:42:39 +00:00
emersion c2e1474010
Reformat all #include directives 2018-02-12 21:29:23 +01:00
emersion 36ead80cd1
Make wlr_signal_emit_safe private 2018-02-12 19:52:47 +01:00
emersion 5e58d46cc1
Add wlr_signal_emit_safe 2018-02-12 09:12:31 +01:00
emersion bf6d245400
Swap buffers with damage 2018-02-09 22:54:14 +01:00
emersion ddb1779f9f
render: make wlr_renderer_clear take a float[4] for the color 2018-02-03 09:32:02 +01:00
emersion 51c22d39a4
Merge remote-tracking branch 'upstream/master' into output-damage 2018-01-29 23:24:09 +01:00
Tony Crisci ed5b1fdedd
Merge pull request #580 from emersion/screenshooter-renderer-backport
Backport screenshooter fixes from the renderer redesign v1
2018-01-29 17:13:23 -05:00
emersion f34a1b75eb
render/gles2: use format bpp when reading pixels 2018-01-26 23:13:41 +01:00
emersion 6281deb90f
Merge remote-tracking branch 'upstream/master' into output-damage 2018-01-24 14:48:01 +01:00
emersion 4fa90b0511
Backport screenshooter fixes from the renderer redesign v1
This backports some changes to #319 to fix the screenshooter data
format. This also adds wlr_backend_get_renderer which will be
useful to support multiple renderers.
2018-01-23 22:06:54 +01:00
emersion 415a2b7c56
render: add wlr_renderer_clear and wlr_renderer_scissor 2018-01-22 16:42:22 +01:00
Tony Crisci 85a6939cf2 rename matrix model box to project box 2018-01-21 19:03:10 -05:00
Tony Crisci d13114520a move matrix model code to matrix.h 2018-01-21 15:53:42 -05:00
emersion 0365b587f0
output: add damage tracking via buffer age 2018-01-21 00:06:35 +01:00
emersion a0f24b809e
output: add damage event 2018-01-19 13:13:46 +01:00
emersion bde255933e
output: add wlr_output::damage, fixes #572 2018-01-18 19:47:21 +01:00
emersion 5017d7f762
rootston: only draw damaged regions 2018-01-18 14:36:42 +01:00
Tony Crisci 3751a17321 decorate xwayland views 2018-01-16 07:51:10 -05:00
emersion b99d1f4fcc
Refactor wlr_egl_init to accept config_attribs 2017-12-17 23:51:04 +01:00
Drew DeVault 23fb663ea4
Merge pull request #453 from emersion/surface-transform
Add surface transforms support
2017-12-14 14:43:04 -05:00
emersion 18eb1eee3f
Listen to display destroy in xwayland, rename wlr_egl_free 2017-12-08 00:59:37 +01:00
emersion 4a56957a37
Fix inverted flipped-90 and flipped-270 2017-12-01 09:49:32 +01:00
emersion 6a69b4419f
Make wlr_output_transform_* functions public, refactoring 2017-12-01 09:15:33 +01:00
emersion f4754ad1a2
Fix surface transforms 2017-11-30 23:58:12 +01:00
Scott Anderson bc113c16aa Use correct include path for glapi.h 2017-11-30 10:32:55 +13:00
Scott Anderson 02374b945d Change glapi.sh to generate both files 2017-11-22 14:04:29 +13:00
Scott Anderson 37b8a096a9 Pass backend to render 2017-10-22 10:39:23 +13:00
Scott Anderson 9b984253e2 Move egl.h to render/egl.h 2017-10-22 10:36:07 +13:00
Drew DeVault 9e1ff2dce9 Merge pull request #140 from emersion/screenshooter
Add screenshooter
2017-10-08 10:06:41 -04:00
Scott Anderson c0e5feea37 Add GL/EGL extension loader generator 2017-10-08 13:23:41 +13:00
emersion 0ce3135304
Move read_pixels from output to renderer 2017-10-08 02:11:56 +02:00
Versus Void c5df6ca900 Fix memory leaks 2017-10-05 20:01:56 +00:00
Scott Anderson 009c3747a8 Multi-GPU DRM 2017-10-01 22:29:25 +13:00
Scott Anderson 517ba0bc16 Change egl_get_config to always use visual id 2017-09-29 16:15:09 +13:00
Drew DeVault 220a6e9bf6 Add xwayland activate and fix EGL bug 2017-09-28 09:11:16 -04:00
Tony Crisci 00f1686ce5 unset egl current before terminating display
fixes segfault when closing the compositor with an egl window.
2017-09-25 19:25:59 -04:00
Drew DeVault 9fa822c666 Fix minor typos 2017-09-17 18:29:52 -04:00
Tony Crisci 368f74e4df Refactor meson build files
Use tabs for indentation and break up function calls over 80 col.
2017-08-30 14:30:47 -04:00
Dominique Martinet f24b3df980 wlr renderer/texture: rename init to create when it does alloc 2017-08-19 08:33:31 +02:00
Drew DeVault 27c13d621d Merge pull request #88 from 4e554c4c/alloc_crashing
Prevent alloc errors from crashing
2017-08-15 12:21:58 -04:00
Tony Crisci 4f2b1cc930 implement get_buffer_size for egl buffers 2017-08-15 07:58:07 -04:00
Tony Crisci 72a33b736f implement texture get buffer size 2017-08-15 07:36:50 -04:00
Calvin Lee 5cc7342606 Prevent alloc errors from crashing
Resolves #76
2017-08-15 08:04:57 +02:00
nyorain f998bb8299 Fix style issues 2017-08-14 17:09:56 +02:00
Dominique Martinet 4bbf718e7d impl->destroy cleanup:
- remove trivial destroy() function
 - make sure we check impl and impl->destroy before calling
 - always call free if not implemented
2017-08-14 16:22:31 +02:00
Drew DeVault 2facf1df65 Fix software cursors 2017-08-14 08:43:17 -04:00
Drew DeVault de6f32c84e Refactor away wlr_renderer_state 2017-08-14 08:37:50 -04:00
Drew DeVault 94e6e6334b Refactor out wlr_texture_state 2017-08-14 08:25:26 -04:00
Drew DeVault d4b4bfb8bc Fix #64 2017-08-13 08:26:32 -04:00
nyorain f066ff6d02 Fix external shader 2017-08-12 14:48:24 +02:00
Drew DeVault 2d6d2bcef9 Merge pull request #75 from nyorain/egl_image_leak
Fix egl image leak in gles renderer
2017-08-12 08:22:04 -04:00
nyorain 862bc9783f Fix egl image leak in gles renderer 2017-08-12 11:41:40 +02:00
Dominique Martinet c323bfc6a0 GLES2: detach and delete shaders after LinkProgram
Also make sure program linked correctly!
2017-08-12 00:24:30 +02:00
Drew DeVault 62d8b252c0 Refactor meson and move xdg-shell into wlroots 2017-08-11 09:37:09 -04:00
Drew DeVault a6efb90382 s/gen/ensure/ fixes #47 2017-08-11 09:00:26 -04:00
Drew DeVault c24351681f Refactor EGL handling 2017-08-10 22:15:37 -04:00
Drew DeVault 7095274a9e Merge branch 'master' into drm_buffer 2017-08-10 13:19:39 -04:00
Drew DeVault 3c12a32d1f Merge pull request #58 from acrisci/feature/enable-gl-blending
enable gl blending
2017-08-10 08:41:11 -04:00
Tony Crisci 49e97857c7 enable gl blending
This makes transparency work correctly.

fixes #56
2017-08-10 08:38:55 -04:00
Drew DeVault 888986b038 Remove excess logging 2017-08-10 08:36:45 -04:00
Drew DeVault 7da43ff8b0 Implement wlr_surface_flush_damage 2017-08-10 08:26:16 -04:00
nyorain 073dff63da Fix style issues 2017-08-10 11:05:18 +02:00
nyorain 67369173aa Implement drm (egl) buffer attaching 2017-08-10 10:59:58 +02:00
Drew DeVault e2b7712302 Use texture->pixel_format instead of re-scanning 2017-08-09 22:56:57 -04:00
Drew DeVault 4de930542f Implement partial texture uploads 2017-08-09 22:17:40 -04:00
Drew DeVault bd2e9a7168 Style cleanup 2017-08-09 17:30:22 -04:00
nyorain e167f41fde Rename wlr_surface -> wlr_texture; attach -> upload 2017-08-08 18:25:16 +02:00
Scott Anderson 1db97a9af9 Updated DRM cursor rendering 2017-08-06 21:38:40 +12:00
Drew DeVault 41b98f21e5 Merge pull request #42 from acrisci/bug/no-switch-active-textures
Remove unnecessary calls to glActiveTexture
2017-08-05 18:26:43 -04:00
nyorain fdab81e1c9 Use meson build system 2017-08-05 22:34:24 +02:00
Tony Crisci 9119be1dd1 Remove unnecessary calls to glActiveTexture
Since wlroots shaders only use one texture at a time (ie there is only one
sampler2D variable in any shader), it is unnecessary to switch between active
texture units at this time.
2017-08-05 10:41:05 -04:00
Tony Crisci effea557bb Implement destroying surfaces
Add a signal for wlr_surface destruction on the wlr_surface that compositors
can listen to to remove the surface from their state.

Implement a listener for this in the example wl_compositor to remove the
surface from its internal list of surfaces.

Destroy the surface in the compositor destroy_surface callback given when the
surface resource was created.

Add a reference to the surface resource to the wlr_surface so a compositor can
find it in its list of resources upon wlr_resource destruction.
2017-08-04 11:53:55 -04:00
Tony Crisci 6610aa7ca7 Implement shm buffer surface attach interface
Implement surface_attach method. This is called when a client attaches an shm
buffer with wl_surface_attach().

Implement the GLES2 interface for attaching shm buffers. This creates an opengl
texture with the shm buffer contents for the surface.

This commit also includes some working code to render the surfaces onto the
screen for demonstration purposes.
2017-08-04 11:41:13 -04:00
Drew DeVault b08aa9fd35 Revert "Merge pull request #27 from ascent12/meson"
This reverts commit 85805da021, reversing
changes made to 8189c64d7f.
2017-07-11 22:16:56 -04:00
Scott Anderson a2ba226ba3 Use subdir 2017-07-11 09:56:54 +12:00
Scott Anderson 924bf0f669 Changed build system to meson 2017-07-11 00:28:56 +12:00
Drew DeVault 8920b5d607 Merge branch 'wlcore' 2017-06-29 16:00:24 -04:00
Scott Anderson 0cd94f0cf0 Added software cursor fallback 2017-06-26 17:34:15 +12:00
Drew DeVault 5a2796266f Support wl_shm pixel formats in gles2 renderer 2017-06-23 14:25:55 -04:00
Drew DeVault 2aafb5dd19 Add wlcore/wl_shm (WIP) 2017-06-23 13:41:07 -04:00
Drew DeVault f252c5a792 Manually transpose matricies in shader
Since GLES2 doesn't do this for us, it seems, on all platforms.
2017-06-23 11:46:09 -04:00
Drew DeVault b18209c904 Switch to GLES2
Closes #13
2017-06-23 11:38:45 -04:00
Drew DeVault f4453d104d Reorganize wlr-common 2017-06-21 12:10:07 -04:00
Drew DeVault c9d5a0b2fb Clean up Wayland backend GL context and such 2017-06-20 15:29:27 -04:00
Drew DeVault 2443a070e7 Add colored quad and ellipse rendering primitives 2017-06-15 15:31:13 -04:00
Drew DeVault 7a25d6c50b Destroy gles3 wlr_surfaces 2017-06-09 10:33:02 -04:00
Drew DeVault 2b909e1729 Add error "handling" to gles3 backend 2017-06-09 10:28:50 -04:00
Drew DeVault cd6a40d816 Further improvements to rendering subsystem 2017-06-08 15:52:42 -04:00
Drew DeVault 83f8864f0a Add wlr_renderer and move quad rendering there 2017-06-08 12:02:51 -04:00
Drew DeVault 211488131f Add wlr_shader to wlr-render 2017-06-08 11:30:38 -04:00
Drew DeVault fc1dc1b5b0 Use constant VBO for quad, add matrix stuff 2017-06-07 21:35:07 -04:00