Do not use DMA buffers for screencast when the client doesn't support it

Also use DMA buffers only for i195 drivers

Resolves: RHEL-4405
This commit is contained in:
Jan Grulich 2023-10-02 11:42:22 +02:00
parent fb7800eb84
commit fe62c442b3
3 changed files with 121 additions and 1 deletions

View File

@ -0,0 +1,45 @@
diff --git a/src/backends/native/meta-backend-native.c b/src/backends/native/meta-backend-native.c
index 2bf7f5e..1221c7b 100644
--- a/src/backends/native/meta-backend-native.c
+++ b/src/backends/native/meta-backend-native.c
@@ -341,25 +341,30 @@ maybe_disable_screen_cast_dma_bufs (MetaBackendNative *native)
MetaGpuKms *primary_gpu;
const char *driver_name;
int i;
- static const char *disable_dma_buf_drivers[] = {
- "qxl",
+ static const char *enable_dma_buf_drivers[] = {
+ "i915",
};
+ MetaScreenCast *screen_cast = meta_backend_get_screen_cast (backend);
+ gboolean enable_dma_buf = FALSE;
primary_gpu = meta_renderer_native_get_primary_gpu (renderer_native);
driver_name = meta_gpu_kms_get_driver_name (primary_gpu);
- for (i = 0; i < G_N_ELEMENTS (disable_dma_buf_drivers); i++)
+ for (i = 0; i < G_N_ELEMENTS (enable_dma_buf_drivers); i++)
{
- if (g_strcmp0 (driver_name, disable_dma_buf_drivers[i]) == 0)
+ if (g_strcmp0 (driver_name, enable_dma_buf_drivers[i]) == 0)
{
- MetaScreenCast *screen_cast = meta_backend_get_screen_cast (backend);
+ enable_dma_buf = TRUE;
+ break;
+ }
+ }
- g_message ("The '%s' driver doesn't support DMA buffer screen sharing, disabling.",
- driver_name);
+ if (!enable_dma_buf)
+ {
+ g_message ("Not enabling DMA buffer screen sharing for driver '%s'.",
+ driver_name);
- meta_screen_cast_disable_dma_bufs (screen_cast);
- return;
- }
+ meta_screen_cast_disable_dma_bufs (screen_cast);
}
}
#endif /* HAVE_REMOTE_DESKTOP */

View File

@ -0,0 +1,68 @@
diff --git a/src/backends/meta-screen-cast-stream-src.c b/src/backends/meta-screen-cast-stream-src.c
index f39d348..c1abc9b 100644
--- a/src/backends/meta-screen-cast-stream-src.c
+++ b/src/backends/meta-screen-cast-stream-src.c
@@ -684,11 +684,18 @@ on_stream_param_changed (void *data,
MetaScreenCastStreamSrc *src = data;
MetaScreenCastStreamSrcPrivate *priv =
meta_screen_cast_stream_src_get_instance_private (src);
+ MetaScreenCastStream *stream = meta_screen_cast_stream_src_get_stream (src);
+ MetaScreenCastSession *session = meta_screen_cast_stream_get_session (stream);
+ MetaScreenCast *screen_cast =
+ meta_screen_cast_session_get_screen_cast (session);
+
uint8_t params_buffer[1024];
int32_t width, height, stride, size;
struct spa_pod_builder pod_builder;
const struct spa_pod *params[3];
const int bpp = 4;
+ int buffer_types;
+ CoglDmaBufHandle *dmabuf_handle;
if (!format || id != SPA_PARAM_Format)
return;
@@ -705,6 +712,16 @@ on_stream_param_changed (void *data,
pod_builder = SPA_POD_BUILDER_INIT (params_buffer, sizeof (params_buffer));
+ buffer_types = 1 << SPA_DATA_MemFd;
+ dmabuf_handle = meta_screen_cast_create_dma_buf_handle (screen_cast,
+ priv->stream_width,
+ priv->stream_height);
+ if (dmabuf_handle)
+ {
+ buffer_types |= 1 << SPA_DATA_DmaBuf;
+ cogl_dma_buf_handle_free(dmabuf_handle);
+ }
+
params[0] = spa_pod_builder_add_object (
&pod_builder,
SPA_TYPE_OBJECT_ParamBuffers, SPA_PARAM_Buffers,
@@ -712,7 +729,8 @@ on_stream_param_changed (void *data,
SPA_PARAM_BUFFERS_blocks, SPA_POD_Int (1),
SPA_PARAM_BUFFERS_size, SPA_POD_Int (size),
SPA_PARAM_BUFFERS_stride, SPA_POD_Int (stride),
- SPA_PARAM_BUFFERS_align, SPA_POD_Int (16));
+ SPA_PARAM_BUFFERS_align, SPA_POD_Int (16),
+ SPA_PARAM_BUFFERS_dataType, SPA_POD_CHOICE_FLAGS_Int (buffer_types));
params[1] = spa_pod_builder_add_object (
&pod_builder,
@@ -751,9 +769,16 @@ on_stream_add_buffer (void *data,
spa_data[0].mapoffset = 0;
spa_data[0].maxsize = stride * priv->video_format.size.height;
- dmabuf_handle = meta_screen_cast_create_dma_buf_handle (screen_cast,
+ if (spa_data[0].type & (1 << SPA_DATA_DmaBuf))
+ {
+ dmabuf_handle = meta_screen_cast_create_dma_buf_handle (screen_cast,
priv->stream_width,
priv->stream_height);
+ }
+ else
+ {
+ dmabuf_handle = NULL;
+ }
if (dmabuf_handle)
{

View File

@ -8,7 +8,7 @@
Name: mutter Name: mutter
Version: 3.32.2 Version: 3.32.2
Release: 71%{?dist} Release: 72%{?dist}
Summary: Window and compositing manager based on Clutter Summary: Window and compositing manager based on Clutter
License: GPLv2+ License: GPLv2+
@ -148,6 +148,8 @@ Patch407: 0004-screen-cast-Disable-DMA-buffer-based-screen-casting-.patch
# https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1365 # https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1365
Patch408: cursor-move-only-screen-cast-fixes.patch Patch408: cursor-move-only-screen-cast-fixes.patch
Patch409: mutter-bump-screencast-api-version.patch Patch409: mutter-bump-screencast-api-version.patch
Patch410: mutter-screencast-dmabuf-i915-only.patch
Patch411: mutter-screencast-negotiate-buffer-type.patch
# Only treat WM_PROTOCOLS messages as WM_PROTOCOL messages (#1847203) # Only treat WM_PROTOCOLS messages as WM_PROTOCOL messages (#1847203)
Patch500: 0001-stage-x11-Check-that-message-is-WM_PROTOCOLS-before-.patch Patch500: 0001-stage-x11-Check-that-message-is-WM_PROTOCOLS-before-.patch
@ -356,6 +358,11 @@ desktop-file-validate %{buildroot}/%{_datadir}/applications/%{name}.desktop
%{_datadir}/mutter-%{mutter_api_version}/tests %{_datadir}/mutter-%{mutter_api_version}/tests
%changelog %changelog
* Mon Oct 02 2023 Jan Grulich <jgrulich@redhat.com> - 3.32.2-72
- Do not use DMA buffers for screencast when the client doesn't support it
- Use DMA buffers only for i195 drivers
Resolves: RHEL-4405
* Thu Aug 17 2023 Carlos Garnacho <cgarnach@redhat.com> - 3.32.2-71 * Thu Aug 17 2023 Carlos Garnacho <cgarnach@redhat.com> - 3.32.2-71
- Fix ordering of keyboard modifiers relative to other keyboard events - Fix ordering of keyboard modifiers relative to other keyboard events
Resolves: #2170830 Resolves: #2170830