[PATCH 1/2] glamor: Add GLAMOR_ACCESS_WO

Dave Airlie airlied at gmail.com
Fri Mar 11 01:17:31 UTC 2016


From: Michel Dänzer <michel.daenzer at amd.com>

[airlied: rebased onto master -
I left WO alone as it's more like the GL interface
review suggested changing it to bits.]

Reviewed-by: Dave Airlie <airlied at redhat.com>
Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>
Signed-off-by: Dave Airlie <airlied at redhat.com>
---
 glamor/glamor_prepare.c | 16 +++++++++++-----
 glamor/glamor_priv.h    |  1 +
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/glamor/glamor_prepare.c b/glamor/glamor_prepare.c
index 5a73e6c..da31677 100644
--- a/glamor/glamor_prepare.c
+++ b/glamor/glamor_prepare.c
@@ -71,7 +71,7 @@ glamor_prep_pixmap_box(PixmapPtr pixmap, glamor_access_t access, BoxPtr box)
         if (!RegionNotEmpty(&region))
             return TRUE;
 
-        if (access == GLAMOR_ACCESS_RW)
+        if (access != GLAMOR_ACCESS_RO)
             FatalError("attempt to remap buffer as writable");
 
         if (priv->pbo) {
@@ -86,7 +86,10 @@ glamor_prep_pixmap_box(PixmapPtr pixmap, glamor_access_t access, BoxPtr box)
             if (priv->pbo == 0)
                 glGenBuffers(1, &priv->pbo);
 
-            gl_usage = GL_STREAM_READ;
+            if (access == GLAMOR_ACCESS_WO)
+                gl_usage = GL_STREAM_DRAW;
+            else
+                gl_usage = GL_STREAM_READ;
 
             glBindBuffer(GL_PIXEL_PACK_BUFFER, priv->pbo);
             glBufferData(GL_PIXEL_PACK_BUFFER,
@@ -101,14 +104,17 @@ 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 (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)
             gl_access = GL_READ_WRITE;
+        else if (priv->map_access == GLAMOR_ACCESS_WO)
+            gl_access = GL_WRITE_ONLY;
         else
             gl_access = GL_READ_ONLY;
 
@@ -144,7 +150,7 @@ glamor_fini_pixmap(PixmapPtr pixmap)
         pixmap->devPrivate.ptr = NULL;
     }
 
-    if (priv->map_access == GLAMOR_ACCESS_RW) {
+    if (priv->map_access != GLAMOR_ACCESS_RO) {
         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 8f994ea..355408c 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -313,6 +313,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