xf86-video-intel: Branch 'modesetting' - 2 commits - src/i830_video.c src/i830_video.h src/i915_video.c src/i965_video.c

Eric Anholt anholt at kemper.freedesktop.org
Thu Dec 28 23:00:24 EET 2006


 src/i830_video.c |   39 ++++++++++++++++++++++++++++++++++++---
 src/i830_video.h |    4 ++--
 src/i915_video.c |   34 +++++++++++++++++++++++-----------
 src/i965_video.c |   32 ++++++++++++++++++++++----------
 4 files changed, 83 insertions(+), 26 deletions(-)

New commits:
diff-tree 9cfbf1ceda8f153438df1ba4b1712c55cc872017 (from e889bde13dcc2438181a03319e204ae7b9235a78)
Author: Eric Anholt <eric at anholt.net>
Date:   Thu Dec 28 12:59:23 2006 -0800

    In EXA mode, force backing pixmaps into memory when doing XV to them.

diff --git a/src/i830_video.c b/src/i830_video.c
index b50b21b..f031a87 100644
--- a/src/i830_video.c
+++ b/src/i830_video.c
@@ -140,6 +140,11 @@ static Atom xvGamma0, xvGamma1, xvGamma2
 #define OVERLAY_DEBUG if (0) ErrorF
 #endif
 
+/* Oops, I never exported this function in EXA.  I meant to. */
+#ifndef exaMoveInPixmap
+void exaMoveInPixmap (PixmapPtr pPixmap);
+#endif
+
 /*
  * This is more or less the correct way to initalise, update, and shut down
  * the overlay.  Note OVERLAY_OFF should be used only after disabling the
@@ -2388,6 +2393,13 @@ I830PutImage(ScrnInfoPtr pScrn,
       pPixmap = (PixmapPtr)pDraw;
    }
 
+#ifdef I830_USE_EXA
+   if (pI830->useEXA) {
+       /* Force the pixmap into framebuffer so we can draw to it. */
+       exaMoveInPixmap(pPixmap);
+   }
+#endif
+
    if (((char *)pPixmap->devPrivate.ptr < (char *)pI830->FbBase) ||
        ((char *)pPixmap->devPrivate.ptr >= (char *)pI830->FbBase +
 	pI830->FbMapSize)) {
diff-tree e889bde13dcc2438181a03319e204ae7b9235a78 (from c7083a6f30fdf1859f60beba4c352bd790af4773)
Author: Eric Anholt <eric at anholt.net>
Date:   Thu Dec 28 12:49:24 2006 -0800

    Draw textured video to the backing pixmap in the composited case.
    
    Currently, when the backing pixmap is not in framebuffer, we just BadAlloc
    rather than drawing garbage to the front buffer.  This can be fixed with EXA.

diff --git a/src/i830_video.c b/src/i830_video.c
index 76d4f9c..b50b21b 100644
--- a/src/i830_video.c
+++ b/src/i830_video.c
@@ -76,6 +76,8 @@ THE USE OR OTHER DEALINGS IN THE SOFTWAR
 #include "xf86fbman.h"
 #include "regionstr.h"
 #include "randrstr.h"
+#include "windowstr.h"
+#include "damage.h"
 #include "i830.h"
 #include "i830_video.h"
 #include "xf86xv.h"
@@ -2016,7 +2018,6 @@ I830DisplayVideo(ScrnInfoPtr pScrn, int 
    OVERLAY_UPDATE;
 }
 
-
 #ifdef I830_USE_EXA
 static void
 I830VideoSave(ScreenPtr pScreen, ExaOffscreenArea *area)
@@ -2167,6 +2168,7 @@ I830PutImage(ScrnInfoPtr pScrn,
    ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex];
    I830OverlayRegPtr overlay =
 	 (I830OverlayRegPtr) (pI830->FbBase + pI830->OverlayMem->Start);
+   PixmapPtr pPixmap;
    INT32 x1, x2, y1, y2;
    int srcPitch, srcPitch2 = 0, dstPitch, destId;
    int top, left, npixels, nlines, size, loops;
@@ -2380,6 +2382,21 @@ I830PutImage(ScrnInfoPtr pScrn,
       break;
    }
 
+   if (pDraw->type == DRAWABLE_WINDOW) {
+      pPixmap = (*pScreen->GetWindowPixmap)((WindowPtr)pDraw);
+   } else {
+      pPixmap = (PixmapPtr)pDraw;
+   }
+
+   if (((char *)pPixmap->devPrivate.ptr < (char *)pI830->FbBase) ||
+       ((char *)pPixmap->devPrivate.ptr >= (char *)pI830->FbBase +
+	pI830->FbMapSize)) {
+      /* If the pixmap wasn't in framebuffer, then we have no way in XAA to
+       * force it there.  So, we simply refuse to draw and fail.
+       */
+      return BadAlloc;
+   }
+
    if (!pPriv->textured) {
       /* update cliplist */
       if (!RegionsEqual(&pPriv->clip, clipBoxes)) {
@@ -2392,12 +2409,16 @@ I830PutImage(ScrnInfoPtr pScrn,
    } else if (IS_I965G(pI830)) {
       I965DisplayVideoTextured(pScrn, pPriv, destId, clipBoxes, width, height,
 			       dstPitch, x1, y1, x2, y2,
-			       src_w, src_h, drw_w, drw_h, pDraw);
+			       src_w, src_h, drw_w, drw_h, pPixmap);
    } else {
       I915DisplayVideoTextured(pScrn, pPriv, destId, clipBoxes, width, height,
 			       dstPitch, x1, y1, x2, y2,
-			       src_w, src_h, drw_w, drw_h, pDraw);
+			       src_w, src_h, drw_w, drw_h, pPixmap);
    }
+   if (pPriv->textured) {
+      DamageDamageRegion(pDraw, clipBoxes);
+   }
+
    pPriv->videoStatus = CLIENT_VIDEO_ON;
 
    return Success;
diff --git a/src/i830_video.h b/src/i830_video.h
index 90c58b7..854d0b8 100644
--- a/src/i830_video.h
+++ b/src/i830_video.h
@@ -92,7 +92,7 @@ void I915DisplayVideoTextured(ScrnInfoPt
 			      int x1, int y1, int x2, int y2,
 			      short src_w, short src_h,
 			      short drw_w, short drw_h,
-			      DrawablePtr pDraw);
+			      PixmapPtr pPixmap);
 
 void I965DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv,
 			      int id, RegionPtr dstRegion, short width,
@@ -100,4 +100,4 @@ void I965DisplayVideoTextured(ScrnInfoPt
 			      int x1, int y1, int x2, int y2,
 			      short src_w, short src_h,
 			      short drw_w, short drw_h,
-			      DrawablePtr pDraw);
+			      PixmapPtr pPixmap);
diff --git a/src/i915_video.c b/src/i915_video.c
index 636b2cb..52fe1a5 100644
--- a/src/i915_video.c
+++ b/src/i915_video.c
@@ -57,12 +57,12 @@ I915DisplayVideoTextured(ScrnInfoPtr pSc
 			 short width, short height, int video_pitch,
 			 int x1, int y1, int x2, int y2,
 			 short src_w, short src_h, short drw_w, short drw_h,
-			 DrawablePtr pDraw)
+			 PixmapPtr pPixmap)
 {
    I830Ptr pI830 = I830PTR(pScrn);
    CARD32 format, ms3, s2, s5;
    BoxPtr pbox;
-   int nbox, dxo, dyo;
+   int nbox, dxo, dyo, pix_xoff, pix_yoff;
    Bool planar;
 
 #if 0
@@ -103,7 +103,8 @@ I915DisplayVideoTextured(ScrnInfoPtr pSc
 
    /* draw rect -- just clipping */
    OUT_RING(_3DSTATE_DRAW_RECT_CMD);
-   OUT_RING(DRAW_DITHER_OFS_X(pDraw->x & 3)| DRAW_DITHER_OFS_Y(pDraw->y & 3)); /* flags */
+   OUT_RING(DRAW_DITHER_OFS_X(pPixmap->drawable.x & 3) |
+	    DRAW_DITHER_OFS_Y(pPixmap->drawable.y & 3));
    OUT_RING(0x00000000);	/* ymin, xmin */
    OUT_RING((pScrn->virtualX - 1) |
 	    (pScrn->virtualY - 1) << 16); /* ymax, xmax */
@@ -155,8 +156,8 @@ I915DisplayVideoTextured(ScrnInfoPtr pSc
    /* front buffer, pitch, offset */
    OUT_RING(_3DSTATE_BUF_INFO_CMD);
    OUT_RING(BUF_3D_ID_COLOR_BACK | BUF_3D_USE_FENCE |
-	    (((pI830->displayWidth * pI830->cpp) / 4) << 2));
-   OUT_RING(pI830->bufferOffset);
+	    BUF_3D_PITCH(pPixmap->devKind));
+   OUT_RING(BUF_3D_ADDR((long)pPixmap->devPrivate.ptr - (long)pI830->FbBase));
    ADVANCE_LP_RING();
 
    if (!planar) {
@@ -340,6 +341,17 @@ I915DisplayVideoTextured(ScrnInfoPtr pSc
       ADVANCE_LP_RING();
    }
 
+   /* Set up the offset for translating from the given region (in screen
+    * coordinates) to the backing pixmap.
+    */
+#ifdef COMPOSITE
+   pix_xoff = -pPixmap->screen_x + pPixmap->drawable.x;
+   pix_yoff = -pPixmap->screen_y + pPixmap->drawable.y;
+#else
+   pix_xoff = 0;
+   pix_yoff = 0;
+#endif
+
    dxo = dstRegion->extents.x1;
    dyo = dstRegion->extents.y1;
 
@@ -380,8 +392,8 @@ I915DisplayVideoTextured(ScrnInfoPtr pSc
 	       (vert_data_count - 1));
 
       /* bottom right */
-      OUT_RING_F(box_x2);
-      OUT_RING_F(box_y2);
+      OUT_RING_F(box_x2 + pix_xoff);
+      OUT_RING_F(box_y2 + pix_yoff);
       if (!planar) {
 	 OUT_RING_F((box_x2 - dxo) * src_scale_x);
 	 OUT_RING_F((box_y2 - dyo) * src_scale_y);
@@ -393,8 +405,8 @@ I915DisplayVideoTextured(ScrnInfoPtr pSc
       }
 
       /* bottom left */
-      OUT_RING_F(box_x1);
-      OUT_RING_F(box_y2);
+      OUT_RING_F(box_x1 + pix_xoff);
+      OUT_RING_F(box_y2 + pix_yoff);
       if (!planar) {
 	 OUT_RING_F((box_x1 - dxo) * src_scale_x);
 	 OUT_RING_F((box_y2 - dyo) * src_scale_y);
@@ -406,8 +418,8 @@ I915DisplayVideoTextured(ScrnInfoPtr pSc
       }
 
       /* top left */
-      OUT_RING_F(box_x1);
-      OUT_RING_F(box_y1);
+      OUT_RING_F(box_x1 + pix_xoff);
+      OUT_RING_F(box_y1 + pix_yoff);
       if (!planar) {
 	 OUT_RING_F((box_x1 - dxo) * src_scale_x);
 	 OUT_RING_F((box_y1 - dyo) * src_scale_y);
diff --git a/src/i965_video.c b/src/i965_video.c
index af22cb2..0d1bec6 100644
--- a/src/i965_video.c
+++ b/src/i965_video.c
@@ -149,11 +149,11 @@ I965DisplayVideoTextured(ScrnInfoPtr pSc
 			 int x1, int y1, int x2, int y2,
 			 short src_w, short src_h,
 			 short drw_w, short drw_h,
-			 DrawablePtr pDraw)
+			 PixmapPtr pPixmap)
 {
     I830Ptr pI830 = I830PTR(pScrn);
     BoxPtr pbox;
-    int nbox, dxo, dyo;
+    int nbox, dxo, dyo, pix_xoff, pix_yoff;
     int urb_vs_start, urb_vs_size;
     int urb_gs_start, urb_gs_size;
     int urb_clip_start, urb_clip_size;
@@ -381,12 +381,13 @@ I965DisplayVideoTextured(ScrnInfoPtr pSc
     dest_surf_state->ss0.mipmap_layout_mode = 0;
     dest_surf_state->ss0.render_cache_read_mode = 0;
 
-    dest_surf_state->ss1.base_addr = pI830->FrontBuffer.Start;
+    dest_surf_state->ss1.base_addr = (long)pPixmap->devPrivate.ptr -
+	(long)pI830->FbBase;
     dest_surf_state->ss2.height = pScrn->virtualY - 1;
     dest_surf_state->ss2.width = pScrn->virtualX - 1;
     dest_surf_state->ss2.mip_count = 0;
     dest_surf_state->ss2.render_target_rotation = 0;
-    dest_surf_state->ss3.pitch = (pI830->displayWidth * pI830->cpp) - 1;
+    dest_surf_state->ss3.pitch = pPixmap->devKind - 1;
 
     /* Set up the source surface state buffer */
     memset(src_surf_state, 0, sizeof(*src_surf_state));
@@ -656,6 +657,17 @@ I965DisplayVideoTextured(ScrnInfoPtr pSc
        ADVANCE_LP_RING();
     }
 
+   /* Set up the offset for translating from the given region (in screen
+    * coordinates) to the backing pixmap.
+    */
+#ifdef COMPOSITE
+    pix_xoff = -pPixmap->screen_x + pPixmap->drawable.x;
+    pix_yoff = -pPixmap->screen_y + pPixmap->drawable.y;
+#else
+    pix_xoff = 0;
+    pix_yoff = 0;
+#endif
+
     dxo = dstRegion->extents.x1;
     dyo = dstRegion->extents.y1;
 
@@ -685,18 +697,18 @@ I965DisplayVideoTextured(ScrnInfoPtr pSc
 	i = 0;
 	vb[i++] = (box_x2 - dxo) * src_scale_x;
 	vb[i++] = (box_y2 - dyo) * src_scale_y;
-	vb[i++] = (float) box_x2;
-	vb[i++] = (float) box_y2;
+	vb[i++] = (float) box_x2 + pix_xoff;
+	vb[i++] = (float) box_y2 + pix_yoff;
 
 	vb[i++] = (box_x1 - dxo) * src_scale_x;
 	vb[i++] = (box_y2 - dyo) * src_scale_y;
-	vb[i++] = (float) box_x1;
-	vb[i++] = (float) box_y2;
+	vb[i++] = (float) box_x1 + pix_xoff;
+	vb[i++] = (float) box_y2 + pix_yoff;
 
 	vb[i++] = (box_x1 - dxo) * src_scale_x;
 	vb[i++] = (box_y1 - dyo) * src_scale_y;
-	vb[i++] = (float) box_x1;
-	vb[i++] = (float) box_y1;
+	vb[i++] = (float) box_x1 + pix_xoff;
+	vb[i++] = (float) box_y1 + pix_yoff;
 
 #if 0
 	ErrorF ("before EU_ATT 0x%08x%08x EU_ATT_DATA 0x%08x%08x\n",



More information about the xorg-commit mailing list