Commit Graph

18155 Commits

Author SHA1 Message Date
Konstantin 6fa9da0431 tests: enable CI for both GLES2 and GLES3 variants
Signed-off-by: Konstantin <ria.freelander@gmail.com>
2023-10-09 17:25:28 +00:00
Konstantin Pugin ee107cd491 glamor: support GLES3 shaders
Some hardware (preferably mobile) working on GLES3 way faster than
on desktop GL and supports more features. This commit will allow using
GLES3 if glamor is running over GL ES, and version 3 is supported.

Changes are the following:
1. Add compatibility layer for 120/GLES2 shaders with defines in and out
2. Switch attribute and varying to in and out in almost all shaders
   (aside gradient)
3. Add newGL-only frag_color variable, which defines as gl_FragColor on
   old pipelines
4. Switch all shaders to use frag_color.
5. Previous commit is reverted, because now we have more than one GL ES
version, previous commit used to set version 100 for all ES shaders, which
is not true for ES 3

Signed-off-by: Konstantin Pugin <ria.freelander@gmail.com>
2023-10-09 17:25:28 +00:00
Konstantin 8adff2891f glamor: require GLES 2.0 on GL ES CI
This will help us to catch GLES 2.0 only bugs.

Signed-off-by: Konstantin <ria.freelander@gmail.com>
2023-10-09 17:25:28 +00:00
Michel Dänzer d5ef57f1ef test: Skip Xwayland test early if PIGLIT_DIR / XTEST_DIR isn't set
No point starting weston and waiting for it to start up in that case.
2023-10-09 14:22:19 +00:00
Michel Dänzer 129ec1cb84 test: Propagate Xwayland stdout/stderr output and exit status
If waiting for weston to start times out. This should make it easier
to diagnose issues.
2023-10-09 14:22:19 +00:00
Michel Dänzer e58203c1e2 test: Kill weston whenever shell exits
This script runs with -e, so if the timeout command returns a non-0
exit status (meaning the while loop timed out), the script exits
immediately as well.

This would leave weston running in the background, which resulted in
meson waiting for weston to terminate until hitting meson's own timeout.

Instead, explicitly kill weston whenever the shell exits. This results
in meson recording the test as failed immediately.

As a bonus, we can drop the special handling around run-piglit.sh.

v2:
* Use trap (José Expósito)
v3:
* Explicitly use bash, and document a bashism we rely on
  (Olivier Fourdan)
2023-10-09 14:22:19 +00:00
Michel Dänzer 3e938ed042 test: Wait only up to 5 seconds for weston to start up
This should be plenty even on CI, no need to wait for a whole minute if something
goes wrong.
2023-10-09 14:22:19 +00:00
Olivier Fourdan 6b56ae68e5 xwayland: Give up on EI on setup failure
If we fail to setup EI, give up on using EI for XTEST and restore the
default XTEST handlers.

This happens when neither the portal nor the socket backends are usable.

This does not affect the portal operation though, if the user choose not
to allow a particular client, Xwayland would continue to use EI.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Joshua Ashton <joshua@froggi.es>
2023-10-09 07:33:09 +00:00
Olivier Fourdan cfcbb075c2 xwayland: Add an option to enable EI portal support
With EI support wired to XTEST, and oeffis being enabled unconditionally
means that Xwayland will always go through the XDG portal for XTEST when
supported.

While this the intended behavior for the general use case of Xwayland
running rootless on a desktop compositor, that breaks when Xwayland is
running on a nested compositor, because the portal is for the entire
session and not limited to the nested Wayland compositor.

Xwayland itself, as a regular Wayland client, has no way to tell that it
is running on a nested compositor.

So to keep backward compatibility with existing (and also common) use
cases such as nested compositors, best is to disable support for the XDG
portal by default, and add a new command line option "-enable-ei-portal"
for the Wayland compositors (who spawn Xwayland rootless) to explicitly
enable support for the input emulation XDG portal in Xwayland.

A Wayland compositor running nested should not use that command line
option with Xwayland.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Joshua Ashton <joshua@froggi.es>
Fixes: a1333342 - xwayland: Add XTEST support using EIS
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1586
See-also: https://gitlab.gnome.org/GNOME/mutter/-/issues/3047
2023-10-09 07:33:09 +00:00
José Expósito 287638db59 xwayland/glamor/gbm: Set GBM_BO_USE_LINEAR if only LINEAR modifier is supported
Some drivers might not support explicit format modifiers. On these
drivers `gbm_bo_create_with_modifiers()` will fail and the
`gbm_bo_create()` code path will be used instead.

In this case, if the LINEAR modifier is advertised (and the INVALID
modifier is not) add the `GBM_BO_USE_LINEAR` flag.

Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1438
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Signed-off-by: José Expósito's avatarJosé Expósito <jexposit@redhat.com>
2023-10-04 14:37:45 +02:00
José Expósito 722e464bff test: Xwayland doesn't start when another X server is running
When running the xserver:xwayland / XTS test in an environment where
an X server is running for :0, Xwayland fails to start with error:

    (EE)
    Fatal server error:
    (EE) Server is already active for display 0
        If this server is no longer running, remove /tmp/.X0-lock
        and start again.
    (EE)

And the `timeout` command fails instead of waiting for Weston to
initialize.

Add the `-displayfd` parameter to Xwayland to avoid this issue.

The `-displayfd` parameter lets Xwayland pick an unused display number,
avoiding the start up error when an X server is already active for :0,
the default display number.

Suggested-by: Michel Dänzer <mdaenzer@redhat.com>
Signed-off-by: José Expósito <jexposit@redhat.com>
2023-09-27 11:59:53 +02:00
Michel Dänzer 32c5b2c044 xwayland/present: Handle NULL window_priv in xwl_present_cleanup
This can happen if the window has never completed a Present operation.

Fixes: 4230176080 ("xwayland/present: Embed present_vblank_rec in xwl_present_event")
2023-09-26 14:08:08 +00:00
Konstantin f273c960c1 glamor: add gl_PointSize for ES shaders
GLES3.2 spec, page 126:
> The variable gl_PointSize is intended for a shader to write
> the size of the point to be rasterized. It is measured in pixels.
> If gl_PointSize is not written to, its value
> is undefined in subsequent pipe stages.

If glamor shader is use points, we should define gl_PointSize for GLES.
On Desktop GL, it "just work" due to default gl_PointSize is 1.

As @anholt requested, define this only for minimal amount of shaders
(point and glyphbit ones), to make sure than performance will not
affected

Reviewed-by: Emma Anholt <emma@anholt.net>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Konstantin <ria.freelander@gmail.com>
2023-09-20 03:00:00 +00:00
Konstantin baaddf47d5 glamor: fixes GL_INVALID_ENUM errors on ES if there is no quads
If there is no quads to draw, then we have a possibility to call
glDrawElements with type as zero, which will generate
GL_INVALID_ENUM error. While this error is harmless, it is annoying.

Signed-off-by: Konstantin <ria.freelander@gmail.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2023-09-19 13:42:34 +03:00
Michel Dänzer d1f142891e glamor: Ignore destination alpha as necessary for composite operation
If the destination drawable is a window with effective depth 24 backed
by a depth 32 pixmap.

Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1575
2023-09-12 16:57:16 +02:00
José Expósito 8cce7f5d64 test: Use Xwayland instead of wayland/weston-info
When neither `wayland-info` nor `weston-info` are installed, the
`xwayland-piglit.sh` script will wait indefinitely for the compositor
to start.

Use `Xwayland -pogo` instead to wait until weston is initialized.

Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1536
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Signed-off-by: José Expósito <jexposit@redhat.com>
2023-09-04 15:18:19 +00:00
Olivier Fourdan e820030de2 xtest: Check whether there is a sendEventsProc to call
If a client tries to send XTEST events while there is no sendEventsProc
defined for the given device, Xwayland would call into 0x0 and crash.

Make sure the handler is defined before trying to use it, to avoid the
crash.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1574
2023-09-04 11:08:42 +02:00
Sam James 94945a5274 Switch to libbsd-overlay
This is more portable than libbsd as everything Just Works, even on BSD systems,
and is the recommended method of consuming libbsd nowadays.

It also helpfully lets things work with glibc-provided functions for new
enough glibc.

Closes: https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/973
Co-authored-by: Guillem Jover <guillem@hadrons.org>
Signed-off-by: Sam James <sam@gentoo.org>
2023-08-16 19:56:50 +00:00
Kenny Levinsen 8128a21554 xwayland: Default geometry for undecorated rootful
We specify a sensible default geometry for decorated rootful windows,
but not for undecorated ones. Make the default geometry apply to rootful
windows in general.

Signed-off-by: Kenny Levinsen <kl@kl.wtf>
2023-08-11 17:26:48 +02:00
Kenny Levinsen 53b6d4db7e xwayland: Apply root toplevel configure dimensions
While we now have support for resize of the root window through
libdecor, we still ignore toplevel configure dimensions when libdecor is
not in use. This ignores user intent in many Wayland servers, and some
xdg_toplevel states when active have strong requirements for adherence
to configure dimensions.

Resize in response to xdg_toplevel configure dimensions like we do for
libdecor configure events.

Signed-off-by: Kenny Levinsen <kl@kl.wtf>
2023-08-11 17:26:35 +02:00
Kenny Levinsen 4f869c6eda xwayland: Make xwl_window_libdecor_resize reusable
The upcoming handling of plain xdg_toplevel.configure events will need
to use the xwl_window resize helper. Move it outside XWL_HAS_LIBDECOR,
move the remaining dimension logic from handle_libdecor_configure into
it and update the name accordingly.

Signed-off-by: Kenny Levinsen <kl@kl.wtf>
2023-08-11 17:18:08 +02:00
Kenny Levinsen 295fb71653 xwayland: Commit after acknowledging configure
When handling libdecor configure, we first update our xwl output and
screen if dimensions differ from the current xwl_screen, and then commit
a new libdecor frame which acknowledges the xdg_surface.configure event.

If the initial configure events contains non-zero dimensions, we will
update the xwl output before acknowledging the initial configure. As we
attach a buffer and commit the surface when updating the output, this
leads to a protocol error.

Instead, move the surface commit till the end of the configure handler
so it always happens after the ack.

Signed-off-by: Kenny Levinsen <kl@kl.wtf>
2023-08-10 16:20:08 +02:00
Olivier Fourdan 34446a9952 xwayland: Make fullscreen used a fixed size
Similar to commit 94deed272 - " xwayland: Use sensible defaults for
rootful size", mark fullscreen mode as fixed so that the actual monitor
layout is not reflected in the single fullscreen rootful window.

Without this, if "-fullscreen" is used without "-geometry", the XRandR
configuration is taken from the compositor via wl_output/xdg-output and
cannot be changed by the X11 clients.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2023-07-27 09:58:51 +02:00
Olivier Fourdan 881e1a5693 xwayland: Set min/max size for rootful with lidecor
Enforce sensible min/max values for the window size when using libdecor.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2023-07-27 09:58:51 +02:00
Olivier Fourdan f19fe9d260 xwayland: Use update size from libdecor configure handler
This is to avoid repeating the same code in two places.

This is essentially a cosmetic change, not a functional change.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2023-07-27 09:58:51 +02:00
Olivier Fourdan c180eca8ef xwayland: Add configuration to libdecor update size
Allow passing an optional libdecor configuration pointer to
xwl_window_update_libdecor_size() so that we can reuse it from more than
one place and avoid duplicating that code.

No functional change.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2023-07-27 09:58:51 +02:00
Olivier Fourdan 6d00c2bc10 xwayland: attach new buffer from libdecor handlers
The configure handler in libdecor is triggered any time a new
configuration is received.

According to the documentation from libdecor, an application should
respond to that event by creating a suitable libdecor_state, and apply
it using libdecor_frame_commit().

So we ought to attach a new buffer matching the new size and commit
the Wayland surface.

The actual content of the window does not need to be explicitly
repainted, that occurs through the call to SetRootClip():

  xwl_output_set_mode_fixed()
  -> update_screen_size()
     -> SetRootClip()
        -> miHandleValidateExposures()
           -> miWindowExposures()
              -> miPaintWindow()

This fixes an issue with mutter where maximizing a window and then
switching to another window would sometimes resize the Xwayland window
back to its pre-maximized size, or with Weston where the Xwayland window
would initially show up black until the pointer moves to the window.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2023-07-27 09:58:51 +02:00
Olivier Fourdan e37539e1e2 xwayland: Move the libdecor resize to its own function
This moves the code which updates the XRandR modes and sets the root
window size to its own function.

This preparation work for the next commit, no functional change.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2023-07-27 09:58:51 +02:00
Olivier Fourdan cda004c2a9 xwayland: Use the screen width/height for libdecor state
The configure handler for libdecor, namely handle_libdecor_configure(),
is where both the content and the decorations get resized (when needed).

If for any reason, the actual size of the Xwayland screen fails to be
updated, we would still appy the expected size rather than the actual
one for the libdecor state.

To avoid this, use the actual xwl_screen width/height for the libdecor
state.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2023-07-27 09:58:51 +02:00
Olivier Fourdan 8bbd908d1d xwayland: Move attach buffer out of post damage
For libdecor, we will have to attach a new buffer and commit from two
different handlers (libdecor configure and commit).

Having xwl_window_attach_buffer() separate from xwl_window_post_damage()
is to allow for that.

This commit should not introduce any functional change.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2023-07-27 09:58:51 +02:00
Michel Dänzer 4bb1f976d5 xwayland/glamor: Avoid implicit redirection with depth 32 parent windows
glamor ensures that a depth 32 pixmap backing a depth 24 window contains
fully opaque alpha channel values for the window's pixels, so we can
allow this without implicit redirection, saving pixmap storage and
intermediate copies.

Second attempt, after fixing a few regressions from the first attempt.
2023-07-20 10:15:15 +02:00
Michel Dänzer d4e11f4c92 glamor: Make glamor_solid_boxes take a DrawablePtr
Instead of a PixmapPtr. Gives better results if the window depth
doesn't match the backing pixmap depth.

Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1565
2023-07-20 10:14:56 +02:00
Michel Dänzer 2de50de563 mi: Fix up alpha channel if needed in miPaintWindow
See also the previous commit log.

Fixes the issues with xterm & xcalc described in the GitLab issue below.

Issue: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1564
2023-07-20 10:14:56 +02:00
Michel Dänzer 3e044b1e64 glamor: Add and use glamor_drawable_effective_depth helper
Consider the following window hierarchy, from ancestors to descendants:

 A
 |
 B
 |
 C

If both A & C have depth 32, but B has depth 24, C must effectively
behave as if it had depth 24, even if its backing pixmap has depth 32
as well.

Fixes the xmag issue described in the GitLab issue below.

Issue: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1564
2023-07-20 10:14:56 +02:00
Olivier Fourdan c4ee35ef24 Revert "xwayland/glamor: Avoid implicit redirection with depth 32 parent windows"
This commit is meant as an optimization, but has been identified as the
cause of multiple regressions reported in issues xorg/xserver#1564 and
xorg/xserver#1565.

Reverting that commit alone fixes the aforementioned issues, the rest of
the commits from xorg/xserver!1131 seem harmless and do not need
reverting.

This reverts commit d6c5999e94.

See-also: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1564
See-also: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1565
2023-07-19 17:05:25 +02:00
Olivier Fourdan 94deed272c xwayland: Use sensible defaults for rootful size
If "-decorate" is used but no "-geometry" is specified, Xwayland rootful
would take its size from the actual Wayland outputs combined.

That is not practical, especially when using multiple outputs, as the
resulting Xwayland window would be much larger than a single monitor.

To avoid that, set a sensible default size for the Xwayland decorate
window, using 640x480 to match what Xephyr does.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
2023-07-18 12:25:26 +02:00
Olivier Fourdan 7c85877485 Xwayland: Do not mark decorate as experimental
libdecor support seems quite stable, no need to mark that experimental.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2023-07-18 12:25:26 +02:00
Olivier Fourdan 516f1b96cd xwayland: Make Xwayland rootful resizable
By default, the Xwayland window in rootful mode was not resizable.

Make the Xwayland window resizable using libdecor in rootful mode.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
2023-07-18 12:25:26 +02:00
Olivier Fourdan 63c0a2dfa2 xwayland: Make xwl_randr_add_modes_fixed() public API
This is preparation work for making Xwayland rootful resizeable.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2023-07-18 12:25:26 +02:00
Michel Dänzer d6c5999e94 xwayland/glamor: Avoid implicit redirection with depth 32 parent windows
glamor ensures that a depth 32 pixmap backing a depth 24 window contains
fully opaque alpha channel values for the window's pixels, so we can
allow this without implicit redirection, saving pixmap storage and
intermediate copies.
2023-07-18 09:34:39 +00:00
Michel Dänzer c38442bc30 xwayland/glamor: Require equal pixmap depths in xwl_glamor_check_flip
This will be needed with the next commit: If a child window completely
obscures a toplevel ancestor of different depth, the child window can
use page flipping only if the depth of the presented pixmap matches that
of the window's backing pixmap, or the former may contain pixel values
which are not suitable for the toplevel window's depth.
2023-07-18 09:34:39 +00:00
Michel Dänzer 9fb1f0ef22 composite: Expose CompositeIsImplicitRedirectException
Make it usable by code outside of the composite layer.
2023-07-18 09:34:39 +00:00
Michel Dänzer ff0c252e57 composite: Free cs->implicitRedirectExceptions in compCloseScreen
Fixes leaking the memory it points to.
2023-07-18 09:34:39 +00:00
Michel Dänzer 16aa40f1c8 glamor: Use DrawablePtr in struct copy_args
Will give better results if the window depth doesn't match the backing
pixmap depth.
2023-07-18 09:34:39 +00:00
Michel Dänzer 5371690891 glamor: Fix up alpha channel if needed in glamor_upload_boxes
It's needed for a depth 24 window backed by a depth 32 pixmap, to make
sure the window's pixels sample alpha as 1.0.

v2:
* Make sure glamor_finish_access doesn't pass in a NULL pointer.
2023-07-18 09:34:39 +00:00
Michel Dänzer 78e0bb500e glamor: glamor_prep_pixmap_box → glamor_prep_drawable_box
Pass the DrawablePtr directly to glamor_download_boxes. This will allow
for better results if the window depth doesn't match the backing pixmap
depth.
2023-07-18 09:34:39 +00:00
Michel Dänzer ff27ffa1c1 glamor: Eliminate glamor_fini_pixmap
Pass the DrawablePtr directly from glamor_finish_access to
glamor_upload_boxes. This will allow for better results if the window
depth doesn't match the backing pixmap depth.
2023-07-18 09:34:39 +00:00
Michel Dänzer a504f65d89 glamor: Take DrawablePtr instead of PixmapPtr in up/download_boxes
Will allow for better results if the window depth doesn't match the
backing pixmap depth.
2023-07-18 09:34:39 +00:00
Michel Dänzer 5893de5a22 glamor: Make program APIs take DrawablePtrs instead of PixmapPtrs
Will give better results if the window depth doesn't match the backing
pixmap depth.
2023-07-18 09:34:39 +00:00
Michel Dänzer 0ed2d69217 glamor: Remove unused transfer functions
Never used AFAICT.
2023-07-18 09:34:39 +00:00