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>
This commit is contained in:
parent
3e7218a6c2
commit
5064ffab63
|
@ -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->width = screen_pixmap->drawable.width;
|
||||||
pixmap_priv->base.fbo->height = screen_pixmap->drawable.height;
|
pixmap_priv->base.fbo->height = screen_pixmap->drawable.height;
|
||||||
|
|
||||||
glamor_priv->back_pixmap = back_pixmap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t
|
uint32_t
|
||||||
|
@ -218,27 +216,17 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
|
||||||
return pixmap;
|
return pixmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
glamor_destroy_textured_pixmap(PixmapPtr pixmap)
|
|
||||||
{
|
|
||||||
if (pixmap->refcnt == 1) {
|
|
||||||
glamor_pixmap_private *pixmap_priv;
|
|
||||||
|
|
||||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
|
||||||
if (pixmap_priv != NULL)
|
|
||||||
glamor_pixmap_destroy_fbo(pixmap_priv);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Bool
|
Bool
|
||||||
glamor_destroy_pixmap(PixmapPtr pixmap)
|
glamor_destroy_pixmap(PixmapPtr pixmap)
|
||||||
{
|
{
|
||||||
glamor_screen_private
|
if (pixmap->refcnt == 1) {
|
||||||
*glamor_priv = glamor_get_screen_private(pixmap->drawable.pScreen);
|
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||||
if (glamor_priv->dri3_enabled)
|
if (pixmap_priv != NULL)
|
||||||
glamor_egl_destroy_textured_pixmap(pixmap);
|
glamor_pixmap_destroy_fbo(pixmap_priv);
|
||||||
else
|
#if GLAMOR_HAS_GBM
|
||||||
glamor_destroy_textured_pixmap(pixmap);
|
glamor_egl_destroy_pixmap_image(pixmap);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
return fbDestroyPixmap(pixmap);
|
return fbDestroyPixmap(pixmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -619,8 +607,6 @@ glamor_close_screen(ScreenPtr screen)
|
||||||
#endif
|
#endif
|
||||||
screen_pixmap = screen->GetScreenPixmap(screen);
|
screen_pixmap = screen->GetScreenPixmap(screen);
|
||||||
glamor_set_pixmap_private(screen_pixmap, NULL);
|
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);
|
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,
|
extern _X_EXPORT void glamor_set_pixmap_type(PixmapPtr pixmap,
|
||||||
glamor_pixmap_type_t type);
|
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 void glamor_block_handler(ScreenPtr screen);
|
||||||
|
|
||||||
extern _X_EXPORT PixmapPtr glamor_create_pixmap(ScreenPtr screen, int w, int h,
|
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,
|
unsigned int, Bool,
|
||||||
CARD16 *, CARD32 *);
|
CARD16 *, CARD32 *);
|
||||||
|
|
||||||
|
extern void glamor_egl_destroy_pixmap_image(PixmapPtr pixmap);
|
||||||
|
|
||||||
/* @glamor_supports_pixmap_import_export: Returns whether
|
/* @glamor_supports_pixmap_import_export: Returns whether
|
||||||
* glamor_fd_from_pixmap(), glamor_name_from_pixmap(), and
|
* glamor_fd_from_pixmap(), glamor_name_from_pixmap(), and
|
||||||
* glamor_pixmap_from_fd() are supported.
|
* glamor_pixmap_from_fd() are supported.
|
||||||
|
|
|
@ -70,7 +70,6 @@ struct glamor_egl_screen_private {
|
||||||
CloseScreenProcPtr CloseScreen;
|
CloseScreenProcPtr CloseScreen;
|
||||||
int fd;
|
int fd;
|
||||||
EGLImageKHR front_image;
|
EGLImageKHR front_image;
|
||||||
PixmapPtr *back_pixmap;
|
|
||||||
int cpp;
|
int cpp;
|
||||||
#ifdef GLAMOR_HAS_GBM
|
#ifdef GLAMOR_HAS_GBM
|
||||||
struct gbm_device *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_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;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,15 +243,7 @@ glamor_egl_create_textured_screen_ext(ScreenPtr screen,
|
||||||
int handle,
|
int handle,
|
||||||
int stride, PixmapPtr *back_pixmap)
|
int stride, PixmapPtr *back_pixmap)
|
||||||
{
|
{
|
||||||
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
|
return glamor_egl_create_textured_screen(screen, handle, stride);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Bool
|
static Bool
|
||||||
|
@ -519,16 +510,17 @@ glamor_pixmap_from_fd(ScreenPtr screen,
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
void
|
||||||
_glamor_egl_destroy_pixmap_image(PixmapPtr pixmap)
|
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 =
|
struct glamor_pixmap_private *pixmap_priv =
|
||||||
glamor_get_pixmap_private(pixmap);
|
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
|
/* Before destroy an image which was attached to
|
||||||
* a texture. we must call glFlush to make sure the
|
* a texture. we must call glFlush to make sure the
|
||||||
* operation on that texture has been done.*/
|
* 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
|
static Bool
|
||||||
glamor_egl_close_screen(ScreenPtr screen)
|
glamor_egl_close_screen(ScreenPtr screen)
|
||||||
{
|
{
|
||||||
|
@ -587,14 +571,6 @@ glamor_egl_close_screen(ScreenPtr screen)
|
||||||
pixmap_priv->base.image = NULL;
|
pixmap_priv->base.image = NULL;
|
||||||
glamor_egl->front_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;
|
screen->CloseScreen = glamor_egl->saved_close_screen;
|
||||||
|
|
||||||
return screen->CloseScreen(screen);
|
return screen->CloseScreen(screen);
|
||||||
|
|
|
@ -36,7 +36,7 @@ glamor_egl_screen_init(ScreenPtr screen, struct glamor_context *glamor_ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
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 linear_max_nstops;
|
||||||
int radial_max_nstops;
|
int radial_max_nstops;
|
||||||
|
|
||||||
PixmapPtr *back_pixmap;
|
|
||||||
int screen_fbo;
|
int screen_fbo;
|
||||||
struct glamor_saved_procs saved_procs;
|
struct glamor_saved_procs saved_procs;
|
||||||
char delayed_fallback_string[GLAMOR_DELAYED_STRING_MAX + 1];
|
char delayed_fallback_string[GLAMOR_DELAYED_STRING_MAX + 1];
|
||||||
|
|
|
@ -398,9 +398,8 @@ xwl_screen_init_glamor(struct xwl_screen *xwl_screen,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
glamor_egl_destroy_textured_pixmap(PixmapPtr pixmap)
|
glamor_egl_destroy_pixmap_image(PixmapPtr pixmap)
|
||||||
{
|
{
|
||||||
glamor_destroy_textured_pixmap(pixmap);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
Loading…
Reference in New Issue
Block a user