mirror of
https://github.com/brl/mutter.git
synced 2024-11-26 01:50:42 -05:00
renderer/native: Fix EGLSurface destruction order
Make sure to destroy the EGL surface after releasing held buffers, otherwise we'll get the following valgrind warnings: ==24016== Invalid read of size 8 ==24016== at 0x1739943F: release_buffer (platform_drm.c:73) ==24016== by 0x49AC355: meta_drm_buffer_gbm_finalize (meta-drm-buffer-gbm.c:213) ==24016== by 0x4B75B61: g_object_unref (gobject.c:3346) ==24016== by 0x49B4B41: free_current_bo (meta-renderer-native.c:991) ==24016== by 0x49B816F: meta_renderer_native_release_onscreen (meta-renderer-native.c:2971) ==24016== by 0x5209441: _cogl_onscreen_free (cogl-onscreen.c:167) ==24016== by 0x5208D81: _cogl_object_onscreen_indirect_free (cogl-onscreen.c:51) ==24016== by 0x51C8066: _cogl_object_default_unref (cogl-object.c:103) ==24016== by 0x5207989: _cogl_framebuffer_unref (cogl-framebuffer.c:1814) ==24016== by 0x51C80B1: cogl_object_unref (cogl-object.c:115) ==24016== by 0x53673C7: clutter_stage_view_dispose (clutter-stage-view.c:304) ==24016== by 0x4B75AF2: g_object_unref (gobject.c:3309) ==24016== Address 0x18e742a8 is 536 bytes inside a block of size 784 free'd ==24016== at 0x4839A0C: free (vg_replace_malloc.c:540) ==24016== by 0x17399764: dri2_drm_destroy_surface (platform_drm.c:231) ==24016== by 0x1738550A: eglDestroySurface (eglapi.c:1145) ==24016== by 0x5440286: eglDestroySurface (in /home/jonas/Dev/gnome/install/lib/libEGL.so.1.1.0) ==24016== by 0x49613A5: meta_egl_destroy_surface (meta-egl.c:432) ==24016== by 0x49B80F9: meta_renderer_native_release_onscreen (meta-renderer-native.c:2954) ==24016== by 0x5209441: _cogl_onscreen_free (cogl-onscreen.c:167) ==24016== by 0x5208D81: _cogl_object_onscreen_indirect_free (cogl-onscreen.c:51) ==24016== by 0x51C8066: _cogl_object_default_unref (cogl-object.c:103) ==24016== by 0x5207989: _cogl_framebuffer_unref (cogl-framebuffer.c:1814) ==24016== by 0x51C80B1: cogl_object_unref (cogl-object.c:115) ==24016== by 0x53673C7: clutter_stage_view_dispose (clutter-stage-view.c:304) ==24016== Block was alloc'd at ==24016== at 0x483AB1A: calloc (vg_replace_malloc.c:762) ==24016== by 0x173997AE: dri2_drm_create_window_surface (platform_drm.c:145) ==24016== by 0x17388906: _eglCreateWindowSurfaceCommon (eglapi.c:929) ==24016== by 0x5440197: eglCreateWindowSurface (in /home/jonas/Dev/gnome/install/lib/libEGL.so.1.1.0) ==24016== by 0x49612FF: meta_egl_create_window_surface (meta-egl.c:396) ==24016== by 0x49B752E: meta_renderer_native_create_surface_gbm (meta-renderer-native.c:2538) ==24016== by 0x49B7E6C: meta_onscreen_native_allocate (meta-renderer-native.c:2870) ==24016== by 0x49B8BCF: meta_renderer_native_create_view (meta-renderer-native.c:3387) ==24016== by 0x48D274B: meta_renderer_create_view (meta-renderer.c:78) ==24016== by 0x48D27DE: meta_renderer_rebuild_views (meta-renderer.c:111) ==24016== by 0x49BB4FB: meta_stage_native_rebuild_views (meta-stage-native.c:142) ==24016== by 0x49A733C: meta_backend_native_update_screen_size (meta-backend-native.c:517) https://gitlab.gnome.org/GNOME/mutter/merge_requests/622
This commit is contained in:
parent
56ddaaa380
commit
d9fb11b043
@ -2905,6 +2905,28 @@ meta_onscreen_native_allocate (CoglOnscreen *onscreen,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
destroy_egl_surface (CoglOnscreen *onscreen)
|
||||
{
|
||||
CoglOnscreenEGL *onscreen_egl = onscreen->winsys;
|
||||
|
||||
if (onscreen_egl->egl_surface != EGL_NO_SURFACE)
|
||||
{
|
||||
MetaOnscreenNative *onscreen_native = onscreen_egl->platform;
|
||||
MetaEgl *egl = meta_onscreen_native_get_egl (onscreen_native);
|
||||
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
|
||||
CoglContext *cogl_context = framebuffer->context;
|
||||
CoglRenderer *cogl_renderer = cogl_context->display->renderer;
|
||||
CoglRendererEGL *cogl_renderer_egl = cogl_renderer->winsys;
|
||||
|
||||
meta_egl_destroy_surface (egl,
|
||||
cogl_renderer_egl->edpy,
|
||||
onscreen_egl->egl_surface,
|
||||
NULL);
|
||||
onscreen_egl->egl_surface = EGL_NO_SURFACE;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
meta_renderer_native_release_onscreen (CoglOnscreen *onscreen)
|
||||
{
|
||||
@ -2947,17 +2969,6 @@ meta_renderer_native_release_onscreen (CoglOnscreen *onscreen)
|
||||
g_source_destroy);
|
||||
}
|
||||
|
||||
if (onscreen_egl->egl_surface != EGL_NO_SURFACE)
|
||||
{
|
||||
MetaEgl *egl = meta_onscreen_native_get_egl (onscreen_native);
|
||||
|
||||
meta_egl_destroy_surface (egl,
|
||||
cogl_renderer_egl->edpy,
|
||||
onscreen_egl->egl_surface,
|
||||
NULL);
|
||||
onscreen_egl->egl_surface = EGL_NO_SURFACE;
|
||||
}
|
||||
|
||||
renderer_gpu_data =
|
||||
meta_renderer_native_get_gpu_data (onscreen_native->renderer_native,
|
||||
onscreen_native->render_gpu);
|
||||
@ -2970,6 +2981,8 @@ meta_renderer_native_release_onscreen (CoglOnscreen *onscreen)
|
||||
|
||||
free_current_bo (onscreen);
|
||||
|
||||
destroy_egl_surface (onscreen);
|
||||
|
||||
if (onscreen_native->gbm.surface)
|
||||
{
|
||||
gbm_surface_destroy (onscreen_native->gbm.surface);
|
||||
@ -2980,6 +2993,9 @@ meta_renderer_native_release_onscreen (CoglOnscreen *onscreen)
|
||||
case META_RENDERER_NATIVE_MODE_EGL_DEVICE:
|
||||
release_dumb_fb (&onscreen_native->egl.dumb_fb,
|
||||
onscreen_native->render_gpu);
|
||||
|
||||
destroy_egl_surface (onscreen);
|
||||
|
||||
if (onscreen_native->egl.stream != EGL_NO_STREAM_KHR)
|
||||
{
|
||||
MetaEgl *egl = meta_onscreen_native_get_egl (onscreen_native);
|
||||
|
Loading…
Reference in New Issue
Block a user