diff options
author | Keith Packard <keithp@keithp.com> | 2014-12-05 10:58:28 -0800 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2014-12-09 08:46:45 -0800 |
commit | 5064ffab631dcbc4265079fb32a02d3e2f1c4cd8 (patch) | |
tree | 76c3e0ec93522f827c22bf1891439a054ae2c59f /glamor | |
parent | 3e7218a6c23354d66f508b18164cac98a346b3ee (diff) |
glamor: Always destroy EGL image associated with destroyed pixmap
There were three paths that called eglDestroyImageKHR:
* The front buffer
* The intel driver's flip buffer
* pixmaps under DRI3
This patch unifies the second two by having glamor_destroy_pixmap
always destroy any associaged EGL image. This allows us to stop
storing the back_pixmap pointer in glamor as that was only used to
make sure that buffer was freed at server reset time.
v2: check for valid pixmap_priv before using it in
glamor_egl_destroy_pixmap_image
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
Diffstat (limited to 'glamor')
-rw-r--r-- | glamor/glamor.c | 26 | ||||
-rw-r--r-- | glamor/glamor.h | 3 | ||||
-rw-r--r-- | glamor/glamor_egl.c | 42 | ||||
-rw-r--r-- | glamor/glamor_egl_stubs.c | 2 | ||||
-rw-r--r-- | glamor/glamor_priv.h | 1 |
5 files changed, 18 insertions, 56 deletions
diff --git a/glamor/glamor.c b/glamor/glamor.c index d228e35ad..6cf9bdf9d 100644 --- a/glamor/glamor.c +++ b/glamor/glamor.c @@ -123,8 +123,6 @@ glamor_set_screen_pixmap(PixmapPtr screen_pixmap, PixmapPtr *back_pixmap) pixmap_priv->base.fbo->width = screen_pixmap->drawable.width; pixmap_priv->base.fbo->height = screen_pixmap->drawable.height; - - glamor_priv->back_pixmap = back_pixmap; } uint32_t @@ -218,27 +216,17 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth, return pixmap; } -void -glamor_destroy_textured_pixmap(PixmapPtr pixmap) +Bool +glamor_destroy_pixmap(PixmapPtr pixmap) { if (pixmap->refcnt == 1) { - glamor_pixmap_private *pixmap_priv; - - pixmap_priv = glamor_get_pixmap_private(pixmap); + glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap); if (pixmap_priv != NULL) glamor_pixmap_destroy_fbo(pixmap_priv); +#if GLAMOR_HAS_GBM + glamor_egl_destroy_pixmap_image(pixmap); +#endif } -} - -Bool -glamor_destroy_pixmap(PixmapPtr pixmap) -{ - glamor_screen_private - *glamor_priv = glamor_get_screen_private(pixmap->drawable.pScreen); - if (glamor_priv->dri3_enabled) - glamor_egl_destroy_textured_pixmap(pixmap); - else - glamor_destroy_textured_pixmap(pixmap); return fbDestroyPixmap(pixmap); } @@ -619,8 +607,6 @@ glamor_close_screen(ScreenPtr screen) #endif screen_pixmap = screen->GetScreenPixmap(screen); glamor_set_pixmap_private(screen_pixmap, NULL); - if (glamor_priv->back_pixmap && *glamor_priv->back_pixmap) - glamor_set_pixmap_private(*glamor_priv->back_pixmap, NULL); glamor_release_screen_priv(screen); diff --git a/glamor/glamor.h b/glamor/glamor.h index 405dbe8ed..168341443 100644 --- a/glamor/glamor.h +++ b/glamor/glamor.h @@ -132,7 +132,6 @@ extern _X_EXPORT void glamor_set_pixmap_texture(PixmapPtr pixmap, extern _X_EXPORT void glamor_set_pixmap_type(PixmapPtr pixmap, glamor_pixmap_type_t type); -extern _X_EXPORT void glamor_destroy_textured_pixmap(PixmapPtr pixmap); extern _X_EXPORT void glamor_block_handler(ScreenPtr screen); extern _X_EXPORT PixmapPtr glamor_create_pixmap(ScreenPtr screen, int w, int h, @@ -170,6 +169,8 @@ extern _X_EXPORT int glamor_egl_dri3_fd_name_from_tex(ScreenPtr, PixmapPtr, unsigned int, Bool, CARD16 *, CARD32 *); +extern void glamor_egl_destroy_pixmap_image(PixmapPtr pixmap); + /* @glamor_supports_pixmap_import_export: Returns whether * glamor_fd_from_pixmap(), glamor_name_from_pixmap(), and * glamor_pixmap_from_fd() are supported. diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c index 182e2e8c9..8b656fe38 100644 --- a/glamor/glamor_egl.c +++ b/glamor/glamor_egl.c @@ -70,7 +70,6 @@ struct glamor_egl_screen_private { CloseScreenProcPtr CloseScreen; int fd; EGLImageKHR front_image; - PixmapPtr *back_pixmap; int cpp; #ifdef GLAMOR_HAS_GBM struct gbm_device *gbm; @@ -235,7 +234,7 @@ glamor_egl_create_textured_screen(ScreenPtr screen, int handle, int stride) } glamor_egl->front_image = pixmap_priv->base.image; - glamor_set_screen_pixmap(screen_pixmap, glamor_egl->back_pixmap); + glamor_set_screen_pixmap(screen_pixmap, NULL); return TRUE; } @@ -244,15 +243,7 @@ glamor_egl_create_textured_screen_ext(ScreenPtr screen, int handle, int stride, PixmapPtr *back_pixmap) { - ScrnInfoPtr scrn = xf86ScreenToScrn(screen); - struct glamor_egl_screen_private *glamor_egl; - - glamor_egl = glamor_egl_get_screen_private(scrn); - - glamor_egl->back_pixmap = back_pixmap; - if (!glamor_egl_create_textured_screen(screen, handle, stride)) - return FALSE; - return TRUE; + return glamor_egl_create_textured_screen(screen, handle, stride); } static Bool @@ -519,16 +510,17 @@ glamor_pixmap_from_fd(ScreenPtr screen, #endif } -static void -_glamor_egl_destroy_pixmap_image(PixmapPtr pixmap) +void +glamor_egl_destroy_pixmap_image(PixmapPtr pixmap) { - ScrnInfoPtr scrn = xf86ScreenToScrn(pixmap->drawable.pScreen); - struct glamor_egl_screen_private *glamor_egl = - glamor_egl_get_screen_private(scrn); struct glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap); - if (pixmap_priv->base.image) { + if (pixmap_priv && pixmap_priv->base.image) { + ScrnInfoPtr scrn = xf86ScreenToScrn(pixmap->drawable.pScreen); + struct glamor_egl_screen_private *glamor_egl = + glamor_egl_get_screen_private(scrn); + /* Before destroy an image which was attached to * a texture. we must call glFlush to make sure the * operation on that texture has been done.*/ @@ -562,14 +554,6 @@ glamor_egl_exchange_buffers(PixmapPtr front, PixmapPtr back) } -void -glamor_egl_destroy_textured_pixmap(PixmapPtr pixmap) -{ - if (pixmap->refcnt == 1) - _glamor_egl_destroy_pixmap_image(pixmap); - glamor_destroy_textured_pixmap(pixmap); -} - static Bool glamor_egl_close_screen(ScreenPtr screen) { @@ -587,14 +571,6 @@ glamor_egl_close_screen(ScreenPtr screen) pixmap_priv->base.image = NULL; glamor_egl->front_image = NULL; - if (glamor_egl->back_pixmap && *glamor_egl->back_pixmap) { - pixmap_priv = glamor_get_pixmap_private(*glamor_egl->back_pixmap); - if (pixmap_priv->base.image) { - eglDestroyImageKHR(glamor_egl->display, pixmap_priv->base.image); - pixmap_priv->base.image = NULL; - } - } - screen->CloseScreen = glamor_egl->saved_close_screen; return screen->CloseScreen(screen); diff --git a/glamor/glamor_egl_stubs.c b/glamor/glamor_egl_stubs.c index 028d1cc05..a93f62dcb 100644 --- a/glamor/glamor_egl_stubs.c +++ b/glamor/glamor_egl_stubs.c @@ -36,7 +36,7 @@ glamor_egl_screen_init(ScreenPtr screen, struct glamor_context *glamor_ctx) } void -glamor_egl_destroy_textured_pixmap(PixmapPtr pixmap) +glamor_egl_destroy_pixmap_image(PixmapPtr pixmap) { } diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h index 885f12a6d..ffd327e13 100644 --- a/glamor/glamor_priv.h +++ b/glamor/glamor_priv.h @@ -306,7 +306,6 @@ typedef struct glamor_screen_private { int linear_max_nstops; int radial_max_nstops; - PixmapPtr *back_pixmap; int screen_fbo; struct glamor_saved_procs saved_procs; char delayed_fallback_string[GLAMOR_DELAYED_STRING_MAX + 1]; |