From c4d0e970dc12d1f59124bc60dcc179a0cbba9d06 Mon Sep 17 00:00:00 2001 From: Daniel van Vugt Date: Thu, 18 Jul 2024 17:26:38 +0800 Subject: [PATCH 1/2] onscreen/native: Move next_frame storage to later in the function It won't be used until later when we flip, and in fact assigning it early could have led to its own assertion failing on the next frame in the unlikely event that we return with "Failed to ensure KMS FB ID... Part-of: --- src/backends/native/meta-onscreen-native.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backends/native/meta-onscreen-native.c b/src/backends/native/meta-onscreen-native.c index 8a25fca8cc4..366d768a57c 100644 --- a/src/backends/native/meta-onscreen-native.c +++ b/src/backends/native/meta-onscreen-native.c @@ -1365,9 +1365,6 @@ meta_onscreen_native_swap_buffers_with_damage (CoglOnscreen *onscreen, primary_gpu_fb, secondary_gpu_fb); - g_warn_if_fail (!onscreen_native->next_frame); - onscreen_native->next_frame = clutter_frame_ref (frame); - switch (renderer_gpu_data->mode) { case META_RENDERER_NATIVE_MODE_GBM: @@ -1392,6 +1389,9 @@ meta_onscreen_native_swap_buffers_with_damage (CoglOnscreen *onscreen, #endif } + g_warn_if_fail (!onscreen_native->next_frame); + onscreen_native->next_frame = clutter_frame_ref (frame); + /* * If we changed EGL context, cogl will have the wrong idea about what is * current, making it fail to set it when it needs to. Avoid that by making -- GitLab From 21bc7432dc173f32673e699ca20b5d98860627dc Mon Sep 17 00:00:00 2001 From: Daniel van Vugt Date: Thu, 18 Jul 2024 17:37:06 +0800 Subject: [PATCH 2/2] onscreen/native: Squash adjacent switch statements Because we can. And it's now clearer that `buffer` is only used in `META_RENDERER_NATIVE_MODE_GBM`. Part-of: --- src/backends/native/meta-onscreen-native.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/src/backends/native/meta-onscreen-native.c b/src/backends/native/meta-onscreen-native.c index 366d768a57c..78eebf7fa18 100644 --- a/src/backends/native/meta-onscreen-native.c +++ b/src/backends/native/meta-onscreen-native.c @@ -1350,24 +1350,10 @@ meta_onscreen_native_swap_buffers_with_damage (CoglOnscreen *onscreen, } primary_gpu_fb = META_DRM_BUFFER (g_steal_pointer (&buffer_gbm)); - break; - case META_RENDERER_NATIVE_MODE_SURFACELESS: - g_assert_not_reached (); - break; -#ifdef HAVE_EGL_DEVICE - case META_RENDERER_NATIVE_MODE_EGL_DEVICE: - break; -#endif - } - - buffer = acquire_front_buffer (onscreen, - &egl_context_changed, - primary_gpu_fb, - secondary_gpu_fb); - - switch (renderer_gpu_data->mode) - { - case META_RENDERER_NATIVE_MODE_GBM: + buffer = acquire_front_buffer (onscreen, + &egl_context_changed, + primary_gpu_fb, + secondary_gpu_fb); meta_frame_native_set_buffer (frame_native, buffer); if (!meta_drm_buffer_ensure_fb_id (buffer, &error)) -- GitLab