1
0
Fork 0
Commit graph

1234 commits

Author SHA1 Message Date
Jonas Ådahl
be4e6484ae render-device: Unmake the EGLContext after checking whether hw accelerated
When creating a render device, we create a temporary EGLContext where we
then query the `GL_RENDERER` string to check whether the renderer is any
of the known software renderers. After we're done, we destroy the
context and move on.

This should be fine as according to specification eglDestroyContext(),
with the context being actually destroyed a bit later when it's no
longer current, but mesa, when running RK3399 (Pinebook Pro), this
results in a crash in a future eglMakeCurrent():

  #0 in dri_unbind_context () at ../src/gallium/frontends/dri/dri_context.c:266
  #1 in driUnbindContext () at ../src/gallium/frontends/dri/dri_util.c:763
  #2 in dri2_make_current () at ../src/egl/drivers/dri2/egl_dri2.c:1814
  #3 in eglMakeCurrent () at ../src/egl/main/eglapi.c:907
  ...

We can avoid this, however, by calling eglMakeCurrent() with
EGL_NO_CONTEXT on the EGLDisplay, prior to destroying, effectively
avoiding the crash, so lets do that.

Related: https://gitlab.freedesktop.org/mesa/mesa/-/issues/7194
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2414
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2612>
2022-09-03 18:34:49 +02:00
Jonas Ådahl
44dae3e160 kms: Only force legacy mode setting when using EGLStream
EGLStream is incompatible with atomic mode setting, but nvidia-drm when
using libgbm is not, so lets only deny using atomic mode setting when
the render device is an EGLStream based one.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2578>
2022-09-02 20:43:05 +00:00
Jonas Ådahl
58c3734d78 backend/native: Prepare render devices earlier than KMS
The type of render device used for a specific GPU affects the mode
setting backend that can be used, more specifically, when the render
device is an EGLStream based one, atomic mode setting isn't possible, as
page flipping is done via EGL, not via atomic mode setting commits.

Preparing the render devices before KMS devices means can make a more
informed decision whether to deny-list atomic mode setting for when
a certain GPU uses a EGLStream based render device instance.

This also means we need to translate mode setting devices to render node
devices when creating the render device itself, as doing it later when
creating the mode setting device is already too late.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2578>
2022-09-02 20:43:05 +00:00
Jonas Ådahl
b59dc05b22 crtc: Get/set gamma via helper struct
Instead of passing 4 arguments (red, green and blue arrays as well as a
size), always pass them together in a new struct MetaGammaLut. Makes
things slightly less tedious.

The KMS layer still has its own variant, but lets leave it as that for
now, to keep the KMS layer "below" the cross backend CRTC layer.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2165>
2022-09-01 17:52:01 +02:00
Jonas Ådahl
9dda79b281 monitor-manager: Move gamma LUT manipulation API to MetaCrtc
In practice, for KMS backend CRTC's, we cache the gamma in the monitor
manager instance, so that anyone asking gets the pending or up to date
value, instead of the potentially not up to date value if one queries
after gamma was scheduled to be updated, and before it was actually
updated.

While this is true, lets still move the API to the MetaCrtc type; the
backend specific implementation can still look up cached values from the
MetaMonitorManager, but for users, it becomes less cumbersome to not
have to go via the monitor manager.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2165>
2022-09-01 17:52:01 +02:00
Jonas Ådahl
ccb6a7e84f monitor: Allow vendor/product/serial to return NULL
Same applies to MetaOutput. The reason for this is to make it possible
to more reliably know when there was EDID telling us about these
details. This will be used for colord integration.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2141>
2022-09-01 14:31:40 +00:00
Jonas Ådahl
972e393fc0 monitor: Add API to check whether the monitor is virtual or not
As for the types of monitor, X11 and KMS are currently assumed to always be
physical, while the virtual ones are assumed to be virtual. In theory
X11 ones could be virtual, but lets not bother. KMS ones can be virtual
in the case of virtual KMS, but we typically use that for testing as if
it was physical, so lets leave it as such.

Will later be used to feed correct information to colord.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2141>
2022-09-01 14:31:40 +00:00
Jonas Ådahl
15bbded86b monitor-manager/native: Bail if gamma LUT size differs
Don't attempt to set a CRTC GAMMA LUT with a different size than what is
already there.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2141>
2022-09-01 14:31:40 +00:00
Jonas Ådahl
b6aea1318d util: Add 'color' debug topic
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2141>
2022-09-01 14:31:40 +00:00
Jonas Ådahl
20a91aa4e9 backend: Add color manager skeleton
Create a color manager type that eventually will be the high level
manager of color related behavior, such as ICC profiles and
color "temperature" a.k.a. night light.

For now, it's only an empty shell. It's also constructed by the actual
backend, as at a later point, the X11 and native color management
implementations will differ.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2141>
2022-09-01 14:31:40 +00:00
Mario Limonciello
96aa0fb853 output/kms: Add more heuristics to decide when to offer fallback modes
If the panel is connected via eDP and supports more than one mode
at different resolutions don't try to add more.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2586>
2022-08-31 08:15:57 +00:00
Daniel van Vugt
8e2085dad9 backends/native: Add xlnx to the atomic deny list
Although its atomic KMS support seems to work at first, mode sets to
anything other than the Xilinx preferred max resolution of 2048x1280
would result in a hang. The xlnx kernel driver is given:
`DRM_MODE_ATOMIC_ALLOW_MODESET | DRM_MODE_PAGE_FLIP_EVENT`
and it does complete the mode set without error, but page flip events
never arrive and so you're frozen on the first frame.

Revert to legacy KMS which has no such problem with non-default modes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2596>
2022-08-26 18:39:12 +08:00
Daniel van Vugt
978cbe2da4 onscreen-native: Set max_bpc with mode sets
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2412>
2022-08-19 17:07:12 +00:00
Daniel van Vugt
f19b350c94 output-kms: Add max_bpc support
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2412>
2022-08-19 17:07:12 +00:00
Daniel van Vugt
b6dbb686e2 kms-impl-device-simple: Apply META_KMS_CONNECTOR_PROP_MAX_BPC
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2412>
2022-08-19 17:07:12 +00:00
Daniel van Vugt
0cc4815837 kms-impl-device-atomic: Apply META_KMS_CONNECTOR_PROP_MAX_BPC
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2412>
2022-08-19 17:07:12 +00:00
Daniel van Vugt
2b561a369c kms-update: Add function meta_kms_update_set_max_bpc
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2412>
2022-08-19 17:07:12 +00:00
Daniel van Vugt
33ee155630 kms-connector: Add "max bpc" property
This limits the bits-per-channel colour depth of the signal that
the connector is allowed to output.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2412>
2022-08-19 17:07:12 +00:00
Daniel van Vugt
f765437410 kms-types: Add type MetaKmsRange
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2412>
2022-08-19 17:07:12 +00:00
Daniel van Vugt
f760b47a3c kms-impl-device: Remember the min/max values for a DRM_MODE_PROP_RANGE
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2412>
2022-08-19 17:07:12 +00:00
Simon McVittie
64a67aa00b backend/native: Don't warn on EACCES if headless
Since commit 1bf70334 "tests/runner: Make test runner use the headless
backend", tests are run with the native backend in headless mode, which
will attempt to open each GPU and show a warning (fatal during tests)
if it cannot.

However, in headless mode we might not be logged in on any seat (for
example we might be logged in via ssh instead), which means we might
legitimately not have permission to use any GPUs, even if they exist.
Downgrade the warning to a debug message in this case.

Resolves: https://gitlab.gnome.org/GNOME/mutter/-/issues/2381
Signed-off-by: Simon McVittie <smcv@debian.org>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2584>
2022-08-19 16:07:23 +00:00
Daniel van Vugt
b5169f2567 output-kms: Change SYNC_TOLERANCE from 1% to 0.001Hz
1% of 60Hz is 0.6Hz so it was losing the usual two decimal places
precision you would expect as a minimum. Now we use three to be sure.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2465>
2022-08-19 15:28:56 +00:00
Daniel van Vugt
2a725f0bd9 cursor-renderer-native: Don't retry forever after GBM cursor functions fail
This avoids flooding the log with every cursor change:
```
(gnome-shell:19923): libmutter-WARNING **: 10:15:23.404: Realizing HW cursor failed: Failed to allocate gbm_bo: Invalid argument

(gnome-shell:19923): libmutter-WARNING **: 10:15:23.450: Realizing HW cursor failed: Failed to allocate gbm_bo: Invalid argument

(gnome-shell:19923): libmutter-WARNING **: 10:15:23.451: Realizing HW cursor failed: Failed to allocate gbm_bo: Invalid argument
```

Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/2354
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2520>
2022-08-10 15:35:55 +00:00
Jonas Ådahl
50396fc00e kms/device: Differentiate between lack of AddFb2() and udev rule
We disable modifiers for two reasons: an udev rule saying so, or the
lack of a working drmModeAddFB2(). However, to the users, this is not
granular enough. While the current user, whether to enable modifiers in
MetaRendererNative, doesn't need more granularity, we want to send
modifiers to Wayland clients even if the onscreen framebuffers should
still be allocated without modifiers.

Prepare for differentiating between how Wayland DMA buffers work and how
onscreen buffer allocation work by separating the relevant device flags.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2546>
2022-08-02 10:04:52 +00:00
Daniel van Vugt
7c8ffe7efe renderer-native: Fall back to ARGB if XRGB is not supported
This fixes mutter failing to start on some ARM/Mali boards.

Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/2354
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2519>
2022-07-29 08:48:57 +00:00
Jonas Ådahl
9966c8717b tests/kms: Run tests both using simple and atomic KMS
Two sanity checks to make sure the debug env vars still work are added
too.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2456>
2022-07-28 23:59:24 +00:00
Jonas Ådahl
5823d2d1ae kms/impl-device/simple: Ensure buffer fb_id on test update too
This ensures the fb_id will be there when we actually apply the update,
and will also make scanout test case pass if we run it with the
non-atomic KMS API.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2456>
2022-07-28 23:59:24 +00:00
Jonas Ådahl
27b75d3c96 barrier: Modernize type implementation
This means using G_DECLARE*() to declare the type, using
`_get_private_instance()` everywhere, and other smaller cleanups.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2442>
2022-07-26 20:27:24 +00:00
Jonas Ådahl
0debb24e12 barriers: Make barriers fully part of the backend
Prior to this commit, barriers were created with a MetaDisplay pointer,
despite being entities related and owned by the backend. In the X11
case, it was also not hooked up to the backend X11 connection, but the
clutter one, meaning for example that the logic was active (but dormant)
also for the Xwayland connection.

Fix this by moving X11 barrier management and event processing fully to
the backend. Also replace passing a display pointer with passing a
backend pointer. Keep the display pointer around for a release, but mark
it as deprecated.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2442>
2022-07-26 20:27:24 +00:00
Robert Mader
0c34908132 cursor-renderer/native: Various fixes for rotated cursors
- Drop bogus `meta_monitor_transform_invert()`. It papered over
  wrong `meta_rectangle_transform()` behaviour for non-flipped
  output transforms.
- Update `scale_and_transform_cursor_sprite_cpu` to match the GL
  pipeline matrix in `MetaShapedTexture`, fixing several of the
  flipped cases. Note: the rotation applied is the one a client would
  need to apply to the buffer for a given monitor transform.
- While on it, drop a redundant `return`.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2459>
2022-07-26 18:41:43 +00:00
Robert Mader
29cafe6f6c monitor-transform: Fix transform() and drop relative_transform()
The following implicit definition for `transform()` did not
correctly apply:
```
a * b = c
c * invert(b) = a
```

Crucially the following did not apply for `FLIPPED-90`
and `FLIPPED-270`:
```
a * invert(a) = identity
```

Fix this by applying the operations, first the flip, then the
rotation, in this order and add tests to ensure correct results
for the requirement above.

Also drop `relative_transform()` as it only had a single user and
can be replaced by `transform()`:
```
invert(a) * b = c
a * c = b
```

As this is not very intuitive, ensure in tests as well.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2459>
2022-07-26 18:41:43 +00:00
Robert Mader
c6cf4bd9c3 backends/native: Fix checks for 'reflect-x' and 'reflect-y' bits
Checking for both bits at once means only one matching bit is
sufficient - very likely in case of `rotate-0'.

This fixes crashes on hardware that does not support 'reflect-'
bits when setting a flipped output transform.

While on it, also update the check for `reflect-y` instead of
`reflect-x` + `rotate-180`. They are logically equivalent,
however some hardware may support `reflect-y` but not both
other bits.

Fixes commit 4e3f3842a1

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2459>
2022-07-26 18:41:43 +00:00
Jonas Ådahl
d985069542 kms/crtc: Don't report predicted gamma changes
We started to report resource changes using prediction when an update
had been successfully committed. While at it, gamma changes were
reported too, but this was problematic, as gsd-color will listen for the
MonitorsChanged D-Bus signal and naively set the gamma again, even if it
didn't change. There aren't currently any actual use cases for being
told when gamma changes from a prediction, so just ignore it and just
report privacy screen changes.

This avoids a feedback loop between mutter and gsd-color.

Fixes: 81b28a1d97
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2531>
2022-07-26 11:04:52 +02:00
Jonas Ådahl
81b28a1d97 kms: Notify about privacy screen changes via predictions
When we change the privacy screen, we added a result listener to the KMS
update object to notify the upper layer about the privacy screen state
change. This was slightly awkward as one might have changed the state
multiple times for a single update, thus it was necessary to remove any
old result listeners to an update before adding a new one.

Doing this will not be possible when updates are fully async and managed
by the KMS impl device.

To handle this, instead make the post-commit prediction notify about
changes that happens in response to a successfully committed update. We
already predicted the new privacy screen state, so the necessary change
was to plumb the actual change into a callback which emits the signal if
there actually was a privacy screen change.

This will then be communicated via the same signal listener that already
listens to the 'resources-changed' signal.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2340>
2022-07-25 11:02:35 +00:00
Jonas Ådahl
1b0aa0b3ad kms: Rename MetaKmsUpdateChanges to MetaKmsResourceChanges
The name had a bit conceptual conflicts with MetaKmsUpdate, as it shared
its namespace but had no relation to it. Fix this by renaming it
MetaKmsResourceChanges (and the corresponding META_KMS_UPDATE_CHANGE_*
to META_KMS_RESOURCE_CHANGE_*). The term "resource" is used since that's
already used in the signal, and the fact that the changes partly comes
from changes in the DRM resource as retrieved by drmModeGetResources.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2340>
2022-07-25 11:02:35 +00:00
Michel Dänzer
10c7ab2dec cursor-renderer/native: Fix type in unset_crtc_cursor_renderer_privates
Since the commit below, meta_crtc_kms_get_cursor_renderer_private has
returned a CrtcCursorData pointer, but this code was still treating it
as a MetaDrmBuffer pointer.

Fixes: fea8ebcca9 ("cursor-renderer/native: Store struct in CRTC private")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2524>
2022-07-21 21:03:18 +00:00
José Expósito
5171e5b795 backends/native: Migrate discrete scroll
Change meta_seat_impl_notify_discrete_scroll_in_impl to receive 120
based values and report high-resolution scroll values as smooth scroll.

Notify discrete scroll only when the accumulated value reach 120.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1962>
2022-07-14 22:29:56 +00:00
José Expósito
a1c50194a9 backends/native: Migrate continuous scroll
In order to get the delta X/Y value of the
LIBINPUT_EVENT_POINTER_SCROLL_FINGER
or LIBINPUT_EVENT_POINTER_SCROLL_CONTINUOUS events the new function
libinput_event_pointer_get_scroll_value should be used instead of
libinput_event_pointer_get_axis_value.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1962>
2022-07-14 22:29:56 +00:00
José Expósito
5d884d49b5 backends/native: Deprecate LIBINPUT_EVENT_POINTER_AXIS
Ignore deprecated LIBINPUT_EVENT_POINTER_AXIS events and handle
LIBINPUT_EVENT_POINTER_SCROLL_WHEEL,
LIBINPUT_EVENT_POINTER_SCROLL_FINGER and
LIBINPUT_EVENT_POINTER_SCROLL_CONTINUOUS instead.

The scroll source is now encoded in the event type making
libinput_event_pointer_get_axis_source and translate_scroll_source
redundant.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1962>
2022-07-14 22:29:56 +00:00
Sebastian Keller
fe0a383d6f pointer-constraints/native: Fix borders array memory leaks
The borders arrays were not (fully) freed when going out of scope.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2337
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2497>
2022-07-06 19:27:20 +00:00
Jonas Ådahl
43860110ff output/kms: Replace common mode bandwidth check with clock check
The pixel clock determines how fast pixels can be processed. When adding
non-native common modes, avoid adding modes that exceed the max pixel
clock frequency of the native modes. Avoiding these avoids potential
mode setting failures where the GPU can't handle the modeline since the
configured pixel clock is too fast. This replaces the "bandwidth" check
which used the number of pixels and refresh rate, which wasn't enough to
avoid incompatible modes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2492>
2022-07-01 16:13:18 +02:00
Jonas Ådahl
6d46ffccbc pointer-constraints: Move min edge distance from backend to Wayland
The min distance to the right/bottom edge depends on Wayland concepts
(wl_fixed_t) and eventually geometry scale. Move the logic the Wayland
side of the pointer constraints machinery to avoid the backend trying to
figure this out without the proper data.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2460>
2022-06-13 18:38:50 +00:00
Jonas Ådahl
94aaa65bd2 pointer-constraints/native: Remove old clutter float math work around
There were some coordinate nudging to avoid running into Clutter
floating point math issues related to coordinate transformations. Over
the years these things have improved, especially with the move to
graphene, so remove the old work around.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2460>
2022-06-13 18:38:50 +00:00
Sebastian Wick
a49c4e188a backends/native: Use the PropTable to look up KMS values
We already look up all the metadata and values in the
MetaKmsConnectorPropTable so we can just use them instead of looking it
all up again.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2379>
2022-06-10 17:49:07 +00:00
Sebastian Wick
4e3f3842a1 backends/native: Use MetaKmsPlaneRotation in plane updates
The ImplDeviceAtomic converts the MetaKmsPlaneRotation back to the
concrete KMS value. The MetaMonitorTransform is always directly
converted to a MetaKmsPlaneRotation.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2379>
2022-06-10 17:49:07 +00:00
Sebastian Wick
981524c268 backends/native: Update PropTable on hotplug and remove parse callback
Updating the PropTable has the side effect that the parse callback now
also gets called on hotplug but it is used to initialize data. The parse
callbacks are moved to the read_state functions which are aware if this
is an initializing call or just an update.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2379>
2022-06-10 17:49:07 +00:00
Sebastian Wick
1e06b346cb backends/native: Store Enum and Bitmask information in MetaKmsProp
Add functions for converting between the values used by DRM and the
enums/bitmasks used by mutter.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2379>
2022-06-10 17:49:07 +00:00
Sebastian Wick
9519a84967 backends/native: Define all KMS properties in PropTable we actually use
Currently those properties are looked up manually or fixed values are
used when they should be looked up. The following commits will actually
make use of this.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2379>
2022-06-10 17:49:07 +00:00
Dor Askayo
a0ff90a329 kms/page-flip: Add a debug print with page flip event timings
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2439>
2022-06-03 06:55:28 +00:00
Jonas Ådahl
c9960850c8 tests/kms/render: Add direct scanout test case
This adds a minimalistic fullscreen direct scanout test case, that runs
on vkms. It doesn't use EGL, and it uses uninitialized memory, thus it
lacks any kind of implicit synchronization, but it does test that the
scanout selection paths are working.

What is tested is:

  * DMA buffer allocated using gbm on top of VKMS
  * Buffer passes a mode setting TEST_ONLY check
  * Paint is omitted
  * Correct buffer active in KMS after presentation

What isn't yet tested:

  * Implicit synchronization related behavior
  * Presented pixel content

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2417>
2022-06-02 08:59:13 +00:00