Commit Graph

11 Commits

Author SHA1 Message Date
Enrico Weigelt, metux IT consult a1fd7e7ba5 treewide: replace xnfrealloc() calls to XNFrealloc()
This has been nothing but an alias for two decades now (somewhere in R6.6),
so there doesn't seem to be any practical need for this indirection.

The macro still needs to remain, as long as (external) drivers still using it.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1529>
2024-07-26 23:41:33 +00:00
Enrico Weigelt, metux IT consult 61233adbca treewide: replace xnfreallocarray macro call by XNFreallocarray()
The xnfreallocarray was added along (and just as an alias to) XNFreallocarray
back a decade ago. It's just used in a few places and it's only saves us from
passing the first parameter (NULL), so the actual benefit isn't really huge.

No (known) driver is using it, so the macro can be dropped entirely.

Fixes: ae75d50395
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1529>
2024-07-26 23:41:33 +00:00
Olivier Fourdan fa04e15afc xwayland/window-buffers: optionally force disposal
For cases (to come) where we would want to force the disposal of the
window buffers, add a parameter to force the disposal by calling
dispose() directly instead of maybe_dispose().

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1589>
2024-07-04 08:26:23 +00:00
Michel Dänzer 4dc7e99840 xwayland: Use drmDevicesEqual in xwl_dmabuf_feedback_tranche_done
xwl_dmabuf_feedback_tranche_target_device always allocates a new
drmDevice for xwl_feedback->tmp_tranche.drm_dev, so the pointers are
never equal here.

Fixes: 6f0b9deed6 ("xwayland: use drmDevice to compare DRM devices")

v2:
* Flip order of checks, so drmDevicesEqual is called only if the
  supports_scanout flags match.

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1484>
2024-04-12 07:25:55 +00:00
Michel Dänzer 82d3b8ff05 xwayland: Call drmFreeDevice for dma-buf default feedback
Fixes leaks:

==13712== 144 bytes in 1 blocks are definitely lost in loss record 4,827 of 7,462
==13712==    at 0x48459F3: calloc (vg_replace_malloc.c:1340)
==13712==    by 0x49BE94D: drmDeviceAlloc (xf86drm.c:4072)
==13712==    by 0x49BFAC9: drmProcessPciDevice (xf86drm.c:4104)
==13712==    by 0x49BFAC9: process_device (xf86drm.c:4508)
==13712==    by 0x49C35FB: drmGetDeviceFromDevId (xf86drm.c:4670)
==13712==    by 0x1AD370: xwl_dmabuf_feedback_main_device (xwayland-dmabuf.c:477)
==13712==    by 0x53C03FD: ffi_call_unix64 (unix64.S:104)
==13712==    by 0x53BF70C: ffi_call_int (ffi64.c:673)
==13712==    by 0x53BFEE2: ffi_call (ffi64.c:710)
==13712==    by 0x49AC920: wl_closure_invoke (connection.c:1025)
==13712==    by 0x49A8C08: dispatch_event.isra.0 (wayland-client.c:1631)
==13712==    by 0x49AA5AB: dispatch_queue (wayland-client.c:1777)
==13712==    by 0x49AA5AB: wl_display_dispatch_queue_pending (wayland-client.c:2019)
==13712==    by 0x49AAB5E: wl_display_roundtrip_queue (wayland-client.c:1403)

==13712== 576 bytes in 4 blocks are definitely lost in loss record 6,289 of 7,462
==13712==    at 0x48459F3: calloc (vg_replace_malloc.c:1340)
==13712==    by 0x49BE94D: drmDeviceAlloc (xf86drm.c:4072)
==13712==    by 0x49BFAC9: drmProcessPciDevice (xf86drm.c:4104)
==13712==    by 0x49BFAC9: process_device (xf86drm.c:4508)
==13712==    by 0x49C35FB: drmGetDeviceFromDevId (xf86drm.c:4670)
==13712==    by 0x1AD583: xwl_dmabuf_feedback_main_device (xwayland-dmabuf.c:477)
==13712==    by 0x1AD583: xwl_window_dmabuf_feedback_main_device (xwayland-dmabuf.c:691)
==13712==    by 0x53C03FD: ffi_call_unix64 (unix64.S:104)
==13712==    by 0x53BF70C: ffi_call_int (ffi64.c:673)
==13712==    by 0x53BFEE2: ffi_call (ffi64.c:710)
==13712==    by 0x49AC920: wl_closure_invoke (connection.c:1025)
==13712==    by 0x49A8C08: dispatch_event.isra.0 (wayland-client.c:1631)
==13712==    by 0x49AA5AB: dispatch_queue (wayland-client.c:1777)
==13712==    by 0x49AA5AB: wl_display_dispatch_queue_pending (wayland-client.c:2019)
==13712==    by 0x1A1842: xwl_read_events (xwayland-screen.c:566)
==13712==    by 0x1A1842: xwl_read_events (xwayland-screen.c:553)

Fixes: 6f0b9deed6 ("xwayland: use drmDevice to compare DRM devices")
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1484>
2024-04-12 07:25:55 +00:00
Michel Dänzer 3a0fc2684a xwayland: Add xwl_window::surface_window
It may track a non-toplevel window which fully covers the area of the
window pixmap / Wayland surface. It is now used instead of
xwl_window::toplevel for updating the Wayland surface contents.

The surface_window can now hit the Present page flip path while it's
automatically redirected.

v2:
* Use "surface_window" instead of "surf_win". (Olivier Fourdan)
* Add comment describing surface_window, and describe what
  surface_window/toplevel are useful for respectively. (Olivier Fourdan)
* Use surface_window in xwl_realize_window.
v3:
* Backtrack up to the closest opaque ancestor in
  xwl_window_update_surface_window. (Olivier Fourdan)
v4:
* Clean up logic for determining the surface window in
  xwl_window_update_surface_window, and document it better.
* Handle window_get_damage(xwl_window->surface_window) returning NULL
  in xwl_window_update_surface_window.
* Call xwl_window_update_surface_window after xwl_window_buffers_init
  in ensure_surface_for_window, since the former may call
  xwl_window_buffers_dispose.
* Rename surf/win_pix to surface/window_pixmap in
  xwl_window_update_surface_window.

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1300>
2024-04-10 08:55:08 +00:00
Michel Dänzer 972d5af537 xwayland: Rename xwl_window::window to ::toplevel
It's always the toplevel window, i.e. either the root window or a child
of it.

Preparation for later commits, no functional change.

v2: (Olivier Fourdan)
* Fix debug build.
* Add comment describing ::toplevel.

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1300>
2024-04-10 08:55:08 +00:00
Olivier Fourdan 6466c1ee81 xwayland/glamor: Drop xwl_screen_get_main_dev()
This is made redundant with xwl_gbm_get_main_device(), and this is not
really an xwl_screen function either.

Let's remove it.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1386>
2024-03-18 15:41:18 +00:00
Olivier Fourdan 5fd0c92b0e xwayland/glamor: Remove the flag "is_available"
Now that we have only one GBM backend, either it is available and
usable, or we cannot use GLAMOR.

Therefore we can drop the flag "is_available".

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1386>
2024-03-18 15:41:18 +00:00
Olivier Fourdan 439c0ee5e4 xwayland/glamor: Drop the get_main_device() hook
Call xwl_gbm_get_main_device() directly from xwl_screen_get_main_dev().

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1386>
2024-03-18 15:41:17 +00:00
Olivier Fourdan 722ea5d000 xwayland: Move dmabuf code to its own source file
The dmabuf support code is scattered across different source files,
making it hard to follow and bloating unrelated sources.

Move the dmabuf related source code to its own source files.

This is just a cleanup aimed at helping with code readability, no
functional change intended.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1111>
2024-03-14 15:00:46 +01:00