[mutter/wip/texture-purge-on-nvidia: 47/66] renderer/native: Also wrap flip closures for EGLStreams
- From: Ray Strode <halfline src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/texture-purge-on-nvidia: 47/66] renderer/native: Also wrap flip closures for EGLStreams
- Date: Tue, 8 Jan 2019 22:02:22 +0000 (UTC)
commit fcd430f9c8ba8f279157fd6acfff670c3b297999
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
(cherry picked from commit 8ee14a7cb7e8f072d2731d59c7dc735f83a9bb0b)
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 08c1e7dbe..815caf501 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;
@@ -209,11 +215,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,
@@ -239,14 +260,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,
@@ -255,7 +273,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;
}
@@ -286,12 +304,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 d53ed98c8..01c3f2c0c 100644
--- a/src/backends/native/meta-gpu-kms.h
+++ b/src/backends/native/meta-gpu-kms.h
@@ -40,6 +40,8 @@ GQuark meta_gpu_kms_error_quark (void);
#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;
@@ -94,4 +96,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 d0da98f74..470da8845 100644
--- a/src/backends/native/meta-renderer-native.c
+++ b/src/backends/native/meta-renderer-native.c
@@ -1286,6 +1286,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;
@@ -1295,9 +1296,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
};
@@ -1316,6 +1320,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]