Commit graph

7866 commits

Author SHA1 Message Date
Furkan Sahin
56bb41f9f3 Merge branch 'vulkan-icc-2' into 'master'
ext_image_capture_source_v1: render hidden sRGB for ICC correct

See merge request wlroots/wlroots!5357
2026-06-13 11:06:46 +00:00
Simon Ser
f141edcd02 render/vulkan: add support for split render/display devices
Some systems have a split render/display architecture: the display
side is managed by a KMS driver and the render side is managed by a
separate Vulkan driver. Figuring out that these two drivers can
work together is not trivial.

Currently, the Vulkan renderer tries to find a Vulkan physical
device which matches the DRM device's dev_t. On split render/display,
there is no such device.

The platform bus has historically been abused for situations
where no other bus would make sense (e.g. VKMS, evdi). A new "faux"
bus has been introduced [1] for such devices, so the platform bus
should now be a pretty good hint that all devices are on the same
system-on-chip.

When we don't find a Vulkan physical device and the DRM device is
using the platform bus, fall back to any Vulkan physical which
also uses the platform bus.

[1]: https://lore.kernel.org/all/2025021023-sandstorm-precise-9f5d@gregkh/

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/work_items/4055
2026-06-13 09:59:46 +00:00
Félix Poisot
2ab2775743 scene: make buffer sample event register syncobj use for all outputs
Not just the frame pacing output.

Fixes b2f6a390a4
2026-06-13 09:52:38 +00:00
twilligon
5d150267e2 render/vulkan: clear blend image on first use
The two-pass blend image is created with VK_IMAGE_LAYOUT_UNDEFINED, so
on its first use loadOp=LOAD loads uninitialized memory. This oughtn't
be an issue, as we render onto it before we read it. These renders are
blends, so even opaque content is rendered with reference to an uninit
dst. This too ought to be fine: src*1 + dst*0 = src for all finite dst.

But the blend image pixfmt is VK_FORMAT_R16G16B16A16_SFLOAT, so uninit
pixels can be NaN, inf, or -inf, and now src*1 + dst*0 = NaN/inf/-inf.
This is bad enough assuming the uninitialized blend image holds random
bytes (2048/65536 values are not finite), even worse on any driver/GPU
with a framebuffer compression scheme that so happens to reliably read
NaNs from any uninitialized compressed image...

Most Mesa drivers happen not to do this perfectly valid thing, so this
is only reliably a problem (afaict) for honeykrisp i.e. AGX i.e. Asahi
Linux i.e. Apple Silicon, where after an upgrade to wlroots 0.20, sway
renders a black screen forever, unless you get quite lucky spamming VT
switches, in which case there's flickery garbage on exactly one of the
two swapchain buffers.

The blend image persists across frames, so it suffices to clear before
first real use. Rather than clear by hand, make a loadOp=CLEAR variant
of the render pass and use it for that first frame only. Adding a pass
sounds heavy, but render pass compatibility ignores loadOp and layouts
such that the new pass reuses the pipelines and framebuffer, and costs
one VkRenderPass object but not the usual pipeline/shader (re)compile.
2026-06-12 18:11:23 +00:00
Simon Ser
63318d28b1 xwayland/xwm: check WM_TRANSIENT_FOR length
Without this check, the reply value might be smaller than
xcb_window_t and will result in an invalid memory read.

Reported-by: Tristan <TristanInSec@gmail.com>
2026-06-11 17:00:59 +02:00
Wang Yu
a5691ea7c3 types/linux_dmabuf: fix use-after-free of device node name
The name pointer points into the drmDevice structure, which is freed by
drmFreeDevice(). The error log was using name after the free, which is
undefined behavior.

Move the error log before drmFreeDevice() so name is still valid when
used in the log message.

Signed-off-by: Wang Yu <wangyu@uniontech.com>
2026-06-10 06:00:57 +00:00
Jaeyong Lee
fc1cc7656a screencopy-v1: fail concurrent capture_output requests
Send the failed event immediately when a client sends capture_output
or capture_output_region for an output that already has a live frame
owned by that client.

Enforces one frame per (client, output) pair, matching ext-image-copy-
capture-v1's create_frame restriction without adding a new error code
or bumping the interface version.
2026-06-09 19:29:43 +00:00
rewine
a94cd29eb1
xwayland: emit set_parent signal when parent is destroyed
When a xwayland surface is destroyed, its children's parent pointer
is set to NULL, but the set_parent signal was not emitted.
2026-06-02 17:15:46 +08:00
Furkan Sahin
53b399d054 ext_image_capture_source_v1: add scene-per-output capture source
When a compositor uses color transforms (ICC profiles) the output's
postrender buffer is in the display's color space, not sRGB. A
screenshot client receives this buffer and saves it as an untagged PNG,
which appears oversaturated in non-colormanaged viewers.

To fix this without altering the semantics of the raw output source
(which must deliver the exact hardware scanned buffer, including
overlays and direct scanout), add an optional, compositor driven
scene-per-output capture source. This source re-renders the entire scene
graph for a given output with an identity color transform (sRGB), using
a hidden headless output to avoid flicker.

The new function
`wlr_ext_image_capture_source_v1_create_with_scene_output()` takes a
wlr_scene, a reference wlr_output (for dimensions, scale,
renderer/allocator), and an optional wlr_output_layout (for correct
positioning). The source is created on demand in the existing output
capture manager when the compositor has called
`wlr_ext_output_image_capture_source_manager_v1_set_scene()` and
`wlr_ext_output_image_capture_source_manager_v1_set_layout()`.

If the compositor never provides a scene, the manager continues to
create the original raw output source, preserving backward compatibility
and hardware plane capture for compositors that need it.
2026-06-01 12:39:05 -04:00
Furkan Sahin
07ff0a8b1e Revert previous 3 commits
As suggested by Felix Poisot, it's better to extend the
`scene_node_source` rather than turn output based source into another
scene based source.
2026-06-01 12:38:14 -04:00
Furkan Sahin
8b95c20250 account for scale factor 2026-06-01 12:31:40 -04:00
Furkan Sahin
77e59d5991 Allow copying of any outputs
current attempts at copying regions outside the first output end up
wrapping into the first output. Fix this by allowing compositors to
expose the layout.
2026-06-01 12:31:40 -04:00
Furkan Sahin
f56e1f6a52 ext_image_capture_source_v1: render hidden sRGB for ICC correct
screencopy

When a compositor uses color transforms (ICC profiles), the output's
post-render buffer is in the display's color space, not sRGB.  A
screenshot client like grim receives this buffer and saves it as an
untagged PNG, which then appears over-saturated in non-color-managed
viewers.

To avoid this, the output capture source now creates a hidden headless
output that re-renders the same scene graph with an identity color
transform (sRGB).  The hidden output is driven entirely within the
capture source and does not affect the real output or cause any visual
flicker.
2026-06-01 12:31:40 -04:00
llyyr
bd99e8c2bd wlr_xdg_decoration_v1: support version 2 2026-05-31 08:03:46 +00:00
Consolatis
b287e361fc render/pixman: use a single global dependency
The pixman renderer can not be disabled and other parts of wlroots
do not carry their own dependency of libpixman around. Use a single
global dependency which also satisfies the pixman renderer.
2026-05-30 16:49:13 +02:00
Isaac Freund
15a378316e ext-image-capture-source-v1: add user data pointer
This addition would make the code in my compositor simpler and is
consistent with the rest of wlroots.
2026-05-28 09:13:36 +00:00
Simon Ser
7265a79e46 Drop "restrict" keyword
The "restrict" keyword can be used to indicate that no other
pointer will be used to access a chunk of memory while the
restricted pointer is alive. If that promise is not upheld,
undefined behavior is triggered.

It may be difficult to ensure this property, and the property may
be brittle - becoming invalid as code evolves. Just like "inline",
let's just leave optimizations up to the compiler to figure out.
2026-05-25 08:42:35 +00:00
Félix Poisot
3bd8f29b13 scene: don't send new dmabuf feedback after node disable
The comparison done in `scene_buffer_send_dmabuf_feedback()` is
sufficient.

Close https://gitlab.freedesktop.org/wlroots/wlroots/-/work_items/4088
2026-05-22 20:33:53 +00:00
Simon Ser
c6e2af1155 xwayland/xwm: check object type in xwm_handle_surface_id_message()
wlr_surface_from_resource() asserts that the object is a wl_surface.
Since arbitrary clients can send such messages, avoid aborting on
invalid input.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/work_items/4093
2026-05-22 20:10:12 +02:00
Simon Ser
8154d80a4d xwayland/xwm: check whether surface is already associated for WL_SURFACE_ID
xwayland_surface_associate() asserts that the surface has not yet
been associated yet. Arbitrary clients can send these messages,
don't abort when that happens.
2026-05-22 20:05:17 +02:00
Simon Ser
041aa8c048 xwayland/xwm: expand comment about WL_SURFACE_ID event ordering
Make it clearer what's up.
2026-05-22 19:51:11 +02:00
Simon Ser
73d6968cd0 xwayland/xwm: align WL_SURFACE_ID error message with WL_SURFACE_SERIAL 2026-05-22 19:48:09 +02:00
Simon Ser
cb0fa9b0a3 xwayland/selection: stop using VLAs for MIME type atom lists
The size of the VLA is client-controlled and can overflow the
stack. Instead, allocate on the heap.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/work_items/4090
2026-05-22 09:42:52 -04:00
Simon Ser
c91543352a xwayland: stop using xcb_get_property_reply_t.value_len
This field is difficult to use correctly, its meaning depends on
format.

xcb docs read:

> You should use the corresponding accessor instead of this field.

Replace all uses with the safe accessor.

This fixes potential out-of-bounds array accesses when the format
field isn't what we expect.
2026-05-22 09:34:30 -04:00
Simon Ser
5cb5373959 xwayland/xwm: pluralize array variable in read_surface_net_wm_state()
Make it clear this doesn't contain a single atom.
2026-05-22 09:34:30 -04:00
Simon Ser
851cdd0089 xwayland/xwm: fix out-of-bounds strndup() in read_surface_class()
We advance the class pointer here, but we forgot to decrease the
length.
2026-05-22 09:34:30 -04:00
Simon Ser
9d6c9e8783 xwayland: use const pointers for xcb_get_property_value()
These values must not be mutated, they are owned by the
xcb_get_property_reply_t.
2026-05-22 09:34:30 -04:00
Simon Ser
a00a9178ae virtual_keyboard_v1: handle NO_KEYMAP 2026-05-22 09:32:37 -04:00
Simon Ser
91ef4ce208 virtual_keyboard_v1: validate keymap format 2026-05-22 09:32:37 -04:00
Simon Ser
c5c1ba2baa protocol/virtual-keyboard: set format enum in zwp_virtual_keyboard_v1.keymap request 2026-05-22 09:32:37 -04:00
leiliang
1a791c2349 render/gles2: fix missing pop_gles2_debug on early return in render_pass_add_texture 2026-05-22 17:52:35 +08:00
Simon Ser
fd610841cc render/egl: disable implicit flush on context change
By default, switching the EGL context performs an implicit flush.
We may switch contexts quite often in multi-GPU scenarii. Avoid
any unintended flush.

See https://registry.khronos.org/OpenGL/extensions/KHR/KHR_context_flush_control.txt
2026-05-21 14:58:02 -04:00
xurui
cec4f5f04f xwayland: don't ping if client not supports
Signed-off-by: xurui <xurui@kylinos.cn>
2026-05-21 16:49:53 +00:00
qiu
b74e0cc75b backend/libinput: expose libinput context
Add `wlr_backend_get_libinput` getter, which returns a direct
handle to `struct libinput`.

Exposing the libinput context will allow compositors to load
libinput plugins after creating a `wlr_backend`.
Lua plugins are supported since libinput 1.30.0.
2026-05-21 15:23:30 +00:00
Isaac Freund
4b8c11bd46 xdg-foreign: remove unused field 2026-05-21 15:15:30 +00:00
liupeng
5ef24c2d17 wl_event_loop_add_fd: Only watch for READABLE & WRITABLE
Signed-off-by: liupeng <liupeng01@kylinos.cn>
2026-05-21 15:07:21 +00:00
Ronan Pigott
e532b4c26c scene: only send leave events to outputs with matching scene root
In handling scene buffer output updates, wlroots would send a leave event to
all entered outputs, even those that the scene root for the scene output update
event did not own. Leaving the output list inaccurate.

Sending leave events only for the given scene introduces a problem, though:
existing logic to de-duplicate leave events stops us from sending a leave event
when we leave all the outputs in a scene, and when the surface then becomes
visible in another scene, the frame pacing output cannot be selected
accurately. This breaks screen capture for off-screen windows in sway.

So, let us also mark outputs that would have been left but were spared by the
deduplication logic as "suspended" indicating they are ineligible as frame
pacing outputs.

Fixes: https://github.com/swaywm/sway/issues/9094
2026-05-19 19:52:08 +00:00
llyyr
9ecddaa673 wlr_pointer_warp_v1: add implementation 2026-05-17 20:20:53 +05:30
leiliang
aee9fa09f0 drm_syncobj_merger: fix memory leak and sync_fd corruption on error
Fix a memory leak when waiter_init fails in wlr_drm_syncobj_merger_add(),
and prevent the old sync_fd from being closed when sync_file_merge fails
in wlr_drm_syncobj_merger_add_sync_file().
2026-05-15 16:17:33 +08:00
YaoBing Xiao
6b5e2159c4 render/gles2: remove unused v_color varying from quad fragment shader
Signed-off-by: YaoBing Xiao <xiaoyaobing@uniontech.com>
2026-05-14 16:40:39 +08:00
Florian Kraupa
508fdba2c0 fix typo in WLR_HAS_LIBINPUT_BACKEND description in config.h.in 2026-05-12 14:40:38 +00:00
Consolatis
e4a1268b2a Revert "xwm: fix memory leak"
This reverts commit 02abf1cd28.

The change doesn't make sense. It causes a use-after-free when trying
to read the pixel data of the icon. The docs clearly state to use
'xcb_ewmh_get_wm_icon_reply_wipe()' when using the function which
correctly frees the reply *after* processing the pixel data.
2026-05-11 02:45:20 +02:00
Damino
75932662ce color_management_v1: send image description output updates 2026-05-09 03:54:12 +00:00
xurui
28d11d0580 linux_drm_syncobj_v1: fix inverted NULL check
Signed-off-by: xurui <xurui@kylinos.cn>
2026-05-08 15:28:18 +08:00
xurui
19df074c16 linux_drm_syncobj_v1: fix memory leak
Signed-off-by: xurui <xurui@kylinos.cn>
2026-05-08 15:27:50 +08:00
Alexander Orzechowski
37f30dc8d0 drm: Make it clear that we tried to import a shm buffer
Reduces the guess work in logs
2026-05-06 19:56:19 -04:00
Kenny Levinsen
57441ded02 util/rect_union: Limit rect_union_add to 1024 rects
If a very large number of clip rects are accumulated in rect_union_add,
rect_union_evaluate can end up being disproportionately expensive, and
as an extreme numbers of clip rects are not beneficial for drawing, this
is without any benefit.

Limit the number of rects to 1024 in rect_union_add, switching over to
bounding box mode instead when the limit is exceeded. This leads to a
small 70% reduction in CPU time in the Vulkan renderer on the
stacked/clip200/1024 benchmarks.

Signed-off-by: Kenny Levinsen <kl@kl.wtf>
2026-05-01 12:50:04 +00:00
Kenny Levinsen
17c29268c9 util/rect_union: Take pixman_box32_t by pointer
rect_union_add takes a pixman_box32_t by value, and passes it along by
value to internal helpers. render_pass_mark_box_updated which is the
only caller receives the pixman_box32_t by reference, so just plumb it
through that way.

Results in a 13% improvement in CPU time when using the Vulkan renderer
on the stacked/clip200/1024 benchmarks on my machine.

Signed-off-by: Kenny Levinsen <kl@kl.wtf>
2026-05-01 12:50:04 +00:00
Kenny Levinsen
8abe53d1d2 render/vulkan: Use instanced draws instead of scissors
Similar to what we have already done for gles2. To simplify things we
use the staging ring buffer for the vertex buffers by extending the
usage bits, rather than introducing a separate pool.

Signed-off-by: Kenny Levinsen <kl@kl.wtf>
2026-05-01 12:50:04 +00:00
Kenny Levinsen
439258a43b render/vulkan: Intersect clip region once
We are spending quite significant CPU time walking through the clip
rects, taking a pixman box, converting it to a wlr box, intersecting it
and ultimately converting it back to a pixman box before adding it to
the rect union.

Just intersect the clip region once ahead of time, and use pixman boxes
the entire way. This also makes it easy to bail early if nothing
intersects.

Gives a small 97.95% reduction in CPU time for the Vulkan renderer in
the grid/clip200/1024 benchmark.

Signed-off-by: Kenny Levinsen <kl@kl.wtf>
2026-05-01 12:50:04 +00:00