1
0
Fork 0
Commit graph

1224 commits

Author SHA1 Message Date
Sebastian Wick
8ebdae8092 launcher: Use $XDG_SESSION_ID if available
In some cases mutter is started in the user scope from a TTY (for
example using toolbox). Using sd_pid_get_session fails because it's not
in the session scope so it falls back to the primary session
(sd_uid_get_display). We want to start mutter on the TTY we started
mutter on however. Instead of relying on the scope to figure out the
correct session we first look at $XDG_SESSION_ID which is set by
systemd_pam.so.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2254>
2022-01-24 18:09:44 +01:00
Michel Dänzer
5127f7df56 native/cogl-utils: Add 10 bpc format support
Avoids assertion failure in meta_drm_buffer_gbm_fill_timings with direct
scanout of a 10 bpc EGL client surface (which works now with dma-buf
feedback).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2230>
2022-01-17 10:39:13 +00:00
Daniel van Vugt
6673fbcf68 onscreen/native: Remove a goto in DisplayLink fallback
At first glance the `goto` looks like a loop, or potentially an infinite
loop. It's not a loop because the mode has changed at that point to
`META_SHARED_FRAMEBUFFER_COPY_MODE_PRIMARY`. But we can make it more
obvious and avoid the need for a goto.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2240>
2022-01-17 10:03:17 +00:00
Jonas Ådahl
5eae0c84ed stage-impl: Change the backend pointer to MetaBackend
A pointer to the real backend is more useful, so lets use that. This
affects various places that now need to fetch e.g. the clutter backend
via the real backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2014>
2022-01-17 09:48:51 +01:00
Carlos Garnacho
70e44c281c backends/native: Ensure pointer is onscreen in input thread
It's slightly racy to have the main thread update the views and warp
the pointer, since the input thread may not be aware yet of the new
viewport layout.

Make the input thread clamp the pointer so it remains onscreen
instead, when the new viewports are obtained.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/64
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2237>
2022-01-16 18:38:20 +00:00
Jonas Ådahl
1cc786ffd3 launcher: Pass fallback session/seat ID when in test mode
When we test, we might not have a systemd session to rely on, and this
may cause some API we depend on to get various session related data to
not work properly. Avoid this issue by passing fallback values for these
when we're running in test mode.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2151>
2022-01-14 09:16:09 +00:00
Jonas Ådahl
8b628f0ae4 launcher: Fix indentation
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2151>
2022-01-14 09:16:09 +00:00
Jonas Ådahl
c8c9d49f79 Add rudimentary mode setting test
Add a test that uses vkms to test that mode setting works, and that
rendering works. It renders 10 frames in a row after mode setting, then
exits.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2151>
2022-01-14 09:16:09 +00:00
Jonas Ådahl
124a1582e1 native: Replace 'headless' property with 'mode' property
There will be another mode added later, 'test'; prepare for this by
changing the existing "mode" boolean ('headless') to a mode, which is
either 'default' or 'headless'. Checking the is_headless variable is
changed to using the function is_headless(), except for one place, being
VT switching, which in preparation is only allowed on the 'default'
mode. Other places where it makes sense, the conditions are changed to
switch statements.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2151>
2022-01-14 09:16:09 +00:00
Jonas Ådahl
bb6ae40a0f onscreen/native: Always free the next framebuffer on dispose
There was a sanity check that complained if there was still a "next
framebuffer" when disposing an onscreen. This is correct to complain
about under normal operation, as we always wait until receiving the page
flip callback before cleaning up the onscreen and their state.

However, when there are many hotplugs occurring, we might end up with
race conditions when the above sanity check is not valid: when we have
more than one monitor active, paint 1 one of them, but receive a hotplug
event before we paint the other(s), we will discard the already painted
onscreen before really issuing a page flip.

In this situation, we will have the "next framebuffer", but having that
is not a bug, it's a race condition, thus to not leak in this situation,
make sure to clean up the next framebuffer here too.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2081
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2225>
2022-01-09 23:03:02 +00:00
Jonas Ådahl
8e91c6295d renderer/native: Clear old KMS updates on views rebuild
If there are any pending updates, for example if we painted one of
multiple monitors but without having posted the update due to waiting
for another monitor to be painted, but before we paint all of them and
post the update, another hotplug event happens, we'd have stale pending
KMS update. When that update eventually would be processed, we'd try to
apply out-of-date updates which may contain freed memory.

Fix this by discarding any update when we're rebuilding the views. We
can be sure not to need any of the old updates since we're rebuilding
the whole content anyway.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1928
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2216>
2022-01-09 22:34:16 +00:00
Jonas Ådahl
8a2fcf3be0 wayland: Use new KMS update test API to try acquiring scanout
This significantly increases the chance of a fullscreen surface buffer
being scanned out instead of being painted via composition. This is
assuming the client supports the DMA buffer feedback Wayland protocol.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2146>
2022-01-05 20:00:36 +00:00
Jonas Ådahl
a14923e993 kms: Add update test API
This API can be used to construct a MetaKmsUpdate with plane assignments
that in isolation will be tested against the current KMS state. How it
is tested depends on the KMS implementation; in the simple / legacy KMS
backend, the tests are identical to the current scanout requirements
(dimension, stride, format, modifiers, all must match), and with atomic
KMS, it uses the TEST_ONLY on a real constructed atomic mode setting
commit.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2146>
2022-01-05 20:00:36 +00:00
Jonas Ådahl
ae086a31dd device-pool: Remove duplicate include macro
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2202>
2022-01-03 19:24:36 +01:00
Robert Mader
36481b8d21 gen_default_modes: Add more refresh rates to fallback modes
Refresh rates >60Hz become ever more common. In order to allow users
to keep hight refresh rates when not running at a natively advertized
resolution, add common refresh rates to our fallback modes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2189>
2022-01-03 10:48:29 +00:00
Robert Mader
fb9564b87b output/kms: Filter out duplicate fallback modes
Right now we often add a duplicate fallback mode that's almost
identical to the native mode. This adds unnecessary clutter to
UIs, thus filter out such modes.

In order to keep the code small, use `MetaCrtcModeInfo` directly
instead of recalculating the values. And to keep consistency, do
the same in the loop above.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2189>
2022-01-03 10:48:29 +00:00
Jonas Ådahl
287908e05a renderer/native: Don't clear GPU data with pending page flips
An incorrect assumption that after mode set there would be no pending
page flips was made. This meant that if there was a mode set, followed
by a page flip, if that page flip was for a CRTC on a now unused GPU,
we'd crash due to the renderer GPU data having already been freed. This
commit avoids that by keeping it alive as long as the page flips are
still in the air. It fixes crashes with backtraces such as

  0) meta_render_device_get_egl_display (render_device=0x0)
     at ../src/backends/native/meta-render-device.c:320
  1) secondary_gpu_state_free (secondary_gpu_state=0x1c8cc30)
     at ../src/backends/native/meta-onscreen-native.c:560
  2) meta_onscreen_native_dispose (object=0x1cb65e0)
     at ../src/backends/native/meta-onscreen-native.c:2168
  3) g_object_unref (_object=<optimized out>)
     at ../gobject/gobject.c:3540
  4) g_object_unref (_object=0x1cb65e0)
     at ../gobject/gobject.c:3470
  5) clutter_stage_view_finalize (object=0x1cbb450)
     at ../clutter/clutter/clutter-stage-view.c:1412
  6) g_object_unref (_object=<optimized out>)
     at ../gobject/gobject.c:3578
  7) g_object_unref (_object=0x1cbb450)
     at ../gobject/gobject.c:3470
  8) meta_kms_page_flip_closure_free (closure=0x1d47e60)
     at ../src/backends/native/meta-kms-page-flip.c:76
  9) g_list_foreach (list=<optimized out>, func=0x7fb3ada67111 <meta_kms_page_flip_closure_free>, user_data=0x0)
     at ../glib/glist.c:1090
 10) g_list_free_full (list=0x1cb4d20 = {...}, free_func=<optimized out>)
     at ../glib/glist.c:244
 11) meta_kms_page_flip_data_unref (page_flip_data=0x1c65510)
     at ../src/backends/native/meta-kms-page-flip.c:109
 12) meta_kms_callback_data_free (callback_data=0x227ebf0)
     at ../src/backends/native/meta-kms.c:372
 13) flush_callbacks (kms=0x18e2630)
     at ../src/backends/native/meta-kms.c:391
 14) callback_idle (user_data=0x18e2630)
     at ../src/backends/native/meta-kms.c

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2147>
2021-12-22 16:22:08 +00:00
Jonas Ådahl
4159c76a5b cursor-renderer/native: Clear GPU state before closing device
This ensures we don't have any left over cursor GPU buffers (via
gbm_bo's) after destroying the corresponding gbm_device (owned by
MetaRenderDevice).

Fixes crashes with backtraces such as

  1) meta_drm_buffer_gbm_finalize at ../src/backends/native/meta-drm-buffer-gbm.c:450
  4) invalidate_cursor_gpu_state at ../src/backends/native/meta-cursor-renderer-native.c:1167
  9) update_cursor_sprite_texture at ../src/wayland/meta-wayland-cursor-surface.c:70
 10) meta_wayland_surface_role_apply_state at ../src/wayland/meta-wayland-surface.c:1869
 11) meta_wayland_surface_apply_state at ../src/wayland/meta-wayland-surface.c:832
 12) meta_wayland_surface_commit at ../src/wayland/meta-wayland-surface.c:993
 13) wl_surface_commit at ../src/wayland/meta-wayland-surface.c:1158
 14) ffi_call_unix64 at ../src/x86/unix64.S:76
 15) ffi_call at ../src/x86/ffi64.c:525

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2147>
2021-12-22 16:22:08 +00:00
Olivier Fourdan
56939abd2f cursor-renderer/native: Add a means to disable HW cursors
When dealing with a faulty hardware or bugs in the driver, it might be
interesting to force the use of software cursors for debugging purposes.

Add a debug environment variable MUTTER_DEBUG_DISABLE_HW_CURSORS to
disable hardware cursors and force using software cursors.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2046
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2150>
2021-12-20 10:41:28 +00:00
José Expósito
2e8aef6f8a backends/native: Refactor LIBINPUT_EVENT_POINTER_AXIS handling
Move the logic to handle LIBINPUT_EVENT_POINTER_AXIS events to its own
function (handle_pointer_scroll).

Refactor, no functional changes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1966>
2021-12-14 15:44:48 +00:00
Jonas Ådahl
d43cc776ef renderer/native: Allow forcing EGLStream backend
The GBM support in the NVIDIA driver is fairly new, and to make it
easier to identify whether a problem encountered is related to using GBM
instead of EGLStreams, add a debug environment variable to force using
EGLStream instead of GBM.

To force using EGLStream instead of GBM, use

    MUTTER_DEBUG_FORCE_EGL_STREAM=1

Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/2045
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2132>
2021-12-08 15:47:35 +00:00
Carlos Garnacho
508c08fa09 backends: Only reload sprite cursor on changes
Let the meta_cursor_sprite_realize() function return a boolean value
telling whether there was an actual change in the sprite cursor. E.g.
the surface/icon for it changed in between.

This is used in the native backend to avoid converting/uploading again
the cursor surface.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1915>
2021-12-07 20:04:08 +00:00
Joan Torres
754c834590 Add method to show if in headless mode
MetaBackend can now show whether it is in headless mode or not
using a vfunc is_headless.

Fallback of is_headless returns FALSE.

MetaBackendNative implements is_headless returning its
is_headless property.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2130>
2021-12-07 16:03:10 +00:00
Pascal Nowack
d5f2ec6f1e backends/native: Stop freeing slow keys list twice
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1225
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2138>
2021-12-07 09:35:26 +01:00
JoseExposito
d4ba16252b backends/native/meta-seat: Capture hold events
Receive hold gesture events from libinput and enqueue them as Clutter
events.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1830>
2021-12-02 20:48:24 +00:00
Jonas Ådahl
5ca43e7017 renderer/native: Set EGLContext when creating secondary GPU data
When changing to using MetaRenderDevice, setting the EGLContext was
mistakenly dropped. Add it back. Fixes hybrid graphics setups.

Fixes: d4e8cfa17a
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2032
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2111>
2021-11-26 15:04:39 +00:00
Jonas Ådahl
00c329a2e5 cursor-renderer/native: Use MetaCrtcNative API to check capabilities
The cursor renderer shouldn't assume all the CRTCs of a logical are KMS
CRTC's, as we'll end up checking hardware capabilities for CRTC's of
virtual monitors as well, when they were created to not embed the cursor
image directly in the framebuffer.

Instead, use the newly introduced API for checking CRTC cursor
capabilities. This fixes a crash with the following backtrace:

 0) get_plane_with_type_for at ../src/backends/native/meta-kms-device.c:150
 1) meta_kms_device_get_cursor_plane_for at ../src/backends/native/meta-kms-device.c:173
 2) has_cursor_plane at ../src/backends/native/meta-cursor-renderer-native.c:678
 3) foreach_crtc at ../src/backends/meta-logical-monitor.c:247
 4) meta_monitor_mode_foreach_crtc at ../src/backends/meta-monitor.c:1920
 5) meta_logical_monitor_foreach_crtc at ../src/backends/meta-logical-monitor.c:274
 6) crtcs_has_cursor_planes at ../src/backends/native/meta-cursor-renderer-native.c:718
 7) should_have_hw_cursor at ../src/backends/native/meta-cursor-renderer-native.c:881
 8) meta_cursor_renderer_native_update_cursor at ../src/backends/native/meta-cursor-renderer-native.c:1085
 9) meta_cursor_renderer_update_cursor at ../src/backends/meta-cursor-renderer.c:411

Related: https://bugzilla.redhat.com/show_bug.cgi?id=2000183
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1991>
2021-11-26 14:30:27 +00:00
Jonas Ådahl
e82685d049 crtc/native: Add API to check whether the CRTC supports hardware cursors
On a KMS backed CRTC, hardware cursor are supported when there are
cursor planes to assign them to. Note that when using legacy mode
setting, fake cursor planes are added when adequate.

On virtual CRTCs, used with virtual monitors, the equivalent of hardware
cursor are always supported, as they are sent using embedded PipeWire
stream metadata.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1991>
2021-11-26 14:30:27 +00:00
Daniel van Vugt
acadf5b3f7 onscreen/native: Increase buffer ref count in copy_shared_framebuffer_cpu
It was dropping to zero after the first frame because it hadn't been
incremented high enough. So the second frame would crash with:
```
  #0 g_type_check_instance_cast
  #1 META_DRM_BUFFER
  #2 copy_shared_framebuffer_cpu
```
That's the CPU-copy path (fallback-fallback) that probably no one is using
but it does work after this fix. Exactly the same issue as was fixed
in `copy_shared_framebuffer_primary_gpu` by 36352f44f9.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2104>
2021-11-24 15:15:24 +00:00
Jonas Ådahl
cbdd62c197 kms/impl-device: Report 'full' change if we removed connectors
If some connectors disappeared, but the rest didn't change, we missed
actually removing the ones that disappeared, as we incorrectly assumed
nothing changed. Fix this by only assuming nothing changed if 1) we
didn't add any connector, and 2) we have the same amount of connectors
as before the hotplug event. The connector comparison checking makes
sure we report changes if anything of the still available connectors
changed.

Fixes: a8d11161b6
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2007
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2097>
2021-11-18 17:55:22 +01:00
Jonas Ådahl
c765730af7 kms/crtc: Always log whether we updated CRTC state
Change a few early-outs to handle the state changes without returning.
This means we'll get to log the result in all cases, which might help
debugging.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2097>
2021-11-18 17:55:22 +01:00
Jonas Ådahl
8546ca31ff kms/connector: Fix updating the state when drmConnector is NULL
When a docking station is disconnected, a few previously existing DRM
connectors may now be gone. When this happens, getting them via the
libdrm API results in NULL pointers returning, and we need to handle
this gracefully by making sure the connector state is properly updated.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2097>
2021-11-18 17:15:57 +01:00
Piotr Łopatka
33529426a9 backend: Copy damage rectangles to secondary GPU when available
Systems with AMD GPUs do not take advantage of Mutter's zero-copy path
when driving DisplayLink screens. This is due to a very slow CPU access
to the zero-copy texture. Instead they fall back on primary GPU doing a
copy of the texture for fast CPU access. This commit accelerates texture
copy by working through damage regions only.

Tests on a 4K screen with windowed applications show significant
reduction of GPU utilisation.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2033>
2021-11-17 08:24:15 +00:00
Carlos Garnacho
820aa18126 backends/native: Use rtkit to get realtime priority
Instead of using sched_setscheduler directly (and relying that we
somehow got CAP_SYS_NICE), use rtkit to do this for us.

Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/2284
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2060>
2021-10-22 08:35:15 +00:00
Jonas Ådahl
ac907119ae wayland: Only init EGLStream controller if we didn't end up with gbm
When we use gbm together with the NVIDIA driver, we want the EGL/Vulkan
clients to do the same, instead of using the EGLStream paths. To achieve
that, make sure to only initialize the EGLStream controller when we
didn't end up using gbm as the renderer backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2052>
2021-10-20 13:08:06 +00:00
Jonas Ådahl
8fc1325e8e renderer/native: Try the gbm renderer before the EGLDevice renderer
This switches the order of what renderer mode is tried first, so that
the gbm renderer mode is preferred on an NVIDIA driver where it is
supported.

We fall back to still try the EGLDevice renderer mode if the created gbm
renderer is not hardware accelerated.

The last fallback is still to use the gbm renderer, even if it is not
hardware accelerated, as this is needed when hardware acceleration isn't
available at all. The original reason for the old order was due to the
fact that a gbm renderer without hardware acceleration would succeed
even on NVIDIA driver that didn't support gbm.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2051>
2021-10-19 17:43:13 +02:00
Jonas Ådahl
e8249a572d renderer/native: Log render mode per device
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2051>
2021-10-19 17:43:12 +02:00
Jonas Ådahl
d4e8cfa17a renderer/native: Use MetaRenderDevice
This replaces functionality that MetaRenderDevice and friends has
learned, e.g. buffer allocation, EGLDisplay creation, with the usage of
those helper objects. The main objective is to shrink
meta-renderer-native.c and by extension meta-onscreen-native.c, moving
its functionality into more isolated objects.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1854>
2021-10-18 17:36:18 +02:00
Jonas Ådahl
8662f33b9e render-device: Add API to allocate dumb buffers
All render devices that have a device file backing them might be able to
allocate dumb buffers, so add a helper for doing that. Will indirectly
result in an error up front on a surfaceless render device due to lack
of a device file.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1854>
2021-10-18 17:36:17 +02:00
Jonas Ådahl
986588ade2 render-device: Add API to import other buffers
This more or less is a helper for creating MetaDrmBufferImport objects
with a bit more friendly API.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1854>
2021-10-18 17:35:26 +02:00
Jonas Ådahl
802e7eb56f render-device: Add API to allocate DMA buffers
Only possible with the gbm implementation; aims to make it easier for
users of render devices to allocate DMA buffers.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1854>
2021-10-18 17:34:31 +02:00
Jonas Ådahl
9292eba035 render-device/gbm: Add getter for gbm_device
Will be needed, at least during a transition period, to e.g. deal with
gbm_surface's et. al. without having MetaRenderDevice learning about
render surfaces.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1854>
2021-10-18 17:33:33 +02:00
Jonas Ådahl
b3dffb43b3 drm-buffer: Don't always generate fb_id on construction
It might not be needed by the user of the buffer, so don't always
require it up front. Instead make sure that any user that needs it first
calls "meta_drm_buffer_ensure_fb_id()" to create the ID.

Only the plain gbm implementation creates the ID lazilly, the other
still does it on construction due to the objects used to create them
only existing during construction.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1854>
2021-10-18 17:33:33 +02:00
Jonas Ådahl
a1266e19f4 drm-buffer: Add API to export buffer file descriptor
Practically ends up in gbm_bo_get_fd(). For dumb buffer, an
'unsupported' error is returned.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1854>
2021-10-18 17:33:33 +02:00
Jonas Ådahl
6ba86366b3 drm-buffer: Replace 'use-modifier' boolean with flags
This lets us add more customization to the buffer instance without
adding more boolean arguments.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1854>
2021-10-18 17:33:33 +02:00
Jonas Ådahl
99f51d2866 drm-buffer: Remove left-over function declaration
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1854>
2021-10-18 17:33:33 +02:00
Jonas Ådahl
e078718180 drm-buffer: Add getters for more metadata
Mostly calls into gbm_bo_* API, or something somewhat similar when on
dumb buffers. Added API are:

 * get offset for plane
 * get bpp (bits per pixel)
 * get modifier

This will allow users of MetaDrmBuffer to avoid having to "extract" the
gbm_bo to get these metadata.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1854>
2021-10-18 17:33:33 +02:00
Jonas Ådahl
bece36b4ad renderer/native: Get bpp from gbm_bo
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1854>
2021-10-18 17:33:33 +02:00
Jonas Ådahl
2047d2d4e9 Introduce MetaRenderDevice{Gbm,EglStream,Surfaceless}
The purpose of MetaRenderDevice is to contain the logics related to a
render device; i.e. e.g. a gbm_device, or an EGLDevice. It's meant to
help abstract away unrelated details from where it's eventually used,
which will be by MetaRendererNative and the MetaOnscreenNative
instances.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1854>
2021-10-18 17:33:32 +02:00
Jonas Ådahl
259a906b8c cogl/winsys: Remove 'multiple-onscreen' feature
It was always set, and is no longer used; remove it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-10-18 14:36:15 +00:00
Jonas Ådahl
8008f0b7b0 Explicitly create the clutter context and backend
This changes the setup phase of clutter to not be result of calling an
init function that sets up a few global singletons, via global singleton
setup vfuncs.

The way it worked was that mutter first did some initial setup
(connecting to the X11 server), then set a "custom backend" setup vfunc
global, before calling clutter_init().

During the clutter_init() call, the context and backend was setup by
calling the global singleton getters, which implicitly created the
backend and context on-demand.

This has now changed to mutter explicitly creating a `ClutterContext`
(which is actually a `ClutterMainContext`, but with the name shortened to
be consistent with `CoglContext` and `MetaContext`), calling it with a
backend constructor vfunc and user data pointer.

This function now explicitly creates the backend, without having to go
via the previously set global vfunc.

This changes the behavior of some "get_default()" like functions, which
will now fail if called after mutter has shut down, as when it does so,
it now destroys the backends and contexts, not only its own, but the
clutter ones too.

The "ownership" of the clutter backend is also moved to
`ClutterContext`, and MetaBackend is changed to fetch it via the clutter
context.

This also removed the unused option parsing that existed in clutter.

In some places, NULL checks for fetching the clutter context, or
backend, and fetching the cogl context from the clutter backend, had to
be added.

The reason for this is that some code that handles EGL contexts attempts
to restore the cogl EGL context tracking so that the right EGL context
is used by cogl the next time. This makes no sense to do before Cogl and
Clutter are even initialized, which was the case. It wasn't noticed
because the relevant singletons were initialized on demand via their
"getters".

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-10-18 14:36:15 +00:00
Jonas Ådahl
1fbdfa8ca7 clutter/backend/native: Keep a pointer to the actual backend
This eliminates going via a global variable.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-10-18 14:36:15 +00:00
Jonas Ådahl
9179d4a4b1 kms/impl-device/atomic: Add virtio_gpu to deny list
virtio_gpu is used in virtual machine environments, meaning they need
accurate cursor hotspots, which currently needs non-atomic mode setting.

Related: https://bugzilla.redhat.com/show_bug.cgi?id=2009304
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2040>
2021-10-05 13:55:06 +00:00
Marco Trevisan (Treviño)
16e335eb24 backends/native: Remove unused includes
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1964>
2021-09-20 15:37:59 +00:00
Marco Trevisan (Treviño)
3d689989ea kms/connector: Use utility function to get the property ID
We already have one for this, so use it instead of repeating the same

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1964>
2021-09-20 15:37:59 +00:00
Marco Trevisan (Treviño)
cbfb59b828 backends/native: Ignore udev events while we're paused
When the native backend is paused we still process the udev events
even though this isn't needed and may just cause unneeded events to be
triggered afterwards.

Since we'll resume with full changes on such event, we can just block
the signal hander when paused and restore it afterwards.

As per this we can cleanup also a bit the device adding signal handling
given that now we don't have to disconnect/reconnect it again.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1964>
2021-09-20 15:37:59 +00:00
Marco Trevisan (Treviño)
9cb35e2c80 backends/kms: Always perform full changes on KMS resume
Resume happens after we may have received various events that we've
ignored, so at this point we need to just emit an hotplug event like if
everything changed so that user settings may be re-applied.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1964>
2021-09-20 15:37:59 +00:00
Marco Trevisan (Treviño)
dd0ad3bfb1 kms/impl-device: Only update crtc/connector whose ID has changed
On hotplug events we may get informations about what CRTC or connector
changed a property (and the property itself), so in such case let's just
ignore the changes to the non-affected CRTCs/connectors, and let's read
only the affected one

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1964>
2021-09-20 15:37:59 +00:00
Marco Trevisan (Treviño)
91ed95ab6f kms: Only update a device state if it contains the changed crtc/connector
On hotplug events we may receive a "CRTC" or "CONNECTOR" property that
indicates which crtc/connector property ID has changed.

In such case, instead of update data for all the devices, only update the
device containing the relative connector.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1964>
2021-09-20 15:37:59 +00:00
Marco Trevisan (Treviño)
3d3668a389 kms/device: Add functions to find connector and crtc in devices
Hotplug events may contain CRTC or CONNECTOR ids to notify a property
change to just one owner, so we need to find its parent device.

Also we may want to update properties directly without having to go through
all the devices, so expose a simple way to find them.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1964>
2021-09-20 15:37:59 +00:00
Marco Trevisan (Treviño)
ea00c96044 udev: Pass the device as parameter on hotplug events
This will allow to find the related MetaKmsDevice that is emitting the
hotplug event

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1964>
2021-09-20 15:37:59 +00:00
Marco Trevisan (Treviño)
49501c28f2 kms: Return a more specific change if there are no devices
In case we have no devices, after a KMS update (both because they've
all have been removed or because there were none), we may need to behave
differently compared to the case in which nothing changed, so add a more
specific KMS update change type

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1964>
2021-09-20 15:37:59 +00:00
Marco Trevisan (Treviño)
9ce3abad28 monitor-manager-native: Do not reload all the monitors on gamma-only change
If only gamma changed on drm CRTC's we don't have to rebuild the whole
monitors, nor to inform the backed about, the only consumer could be the
DBus API, and so we still emit a signal, but nothing else is needed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1964>
2021-09-20 15:37:59 +00:00
Marco Trevisan (Treviño)
a8d11161b6 kms: Only emit resources-changed signal if we recorded a change
Since we cache already all the KMS parameters we care about let's check at
each device update if anything has really changed and only in such case
emit a resources-changed signal.

In this way we can also filter out the DRM parameters that when changed
don't require a full monitors rebuild.

Examples are the gamma settings or the privacy screen parameters, that
emits an udev "hotplug" event when changed, but we want to register those
only when we handle the changed property.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1964>
2021-09-20 15:37:59 +00:00
Piotr Lopatka
b328c8cc8b onscreen/native: Pass damage rectangles when page flipping
This commit passes damage rectangles metadata to the (KMS) primary
plane.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1879>
2021-09-03 21:37:56 +01:00
Piotr Lopatka
af0460d0ce kms: Allow passing framebuffer damage metadata
This commit adds support to atomic KMS backend for optional plane property
prop_fb_damage_clips. Some drivers (e.g. EVDI) take advantage of this
property and process only updated regions of the screen instead of
processing the full frame. This can save system resources.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1879>
2021-09-03 21:10:35 +01:00
Daniel van Vugt
cd355b5d74 onscreen/native: Remove a tab character
To resolve CI warnings.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1972>
2021-08-24 16:44:44 +08:00
Marco Trevisan (Treviño)
67eb60c19a monitor-manager: Pass the Logical mode when computing the monitor scale
In order to compute proper default scaling value we need to know if the
fractional scaling is enabled or not and thus if we're using a logical
mode or not.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/336>
2021-07-22 13:14:01 +02:00
Carlos Garnacho
d5c3c80dfe backends: Rename ClutterStage[View]Cogl API and types
Rename to MetaStageImpl and MetaStageView, so they are in line with
the rest of the backend code.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1862>
2021-07-16 19:08:06 +02:00
Carlos Garnacho
8f839b2f9c clutter: Move ClutterStageCogl[View] code to src/backends
This is now MetaStageImpl in backend code.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1862>
2021-07-16 19:08:06 +02:00
Carlos Garnacho
5785d8cde0 backends/native: Remove unused array definition
This array is a relic from the input code belonging to Clutter,
and is nowadays unused.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1862>
2021-07-16 19:08:06 +02:00
Jonas Ådahl
a2937a47bb onscreen/native: Change some g_debug() meta_topic()
g_debug() is inconvenient to use; change to meta_topic() with the 'kms'
topic. This makes it possible to enable valuable debug output at
runtime.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1931>
2021-07-16 18:17:04 +02:00
Jonas Ådahl
d057762cdb device-pool: Add debug logging
Enabled by enabling the 'backend' debug topic.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1931>
2021-07-16 18:17:04 +02:00
Jonas Ådahl
b65555a958 renderer/native: Include error message in log entries
We had a GError handed to us, where we logged a warning, but didn't log
the message from the error. Do that so it becomes easier to find out
what might have failed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1931>
2021-07-16 18:10:56 +02:00
Jonas Ådahl
58f053d437 drm-buffer/dumb: Return TRUE when init succeeded
Returning FALSE means it failed, but we returned FALSE even when it
succeeded, meaning it would never succeed.

Fixes: 10c4bc6e3f
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1880
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1888
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1932>
2021-07-16 17:18:55 +02:00
Jonas Ådahl
0330ce1f15 context: Make the context own MetaWaylandCompositor
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:34:37 +02:00
Jonas Ådahl
23b79f33fa launcher: Remove open/close restricted file API
It has since some time been replaced with MetaDevicePool, and isn't used
by anything anymore, so remove it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1929>
2021-07-13 12:19:14 +00:00
Ivan Molodetskikh
1116b14f38 backends/native: Get rendering and swap timings during scanout
Scanout doesn't go through the usual path of compositing and doing
eglSwapBuffers, therefore it doesn't hit the timestamp query placed in
that path. Instead, get the timings by binding the scanout buffer to an
FBO and doing a timestamp query on the FBO.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1762>
2021-07-13 08:09:42 +00:00
Ivan Molodetskikh
5a0d3ed4dd backends/native: Remove unneeded NULL check
There seems to be no way to construct this type with an invalid bo.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1762>
2021-07-13 08:09:42 +00:00
Ivan Molodetskikh
d10567ea3e clutter: Add vblank duration to ClutterStageView
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1762>
2021-07-13 08:09:42 +00:00
Ivan Molodetskikh
2d939754b1 crtc-mode-info: Add vblank duration field
Only populated for KMS backed modes, as that's where it's relevant.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1762>
2021-07-13 08:09:42 +00:00
Ivan Molodetskikh
e40ff9d8b7 backends/native: Add meta_calculate_drm_mode_vblank_duration_us()
Computes the vblank duration from mode timings.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1762>
2021-07-13 08:09:42 +00:00
Daniel van Vugt
9f492a0ee0 kms: Add fixed point formatting to MUTTER_DEBUG=kms printing
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1923>
2021-07-13 15:29:14 +08:00
Daniel van Vugt
b59c5386b9 kms: Add a trivial meta_fixed_16_to_double conversion function
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1923>
2021-07-13 15:26:43 +08:00
Daniel van Vugt
ea75ea0b73 kms: Add an internal MetaKmsPropType to distinguish fixed point values
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1923>
2021-07-13 15:26:43 +08:00
Daniel van Vugt
d996319cf9 kms: Add a missing g_set_error on error
So the GError is not left NULL and then dereferenced.

Fix provided by Jonas Ådahl <jadahl@gmail.com>

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1878
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1925>
2021-07-09 16:26:11 +08:00
Jonas Ådahl
ce5a5789bb native: Release output device files that are unused
In order to make it possible to e.g. unload an unused DRM device, we
need to make sure that we don't keep the file descriptor open if we
don't need it; otherwise we block anyone from unloading the
corresponding module.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:10:30 +02:00
Jonas Ådahl
173d895d53 kms: Remove now unused API to get file descriptor
The last user switched to using MetaDeviceFile, so time to clean up.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:26 +02:00
Jonas Ådahl
10c4bc6e3f drm-buffer: Create from MetaDeviceFile instead of MetaKmsDevice
The DRM buffers aren't really tied to mode setting, so they shouldn't
need to have an associated mode setting device. Now that we have a
device file level object that can fill this role, port over
MetaDrmBuffer and friends away from MetaKmsDevice to MetaDeviceFile.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:26 +02:00
Jonas Ådahl
6613463f58 renderer/native: Decouple device file from MetaKmsDevice
Keep a private MetaDeviceFile instance for the GPU's managed by the
renderer. This is a step towards decoupling rendering from mode setting,
as well as on-demand holding of device file descriptors.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:26 +02:00
Jonas Ådahl
e567cb972d renderer/native: Get 'uses-monotonic' state from MetaKmsDevice
It's better suited to be handled by the MetaKmsDevice abstraction.

This eliminates the last caller of drmGetCaps() from outside
MetaKmsImplDevice.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:26 +02:00
Jonas Ådahl
86c4369f41 renderer/native: Look up prefers-shadow cap via MetaKmsDevice
This eliminates the second last user of drmGetCap() from outside of
MetaKmsImplDevice.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:26 +02:00
Jonas Ådahl
93f9c99cc5 kms/impl-device: Set universal plane client cap when opening file
This means it will be set again if the file is reopened.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:26 +02:00
Jonas Ådahl
5502f956f5 device-file: Add tags
Tags are meant to make it possible for a device file opener to tag a
file if it has affected the state the file descriptor is in; e.g. if it
has enabled a DRM capability.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:26 +02:00
Jonas Ådahl
ceff2a93ca renderer/native: Create dummy offscreens if onscreens fail to allocate
This is less dramatic than aborting, and could in theory be a temporary
issue, so handle it by rendering into an offscreen.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:26 +02:00
Jonas Ådahl
db1d35c53d kms/mode: Recreate blob id each mode set
This simplifies the blob management and isn't that less efficient that
it matters.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:25 +02:00
Jonas Ådahl
3c9ab768ec launcher: Remove now unused file management API
The open/close helpers for (maybe) restricted files has been replaced
with MetaDevicePool, so lets remove that functionality from here.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:25 +02:00
Jonas Ådahl
7ce266628e seat-impl: Open/close files via device pool
This replaces going through MetaLauncher to open/close restricted files.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:25 +02:00
Jonas Ådahl
f6f9c093ba clutter/seat: Remove backend pointer
It was unused, and having a pointer to the MetaBackend in subtypes is
more useful, so remove it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:25 +02:00
Jonas Ådahl
b4cf839e87 device-pool: Add way to open files read-only
Will be used by libinput's tablet device led device files.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:25 +02:00
Jonas Ådahl
a845a07a92 device-pool: Handle interrupted open()
Handle open() failing due to being interrupted by trying again until it
either succeeds, or fails due to some other error. This was an error
handling path taken when opening sysfs files; do the same here to not
potentially regress once we open sysfs files with the device pool.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:25 +02:00
Jonas Ådahl
3d882b6410 device-pool: Only fetch major/minor for taken devices
It's only when we take/release from/to logind we need these two
integers, so only retrieve them when that's done. Making this change
makes it possible to open devices that don't have these parameters.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:25 +02:00
Jonas Ådahl
e6421dc5da kms: Have the device impl open device files themself
This changes the way the KMS backends load; if we're headless, we always
use the dummy one and fail otherwise; in other cases, we first try the
atomic backend, and if that fails, fall back on the simple one.

The aim for this is to have the impl device open and close the device
when needed, using the device pool directly.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:25 +02:00
Jonas Ådahl
f3457b678c kms/device: Use device pool to open/close dri devices
This replaces the usage of MetaLauncher.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:25 +02:00
Jonas Ådahl
ee8c252a8c native: Add device pool for tracking device file descriptors
This practically does the same thing as part of MetaLauncher, except
with added thread safety and caching. For example, opening the same file
a second time will return the same MetaDeviceFile, and only once all
acquired MetaDeviceFile's are released, will the file descriptor be
closed and control of the device released.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:25 +02:00
Carlos Garnacho
841ee0a227 backends/native: Fix logic error
ClutterInputDevice's get_group_n_modes() vfunc is meant to return
-1 for groups that are out of the known range, not within. Fix the
early return condition, and let the native backend return correctly
the number of modes for the given group.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1920>
2021-07-07 18:37:54 +02:00
Jonas Ådahl
8ca087fee9 kms/impl-device/simple: Pass the NULL to discard_page_flip() on shut-down
The second argument is an optional GError, not an impl device pointer.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1911>
2021-07-07 14:51:46 +00:00
Jonas Ådahl
1d7920872d kms: Gracefully handle page flipping direct scanouts failing
When drmModePageFlip() or drmModeAtomicCommit() unexpectedly failed (e.g.
ENOSPC, which has been seen in the wild), this failure was not handled
very gracefully. The page flip listener for the scanout was left in the
MetaKmsUpdate, meaning when the primary plane composition was later page
flipped, two page flip listeners were added, one for the primary plane,
and one for the scanout. This caused the 'page-flipped' event to be
handled twice, the second time being fatal.

Handle this by making 'no-discard' listener flag be somewhat reversed,
and say 'drop-on-error', and then drop all 'drop-on-error' listeners
when a MetaKmsUpdate failed to be processed.

Also for a "preserve" flagged update, don't ever trigger "discard"
callbacks just yet, as preserved updates are used again for the primary
plane composition, in order to not miss e.g. CRTC gamma updates, or
cursor plane updates, which were added separately.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1809
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1910>
2021-07-02 13:29:54 +00:00
Jonas Ådahl
a0343b0abd renderer/native: Clear pending update list before repopulating
Before we did a simple copy, meaning the old list was overriden. Copy
was too eager, as it meant views without modes to set was waited for,
resulting in a dead lock. Instead only the relevant views were added to
the list for view which had pending updates needed. What was missed was
that the list was never cleared, meaning we just appended the new list
on top of the old, causing issues.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1846
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1843
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1844
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1895>
2021-06-12 21:09:55 +02:00
Jonas Ådahl
c0758c63b5 native: Properly ignore devices on init too
There is an udev rule marking whether a device should be ignored by
mutter or not, but it was only respected on hotplug events not on init,
partly defeating its purpose. Fix this.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1892>
2021-06-09 19:21:44 +00:00
Jonas Ådahl
8478db96f9 renderer-native: Don't attempt to queue mode sets on non-onscreen views
A view is only a 'CoglOnscreen' if it ends up on a CRTC, thus needs a
mode. Other views are for virtual monitors, and require no mode setting,
so exclude them from the pending mode set list.

This avoids a dead lock when we'll be waiting indefinitely for mode
setting on a virtual monitor.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1891>
2021-06-09 17:40:34 +00:00
Jonas Ådahl
18d670e69f backends: Introduce MetaIdleManager
This object takes over the functionality of meta-idle-monitor-dbus.c,
meta-idle-monitor.c and meta-backend.c, all related to higher level
management of idle watches etc.

The idle D-Bus API is changed to be initialized by the backend instead
of MetaDisplay, as it's more of a backend functionality than what
MetaDisplay usually deals with.

It also takes over the work of implementing "core" idle monitors. The
singleton API is replaced with thin wrapper functions on the backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1859>
2021-05-18 13:19:36 +00:00
Jonas Ådahl
c9992a2953 main: Initialize Wayland just before MetaDisplay
Wayland support is not really a "backend" thing, it just lacked a better
place to store its instance pointer. Eventually we'll have a better
place, but prepare for that by initializing it together with the more
similar subsystems.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1833>
2021-05-17 16:08:42 +00:00
Jonas Ådahl
22417b8a94 backend/native: Split up KMS shutdown in two phases
The first phase happens early, which discards pending page flips,
meaning the references held by those page flip closures are released.

The second phase happens late, after other units depending on the KMS
abstraction, have been cleaned up.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
1af874fca6 kms/impl-device/atomic: Discard pending page flip datas on finalize
This is so page flip listeners can clean up any references attached to a
page flip.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
7c924a562f kms/impl-simple: Clean up pending page flip datas on finalize
They might be holding on to references, so lets keep track of them and
clean up on finalize.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
2ed4e8c906 kms-impl/simple: Discard pending flips when finalizing
Removing the reference isn't enough, the callbacks needs to be invoked
so the buffer state machinery gets notified about the page flips being
discarded.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
4dec1f5ddf kms/impl-simple: Add helper for dispatching page flip datas
Instead of a invoke helper, and a clear helper, use a single dispatch
helper that does both.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
c29f8c8b73 onscreen/native: Complete buffer swap also if we discarded
We already swapped the front buffer, and even if it didn't get
presented, we should still swap our representation of the state, to not
get into a confused buffer tracking state.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
4cb6033a27 onscreen/native: Simplyify notify_view_crtc_presented()
We don't really need to fetch the rendering mode, as we'd only ever call
a function that is effectively a no-op if render modes it isn't relevant
to.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
b731eb29b5 kms: Remove idle flush callback when flushing
We might flush in other places than the idle callback; in this case, we
don't need the idle callback anymore, so remove it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
023dd13d6c onscreen/native: Get backend pointer from GPU
If we clean things up during destruction, the singleton pointer to the
backend is already gone; get it from a better place instead, to not
crash.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
d077baadbb renderer/native: Destory EGL context on GPU data tear down
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Carlos Garnacho
63d969537f backends: Drop MetaInputSettings::seat property
This is now entirely unused, and it's dubious it should ever
be again.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1849>
2021-05-05 19:07:26 +00:00
Florian Müllner
d4a042b88d native: Fix compiler warning
cogl_context is only used when building with EGLDevice support,
resulting in an "unused variable" warning otherwise.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1852>
2021-05-05 10:32:28 +02:00
Jonas Ådahl
8989c42d40 backend/native: Add udev rule to ignore vkms devices
Virtual Kernel Mode Setting (vkms) is a virtual /dev/dri/card* device
not backed by any actual hardware. It's intended for testing purposes,
e.g. to run tests suites with a reproducable setup, or in continuous
integration pipelines.

Currently mutter don't have any tests that can run on top of vkms, but
will eventually get that. To prepare for the ability to do that, and
having said kernel module loaded without causing wierd issues with any
active session, add an udev rule that tells mutter to ignore any vkms
device.

Otherwise, when vkms is loaded, mutter would detect it, assume it's a
regular monitor, configure it as such, thus add a region of the stage
that ends up nowhere, which isn't very helpful. It might also conflict
with running actual tests that need to interact with vkms if the active
session has taken control of it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1740>
2021-04-30 15:10:28 +02:00
Jonas Ådahl
4af0f05603 udev: Move device tag detection into helper
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1740>
2021-04-30 15:10:28 +02:00
Jonas Ådahl
eaf75f0706 udev: Don't only check 'platform' device for KMS modifier tag
Only checking the 'platform' device missed the tags added for i915 and
others, meaning the multi head configurations yet again started to fail
due to default modifier behavior is incompatible with multi many head
configurations.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1769
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1774
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1843>
2021-04-29 18:48:24 +00:00
Jonas Ådahl
c5e4d7db45 native: Invalidate CRTC gamma when resuming or leaving power save
With atomic mode setting, commits don't work when CRTCs aren't enabled,
which they aren't when we're power saving. This means the gamma state
fails to being update. To fix night light and for whatever other reason
gamma ramps was changed during power saving by marking the CRTC gamma
state as invalid when leaving power saving, as well as when resuming.
This means that the next frame will append the CRTC gamma state to the
KMS commit.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1755
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1835>
2021-04-29 18:04:04 +00:00
Jonas Ådahl
efd9af1183 output/kms: Add back common modes on non-single mode outputs
But this time, filter out modes that exceed a roughly calculated maximum
bandwidth. This should avoid e.g. setting a 60 Hz 4K mode, when 4K is
limited to 30 Hz, but lower resolutions supporting 60 Hz.

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4155
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1834>
2021-04-27 16:12:18 +00:00
Carlos Garnacho
b4a7f35146 backends/native: Unref/unset key repeat GSource when cleared
This GSource is not being properly unref nor the variable holding it
cleared. This on one hand leaks the GSource memory, on the other hand
may trigger warnings in keyboard_repeat() as the source may be
(reentrantly) cleared, yet we don't exit early as
seat_impl->repeat_source is never NULL.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1839>
2021-04-27 08:37:38 +00:00
Jonas Ådahl
90eab42867 input-settings/native: Check mapping mode in input thread
When we set the matrix, we checked the device mapping mode in the main
thread, then passed along the calculated matrix to the input thread for
application. This could however be racy, as the mapping mode is managed
in the input thread. Fix this by sending the unaltered matrix, having
the input thread checking the mapping mode.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1806>
2021-04-14 19:16:22 +00:00
Jonas Ådahl
efde781747 input-settings: Make set_matrix() vfunc take const float array pointer
It shouldn't alter it, or take ownership, so clarify that by making it
constant.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1806>
2021-04-14 19:16:22 +00:00
Jonas Ådahl
e956078052 kms/connector: Properly predict connectors turning off
The connector state wasn't properly predicted, as it earlied out if
the connector wasn't part of a mode set connector list.

Instead use the old CRTC to check whether it was used in any mode set,
and whether the connector was part of any new mode set, to predict
whether the connector is inactive or active.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1821>
2021-04-14 18:44:57 +00:00
Jonas Ådahl
4b78c8d84f renderer/native: Fix disabling monitors on otherwise unchanged device
When a device only had mode sets which turned off monitors, not enabling
anything, there would be no KMS update created and posted, and the
active monitors would remain on.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1821>
2021-04-14 18:44:57 +00:00
Jonas Ådahl
14f6869381 onscreen/native: Make sure to reset the EGL context after dGPU blit
On hybrid graphics system, the primary path used to transfer the stage
framebuffer onto the dedicated GPU's video memory preparing for scanout,
is using the dedicated GPU to glBlitFramebuffer() the content from the
iGPU texture onto the scanout buffer.

After we have done this, we reset the current EGL context back to the
one managed by cogl. What we failed to do, however, was to reset the
current EGL context when we inhibited the actual page flip due to having
entered power save mode.

When we later started to paint again, Cogl thought the current EGL
context was still the correct one, but in fact it was the one used for
the iGPU -> dGPU blit, causing various EGL surface errors, and as a side
effect, eventually hitting an assert.

Fix this by making sure we reset to the Cogl managed EGL context also
for this case.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1803>
2021-04-14 17:42:32 +00:00
Jonas Ådahl
60a998bdbc onscreen/native: Release buffer before destroying EGLSurface
Destroying the EGLSurface frees the underlying container structs. When
we call gbm_surface_release_buffer() with a gbm_surface the EGLSurface
was created from, doing that after the EGLSurface was destroyed results
in attempts to access freed memory. Fix this by releasing any buffer
first, followed by destroying the EGLSurface, and lastly, the
gbm_surface.

This was not a problem prior to CoglOnscreen turning into a GObject, as
in that case, the dispose-chain was not setup correctly, and the
EGLSurface destruction was done in the native backend implementation.

This also changes a g_return_if_fail() to a g_warn_if_fail(), as if we
hit the unexpected case, we still need to call up to the parent dispose
vfunc to not cause critical issues.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1803>
2021-04-14 17:42:32 +00:00
Jonas Ådahl
abbbe8f755 onscreen/native: Remove redundant EGLSurface cleanup
It's handled by CoglOnscreenEgl's dispose() implementation. It was
failed to be invoked in the past because the old non-GObject web of
vtables were not setup correctly, meaning the old generic EGL layer of
the CoglOnscreen de-init was never invoked.

When the type inheritence was cleaned up, this mistake was not cleaned
up, so do that now.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1803>
2021-04-14 17:42:32 +00:00
Jonas Ådahl
4c7a846dc8 output/kms: Only add common modes for single mode connectors
If there was only a single mode, add the common modes to provide options
to select other resolutions than the built in default. This avoids
issues where the connector listed multiple supported modes, but where
the common modes added would exceed the possible bandwidth. We could
probably make an attempt to filter out more modes from the common mode
list to avoid these issues, but it's likely that the driver already
lists suitable modes, meaning there is no point in adding the common
modes.

The common modes were initially added[0] to add modes to connectors with
a single bundled mode, so we shouldn't regress the original bug fix.

[0] https://bugzilla.gnome.org/show_bug.cgi?id=744544

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1232
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1824>
2021-04-14 15:15:52 +00:00
Jonas Ådahl
1f3c5bd316 kms/impl-device-atomic: Remove useless warning
No much use having a "g_return_if_fail (expr);" when we "if (expr)
return;" just above.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1820>
2021-04-14 12:53:25 +00:00
Jonas Ådahl
dc35514fb4 renderer: Switch open coded list clearing to g_clear_list()
The same for MetaRendererNative.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1820>
2021-04-14 12:53:25 +00:00
Jonas Ådahl
1a7f4d49f3 renderer/native: Remove unused function parameter
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1820>
2021-04-14 12:53:25 +00:00
Jonas Ådahl
a40b040cd6 seat-native: Remove left-over function declaration
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1820>
2021-04-14 12:53:25 +00:00
Jonas Ådahl
c822c799e4 kms/impl-device: Fix some argument naming mistakes
It was left-overs from when the MetaKmsImpl was not per device.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1820>
2021-04-14 12:53:25 +00:00
Jonas Ådahl
8867b11e19 launcher: Use gnome.gdbusgen and add prefix to generated API
This is more in line with how generated D-Bus boilerplate work, lets
stay consistent.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1820>
2021-04-14 12:53:25 +00:00
Jonas Ådahl
da3baba980 backend/native: Only disable KMS modifiers for i915
The intel DRM driver is known for not being able to handle multi head
setups when KMS modifiers are enabled, due to the implicitly selected
modifiers, while being more suitable for single head setups, cause
bandwidth issues when a certain number of monitor times resolution and
refresh rate is configured.

We don't yet support automatically finding a combination of modifiers
that work, and have because of this disabled KMS modifiers unless the
driver actually needs it.

Lets flip this configuration the other way around, changing the current
udev rule to decide wen to *disable* KMS modifier support, as it so that
only the Intel driver has this problem, while on the other hand, there
several drivers that requires modifiers to function at all.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1792>
2021-04-14 07:14:24 +00:00
Carlos Garnacho
f92232ae4f backends/native: Check whether views are scaled via MetaViewportInfo
The input thread is in deep water doing the meta_is_*() check itself,
as that pokes the MetaMonitorManager managed by the main thread. Use
the getter from the MetaViewportInfo instead.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1793>
2021-04-13 10:32:14 +00:00
Jonas Ådahl
ab600cafd2 backend: Destroy seat explicitly
Don't let any dangling pointer keeping it alive.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1775>
2021-03-13 18:56:21 +00:00
Jonas Ådahl
6ecd911dd0 backend: Take over seat ownership from the clutter backend
Having the clutter backend owning and managing creates complication for
implementing graceful shutdown, so move it to the real backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1775>
2021-03-13 18:56:21 +00:00
Jonas Ådahl
5aa43ec6c4 clutter/backend/native: Don't double manage stage implementation
The stage owns the "stage window", so don't double manage it in
MetaClutterBackendNative, as that means it'd be double-destroyed if the
stage would be destroyed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1775>
2021-03-13 18:56:21 +00:00