xserver: Branch 'master' - 3 commits

Keith Packard keithp at kemper.freedesktop.org
Tue Dec 9 08:49:24 PST 2014


 glamor/glamor.c               |   26 +++----------
 glamor/glamor.h               |    3 +
 glamor/glamor_egl.c           |   83 +++++++++++++++---------------------------
 glamor/glamor_egl_stubs.c     |    2 -
 glamor/glamor_priv.h          |    1 
 hw/xwayland/xwayland-glamor.c |    3 -
 6 files changed, 41 insertions(+), 77 deletions(-)

New commits:
commit 8aa23f27c7e29c62d23867440b0bb00fc288b5ba
Author: Keith Packard <keithp at keithp.com>
Date:   Mon Dec 8 12:59:31 2014 -0800

    glamor: Free existing EGL image when assigning new one
    
    When reallocating the framebuffer on screen resize, the old EGL image
    was getting leaked. Check for an existing EGL image and free it in
    this case.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>
    Revewied-by: Zhigang Gong <zhigang.gong at linux.intel.com>

diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
index e90782e..e821601 100644
--- a/glamor/glamor_egl.c
+++ b/glamor/glamor_egl.c
@@ -253,6 +253,24 @@ glamor_egl_check_has_gem(int fd)
     return FALSE;
 }
 
+static void
+glamor_egl_set_pixmap_image(PixmapPtr pixmap, EGLImageKHR image)
+{
+    struct glamor_pixmap_private *pixmap_priv =
+        glamor_get_pixmap_private(pixmap);
+    EGLImageKHR old;
+
+    old = pixmap_priv->base.image;
+    if (old) {
+        ScreenPtr                               screen = pixmap->drawable.pScreen;
+        ScrnInfoPtr                             scrn = xf86ScreenToScrn(screen);
+        struct glamor_egl_screen_private        *glamor_egl = glamor_egl_get_screen_private(scrn);
+
+        eglDestroyImageKHR(glamor_egl->display, old);
+    }
+    pixmap_priv->base.image = image;
+}
+
 Bool
 glamor_egl_create_textured_pixmap(PixmapPtr pixmap, int handle, int stride)
 {
@@ -260,8 +278,6 @@ glamor_egl_create_textured_pixmap(PixmapPtr pixmap, int handle, int stride)
     ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
     struct glamor_screen_private *glamor_priv =
         glamor_get_screen_private(screen);
-    struct glamor_pixmap_private *pixmap_priv =
-        glamor_get_pixmap_private(pixmap);
     struct glamor_egl_screen_private *glamor_egl;
     EGLImageKHR image;
     GLuint texture;
@@ -296,7 +312,7 @@ glamor_egl_create_textured_pixmap(PixmapPtr pixmap, int handle, int stride)
     glamor_create_texture_from_image(screen, image, &texture);
     glamor_set_pixmap_type(pixmap, GLAMOR_TEXTURE_DRM);
     glamor_set_pixmap_texture(pixmap, texture);
-    pixmap_priv->base.image = image;
+    glamor_egl_set_pixmap_image(pixmap, image);
     ret = TRUE;
 
  done:
@@ -310,8 +326,6 @@ glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr pixmap, void *bo)
     ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
     struct glamor_screen_private *glamor_priv =
         glamor_get_screen_private(screen);
-    struct glamor_pixmap_private *pixmap_priv =
-        glamor_get_pixmap_private(pixmap);
     struct glamor_egl_screen_private *glamor_egl;
     EGLImageKHR image;
     GLuint texture;
@@ -331,7 +345,7 @@ glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr pixmap, void *bo)
     glamor_create_texture_from_image(screen, image, &texture);
     glamor_set_pixmap_type(pixmap, GLAMOR_TEXTURE_DRM);
     glamor_set_pixmap_texture(pixmap, texture);
-    pixmap_priv->base.image = image;
+    glamor_egl_set_pixmap_image(pixmap, image);
     ret = TRUE;
 
  done:
@@ -404,8 +418,8 @@ glamor_egl_dri3_fd_name_from_tex(ScreenPtr screen,
         if (image == EGL_NO_IMAGE_KHR)
             goto failure;
 
-        pixmap_priv->base.image = image;
         glamor_set_pixmap_type(pixmap, GLAMOR_TEXTURE_DRM);
+        glamor_egl_set_pixmap_image(pixmap, image);
     }
 
     bo = gbm_bo_import(glamor_egl->gbm, GBM_BO_IMPORT_EGL_IMAGE, image, 0);
commit c22433d55ea16e4879b092ee28d284fc895c9956
Author: Keith Packard <keithp at keithp.com>
Date:   Fri Dec 5 11:02:11 2014 -0800

    glamor: Remove redundant reference to screen pixmap EGL image
    
    There's no reason to store this in the egl screen private as the
    screen pixmap will always hold a reference to it anyways.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>
    Revewied-by: Zhigang Gong <zhigang.gong at linux.intel.com>

diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
index 8b656fe..e90782e 100644
--- a/glamor/glamor_egl.c
+++ b/glamor/glamor_egl.c
@@ -69,7 +69,6 @@ struct glamor_egl_screen_private {
     CreateScreenResourcesProcPtr CreateScreenResources;
     CloseScreenProcPtr CloseScreen;
     int fd;
-    EGLImageKHR front_image;
     int cpp;
 #ifdef GLAMOR_HAS_GBM
     struct gbm_device *gbm;
@@ -219,13 +218,9 @@ Bool
 glamor_egl_create_textured_screen(ScreenPtr screen, int handle, int stride)
 {
     ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
-    struct glamor_pixmap_private *pixmap_priv;
-    struct glamor_egl_screen_private *glamor_egl;
     PixmapPtr screen_pixmap;
 
-    glamor_egl = glamor_egl_get_screen_private(scrn);
     screen_pixmap = screen->GetScreenPixmap(screen);
-    pixmap_priv = glamor_get_pixmap_private(screen_pixmap);
 
     if (!glamor_egl_create_textured_pixmap(screen_pixmap, handle, stride)) {
         xf86DrvMsg(scrn->scrnIndex, X_ERROR,
@@ -233,7 +228,6 @@ glamor_egl_create_textured_screen(ScreenPtr screen, int handle, int stride)
         return FALSE;
     }
 
-    glamor_egl->front_image = pixmap_priv->base.image;
     glamor_set_screen_pixmap(screen_pixmap, NULL);
     return TRUE;
 }
@@ -533,9 +527,6 @@ glamor_egl_destroy_pixmap_image(PixmapPtr pixmap)
 _X_EXPORT void
 glamor_egl_exchange_buffers(PixmapPtr front, PixmapPtr back)
 {
-    ScrnInfoPtr scrn = xf86ScreenToScrn(front->drawable.pScreen);
-    struct glamor_egl_screen_private *glamor_egl =
-        glamor_egl_get_screen_private(scrn);
     EGLImageKHR temp;
     struct glamor_pixmap_private *front_priv =
         glamor_get_pixmap_private(front);
@@ -550,7 +541,6 @@ glamor_egl_exchange_buffers(PixmapPtr front, PixmapPtr back)
 
     glamor_set_pixmap_type(front, GLAMOR_TEXTURE_DRM);
     glamor_set_pixmap_type(back, GLAMOR_TEXTURE_DRM);
-    glamor_egl->front_image = front_priv->base.image;
 
 }
 
@@ -567,9 +557,8 @@ glamor_egl_close_screen(ScreenPtr screen)
     screen_pixmap = screen->GetScreenPixmap(screen);
     pixmap_priv = glamor_get_pixmap_private(screen_pixmap);
 
-    eglDestroyImageKHR(glamor_egl->display, glamor_egl->front_image);
+    eglDestroyImageKHR(glamor_egl->display, pixmap_priv->base.image);
     pixmap_priv->base.image = NULL;
-    glamor_egl->front_image = NULL;
 
     screen->CloseScreen = glamor_egl->saved_close_screen;
 
commit 5064ffab631dcbc4265079fb32a02d3e2f1c4cd8
Author: Keith Packard <keithp at keithp.com>
Date:   Fri Dec 5 10:58:28 2014 -0800

    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 at keithp.com>
    Reviewed-by: Zhigang Gong <zhigang.gong at linux.intel.com>

diff --git a/glamor/glamor.c b/glamor/glamor.c
index d228e35..6cf9bdf 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 405dbe8..1683414 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 182e2e8..8b656fe 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 028d1cc..a93f62d 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 885f12a..ffd327e 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];
diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c
index 4be883f..09b454f 100644
--- a/hw/xwayland/xwayland-glamor.c
+++ b/hw/xwayland/xwayland-glamor.c
@@ -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


More information about the xorg-commit mailing list