e82d74
From d442ef48412e3dc1b24a9f97b02ee3383404d501 Mon Sep 17 00:00:00 2001
e82d74
From: Emil Velikov <emil.velikov@collabora.com>
e82d74
Date: Wed, 12 Jun 2019 16:58:54 +0000
e82d74
Subject: [PATCH 1/8] renderer/native: add missing eglTerminate in EGLDevice
e82d74
 error path
e82d74
MIME-Version: 1.0
e82d74
Content-Type: text/plain; charset=UTF-8
e82d74
Content-Transfer-Encoding: 8bit
e82d74
e82d74
Currently the EGLDevice code gets the display and calls eglInitialize.
e82d74
As a follow-up it checks the required EGL extensions - technically it
e82d74
could check the EGL device extensions earlier.
e82d74
e82d74
In either case, eglTerminate is missing. Thus the connection to the
e82d74
display was still bound.
e82d74
e82d74
This was highlighted with Mesa commit d6edccee8da ("egl: add
e82d74
EGL_platform_device support") + amdgpu.
e82d74
e82d74
In that case, since the eglTerminate is missing, we end up reusing the
e82d74
underlying amdgpu_device due to some caching in libdrm_amdgpu. The
e82d74
latter in itself being a good solution since it allows buffer sharing
e82d74
across primary and render node of the same device.
e82d74
e82d74
Note: we should really get this in branches all the way back to 3.30.
e82d74
e82d74
https://gitlab.gnome.org/GNOME/mutter/merge_requests/619
e82d74
e82d74
Fixes: 934184e23 ("MetaRendererNative: Add EGLDevice based rendering support")
e82d74
Cc: Jonas Ã…dahl <jadahl@gmail.com>
e82d74
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
e82d74
e82d74
e82d74
(cherry picked from commit 9213574870faee7fe40609791fc48f4b44f861c0)
e82d74
---
e82d74
 src/backends/native/meta-renderer-native.c | 1 +
e82d74
 1 file changed, 1 insertion(+)
e82d74
e82d74
diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c
e82d74
index dbfc97aae..207b654fa 100644
e82d74
--- a/src/backends/native/meta-renderer-native.c
e82d74
+++ b/src/backends/native/meta-renderer-native.c
e82d74
@@ -4038,6 +4038,7 @@ create_renderer_gpu_data_egl_device (MetaRendererNative  *renderer_native,
e82d74
                    G_IO_ERROR_FAILED,
e82d74
                    "Missing EGL extensions required for EGLDevice renderer: %s",
e82d74
                    missing_extensions_str);
e82d74
+      meta_egl_terminate (egl, egl_display, NULL);
e82d74
       g_free (missing_extensions_str);
e82d74
       g_free (missing_extensions);
e82d74
       return NULL;
e82d74
-- 
e82d74
2.24.1
e82d74
e82d74
e82d74
From e18dfc888343585d21b3f64568571009c4967a95 Mon Sep 17 00:00:00 2001
e82d74
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
e82d74
Date: Mon, 17 Jun 2019 18:18:12 +0200
e82d74
Subject: [PATCH 2/8] renderer/native: Use g_set_error() instead of
e82d74
 _cogl_set_error()
e82d74
e82d74
It's even a GError, so lets use the proper API.
e82d74
e82d74
https://gitlab.gnome.org/GNOME/mutter/merge_requests/622
e82d74
(cherry picked from commit 1efb32d3000ca06ee3cfcc146dc812866d243619)
e82d74
---
e82d74
 src/backends/native/meta-renderer-native.c | 2 +-
e82d74
 1 file changed, 1 insertion(+), 1 deletion(-)
e82d74
e82d74
diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c
e82d74
index 207b654fa..e7aa6f389 100644
e82d74
--- a/src/backends/native/meta-renderer-native.c
e82d74
+++ b/src/backends/native/meta-renderer-native.c
e82d74
@@ -1277,7 +1277,7 @@ meta_renderer_native_egl_context_created (CoglDisplay *cogl_display,
e82d74
                                       cogl_display_egl->dummy_surface,
e82d74
                                       cogl_display_egl->egl_context))
e82d74
     {
e82d74
-      _cogl_set_error (error, COGL_WINSYS_ERROR,
e82d74
+      g_set_error (error, COGL_WINSYS_ERROR,
e82d74
                    COGL_WINSYS_ERROR_CREATE_CONTEXT,
e82d74
                    "Failed to make context current");
e82d74
       return FALSE;
e82d74
-- 
e82d74
2.24.1
e82d74
e82d74
e82d74
From 1947a81db93624d57471ce1edf5548c7774c3569 Mon Sep 17 00:00:00 2001
e82d74
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
e82d74
Date: Mon, 17 Jun 2019 18:18:42 +0200
e82d74
Subject: [PATCH 3/8] renderer/native: Make sure we're not destroying an active
e82d74
 EGLSurface
e82d74
e82d74
When making a new surface/context pair current, mesa may want to flush
e82d74
the old context. Make sure we don't try to flush any freed memory by
e82d74
unmaking a surface/context pair current before freeing it.
e82d74
e82d74
Not doing this results in the following valgrind warnings:
e82d74
e82d74
==15986== Invalid read of size 8
e82d74
==15986==    at 0x69A6D80: dri_flush_front_buffer (gbm_dri.c:92)
e82d74
==15986==    by 0x1750D458: intel_flush_front (brw_context.c:251)
e82d74
==15986==    by 0x1750D4BB: intel_glFlush (brw_context.c:296)
e82d74
==15986==    by 0x1739D8DD: dri2_make_current (egl_dri2.c:1461)
e82d74
==15986==    by 0x17393A3A: eglMakeCurrent (eglapi.c:869)
e82d74
==15986==    by 0x54381FB: InternalMakeCurrentVendor (in /home/jonas/Dev/gnome/install/lib/libEGL.so.1.1.0)
e82d74
==15986==    by 0x5438515: eglMakeCurrent (in /home/jonas/Dev/gnome/install/lib/libEGL.so.1.1.0)
e82d74
==15986==    by 0x522A782: _cogl_winsys_egl_make_current (cogl-winsys-egl.c:303)
e82d74
==15986==    by 0x49B64C8: meta_renderer_native_create_view (meta-renderer-native.c:3076)
e82d74
==15986==    by 0x48D26E7: meta_renderer_create_view (meta-renderer.c:78)
e82d74
==15986==    by 0x48D277A: meta_renderer_rebuild_views (meta-renderer.c:111)
e82d74
==15986==    by 0x49BF46E: meta_stage_native_rebuild_views (meta-stage-native.c:142)
e82d74
==15986==  Address 0x1b076600 is 0 bytes inside a block of size 48 free'd
e82d74
==15986==    at 0x4839A0C: free (vg_replace_malloc.c:540)
e82d74
==15986==    by 0x49B59F3: meta_renderer_native_release_onscreen (meta-renderer-native.c:2651)
e82d74
==15986==    by 0x5211441: _cogl_onscreen_free (cogl-onscreen.c:167)
e82d74
==15986==    by 0x5210D81: _cogl_object_onscreen_indirect_free (cogl-onscreen.c:51)
e82d74
==15986==    by 0x51D0066: _cogl_object_default_unref (cogl-object.c:103)
e82d74
==15986==    by 0x520F989: _cogl_framebuffer_unref (cogl-framebuffer.c:1814)
e82d74
==15986==    by 0x51D00B1: cogl_object_unref (cogl-object.c:115)
e82d74
==15986==    by 0x536F3C7: clutter_stage_view_dispose (clutter-stage-view.c:304)
e82d74
==15986==    by 0x4B7DAF2: g_object_unref (gobject.c:3309)
e82d74
==15986==    by 0x4A9596C: g_list_foreach (glist.c:1013)
e82d74
==15986==    by 0x4A9599A: g_list_free_full (glist.c:223)
e82d74
==15986==    by 0x48D2737: meta_renderer_rebuild_views (meta-renderer.c:100)
e82d74
==15986==  Block was alloc'd at
e82d74
==15986==    at 0x483AB1A: calloc (vg_replace_malloc.c:762)
e82d74
==15986==    by 0x69A76B2: gbm_dri_surface_create (gbm_dri.c:1252)
e82d74
==15986==    by 0x69A6BFE: gbm_surface_create (gbm.c:600)
e82d74
==15986==    by 0x49B4E29: meta_renderer_native_create_surface_gbm (meta-renderer-native.c:2221)
e82d74
==15986==    by 0x49B57DB: meta_onscreen_native_allocate (meta-renderer-native.c:2569)
e82d74
==15986==    by 0x49B6423: meta_renderer_native_create_view (meta-renderer-native.c:3062)
e82d74
==15986==    by 0x48D26E7: meta_renderer_create_view (meta-renderer.c:78)
e82d74
==15986==    by 0x48D277A: meta_renderer_rebuild_views (meta-renderer.c:111)
e82d74
==15986==    by 0x49BF46E: meta_stage_native_rebuild_views (meta-stage-native.c:142)
e82d74
==15986==    by 0x49A75B5: meta_backend_native_update_screen_size (meta-backend-native.c:520)
e82d74
==15986==    by 0x48B01BB: meta_backend_sync_screen_size (meta-backend.c:224)
e82d74
==15986==    by 0x48B09B7: meta_backend_real_post_init (meta-backend.c:501)
e82d74
e82d74
https://gitlab.gnome.org/GNOME/mutter/merge_requests/622
e82d74
(cherry picked from commit 56ddaaa3809240a357b5e19b5789d1aa49aaecc3)
e82d74
---
e82d74
 src/backends/native/meta-renderer-native.c | 13 +++++++++++++
e82d74
 1 file changed, 13 insertions(+)
e82d74
e82d74
diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c
e82d74
index e7aa6f389..b7bc3121a 100644
e82d74
--- a/src/backends/native/meta-renderer-native.c
e82d74
+++ b/src/backends/native/meta-renderer-native.c
e82d74
@@ -3040,6 +3040,8 @@ meta_renderer_native_release_onscreen (CoglOnscreen *onscreen)
e82d74
 {
e82d74
   CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
e82d74
   CoglContext *cogl_context = framebuffer->context;
e82d74
+  CoglDisplay *cogl_display = cogl_context_get_display (cogl_context);
e82d74
+  CoglDisplayEGL *cogl_display_egl = cogl_display->winsys;
e82d74
   CoglRenderer *cogl_renderer = cogl_context->display->renderer;
e82d74
   CoglRendererEGL *cogl_renderer_egl = cogl_renderer->winsys;
e82d74
   CoglOnscreenEGL *onscreen_egl = onscreen->winsys;
e82d74
@@ -3052,6 +3054,17 @@ meta_renderer_native_release_onscreen (CoglOnscreen *onscreen)
e82d74
 
e82d74
   onscreen_native = onscreen_egl->platform;
e82d74
 
e82d74
+  if (onscreen_egl->egl_surface != EGL_NO_SURFACE &&
e82d74
+      (cogl_display_egl->current_draw_surface == onscreen_egl->egl_surface ||
e82d74
+       cogl_display_egl->current_read_surface == onscreen_egl->egl_surface))
e82d74
+    {
e82d74
+      if (!_cogl_winsys_egl_make_current (cogl_display,
e82d74
+                                          cogl_display_egl->dummy_surface,
e82d74
+                                          cogl_display_egl->dummy_surface,
e82d74
+                                          cogl_display_egl->egl_context))
e82d74
+        g_warning ("Failed to clear current context");
e82d74
+    }
e82d74
+
e82d74
   g_list_free_full (onscreen_native->pending_page_flip_retries,
e82d74
                     (GDestroyNotify) retry_page_flip_data_free);
e82d74
   if (onscreen_native->retry_page_flips_source)
e82d74
-- 
e82d74
2.24.1
e82d74
e82d74
e82d74
From 60551e5e6f984a7ed3ba3339f027ed7b37f802c4 Mon Sep 17 00:00:00 2001
e82d74
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
e82d74
Date: Mon, 17 Jun 2019 19:16:12 +0200
e82d74
Subject: [PATCH 4/8] renderer/native: Fix EGLSurface destruction order
e82d74
e82d74
Make sure to destroy the EGL surface after releasing held buffers,
e82d74
otherwise we'll get the following valgrind warnings:
e82d74
e82d74
==24016== Invalid read of size 8
e82d74
==24016==    at 0x1739943F: release_buffer (platform_drm.c:73)
e82d74
==24016==    by 0x49AC355: meta_drm_buffer_gbm_finalize (meta-drm-buffer-gbm.c:213)
e82d74
==24016==    by 0x4B75B61: g_object_unref (gobject.c:3346)
e82d74
==24016==    by 0x49B4B41: free_current_bo (meta-renderer-native.c:991)
e82d74
==24016==    by 0x49B816F: meta_renderer_native_release_onscreen (meta-renderer-native.c:2971)
e82d74
==24016==    by 0x5209441: _cogl_onscreen_free (cogl-onscreen.c:167)
e82d74
==24016==    by 0x5208D81: _cogl_object_onscreen_indirect_free (cogl-onscreen.c:51)
e82d74
==24016==    by 0x51C8066: _cogl_object_default_unref (cogl-object.c:103)
e82d74
==24016==    by 0x5207989: _cogl_framebuffer_unref (cogl-framebuffer.c:1814)
e82d74
==24016==    by 0x51C80B1: cogl_object_unref (cogl-object.c:115)
e82d74
==24016==    by 0x53673C7: clutter_stage_view_dispose (clutter-stage-view.c:304)
e82d74
==24016==    by 0x4B75AF2: g_object_unref (gobject.c:3309)
e82d74
==24016==  Address 0x18e742a8 is 536 bytes inside a block of size 784 free'd
e82d74
==24016==    at 0x4839A0C: free (vg_replace_malloc.c:540)
e82d74
==24016==    by 0x17399764: dri2_drm_destroy_surface (platform_drm.c:231)
e82d74
==24016==    by 0x1738550A: eglDestroySurface (eglapi.c:1145)
e82d74
==24016==    by 0x5440286: eglDestroySurface (in /home/jonas/Dev/gnome/install/lib/libEGL.so.1.1.0)
e82d74
==24016==    by 0x49613A5: meta_egl_destroy_surface (meta-egl.c:432)
e82d74
==24016==    by 0x49B80F9: meta_renderer_native_release_onscreen (meta-renderer-native.c:2954)
e82d74
==24016==    by 0x5209441: _cogl_onscreen_free (cogl-onscreen.c:167)
e82d74
==24016==    by 0x5208D81: _cogl_object_onscreen_indirect_free (cogl-onscreen.c:51)
e82d74
==24016==    by 0x51C8066: _cogl_object_default_unref (cogl-object.c:103)
e82d74
==24016==    by 0x5207989: _cogl_framebuffer_unref (cogl-framebuffer.c:1814)
e82d74
==24016==    by 0x51C80B1: cogl_object_unref (cogl-object.c:115)
e82d74
==24016==    by 0x53673C7: clutter_stage_view_dispose (clutter-stage-view.c:304)
e82d74
==24016==  Block was alloc'd at
e82d74
==24016==    at 0x483AB1A: calloc (vg_replace_malloc.c:762)
e82d74
==24016==    by 0x173997AE: dri2_drm_create_window_surface (platform_drm.c:145)
e82d74
==24016==    by 0x17388906: _eglCreateWindowSurfaceCommon (eglapi.c:929)
e82d74
==24016==    by 0x5440197: eglCreateWindowSurface (in /home/jonas/Dev/gnome/install/lib/libEGL.so.1.1.0)
e82d74
==24016==    by 0x49612FF: meta_egl_create_window_surface (meta-egl.c:396)
e82d74
==24016==    by 0x49B752E: meta_renderer_native_create_surface_gbm (meta-renderer-native.c:2538)
e82d74
==24016==    by 0x49B7E6C: meta_onscreen_native_allocate (meta-renderer-native.c:2870)
e82d74
==24016==    by 0x49B8BCF: meta_renderer_native_create_view (meta-renderer-native.c:3387)
e82d74
==24016==    by 0x48D274B: meta_renderer_create_view (meta-renderer.c:78)
e82d74
==24016==    by 0x48D27DE: meta_renderer_rebuild_views (meta-renderer.c:111)
e82d74
==24016==    by 0x49BB4FB: meta_stage_native_rebuild_views (meta-stage-native.c:142)
e82d74
==24016==    by 0x49A733C: meta_backend_native_update_screen_size (meta-backend-native.c:517)
e82d74
e82d74
https://gitlab.gnome.org/GNOME/mutter/merge_requests/622
e82d74
(cherry picked from commit d9fb11b04319c00fd89715dd9207fe54e1d18c2d)
e82d74
---
e82d74
 src/backends/native/meta-renderer-native.c | 38 +++++++++++++++-------
e82d74
 1 file changed, 27 insertions(+), 11 deletions(-)
e82d74
e82d74
diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c
e82d74
index b7bc3121a..62c27c191 100644
e82d74
--- a/src/backends/native/meta-renderer-native.c
e82d74
+++ b/src/backends/native/meta-renderer-native.c
e82d74
@@ -3035,6 +3035,28 @@ meta_onscreen_native_allocate (CoglOnscreen *onscreen,
e82d74
   return TRUE;
e82d74
 }
e82d74
 
e82d74
+static void
e82d74
+destroy_egl_surface (CoglOnscreen *onscreen)
e82d74
+{
e82d74
+  CoglOnscreenEGL *onscreen_egl = onscreen->winsys;
e82d74
+
e82d74
+  if (onscreen_egl->egl_surface != EGL_NO_SURFACE)
e82d74
+    {
e82d74
+      MetaOnscreenNative *onscreen_native = onscreen_egl->platform;
e82d74
+      MetaEgl *egl = meta_onscreen_native_get_egl (onscreen_native);
e82d74
+      CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
e82d74
+      CoglContext *cogl_context = framebuffer->context;
e82d74
+      CoglRenderer *cogl_renderer = cogl_context->display->renderer;
e82d74
+      CoglRendererEGL *cogl_renderer_egl = cogl_renderer->winsys;
e82d74
+
e82d74
+      meta_egl_destroy_surface (egl,
e82d74
+                                cogl_renderer_egl->edpy,
e82d74
+                                onscreen_egl->egl_surface,
e82d74
+                                NULL);
e82d74
+      onscreen_egl->egl_surface = EGL_NO_SURFACE;
e82d74
+    }
e82d74
+}
e82d74
+
e82d74
 static void
e82d74
 meta_renderer_native_release_onscreen (CoglOnscreen *onscreen)
e82d74
 {
e82d74
@@ -3077,17 +3099,6 @@ meta_renderer_native_release_onscreen (CoglOnscreen *onscreen)
e82d74
                        g_source_destroy);
e82d74
     }
e82d74
 
e82d74
-  if (onscreen_egl->egl_surface != EGL_NO_SURFACE)
e82d74
-    {
e82d74
-      MetaEgl *egl = meta_onscreen_native_get_egl (onscreen_native);
e82d74
-
e82d74
-      meta_egl_destroy_surface (egl,
e82d74
-                                cogl_renderer_egl->edpy,
e82d74
-                                onscreen_egl->egl_surface,
e82d74
-                                NULL);
e82d74
-      onscreen_egl->egl_surface = EGL_NO_SURFACE;
e82d74
-    }
e82d74
-
e82d74
   renderer_gpu_data =
e82d74
     meta_renderer_native_get_gpu_data (onscreen_native->renderer_native,
e82d74
                                        onscreen_native->render_gpu);
e82d74
@@ -3100,6 +3111,8 @@ meta_renderer_native_release_onscreen (CoglOnscreen *onscreen)
e82d74
 
e82d74
       free_current_bo (onscreen);
e82d74
 
e82d74
+      destroy_egl_surface (onscreen);
e82d74
+
e82d74
       if (onscreen_native->gbm.surface)
e82d74
         {
e82d74
           gbm_surface_destroy (onscreen_native->gbm.surface);
e82d74
@@ -3110,6 +3123,9 @@ meta_renderer_native_release_onscreen (CoglOnscreen *onscreen)
e82d74
     case META_RENDERER_NATIVE_MODE_EGL_DEVICE:
e82d74
       release_dumb_fb (&onscreen_native->egl.dumb_fb,
e82d74
                        onscreen_native->render_gpu);
e82d74
+
e82d74
+      destroy_egl_surface (onscreen);
e82d74
+
e82d74
       if (onscreen_native->egl.stream != EGL_NO_STREAM_KHR)
e82d74
         {
e82d74
           MetaEgl *egl = meta_onscreen_native_get_egl (onscreen_native);
e82d74
-- 
e82d74
2.24.1
e82d74
e82d74
e82d74
From c447010a23edc03c7a1103b477972ad666c2600f Mon Sep 17 00:00:00 2001
e82d74
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
e82d74
Date: Wed, 19 Jun 2019 20:55:48 +0200
e82d74
Subject: [PATCH 5/8] renderer/native: Remove left-over function declarations
e82d74
e82d74
There are no callers and no definitions of these.
e82d74
e82d74
https://gitlab.gnome.org/GNOME/mutter/merge_requests/655
e82d74
---
e82d74
 src/backends/native/meta-renderer-native.h | 12 ------------
e82d74
 1 file changed, 12 deletions(-)
e82d74
e82d74
diff --git a/src/backends/native/meta-renderer-native.h b/src/backends/native/meta-renderer-native.h
e82d74
index a006dcbe7..8468208e1 100644
e82d74
--- a/src/backends/native/meta-renderer-native.h
e82d74
+++ b/src/backends/native/meta-renderer-native.h
e82d74
@@ -55,18 +55,6 @@ gboolean meta_renderer_native_supports_mirroring (MetaRendererNative *renderer_n
e82d74
 
e82d74
 void meta_renderer_native_queue_modes_reset (MetaRendererNative *renderer_native);
e82d74
 
e82d74
-gboolean meta_renderer_native_set_legacy_view_size (MetaRendererNative *renderer_native,
e82d74
-                                                    MetaRendererView   *view,
e82d74
-                                                    int                 width,
e82d74
-                                                    int                 height,
e82d74
-                                                    GError            **error);
e82d74
-
e82d74
-void meta_renderer_native_set_ignore_crtc (MetaRendererNative *renderer_native,
e82d74
-                                           uint32_t            id,
e82d74
-                                           gboolean            ignore);
e82d74
-
e82d74
-MetaRendererView * meta_renderer_native_create_legacy_view (MetaRendererNative *renderer_native);
e82d74
-
e82d74
 void meta_renderer_native_finish_frame (MetaRendererNative *renderer_native);
e82d74
 
e82d74
 int64_t meta_renderer_native_get_frame_counter (MetaRendererNative *renderer_native);
e82d74
-- 
e82d74
2.24.1
e82d74
e82d74
e82d74
From 7f97403d12df19cf936a341cc218743ec339aa0a Mon Sep 17 00:00:00 2001
e82d74
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
e82d74
Date: Wed, 19 Jun 2019 20:57:14 +0200
e82d74
Subject: [PATCH 6/8] renderer/native: Queue mode reset from new rebuild_views
e82d74
 vfunc
e82d74
e82d74
Simplify the call site a bit and make the native renderer know it should
e82d74
queue mode reset itself when views have been rebuilt. This is done
e82d74
partly due to more things needing to be dealt with after views have been
e82d74
rebuilt.
e82d74
e82d74
https://gitlab.gnome.org/GNOME/mutter/merge_requests/655
e82d74
---
e82d74
 src/backends/meta-renderer.c               |  8 ++++++++
e82d74
 src/backends/meta-renderer.h               |  1 +
e82d74
 src/backends/native/meta-renderer-native.c | 17 ++++++++++++++++-
e82d74
 src/backends/native/meta-renderer-native.h |  2 --
e82d74
 src/backends/native/meta-stage-native.c    |  1 -
e82d74
 5 files changed, 25 insertions(+), 4 deletions(-)
e82d74
e82d74
diff --git a/src/backends/meta-renderer.c b/src/backends/meta-renderer.c
e82d74
index 28637437b..87ba9f9f0 100644
e82d74
--- a/src/backends/meta-renderer.c
e82d74
+++ b/src/backends/meta-renderer.c
e82d74
@@ -90,6 +90,12 @@ meta_renderer_create_view (MetaRenderer       *renderer,
e82d74
  */
e82d74
 void
e82d74
 meta_renderer_rebuild_views (MetaRenderer *renderer)
e82d74
+{
e82d74
+  return META_RENDERER_GET_CLASS (renderer)->rebuild_views (renderer);
e82d74
+}
e82d74
+
e82d74
+static void
e82d74
+meta_renderer_real_rebuild_views (MetaRenderer *renderer)
e82d74
 {
e82d74
   MetaRendererPrivate *priv = meta_renderer_get_instance_private (renderer);
e82d74
   MetaBackend *backend = meta_get_backend ();
e82d74
@@ -181,4 +187,6 @@ meta_renderer_class_init (MetaRendererClass *klass)
e82d74
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
e82d74
 
e82d74
   object_class->finalize = meta_renderer_finalize;
e82d74
+
e82d74
+  klass->rebuild_views = meta_renderer_real_rebuild_views;
e82d74
 }
e82d74
diff --git a/src/backends/meta-renderer.h b/src/backends/meta-renderer.h
e82d74
index dae52cb9a..478baee91 100644
e82d74
--- a/src/backends/meta-renderer.h
e82d74
+++ b/src/backends/meta-renderer.h
e82d74
@@ -43,6 +43,7 @@ struct _MetaRendererClass
e82d74
   CoglRenderer * (* create_cogl_renderer) (MetaRenderer *renderer);
e82d74
   MetaRendererView * (* create_view) (MetaRenderer       *renderer,
e82d74
                                       MetaLogicalMonitor *logical_monitor);
e82d74
+  void (* rebuild_views) (MetaRenderer *renderer);
e82d74
 };
e82d74
 
e82d74
 CoglRenderer * meta_renderer_create_cogl_renderer (MetaRenderer *renderer);
e82d74
diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c
e82d74
index 62c27c191..70e1c4f9d 100644
e82d74
--- a/src/backends/native/meta-renderer-native.c
e82d74
+++ b/src/backends/native/meta-renderer-native.c
e82d74
@@ -258,6 +258,9 @@ cogl_pixel_format_from_drm_format (uint32_t               drm_format,
e82d74
                                    CoglPixelFormat       *out_format,
e82d74
                                    CoglTextureComponents *out_components);
e82d74
 
e82d74
+static void
e82d74
+meta_renderer_native_queue_modes_reset (MetaRendererNative *renderer_native);
e82d74
+
e82d74
 static MetaBackend *
e82d74
 backend_from_renderer_native (MetaRendererNative *renderer_native)
e82d74
 {
e82d74
@@ -3186,7 +3189,7 @@ meta_renderer_native_supports_mirroring (MetaRendererNative *renderer_native)
e82d74
   return TRUE;
e82d74
 }
e82d74
 
e82d74
-void
e82d74
+static void
e82d74
 meta_renderer_native_queue_modes_reset (MetaRendererNative *renderer_native)
e82d74
 {
e82d74
   MetaRenderer *renderer = META_RENDERER (renderer_native);
e82d74
@@ -3552,6 +3555,17 @@ meta_renderer_native_create_view (MetaRenderer       *renderer,
e82d74
   return view;
e82d74
 }
e82d74
 
e82d74
+static void
e82d74
+meta_renderer_native_rebuild_views (MetaRenderer *renderer)
e82d74
+{
e82d74
+  MetaRendererClass *parent_renderer_class =
e82d74
+    META_RENDERER_CLASS (meta_renderer_native_parent_class);
e82d74
+
e82d74
+  parent_renderer_class->rebuild_views (renderer);
e82d74
+
e82d74
+  meta_renderer_native_queue_modes_reset (META_RENDERER_NATIVE (renderer));
e82d74
+}
e82d74
+
e82d74
 void
e82d74
 meta_renderer_native_finish_frame (MetaRendererNative *renderer_native)
e82d74
 {
e82d74
@@ -4350,6 +4364,7 @@ meta_renderer_native_class_init (MetaRendererNativeClass *klass)
e82d74
 
e82d74
   renderer_class->create_cogl_renderer = meta_renderer_native_create_cogl_renderer;
e82d74
   renderer_class->create_view = meta_renderer_native_create_view;
e82d74
+  renderer_class->rebuild_views = meta_renderer_native_rebuild_views;
e82d74
 
e82d74
   obj_props[PROP_MONITOR_MANAGER] =
e82d74
     g_param_spec_object ("monitor-manager",
e82d74
diff --git a/src/backends/native/meta-renderer-native.h b/src/backends/native/meta-renderer-native.h
e82d74
index 8468208e1..9eecdead1 100644
e82d74
--- a/src/backends/native/meta-renderer-native.h
e82d74
+++ b/src/backends/native/meta-renderer-native.h
e82d74
@@ -53,8 +53,6 @@ struct gbm_device * meta_gbm_device_from_gpu (MetaGpuKms *gpu_kms);
e82d74
 
e82d74
 gboolean meta_renderer_native_supports_mirroring (MetaRendererNative *renderer_native);
e82d74
 
e82d74
-void meta_renderer_native_queue_modes_reset (MetaRendererNative *renderer_native);
e82d74
-
e82d74
 void meta_renderer_native_finish_frame (MetaRendererNative *renderer_native);
e82d74
 
e82d74
 int64_t meta_renderer_native_get_frame_counter (MetaRendererNative *renderer_native);
e82d74
diff --git a/src/backends/native/meta-stage-native.c b/src/backends/native/meta-stage-native.c
e82d74
index add3e81fd..9b9c45ef3 100644
e82d74
--- a/src/backends/native/meta-stage-native.c
e82d74
+++ b/src/backends/native/meta-stage-native.c
e82d74
@@ -140,7 +140,6 @@ meta_stage_native_rebuild_views (MetaStageNative *stage_native)
e82d74
   ClutterActor *stage = meta_backend_get_stage (backend);
e82d74
 
e82d74
   meta_renderer_rebuild_views (renderer);
e82d74
-  meta_renderer_native_queue_modes_reset (META_RENDERER_NATIVE (renderer));
e82d74
   clutter_stage_update_resource_scales (CLUTTER_STAGE (stage));
e82d74
   ensure_frame_callbacks (stage_native);
e82d74
 }
e82d74
-- 
e82d74
2.24.1
e82d74
e82d74
e82d74
From 025054c93e43e8359c9ecafb6edea1eb4b7ad681 Mon Sep 17 00:00:00 2001
e82d74
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
e82d74
Date: Wed, 19 Jun 2019 21:14:05 +0200
e82d74
Subject: [PATCH 7/8] renderer/native: Discard page flip retries when
e82d74
 rebuilding views
e82d74
e82d74
Rebuilding views means we don't care to retry page flip attempts for
e82d74
previous views, especially since connectors may have been disconnected,
e82d74
making a page flip retry hit an assert a flipped CRTC has connectors
e82d74
associated with it.
e82d74
e82d74
https://gitlab.gnome.org/GNOME/mutter/merge_requests/655
e82d74
---
e82d74
 src/backends/native/meta-renderer-native.c | 50 +++++++++++++++++-----
e82d74
 1 file changed, 39 insertions(+), 11 deletions(-)
e82d74
e82d74
diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c
e82d74
index 70e1c4f9d..3cd01bcb7 100644
e82d74
--- a/src/backends/native/meta-renderer-native.c
e82d74
+++ b/src/backends/native/meta-renderer-native.c
e82d74
@@ -3060,6 +3060,24 @@ destroy_egl_surface (CoglOnscreen *onscreen)
e82d74
     }
e82d74
 }
e82d74
 
e82d74
+static void
e82d74
+discard_onscreen_page_flip_retries (MetaOnscreenNative *onscreen_native)
e82d74
+{
e82d74
+  g_list_free_full (onscreen_native->pending_page_flip_retries,
e82d74
+                    (GDestroyNotify) retry_page_flip_data_free);
e82d74
+  onscreen_native->pending_page_flip_retries = NULL;
e82d74
+
e82d74
+  if (onscreen_native->retry_page_flips_source)
e82d74
+    {
e82d74
+      MetaBackend *backend =
e82d74
+        backend_from_renderer_native (onscreen_native->renderer_native);
e82d74
+
e82d74
+      meta_backend_thaw_updates (backend);
e82d74
+      g_clear_pointer (&onscreen_native->retry_page_flips_source,
e82d74
+                       g_source_destroy);
e82d74
+    }
e82d74
+}
e82d74
+
e82d74
 static void
e82d74
 meta_renderer_native_release_onscreen (CoglOnscreen *onscreen)
e82d74
 {
e82d74
@@ -3090,17 +3108,7 @@ meta_renderer_native_release_onscreen (CoglOnscreen *onscreen)
e82d74
         g_warning ("Failed to clear current context");
e82d74
     }
e82d74
 
e82d74
-  g_list_free_full (onscreen_native->pending_page_flip_retries,
e82d74
-                    (GDestroyNotify) retry_page_flip_data_free);
e82d74
-  if (onscreen_native->retry_page_flips_source)
e82d74
-    {
e82d74
-      MetaBackend *backend =
e82d74
-        backend_from_renderer_native (onscreen_native->renderer_native);
e82d74
-
e82d74
-      meta_backend_thaw_updates (backend);
e82d74
-      g_clear_pointer (&onscreen_native->retry_page_flips_source,
e82d74
-                       g_source_destroy);
e82d74
-    }
e82d74
+  discard_onscreen_page_flip_retries (onscreen_native);
e82d74
 
e82d74
   renderer_gpu_data =
e82d74
     meta_renderer_native_get_gpu_data (onscreen_native->renderer_native,
e82d74
@@ -3555,12 +3563,32 @@ meta_renderer_native_create_view (MetaRenderer       *renderer,
e82d74
   return view;
e82d74
 }
e82d74
 
e82d74
+static void
e82d74
+discard_page_flip_retries (MetaRenderer *renderer)
e82d74
+{
e82d74
+  GList *l;
e82d74
+
e82d74
+  for (l = meta_renderer_get_views (renderer); l; l = l->next)
e82d74
+    {
e82d74
+      ClutterStageView *stage_view = l->data;
e82d74
+      CoglFramebuffer *framebuffer =
e82d74
+        clutter_stage_view_get_onscreen (stage_view);
e82d74
+      CoglOnscreen *onscreen = COGL_ONSCREEN (framebuffer);
e82d74
+      CoglOnscreenEGL *onscreen_egl = onscreen->winsys;
e82d74
+      MetaOnscreenNative *onscreen_native = onscreen_egl->platform;
e82d74
+
e82d74
+      discard_onscreen_page_flip_retries (onscreen_native);
e82d74
+    }
e82d74
+}
e82d74
+
e82d74
 static void
e82d74
 meta_renderer_native_rebuild_views (MetaRenderer *renderer)
e82d74
 {
e82d74
   MetaRendererClass *parent_renderer_class =
e82d74
     META_RENDERER_CLASS (meta_renderer_native_parent_class);
e82d74
 
e82d74
+  discard_page_flip_retries (renderer);
e82d74
+
e82d74
   parent_renderer_class->rebuild_views (renderer);
e82d74
 
e82d74
   meta_renderer_native_queue_modes_reset (META_RENDERER_NATIVE (renderer));
e82d74
-- 
e82d74
2.24.1
e82d74
e82d74
e82d74
From f4fdec6003e2cf9fa4b1882e92faf1da64e6052e Mon Sep 17 00:00:00 2001
e82d74
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
e82d74
Date: Wed, 27 Nov 2019 17:34:35 +0100
e82d74
Subject: [PATCH 8/8] =?UTF-8?q?crtc-kms:=20Ignore=2090=C2=B0=20rotations?=
e82d74
MIME-Version: 1.0
e82d74
Content-Type: text/plain; charset=UTF-8
e82d74
Content-Transfer-Encoding: 8bit
e82d74
e82d74
They tend to require special modifiers or won't work at all; ignore
e82d74
them.
e82d74
---
e82d74
 src/backends/native/meta-crtc-kms.c | 4 ----
e82d74
 1 file changed, 4 deletions(-)
e82d74
e82d74
diff --git a/src/backends/native/meta-crtc-kms.c b/src/backends/native/meta-crtc-kms.c
e82d74
index 8c2fbfe3c..8374376d5 100644
e82d74
--- a/src/backends/native/meta-crtc-kms.c
e82d74
+++ b/src/backends/native/meta-crtc-kms.c
e82d74
@@ -368,12 +368,8 @@ parse_transforms (MetaCrtc          *crtc,
e82d74
 
e82d74
       if (strcmp (prop->enums[i].name, "rotate-0") == 0)
e82d74
         transform = META_MONITOR_TRANSFORM_NORMAL;
e82d74
-      else if (strcmp (prop->enums[i].name, "rotate-90") == 0)
e82d74
-        transform = META_MONITOR_TRANSFORM_90;
e82d74
       else if (strcmp (prop->enums[i].name, "rotate-180") == 0)
e82d74
         transform = META_MONITOR_TRANSFORM_180;
e82d74
-      else if (strcmp (prop->enums[i].name, "rotate-270") == 0)
e82d74
-        transform = META_MONITOR_TRANSFORM_270;
e82d74
 
e82d74
       if (transform != -1)
e82d74
         {
e82d74
-- 
e82d74
2.24.1
e82d74