st/xorg: use surface_copy for blits if available
authorKeith Whitwell <keithw@vmware.com>
Tue, 24 Nov 2009 20:48:12 +0000 (20:48 +0000)
committerKeith Whitwell <keithw@vmware.com>
Tue, 24 Nov 2009 21:15:35 +0000 (21:15 +0000)
Even if its not available, we really want to be coalescing blit
operations better.

src/gallium/state_trackers/xorg/xorg_exa.c
src/gallium/state_trackers/xorg/xorg_exa.h

index 3d83b5700d50d0aa95456c2ef026c0a95eac2f3b..3e2f4e8834dd3716b03c1abd6afde590a96e0750 100644 (file)
@@ -156,6 +156,8 @@ xorg_exa_common_done(struct exa_context *exa)
 
    exa->copy.src = NULL;
    exa->copy.dst = NULL;
+   pipe_surface_reference(&exa->copy.src_surface, NULL);
+   pipe_surface_reference(&exa->copy.dst_surface, NULL);
    exa->transform.has_src = FALSE;
    exa->transform.has_mask = FALSE;
    exa->has_solid_color = FALSE;
@@ -438,6 +440,21 @@ ExaPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int xdir,
 
     exa->copy.src = src_priv;
     exa->copy.dst = priv;
+    
+    if (exa->pipe->surface_copy) {
+       exa->copy.src_surface =
+          exa->scrn->get_tex_surface( exa->scrn,
+                                      exa->copy.src->tex,
+                                      0, 0, 0,
+                                      PIPE_BUFFER_USAGE_GPU_READ);
+
+       exa->copy.dst_surface =
+          exa->scrn->get_tex_surface( exa->scrn, 
+                                      exa->copy.dst->tex,
+                                      0, 0, 0, 
+                                      PIPE_BUFFER_USAGE_GPU_WRITE );
+    }
+
 
     return exa->accel;
 }
@@ -458,11 +475,24 @@ ExaCopy(PixmapPtr pDstPixmap, int srcX, int srcY, int dstX, int dstY,
 
    debug_assert(priv == exa->copy.dst);
 
-   renderer_copy_pixmap(exa->renderer, exa->copy.dst, dstX, dstY,
-                        exa->copy.src, srcX, srcY,
-                        width, height);
+   if (exa->copy.src_surface && exa->copy.dst_surface) {
+      /* XXX: consider exposing >1 box in surface_copy interface.
+       */
+      exa->pipe->surface_copy( exa->pipe,
+                             exa->copy.dst_surface,
+                             dstX, dstY,
+                             exa->copy.src_surface,
+                             srcX, srcY,
+                             width, height );
+   }
+   else {
+      renderer_copy_pixmap(exa->renderer, exa->copy.dst, dstX, dstY,
+                           exa->copy.src, srcX, srcY,
+                           width, height);
+   }
 }
 
+
 static Bool
 picture_check_formats(struct exa_pixmap_priv *pSrc, PicturePtr pSrcPicture)
 {
index 15cc29d66209a92a5b86270cd3179f09707e45ff..a67dda65a58274606210d4a43acd7f741b999572 100644 (file)
@@ -37,6 +37,9 @@ struct exa_context
    struct {
       struct exa_pixmap_priv *src;
       struct exa_pixmap_priv *dst;
+
+      struct pipe_surface *src_surface;
+      struct pipe_surface *dst_surface;
    } copy;
 };