[PATCH] [RFC] glamor: implement write-only prepares

Dave Airlie airlied at gmail.com
Thu Mar 10 01:51:45 UTC 2016


From: Dave Airlie <airlied at redhat.com>

For some putimages we know we won't ever care about the data we readback,
we are going to trash it with the putimage contents. So implement
GLAMOR_ACCESS_WO mode.

This will avoid doing the readbacks. Use it for putimages that are copy
with a solid planemask.

inspired by Ilia and xlock -mode wator which does loads of XYBitmap
putimages.

Signed-off-by: Dave Airlie <airlied at redhat.com>
---
 glamor/glamor_image.c   | 6 +++++-
 glamor/glamor_prepare.c | 9 +++++----
 glamor/glamor_priv.h    | 1 +
 3 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/glamor/glamor_image.c b/glamor/glamor_image.c
index 3158749..87fdcf6 100644
--- a/glamor/glamor_image.c
+++ b/glamor/glamor_image.c
@@ -88,7 +88,11 @@ static void
 glamor_put_image_bail(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
                       int w, int h, int leftPad, int format, char *bits)
 {
-    if (glamor_prepare_access_box(drawable, GLAMOR_ACCESS_RW, x, y, w, h))
+    int access = GLAMOR_ACCESS_RW;
+
+    if (gc->alu == GXcopy && glamor_pm_is_solid(gc->depth, gc->planemask))
+        access = GLAMOR_ACCESS_WO;
+    if (glamor_prepare_access_box(drawable, access, x, y, w, h))
         fbPutImage(drawable, gc, depth, x, y, w, h, leftPad, format, bits);
     glamor_finish_access(drawable);
 }
diff --git a/glamor/glamor_prepare.c b/glamor/glamor_prepare.c
index 5a73e6c..1c53165 100644
--- a/glamor/glamor_prepare.c
+++ b/glamor/glamor_prepare.c
@@ -101,13 +101,14 @@ glamor_prep_pixmap_box(PixmapPtr pixmap, glamor_access_t access, BoxPtr box)
         priv->map_access = access;
     }
 
-    glamor_download_boxes(pixmap, RegionRects(&region), RegionNumRects(&region),
-                          0, 0, 0, 0, pixmap->devPrivate.ptr, pixmap->devKind);
+    if (priv->map_access != GLAMOR_ACCESS_WO)
+        glamor_download_boxes(pixmap, RegionRects(&region), RegionNumRects(&region),
+                              0, 0, 0, 0, pixmap->devPrivate.ptr, pixmap->devKind);
 
     RegionUninit(&region);
 
     if (glamor_priv->has_rw_pbo) {
-        if (priv->map_access == GLAMOR_ACCESS_RW)
+        if (priv->map_access == GLAMOR_ACCESS_RW || priv->map_access == GLAMOR_ACCESS_WO)
             gl_access = GL_READ_WRITE;
         else
             gl_access = GL_READ_ONLY;
@@ -144,7 +145,7 @@ glamor_fini_pixmap(PixmapPtr pixmap)
         pixmap->devPrivate.ptr = NULL;
     }
 
-    if (priv->map_access == GLAMOR_ACCESS_RW) {
+    if (priv->map_access == GLAMOR_ACCESS_RW || priv->map_access == GLAMOR_ACCESS_WO) {
         glamor_upload_boxes(pixmap,
                             RegionRects(&priv->prepare_region),
                             RegionNumRects(&priv->prepare_region),
diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index a70f10e..6df10b6 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -317,6 +317,7 @@ typedef struct glamor_screen_private {
 typedef enum glamor_access {
     GLAMOR_ACCESS_RO,
     GLAMOR_ACCESS_RW,
+    GLAMOR_ACCESS_WO,
 } glamor_access_t;
 
 enum glamor_fbo_state {
-- 
2.5.0



More information about the xorg-devel mailing list