[mutter] renderer/native: Also wrap flip closures for EGLStreams
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] renderer/native: Also wrap flip closures for EGLStreams
- Date: Thu, 7 Jun 2018 20:16:17 +0000 (UTC)
commit 8ee14a7cb7e8f072d2731d59c7dc735f83a9bb0b
Author: Jonas Ådahl <jadahl gmail com>
Date: Tue Nov 14 16:08:52 2017 +0800
renderer/native: Also wrap flip closures for EGLStreams
When using the EGLStream backend, the MetaRendererNative passed a
GClosure to KMS when using EGLStreams, but KMS flip callback event
handler in meta-gpu-kms.c expected a closure wrapped in a closure
container, meaning it'd instead crash when using EGLStreams. Make the
flip handler get what it expects also when using EGLStreams by wrapping
the flip closure in the container before handing it over to EGL.
https://bugzilla.gnome.org/show_bug.cgi?id=790316
src/backends/native/meta-gpu-kms.c | 44 +++++++++++++++++++++---------
src/backends/native/meta-gpu-kms.h | 7 +++++
src/backends/native/meta-renderer-native.c | 7 ++++-
3 files changed, 44 insertions(+), 14 deletions(-)
---
diff --git a/src/backends/native/meta-gpu-kms.c b/src/backends/native/meta-gpu-kms.c
index 11951f557..8ee00344d 100644
--- a/src/backends/native/meta-gpu-kms.c
+++ b/src/backends/native/meta-gpu-kms.c
@@ -47,6 +47,12 @@ typedef struct _MetaKmsSource
MetaGpuKms *gpu_kms;
} MetaKmsSource;
+typedef struct _MetaGpuKmsFlipClosureContainer
+{
+ GClosure *flip_closure;
+ MetaGpuKms *gpu_kms;
+} MetaGpuKmsFlipClosureContainer;
+
struct _MetaGpuKms
{
MetaGpu parent;
@@ -199,11 +205,26 @@ meta_gpu_kms_is_crtc_active (MetaGpuKms *gpu_kms,
return TRUE;
}
-typedef struct _GpuClosureContainer
+MetaGpuKmsFlipClosureContainer *
+meta_gpu_kms_wrap_flip_closure (MetaGpuKms *gpu_kms,
+ GClosure *flip_closure)
{
- GClosure *flip_closure;
- MetaGpuKms *gpu_kms;
-} GpuClosureContainer;
+ MetaGpuKmsFlipClosureContainer *closure_container;
+
+ closure_container = g_new0 (MetaGpuKmsFlipClosureContainer, 1);
+ *closure_container = (MetaGpuKmsFlipClosureContainer) {
+ .flip_closure = flip_closure,
+ .gpu_kms = gpu_kms
+ };
+
+ return closure_container;
+}
+
+void
+meta_gpu_kms_flip_closure_container_free (MetaGpuKmsFlipClosureContainer *closure_container)
+{
+ g_free (closure_container);
+}
gboolean
meta_gpu_kms_flip_crtc (MetaGpuKms *gpu_kms,
@@ -229,14 +250,11 @@ meta_gpu_kms_flip_crtc (MetaGpuKms *gpu_kms,
if (!gpu_kms->page_flips_not_supported)
{
- GpuClosureContainer *closure_container;
+ MetaGpuKmsFlipClosureContainer *closure_container;
int kms_fd = meta_gpu_kms_get_fd (gpu_kms);
- closure_container = g_new0 (GpuClosureContainer, 1);
- *closure_container = (GpuClosureContainer) {
- .flip_closure = flip_closure,
- .gpu_kms = gpu_kms
- };
+ closure_container = meta_gpu_kms_wrap_flip_closure (gpu_kms,
+ flip_closure);
ret = drmModePageFlip (kms_fd,
crtc->crtc_id,
@@ -245,7 +263,7 @@ meta_gpu_kms_flip_crtc (MetaGpuKms *gpu_kms,
closure_container);
if (ret != 0 && ret != -EACCES)
{
- g_free (closure_container);
+ meta_gpu_kms_flip_closure_container_free (closure_container);
g_warning ("Failed to flip: %s", strerror (-ret));
gpu_kms->page_flips_not_supported = TRUE;
}
@@ -276,12 +294,12 @@ page_flip_handler (int fd,
unsigned int usec,
void *user_data)
{
- GpuClosureContainer *closure_container = user_data;
+ MetaGpuKmsFlipClosureContainer *closure_container = user_data;
GClosure *flip_closure = closure_container->flip_closure;
MetaGpuKms *gpu_kms = closure_container->gpu_kms;
invoke_flip_closure (flip_closure, gpu_kms);
- g_free (closure_container);
+ meta_gpu_kms_flip_closure_container_free (closure_container);
}
gboolean
diff --git a/src/backends/native/meta-gpu-kms.h b/src/backends/native/meta-gpu-kms.h
index 6c7d5a312..ef1f17ce8 100644
--- a/src/backends/native/meta-gpu-kms.h
+++ b/src/backends/native/meta-gpu-kms.h
@@ -32,6 +32,8 @@
#define META_TYPE_GPU_KMS (meta_gpu_kms_get_type ())
G_DECLARE_FINAL_TYPE (MetaGpuKms, meta_gpu_kms, META, GPU_KMS, MetaGpu)
+typedef struct _MetaGpuKmsFlipClosureContainer MetaGpuKmsFlipClosureContainer;
+
typedef struct _MetaKmsResources
{
drmModeRes *resources;
@@ -84,4 +86,9 @@ gboolean meta_drm_mode_equal (const drmModeModeInfo *one,
float meta_calculate_drm_mode_refresh_rate (const drmModeModeInfo *mode);
+MetaGpuKmsFlipClosureContainer * meta_gpu_kms_wrap_flip_closure (MetaGpuKms *gpu_kms,
+ GClosure *flip_closure);
+
+void meta_gpu_kms_flip_closure_container_free (MetaGpuKmsFlipClosureContainer *closure_container);
+
#endif /* META_GPU_KMS_H */
diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c
index cb8e03abe..772ce07f1 100644
--- a/src/backends/native/meta-renderer-native.c
+++ b/src/backends/native/meta-renderer-native.c
@@ -1271,6 +1271,7 @@ flip_egl_stream (MetaOnscreenNative *onscreen_native,
MetaRendererNativeGpuData *renderer_gpu_data;
EGLDisplay *egl_display;
MetaEgl *egl = meta_onscreen_native_get_egl (onscreen_native);
+ MetaGpuKmsFlipClosureContainer *closure_container;
EGLAttrib *acquire_attribs;
GError *error = NULL;
@@ -1280,9 +1281,12 @@ flip_egl_stream (MetaOnscreenNative *onscreen_native,
if (renderer_gpu_data->egl.no_egl_output_drm_flip_event)
return FALSE;
+ closure_container =
+ meta_gpu_kms_wrap_flip_closure (onscreen_native->render_gpu, flip_closure);
+
acquire_attribs = (EGLAttrib[]) {
EGL_DRM_FLIP_EVENT_DATA_NV,
- (EGLAttrib) flip_closure,
+ (EGLAttrib) closure_container,
EGL_NONE
};
@@ -1301,6 +1305,7 @@ flip_egl_stream (MetaOnscreenNative *onscreen_native,
renderer_gpu_data->egl.no_egl_output_drm_flip_event = TRUE;
}
g_error_free (error);
+ meta_gpu_kms_flip_closure_container_free (closure_container);
return FALSE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]