Commit 5064ffab authored by Keith Packard's avatar Keith Packard

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's avatarKeith Packard <keithp@keithp.com>
Reviewed-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
parent 3e7218a6
......@@ -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);
......
......@@ -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.
......
......@@ -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);
......
......@@ -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)
{
}
......
......@@ -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];
......
......@@ -398,9 +398,8 @@ xwl_screen_init_glamor(struct xwl_screen *xwl_screen,
}
void
glamor_egl_destroy_textured_pixmap(PixmapPtr pixmap)
glamor_egl_destroy_pixmap_image(PixmapPtr pixmap)
{
glamor_destroy_textured_pixmap(pixmap);
}
int
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment