xserver: Branch 'master' - 3 commits

Adam Jackson ajax at kemper.freedesktop.org
Tue Jun 21 15:12:31 UTC 2016


 Xext/xres.c         |   96 +---------------------------------------------------
 composite/compext.c |   15 ++++----
 glx/glxext.c        |   19 ++++++++++
 3 files changed, 29 insertions(+), 101 deletions(-)

New commits:
commit ce82ae1964b2115a780786676c614546297a79c9
Author: Adam Jackson <ajax at redhat.com>
Date:   Tue Feb 2 14:10:49 2016 -0500

    res: Account for GLXPixmap references too
    
    GLX_EXT_tetxure_from_pixmap operates on a GLXPixmap, which takes a
    reference on the backing pixmap; that GLXPixmap might be long-lived, so
    we should account for it in ResQueryClientPixmapBytes.
    
    Acked-by: Michel Dänzer <michel.daenzer at amd.com>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/glx/glxext.c b/glx/glxext.c
index 0de9109..d595a05 100644
--- a/glx/glxext.c
+++ b/glx/glxext.c
@@ -336,6 +336,23 @@ checkScreenVisuals(void)
     return False;
 }
 
+static void
+GetGLXDrawableBytes(void *value, XID id, ResourceSizePtr size)
+{
+    __GLXdrawable *draw = value;
+
+    size->resourceSize = 0;
+    size->pixmapRefSize = 0;
+    size->refCnt = 1;
+
+    if (draw->type == GLX_DRAWABLE_PIXMAP) {
+        SizeType pixmapSizeFunc = GetResourceTypeSizeFunc(RT_PIXMAP);
+        ResourceSizeRec pixmapSize = { 0, };
+        pixmapSizeFunc((PixmapPtr)draw->pDraw, draw->pDraw->id, &pixmapSize);
+        size->pixmapRefSize += pixmapSize.pixmapRefSize;
+    }
+}
+
 /*
 ** Initialize the GLX extension.
 */
@@ -365,6 +382,8 @@ GlxExtensionInit(void)
     if (!__glXContextRes || !__glXDrawableRes)
         return;
 
+    SetResourceTypeSizeFunc(__glXDrawableRes, GetGLXDrawableBytes);
+
     if (!dixRegisterPrivateKey
         (&glxClientPrivateKeyRec, PRIVATE_CLIENT, sizeof(__GLXclientState)))
         return;
commit 5d6ad0d3a7611c4dff2d79b6af9eb5c0885656ef
Author: Adam Jackson <ajax at redhat.com>
Date:   Tue Feb 2 13:49:37 2016 -0500

    res: Fix accounting of redirected window pixmaps for Composite
    
    The previous change removed the special case that matched resources of
    CompositeClientWindowType and walked back from that to the window
    pixmap. That was intentional, since that logic was broken anyway. CCWTs
    don't map 1:1 to references on the backing pixmap; a window redirected
    by multiple clients (say, by the server since it's on the synthetic
    visual, and then manually by a compositor) would have a window pixmap
    refcount of 1, but would have those bytes accounted twice.
    
    The right thing is to have Composite wrap window accounting, and add the
    pixmap bytes once and only once for the redirection reference.
    
    Note that the view from the client can still be non-intuitive in the
    face of Composite.  xcompmgr, for example, holds _two_ references to
    each window pixmap (one each from CompositeNameWindowPixmap and
    RenderCreatePicture), so a synthetic-visual window will have its bytes
    split 2/3 to xcompmgr and 1/3 to the server-client.  Nothing to be done
    about that, and at least this way we're not over-accounting.
    
    Acked-by: Michel Dänzer <michel.daenzer at amd.com>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/composite/compext.c b/composite/compext.c
index b95bf99..5b17dae 100644
--- a/composite/compext.c
+++ b/composite/compext.c
@@ -499,16 +499,17 @@ SProcCompositeDispatch(ClientPtr client)
 }
 
 /** @see GetDefaultBytes */
+static SizeType coreGetWindowBytes;
+
 static void
-GetCompositeClientWindowBytes(void *value, XID id, ResourceSizePtr size)
+GetCompositeWindowBytes(void *value, XID id, ResourceSizePtr size)
 {
     WindowPtr window = value;
 
-    /* Currently only pixmap bytes are reported to clients. */
-    size->resourceSize = 0;
+    /* call down */
+    coreGetWindowBytes(value, id, size);
 
-    /* Calculate pixmap reference sizes. */
-    size->pixmapRefSize = 0;
+    /* account for redirection */
     if (window->redirectDraw != RedirectDrawNone)
     {
         SizeType pixmapSizeFunc = GetResourceTypeSizeFunc(RT_PIXMAP);
@@ -552,8 +553,8 @@ CompositeExtensionInit(void)
     if (!CompositeClientWindowType)
         return;
 
-    SetResourceTypeSizeFunc(CompositeClientWindowType,
-                            GetCompositeClientWindowBytes);
+    coreGetWindowBytes = GetResourceTypeSizeFunc(RT_WINDOW);
+    SetResourceTypeSizeFunc(RT_WINDOW, GetCompositeWindowBytes);
 
     CompositeClientSubwindowsType = CreateNewResourceType
         (FreeCompositeClientSubwindows, "CompositeClientSubwindows");
commit 4f8a72034c4a2654bfc16d929e09a69d1cc138ef
Author: Adam Jackson <ajax at redhat.com>
Date:   Tue Feb 2 13:46:42 2016 -0500

    res: Simplify QueryClientPixmapBytes
    
    I suspect this code predates the common resource hooks for computing
    sizes.  It's ugly in any case since the Resource extension shouldn't
    need to know which extensions can take a reference on pixmaps.  Instead,
    let's just walk every resource for the client and sum up all the pixmap
    bytes that way.
    
    This might be slightly slower since we're calling the size func once for
    every resource.  On the other hand, it might be slightly faster since we
    only walk the resource table once instead of 3-5 times.  Probably a
    wash, and not really a performance path in any case.
    
    Acked-by: Michel Dänzer <michel.daenzer at amd.com>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/Xext/xres.c b/Xext/xres.c
index 83cc691..ae779df 100644
--- a/Xext/xres.c
+++ b/Xext/xres.c
@@ -349,21 +349,6 @@ ProcXResQueryClientResources(ClientPtr client)
     return Success;
 }
 
-static unsigned long
-ResGetApproxPixmapBytes(PixmapPtr pix)
-{
-    unsigned long nPixels;
-    float bytesPerPixel;
-
-    bytesPerPixel = (float)pix->drawable.bitsPerPixel / 8.0;
-    nPixels = pix->drawable.width * pix->drawable.height;
-
-    /* Divide by refcnt as pixmap could be shared between clients,
-     * so total pixmap mem is shared between these.
-     */
-    return (nPixels * bytesPerPixel) / pix->refcnt;
-}
-
 static void
 ResFindResourcePixmaps(void *value, XID id, RESTYPE type, void *cdata)
 {
@@ -375,57 +360,6 @@ ResFindResourcePixmaps(void *value, XID id, RESTYPE type, void *cdata)
     *bytes += size.pixmapRefSize;
 }
 
-static void
-ResFindPixmaps(void *value, XID id, void *cdata)
-{
-    unsigned long *bytes = (unsigned long *) cdata;
-    PixmapPtr pix = (PixmapPtr) value;
-
-    *bytes += ResGetApproxPixmapBytes(pix);
-}
-
-static void
-ResFindWindowPixmaps(void *value, XID id, void *cdata)
-{
-    unsigned long *bytes = (unsigned long *) cdata;
-    WindowPtr pWin = (WindowPtr) value;
-
-    if (pWin->backgroundState == BackgroundPixmap)
-        *bytes += ResGetApproxPixmapBytes(pWin->background.pixmap);
-
-    if (pWin->border.pixmap != NULL && !pWin->borderIsPixel)
-        *bytes += ResGetApproxPixmapBytes(pWin->border.pixmap);
-}
-
-static void
-ResFindGCPixmaps(void *value, XID id, void *cdata)
-{
-    unsigned long *bytes = (unsigned long *) cdata;
-    GCPtr pGC = (GCPtr) value;
-
-    if (pGC->stipple != NULL)
-        *bytes += ResGetApproxPixmapBytes(pGC->stipple);
-
-    if (pGC->tile.pixmap != NULL && !pGC->tileIsPixel)
-        *bytes += ResGetApproxPixmapBytes(pGC->tile.pixmap);
-}
-
-#ifdef RENDER
-static void
-ResFindPicturePixmaps(void *value, XID id, void *cdata)
-{
-    ResFindResourcePixmaps(value, id, PictureType, cdata);
-}
-#endif
-
-#ifdef COMPOSITE
-static void
-ResFindCompositeClientWindowPixmaps (void *value, XID id, void *cdata)
-{
-    ResFindResourcePixmaps(value, id, CompositeClientWindowType, cdata);
-}
-#endif
-
 static int
 ProcXResQueryClientPixmapBytes(ClientPtr client)
 {
@@ -445,34 +379,8 @@ ProcXResQueryClientPixmapBytes(ClientPtr client)
 
     bytes = 0;
 
-    FindClientResourcesByType(clients[clientID], RT_PIXMAP, ResFindPixmaps,
-                              (void *) (&bytes));
-
-    /*
-     * Make sure win background pixmaps also held to account.
-     */
-    FindClientResourcesByType(clients[clientID], RT_WINDOW,
-                              ResFindWindowPixmaps, (void *) (&bytes));
-
-    /*
-     * GC Tile & Stipple pixmaps too.
-     */
-    FindClientResourcesByType(clients[clientID], RT_GC,
-                              ResFindGCPixmaps, (void *) (&bytes));
-
-#ifdef RENDER
-    /* Render extension picture pixmaps. */
-    FindClientResourcesByType(clients[clientID], PictureType,
-                              ResFindPicturePixmaps,
-                              (void *)(&bytes));
-#endif
-
-#ifdef COMPOSITE
-    /* Composite extension client window pixmaps. */
-    FindClientResourcesByType(clients[clientID], CompositeClientWindowType,
-                              ResFindCompositeClientWindowPixmaps,
-                              (void *)(&bytes));
-#endif
+    FindAllClientResources(clients[clientID], ResFindResourcePixmaps,
+                           (void *) (&bytes));
 
     rep = (xXResQueryClientPixmapBytesReply) {
         .type = X_Reply,


More information about the xorg-commit mailing list