|
|
776610 |
From 1c77f0613220b026cbc7eebeb0a00844a675a721 Mon Sep 17 00:00:00 2001
|
|
|
776610 |
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
|
|
|
776610 |
Date: Tue, 14 Nov 2017 16:08:52 +0800
|
|
|
776610 |
Subject: [PATCH] renderer/native: Also wrap flip closures for EGLStreams
|
|
|
776610 |
|
|
|
776610 |
When using the EGLStream backend, the MetaRendererNative passed a
|
|
|
776610 |
GClosure to KMS when using EGLStreams, but KMS flip callback event
|
|
|
776610 |
handler in meta-gpu-kms.c expected a closure wrapped in a closure
|
|
|
776610 |
container, meaning it'd instead crash when using EGLStreams. Make the
|
|
|
776610 |
flip handler get what it expects also when using EGLStreams by wrapping
|
|
|
776610 |
the flip closure in the container before handing it over to EGL.
|
|
|
776610 |
|
|
|
776610 |
https://bugzilla.gnome.org/show_bug.cgi?id=790316
|
|
|
776610 |
(cherry picked from commit 8ee14a7cb7e8f072d2731d59c7dc735f83a9bb0b)
|
|
|
776610 |
---
|
|
|
776610 |
src/backends/native/meta-gpu-kms.c | 44 +++++++++++++++-------
|
|
|
776610 |
src/backends/native/meta-gpu-kms.h | 7 ++++
|
|
|
776610 |
src/backends/native/meta-renderer-native.c | 7 +++-
|
|
|
776610 |
3 files changed, 44 insertions(+), 14 deletions(-)
|
|
|
776610 |
|
|
|
776610 |
diff --git a/src/backends/native/meta-gpu-kms.c b/src/backends/native/meta-gpu-kms.c
|
|
|
776610 |
index 08c1e7dbe..815caf501 100644
|
|
|
776610 |
--- a/src/backends/native/meta-gpu-kms.c
|
|
|
776610 |
+++ b/src/backends/native/meta-gpu-kms.c
|
|
|
776610 |
@@ -47,6 +47,12 @@ typedef struct _MetaKmsSource
|
|
|
776610 |
MetaGpuKms *gpu_kms;
|
|
|
776610 |
} MetaKmsSource;
|
|
|
776610 |
|
|
|
776610 |
+typedef struct _MetaGpuKmsFlipClosureContainer
|
|
|
776610 |
+{
|
|
|
776610 |
+ GClosure *flip_closure;
|
|
|
776610 |
+ MetaGpuKms *gpu_kms;
|
|
|
776610 |
+} MetaGpuKmsFlipClosureContainer;
|
|
|
776610 |
+
|
|
|
776610 |
struct _MetaGpuKms
|
|
|
776610 |
{
|
|
|
776610 |
MetaGpu parent;
|
|
|
776610 |
@@ -209,11 +215,26 @@ meta_gpu_kms_is_crtc_active (MetaGpuKms *gpu_kms,
|
|
|
776610 |
return TRUE;
|
|
|
776610 |
}
|
|
|
776610 |
|
|
|
776610 |
-typedef struct _GpuClosureContainer
|
|
|
776610 |
+MetaGpuKmsFlipClosureContainer *
|
|
|
776610 |
+meta_gpu_kms_wrap_flip_closure (MetaGpuKms *gpu_kms,
|
|
|
776610 |
+ GClosure *flip_closure)
|
|
|
776610 |
{
|
|
|
776610 |
- GClosure *flip_closure;
|
|
|
776610 |
- MetaGpuKms *gpu_kms;
|
|
|
776610 |
-} GpuClosureContainer;
|
|
|
776610 |
+ MetaGpuKmsFlipClosureContainer *closure_container;
|
|
|
776610 |
+
|
|
|
776610 |
+ closure_container = g_new0 (MetaGpuKmsFlipClosureContainer, 1);
|
|
|
776610 |
+ *closure_container = (MetaGpuKmsFlipClosureContainer) {
|
|
|
776610 |
+ .flip_closure = flip_closure,
|
|
|
776610 |
+ .gpu_kms = gpu_kms
|
|
|
776610 |
+ };
|
|
|
776610 |
+
|
|
|
776610 |
+ return closure_container;
|
|
|
776610 |
+}
|
|
|
776610 |
+
|
|
|
776610 |
+void
|
|
|
776610 |
+meta_gpu_kms_flip_closure_container_free (MetaGpuKmsFlipClosureContainer *closure_container)
|
|
|
776610 |
+{
|
|
|
776610 |
+ g_free (closure_container);
|
|
|
776610 |
+}
|
|
|
776610 |
|
|
|
776610 |
gboolean
|
|
|
776610 |
meta_gpu_kms_flip_crtc (MetaGpuKms *gpu_kms,
|
|
|
776610 |
@@ -239,14 +260,11 @@ meta_gpu_kms_flip_crtc (MetaGpuKms *gpu_kms,
|
|
|
776610 |
|
|
|
776610 |
if (!gpu_kms->page_flips_not_supported)
|
|
|
776610 |
{
|
|
|
776610 |
- GpuClosureContainer *closure_container;
|
|
|
776610 |
+ MetaGpuKmsFlipClosureContainer *closure_container;
|
|
|
776610 |
int kms_fd = meta_gpu_kms_get_fd (gpu_kms);
|
|
|
776610 |
|
|
|
776610 |
- closure_container = g_new0 (GpuClosureContainer, 1);
|
|
|
776610 |
- *closure_container = (GpuClosureContainer) {
|
|
|
776610 |
- .flip_closure = flip_closure,
|
|
|
776610 |
- .gpu_kms = gpu_kms
|
|
|
776610 |
- };
|
|
|
776610 |
+ closure_container = meta_gpu_kms_wrap_flip_closure (gpu_kms,
|
|
|
776610 |
+ flip_closure);
|
|
|
776610 |
|
|
|
776610 |
ret = drmModePageFlip (kms_fd,
|
|
|
776610 |
crtc->crtc_id,
|
|
|
776610 |
@@ -255,7 +273,7 @@ meta_gpu_kms_flip_crtc (MetaGpuKms *gpu_kms,
|
|
|
776610 |
closure_container);
|
|
|
776610 |
if (ret != 0 && ret != -EACCES)
|
|
|
776610 |
{
|
|
|
776610 |
- g_free (closure_container);
|
|
|
776610 |
+ meta_gpu_kms_flip_closure_container_free (closure_container);
|
|
|
776610 |
g_warning ("Failed to flip: %s", strerror (-ret));
|
|
|
776610 |
gpu_kms->page_flips_not_supported = TRUE;
|
|
|
776610 |
}
|
|
|
776610 |
@@ -286,12 +304,12 @@ page_flip_handler (int fd,
|
|
|
776610 |
unsigned int usec,
|
|
|
776610 |
void *user_data)
|
|
|
776610 |
{
|
|
|
776610 |
- GpuClosureContainer *closure_container = user_data;
|
|
|
776610 |
+ MetaGpuKmsFlipClosureContainer *closure_container = user_data;
|
|
|
776610 |
GClosure *flip_closure = closure_container->flip_closure;
|
|
|
776610 |
MetaGpuKms *gpu_kms = closure_container->gpu_kms;
|
|
|
776610 |
|
|
|
776610 |
invoke_flip_closure (flip_closure, gpu_kms);
|
|
|
776610 |
- g_free (closure_container);
|
|
|
776610 |
+ meta_gpu_kms_flip_closure_container_free (closure_container);
|
|
|
776610 |
}
|
|
|
776610 |
|
|
|
776610 |
gboolean
|
|
|
776610 |
diff --git a/src/backends/native/meta-gpu-kms.h b/src/backends/native/meta-gpu-kms.h
|
|
|
776610 |
index d53ed98c8..01c3f2c0c 100644
|
|
|
776610 |
--- a/src/backends/native/meta-gpu-kms.h
|
|
|
776610 |
+++ b/src/backends/native/meta-gpu-kms.h
|
|
|
776610 |
@@ -40,6 +40,8 @@ GQuark meta_gpu_kms_error_quark (void);
|
|
|
776610 |
#define META_TYPE_GPU_KMS (meta_gpu_kms_get_type ())
|
|
|
776610 |
G_DECLARE_FINAL_TYPE (MetaGpuKms, meta_gpu_kms, META, GPU_KMS, MetaGpu)
|
|
|
776610 |
|
|
|
776610 |
+typedef struct _MetaGpuKmsFlipClosureContainer MetaGpuKmsFlipClosureContainer;
|
|
|
776610 |
+
|
|
|
776610 |
typedef struct _MetaKmsResources
|
|
|
776610 |
{
|
|
|
776610 |
drmModeRes *resources;
|
|
|
776610 |
@@ -94,4 +96,9 @@ gboolean meta_drm_mode_equal (const drmModeModeInfo *one,
|
|
|
776610 |
|
|
|
776610 |
float meta_calculate_drm_mode_refresh_rate (const drmModeModeInfo *mode);
|
|
|
776610 |
|
|
|
776610 |
+MetaGpuKmsFlipClosureContainer * meta_gpu_kms_wrap_flip_closure (MetaGpuKms *gpu_kms,
|
|
|
776610 |
+ GClosure *flip_closure);
|
|
|
776610 |
+
|
|
|
776610 |
+void meta_gpu_kms_flip_closure_container_free (MetaGpuKmsFlipClosureContainer *closure_container);
|
|
|
776610 |
+
|
|
|
776610 |
#endif /* META_GPU_KMS_H */
|
|
|
776610 |
diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c
|
|
|
776610 |
index d0da98f74..470da8845 100644
|
|
|
776610 |
--- a/src/backends/native/meta-renderer-native.c
|
|
|
776610 |
+++ b/src/backends/native/meta-renderer-native.c
|
|
|
776610 |
@@ -1286,6 +1286,7 @@ flip_egl_stream (MetaOnscreenNative *onscreen_native,
|
|
|
776610 |
MetaRendererNativeGpuData *renderer_gpu_data;
|
|
|
776610 |
EGLDisplay *egl_display;
|
|
|
776610 |
MetaEgl *egl = meta_onscreen_native_get_egl (onscreen_native);
|
|
|
776610 |
+ MetaGpuKmsFlipClosureContainer *closure_container;
|
|
|
776610 |
EGLAttrib *acquire_attribs;
|
|
|
776610 |
GError *error = NULL;
|
|
|
776610 |
|
|
|
776610 |
@@ -1295,9 +1296,12 @@ flip_egl_stream (MetaOnscreenNative *onscreen_native,
|
|
|
776610 |
if (renderer_gpu_data->egl.no_egl_output_drm_flip_event)
|
|
|
776610 |
return FALSE;
|
|
|
776610 |
|
|
|
776610 |
+ closure_container =
|
|
|
776610 |
+ meta_gpu_kms_wrap_flip_closure (onscreen_native->render_gpu, flip_closure);
|
|
|
776610 |
+
|
|
|
776610 |
acquire_attribs = (EGLAttrib[]) {
|
|
|
776610 |
EGL_DRM_FLIP_EVENT_DATA_NV,
|
|
|
776610 |
- (EGLAttrib) flip_closure,
|
|
|
776610 |
+ (EGLAttrib) closure_container,
|
|
|
776610 |
EGL_NONE
|
|
|
776610 |
};
|
|
|
776610 |
|
|
|
776610 |
@@ -1316,6 +1320,7 @@ flip_egl_stream (MetaOnscreenNative *onscreen_native,
|
|
|
776610 |
renderer_gpu_data->egl.no_egl_output_drm_flip_event = TRUE;
|
|
|
776610 |
}
|
|
|
776610 |
g_error_free (error);
|
|
|
776610 |
+ meta_gpu_kms_flip_closure_container_free (closure_container);
|
|
|
776610 |
return FALSE;
|
|
|
776610 |
}
|
|
|
776610 |
|
|
|
776610 |
--
|
|
|
776610 |
2.19.1
|
|
|
776610 |
|