Commit Graph

18200 Commits

Author SHA1 Message Date
Yuriy Vasilev c170056111 glamor: xv: add rgb565
This commit adds RGB565 format to XVideo with reuse of RGBA32 shader

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Yuriy Vasilev <uuvasiliev@yandex.ru>
2023-11-29 21:18:29 +00:00
Yuriy Vasilev 15412e78c8 glamor: xv: add rgba32 format
This commit adds RGBA32 format to XVideo along with shader for handling it.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Yuriy Vasilev <uuvasiliev@yandex.ru>
2023-11-29 21:18:29 +00:00
Konstantin 832b392f70 glamor: xv: enable UYVY acceleration
This commit adds UYVY format in XVideo for Glamor
along with shader support.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Konstantin <ria.freelander@gmail.com>
2023-11-29 21:18:29 +00:00
Konstantin ffd7151b10 glamor: xv: prepare to one-plane formats
As a preparation to one-plane formats (for example, UYVY), second
texture definition is moved inside a format switch, and all allocations
now also done inside a texture switch.
No functional change.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Konstantin <ria.freelander@gmail.com>
2023-11-29 21:18:29 +00:00
Konstantin 81ef43dd4a glamor: xv: reuse ports and shaders when possible
Xv currently calls glamor_xv_free_port_data at the end of every putImage.
This leads to shader recompilation for every frame, which is a huge performance loss.
This commit changes behaviour of glamor_xv_free_port_data, and its now is called only
if width, height or format is changed for xv port.

Shader management also done in a port now, because if shaders will be
stored in core glamor and try to be reused, this can lead to a bug if we
try to play 2 videos with different formats simultaneously.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Konstantin <ria.freelander@gmail.com>
2023-11-29 21:18:29 +00:00
Konstantin a8270fc5f0 glamor: xv: do not force a version on XV shaders
There is a no need to force a low version for XV shaders, it will
work on higher version too.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Konstantin <ria.freelander@gmail.com>
2023-11-29 21:18:29 +00:00
Olivier Fourdan 372f67796f xwayland: Avoid hardcoding the interface name
The Wayland interfaces have a "name" field that we can use instead of
hardcoding their name.

Change the code to use that name instead of the static strings.

This was inspired by a similar change in mutter by Robert Mader
<robert.mader@collabora.com>.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2023-11-28 08:57:53 +00:00
Olivier Fourdan 2cc869626a xwayland: Restrict allow commit to the window manager
Xwayland offers a way for the window and compositing manager to hold the
surface commits through an X11 property _XWAYLAND_ALLOW_COMMITS.

Xwayland, however, does not actually check if the X11 client changing
the value of that property is indeed the X11 window manager, so any X11
client can potentially interfere with the Wayland surface mechanism.

Restrict access to the _XWAYLAND_ALLOW_COMMITS property to read-only,
except for the X11 window manager and the Xserver itself.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2023-11-21 12:55:08 +00:00
Olivier Fourdan a07c2cda98 xwayland: Add an XACE property access handler
This is preparation work to restrict access to Xwayland properties.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2023-11-21 12:55:08 +00:00
Olivier Fourdan 411a61f571 build: Allow for custom server config directory
Most X servers, even those which do not have specific configuration
files, can use the directory specified by SERVER_MISC_CONFIG_PATH when
they have either the XSECURITY or XSELINUX extensions enabled, or when
support for DTRACE is enabled at build time, because this is also where
the "protocol.txt" file is searched for at runtime.

Unfortunately, the SERVER_MISC_CONFIG_PATH is set from serverconfigdir
which is hardcoded in the build system to "$prefix/$libdir/xorg", and
all X server builds share the same path.

That makes it harder for different X servers such as Xwayland to install
in the same path without sharing the same server configuration path
(and hence the same "protocol.txt" file).

Allow for the customization of server configuration path from the build
options so that different X servers can use completely different and
independent paths.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2023-11-21 11:49:44 +01:00
Olivier Fourdan a797776ff2 xwayland: Do not resize when running fullscreen
When running fullscreen, if an X11 client has changed the resolution,
Xwayland is using a viewport to emulate the expected resolution.

When changing focus, the Wayland compositor will send a configure event
with the actual surface size, not the size of the emulated XRandR
resolution.

As a result, changing focus while XRandR emulation (and hence the
viewport) is active in Xwayland will revert the resolution to the actual
output size, defeating the XRandR emulation.

To avoid that issue, only change the size when not running fullscreen.

Fixes: 53b6d4db7 - xwayland: Apply root toplevel configure dimensions
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Kenny Levinsen <kl@kl.wtf>
2023-11-16 11:16:26 +01:00
Olivier Fourdan 06eb7271a9 xwayland: Update the fullscreen window on output change
Make sure to update the fullscreen rootful window configuration whenever
the output setup changes.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Kenny Levinsen <kl@kl.wtf>
2023-11-16 11:14:04 +01:00
Olivier Fourdan 73b9ff53c3 xwayland: Add a helper function to update fullscreen
Whenever the output configuration changes, if Xwayland is running
fullscreen, we may need to update the viewport in use or even update the
output on which Xwayland is currently running fullscreen.

Add a new helper function xwl_window_rootful_update_fullscreen() that
will recompute the fullscreen state and the viewport setup so that the
fullscreen Xwayland rootful window matches the new setup.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Kenny Levinsen <kl@kl.wtf>
2023-11-16 11:14:04 +01:00
Olivier Fourdan 2f84e3fe0d xwayland: Add xwl_output to the Xwayland types
No functional change.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Kenny Levinsen <kl@kl.wtf>
2023-11-16 11:14:04 +01:00
Konstantin 10d7fa53f8 Revert "glamor/glxprov: Stop exposing non-db(-capable) configs"
The recent commit a563f530 - "glamor/glxprov: Stop exposing non-db
(-capable) configs" was aiming at reducing the number of advertised
visuals for optimizing GLX initialization.

Unfortunately, GL applications which rely exclusively on single-buffered
visuals will fail to find a suitable visual with this.

Revert the commit to expose the single-buffered visuals and restore the
compatibility with applications which rely on single-buffered configs.

This reverts commit a563f530f6

Signed-off-by: Konstantin <ria.freelander@gmail.com>
2023-11-14 17:44:47 +03:00
Konstantin Pugin 8252b110f3 Xephyr: use glamor glx provider
Xephyr now gained an ability to use glamor glx provider.
Unfortunately, without DRI3, we end up with same llvmpipe as before

Signed-off-by: Konstantin Pugin <ria.freelander@gmail.com>
2023-11-07 18:20:48 +03:00
Konstantin a449bb4c5d glamor_egl: add support of GlxVendorLibrary option
Same semantics as in glxdri2.c, and same purpose.

Signed-off-by: Konstantin <ria.freelander@gmail.com>
2023-11-07 17:59:43 +03:00
Konstantin Pugin a987fc7c36 xorg: initialize glamor provider
This allows Xorg to use Glamor GLX when Glamor is requested,
and eliminates usage of DRI2 in case of Glamor.

Signed-off-by: Konstantin Pugin <ria.freelander@gmail.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Acked-by: Emma Anholt <emma@anholt.net>
2023-11-07 17:59:43 +03:00
Adam Jackson a563f530f6 glamor/glxprov: Stop exposing non-db(-capable) configs 2023-11-07 17:59:24 +03:00
Adam Jackson 58b88ba0b1 glamor: Lift the GLX EGL backend from Xwayland
This code is almost entirely ddx-agnostic already, and I'd like to use
it from the other EGL glamor consumers. Which, right now that's just
Xorg, but soon it'll be Xephyr too.
2023-11-07 17:59:24 +03:00
Konstantin Pugin 3caf7aa88d glamor: add glvnd_vendor private
This commit adds an ability to store a glvnd vendor in Glamor
structures, which can be used for initialize some vendor-based values
without hooking into DDX internals. Also this adds setting this value
into Xorg and Xwayland

Signed-off-by: Konstantin Pugin <ria.freelander@gmail.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Acked-by: Emma Anholt <emma@anholt.net>
2023-11-07 17:59:24 +03:00
Konstantin 141e7dd8a3 Xwayland: add new "have_glamor_api" pkgconfig
For compositors which want to check if Xwayland is capable to select Glamor
rendering API.

Signed-off-by: Konstantin <ria.freelander@gmail.com>
2023-11-02 08:18:00 +00:00
Konstantin 2023c611ca Xwayland: document new "glamor" option
Signed-off-by: Konstantin <ria.freelander@gmail.com>
2023-11-02 08:18:00 +00:00
Konstantin f815f682ab Xwayland: add "glamor" command line option
This will force Glamor run on GL or GL ES independently from GL version set.

Signed-off-by: Konstantin <ria.freelander@gmail.com>
2023-11-02 08:18:00 +00:00
Konstantin 8fd24a121a hw/Xwayland: add xwl_glamor_mode_flags enum
This replaces int glamor parameter with a new enum to be more clean
and prepare for more glamor options.
No functional change.

Signed-off-by: Konstantin <ria.freelander@gmail.com>
2023-11-02 08:18:00 +00:00
Konstantin 4fc1500f74 xorg.conf.man: document new RenderingAPI option
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Konstantin <ria.freelander@gmail.com>
2023-11-02 08:18:00 +00:00
Konstantin c014f33b43 glamor_egl: add info message about context API
It is useful to know on what context we are running, and
we need to show it into xorg.log

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Konstantin <ria.freelander@gmail.com>
2023-11-02 08:18:00 +00:00
Konstantin a44a4b0d4d glamor_egl: add RenderingAPI option
This allows to choose between Glamor on OpenGL and Glamor on OpenGL ES
via an option.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Konstantin <ria.freelander@gmail.com>
2023-11-02 08:18:00 +00:00
Konstantin d5c2a4d3f5 glamor_egl: add helper functions for contexts
This is just a split big glamor_egl_init to 3 smaller functions.
No functional change.

Signed-off-by: Konstantin <ria.freelander@gmail.com>
2023-11-02 08:18:00 +00:00
Pedro Montes Alcalde 1bb6991bda AutoRepeat: Fix wrong repeat rate being applied
When you set the auto repeat rate trough xset to something like 250 40:
`xset r rate 250 40`
Is setting the first delay to 250ms and set the rate to 40hz (25ms)

However, if you were to apply this configuration from a xorg config file,
the result would be the first delay being applied correctly,
but the repeat rate would be set to 25Hz instead. This is because the config
option is using a rate of repeats per second but XKB stores it as interval.
Make sure this is converted correctly.

Fixes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1558

Signed-off-by: EXtremeExploit <pedro.montes.alcalde@gmail.com>
2023-11-02 01:20:41 +00:00
Balló György 910847f452 glamor: Don't require EXT_gpu_shader4 unconditionally
It causes a shader compilation error on systems without EXT_gpu_shader4.

Fixes: ee107cd4
2023-11-01 07:31:32 +00:00
Konstantin 5fdd3125b4 xwayland/glamor/gbm: use GBM_FORMAT_ARGB8888 for 24-bit on ES
On Mesa, when we request GBM_FORMAT_XRGB8888, driver set surface storage
format to GL_RGB8, which breaks GL ES rendering (on any GL ES version).
If we force set gbm_format to GBM_FORMAT_ARGB8888, then rendering
will happen and working.

Fixes #1288
Fixes #1356
2023-10-30 14:02:08 +03:00
Peter Hutterer 564ccf2ce9 mi: reset the PointerWindows reference on screen switch
PointerWindows[] keeps a reference to the last window our sprite
entered - changes are usually handled by CheckMotion().

If we switch between screens via XWarpPointer our
dev->spriteInfo->sprite->win is set to the new screen's root window.
If there's another window at the cursor location CheckMotion() will
trigger the right enter/leave events later. If there is not, it skips
that process and we never trigger LeaveWindow() - PointerWindows[] for
the device still refers to the previous window.

If that window is destroyed we have a dangling reference that will
eventually cause a use-after-free bug when checking the window hierarchy
later.

To trigger this, we require:
- two protocol screens
- XWarpPointer to the other screen's root window
- XDestroyWindow before entering any other window

This is a niche bug so we hack around it by making sure we reset the
PointerWindows[] entry so we cannot have a dangling pointer. This
doesn't handle Enter/Leave events correctly but the previous code didn't
either.

CVE-2023-5380, ZDI-CAN-21608

This vulnerability was discovered by:
Sri working with Trend Micro Zero Day Initiative

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2023-10-25 00:37:47 +00:00
Peter Hutterer 541ab2ecd4 Xi/randr: fix handling of PropModeAppend/Prepend
The handling of appending/prepending properties was incorrect, with at
least two bugs: the property length was set to the length of the new
part only, i.e. appending or prepending N elements to a property with P
existing elements always resulted in the property having N elements
instead of N + P.

Second, when pre-pending a value to a property, the offset for the old
values was incorrect, leaving the new property with potentially
uninitalized values and/or resulting in OOB memory writes.
For example, prepending a 3 element value to a 5 element property would
result in this 8 value array:
  [N, N, N, ?, ?, P, P, P ] P, P
                            ^OOB write

The XI2 code is a copy/paste of the RandR code, so the bug exists in
both.

CVE-2023-5367, ZDI-CAN-22153

This vulnerability was discovered by:
Jan-Niklas Sohn working with Trend Micro Zero Day Initiative

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2023-10-25 00:32:52 +00:00
John Kennedy 997e17eabe Enable USE_DEV_IO on FreeBSD/aarch64 2023-10-22 16:08:21 +00:00
John Kennedy cf44a4dda3 Extented 'arm' case to 'aarch64' on BSD. 2023-10-22 16:08:21 +00:00
Austin Shafer 947d1c7ecf Compile lnx_platform.c on FreeBSD too. 2023-10-22 16:08:21 +00:00
Peter Grehan 84ff599d0b Fix build on FreeBSD/PowerPC architecture. 2023-10-22 16:08:21 +00:00
Gleb Popov b1abb2efcb The framebuffer driver on FreeBSD is called scfb, use it. 2023-10-22 16:08:21 +00:00
Niclas Zeising 5528b0606e Extend Linux #ifdef to FreeBSD OS. 2023-10-22 16:08:21 +00:00
Gleb Popov f3e347241e Implement -novtswitch option handling for FreeBSD. 2023-10-22 15:39:44 +00:00
Konstantin d63d23bde8 glamor: mark tests fixed by this PR
This tests will pass after previous commit will be merged,
so, mark this tests now as PASS.

Signed-off-by: Konstantin <ria.freelander@gmail.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Acked-by: Martin Roukala <martin.roukala@mupuf.org>
2023-10-20 14:10:21 +03:00
Konstantin Pugin e573d4ca03 glamor: accelerate incomplete textures for GL ES
If texture can be uploaded to GL using glTexImage2D normally, but
cannot be read back using glReadPixels, we still can accelerate it,
but we cannot create pixmap with FBO using this texture type. So,
add a flag to avoid such creations.

This allow us to accelerate 8-bit glyph masks on GL ES 2.0, because those
masks are used only as textures, and in next stages are rendered on RGBA
surfaces normally, so, we do not need to call glReadPixels on them.

This is needed for correctly working fonts on GL ES 2.0, due to inability
to use GL_RED and texture swizzle. We should use GL_ALPHA there, and
with this format we cannot have a complete framebuffer. But completed
framebuffer, according to testing, is not required for fonts anyway.
Also it fixes all 8-bit formats for GLES2.

Fixes #1362
Fixes #1411

Signed-off-by: Konstantin Pugin <ria.freelander@gmail.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Acked-by: Michel Dänzer <mdaenzer@redhat.com>
Acked-by: Martin Roukala <martin.roukala@mupuf.org>
2023-10-20 14:09:57 +03:00
Olivier Fourdan 9617de733b xwayland: Cancel the EI disconnect timer when freed
Xwayland maintains a connection to EI up for 10 minutes after an X11
client has vanished, to avoid going through the connection phase every
time a short lived X11 client comes and goes.

However, if the EI client gets freed (through some other event, e.g. the
user decides to terminate the EI session), Xwayland would still keep the
callback alive and end up trying to free an already freed EI client:

 Invalid read of size 4
    at 0x4C5E6F9: object_unref (util-object.h:89)
    by 0x4C5E6F9: ei_unref (libei.c:77)
    by 0x429525: free_ei (xwayland-xtest.c:224)
    by 0x429A6E: disconnect_timer_cb (xwayland-xtest.c:404)
    by 0x5E63FF: DoTimer (WaitFor.c:276)
    by 0x5E6463: DoTimers (WaitFor.c:290)
    by 0x5E6164: check_timers (WaitFor.c:133)
    by 0x5E61E9: WaitForSomething (WaitFor.c:195)
    by 0x4AD50E: Dispatch (dispatch.c:487)
    by 0x4BBA0B: dix_main (main.c:272)
    by 0x43615D: main (stubmain.c:34)
  Address 0x15cc6ee8 is 8 bytes inside a block of size 240 free'd
    at 0x48452AC: free (vg_replace_malloc.c:974)
    by 0x4C5E729: object_destroy (util-object.h:73)
    by 0x4C5E729: object_unref (util-object.h:91)
    by 0x4C5E729: ei_unref (libei.c:77)
    by 0x429525: free_ei (xwayland-xtest.c:224)
    by 0x42A946: xwl_handle_ei_event (xwayland-xtest.c:804)
    by 0x5EA977: HandleNotifyFd (connection.c:809)
    by 0x5EE8E3: ospoll_wait (ospoll.c:657)
    by 0x5E624D: WaitForSomething (WaitFor.c:208)
    by 0x4AD50E: Dispatch (dispatch.c:487)
    by 0x4BBA0B: dix_main (main.c:272)
    by 0x43615D: main (stubmain.c:34)
  Block was alloc'd at
    at 0x484782C: calloc (vg_replace_malloc.c:1554)
    by 0x4C5E777: ei_create (libei.c:73)
    by 0x4C5E777: ei_create_context (libei.c:97)
    by 0x42994B: setup_ei (xwayland-xtest.c:366)
    by 0x42A383: xwayland_xtest_send_events (xwayland-xtest.c:658)
    by 0x54ED4C: ProcXTestFakeInput (xtest.c:441)
    by 0x54EE56: ProcXTestDispatch (xtest.c:475)
    by 0x4AD6E6: Dispatch (dispatch.c:546)
    by 0x4BBA0B: dix_main (main.c:272)
    by 0x43615D: main (stubmain.c:34)

To avoid that issue, make sure to cancel the timer as soon as a EI
client is freed.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
See-also: https://bugzilla.redhat.com/2243076
2023-10-11 11:05:08 +02:00
Jeffy Chen 0076671e24 glamor: xv: Fix invalid accessing of plane attributes for NV12
NV12 only has 2 planes.

Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
2023-10-10 20:18:43 +00:00
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