Module: Mesa
Branch: master
Commit: 17b27725fe5dd61ed461a45fb320464b45f045d8
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=17b27725fe5dd61ed461a45fb320464b45f045d8

Author: Marc-André Lureau <marcandre.lur...@gmail.com>
Date:   Mon Jun 15 15:09:58 2015 +0200

drisw: use getImageShm() if available

Reviewed-by: Dave Airlie <airl...@redhat.com>
Reviewed-by: Adam Jackson <a...@redhat.com>

---

 src/gallium/state_trackers/dri/drisw.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/dri/drisw.c 
b/src/gallium/state_trackers/dri/drisw.c
index 40cbca5494..e24fcba386 100644
--- a/src/gallium/state_trackers/dri/drisw.c
+++ b/src/gallium/state_trackers/dri/drisw.c
@@ -117,6 +117,26 @@ get_image2(__DRIdrawable *dPriv, int x, int y, int width, 
int height, int stride
                      data, dPriv->loaderPrivate);
 }
 
+static inline bool
+get_image_shm(__DRIdrawable *dPriv, int x, int y, int width, int height,
+              struct pipe_resource *res)
+{
+   __DRIscreen *sPriv = dPriv->driScreenPriv;
+   const __DRIswrastLoaderExtension *loader = sPriv->swrast_loader;
+   struct winsys_handle whandle;
+
+   whandle.type = WINSYS_HANDLE_TYPE_SHMID;
+
+   if (loader->base.version < 4 || !loader->getImageShm)
+      return FALSE;
+
+   if (!res->screen->resource_get_handle(res->screen, NULL, res, &whandle, 
PIPE_HANDLE_USAGE_WRITE))
+      return FALSE;
+
+   loader->getImageShm(dPriv, x, y, width, height, whandle.handle, 
dPriv->loaderPrivate);
+   return TRUE;
+}
+
 static void
 drisw_update_drawable_info(struct dri_drawable *drawable)
 {
@@ -364,7 +384,8 @@ drisw_update_tex_buffer(struct dri_drawable *drawable,
                            x, y, w, h, &transfer);
 
    /* Copy the Drawable content to the mapped texture buffer */
-   get_image(dPriv, x, y, w, h, map);
+   if (!get_image_shm(dPriv, x, y, w, h, res))
+      get_image(dPriv, x, y, w, h, map);
 
    /* The pipe transfer has a pitch rounded up to the nearest 64 pixels.
       get_image() has a pitch rounded up to 4 bytes.  */

_______________________________________________
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to