xf86-video-intel: Branch '2.7' - 3 commits - src/i830_dri.c

Ian Romanick idr at kemper.freedesktop.org
Fri Jun 12 14:07:51 PDT 2009


 src/i830_dri.c |  152 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 145 insertions(+), 7 deletions(-)

New commits:
commit 8adfea19a3b4d95fb95fb3c9f102e16823f8ea6c
Author: Pierre Willenbrock <pierre at pirsoft.de>
Date:   Sat Apr 25 22:58:20 2009 +0200

    format == 0 means "use default" in I830DRI2CreateBuffer
    
    Reviewed-by: Ian Romanick <idr at freedesktop.org>
    (cherry picked from commit 5b05a589efb23b2fc09b06e4271174d922b1ab02)

diff --git a/src/i830_dri.c b/src/i830_dri.c
index 6fc250c..04154cc 100644
--- a/src/i830_dri.c
+++ b/src/i830_dri.c
@@ -1677,7 +1677,7 @@ I830DRI2CreateBuffer(DrawablePtr pDraw, unsigned int attachment,
 	pPixmap = (*pScreen->CreatePixmap)(pScreen,
 					   pDraw->width,
 					   pDraw->height,
-					   format,
+					   (format != 0)?format:pDraw->depth,
 					   hint);
 
     }
commit 5ea315944ada3097fe33a14e0c1bdf1268be0308
Author: Ian Romanick <ian.d.romanick at intel.com>
Date:   Fri Apr 24 12:28:13 2009 -0700

    DRI2: If the SDK supports it, use the DRI2GetBuffersWithFormat interfaces
    
    If DRI2INFOREC_VERSION is defined in the server's dri2.h and has a
    value greater than 1, compile to use the CreateBuffer and
    DestroyBuffer interfaces.  The format parameter parameter to
    CreateBuffer is assumed to be the bits-per-pixel of the buffer.
    
    Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
    Reviewed-by: Kristian Høgsberg <krh at redhat.com>
    (cherry picked from commit 5d6f4f6eb7a4dcbe1ce5a134d882e56f958ed2ba)

diff --git a/src/i830_dri.c b/src/i830_dri.c
index e60af09..6fc250c 100644
--- a/src/i830_dri.c
+++ b/src/i830_dri.c
@@ -93,6 +93,12 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #ifdef DRI2
 #include "dri2.h"
+
+#if DRI2INFOREC_VERSION >= 1
+#define USE_DRI2_1_1_0
+#endif
+
+extern XF86ModuleData dri2ModuleData;
 #endif
 
 static Bool I830InitVisualConfigs(ScreenPtr pScreen);
@@ -1532,6 +1538,7 @@ typedef struct {
     unsigned int attachment;
 } I830DRI2BufferPrivateRec, *I830DRI2BufferPrivatePtr;
 
+#ifndef USE_DRI2_1_1_0
 static DRI2BufferPtr
 I830DRI2CreateBuffers(DrawablePtr pDraw, unsigned int *attachments, int count)
 {
@@ -1615,6 +1622,88 @@ I830DRI2CreateBuffers(DrawablePtr pDraw, unsigned int *attachments, int count)
     return buffers;
 }
 
+#else
+
+static DRI2BufferPtr
+I830DRI2CreateBuffer(DrawablePtr pDraw, unsigned int attachment,
+		     unsigned int format)
+{
+    ScreenPtr pScreen = pDraw->pScreen;
+    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    I830Ptr pI830 = I830PTR(pScrn);
+    DRI2BufferPtr buffers;
+    dri_bo *bo;
+    I830DRI2BufferPrivatePtr privates;
+    PixmapPtr pPixmap;
+
+    buffers = xcalloc(1, sizeof *buffers);
+    if (buffers == NULL)
+	return NULL;
+    privates = xcalloc(1, sizeof *privates);
+    if (privates == NULL) {
+	xfree(buffers);
+	return NULL;
+    }
+
+    if (attachment == DRI2BufferFrontLeft) {
+	if (pDraw->type == DRAWABLE_PIXMAP)
+	    pPixmap = (PixmapPtr) pDraw;
+	else
+	    pPixmap = (*pScreen->GetWindowPixmap)((WindowPtr) pDraw);
+	pPixmap->refcnt++;
+    } else {
+	unsigned int hint = 0;
+
+	switch (attachment) {
+	case DRI2BufferDepth:
+	case DRI2BufferDepthStencil:
+	    if (SUPPORTS_YTILING(pI830))
+		hint = INTEL_CREATE_PIXMAP_TILING_Y;
+	    else
+		hint = INTEL_CREATE_PIXMAP_TILING_X;
+	    break;
+	case DRI2BufferFakeFrontLeft:
+	case DRI2BufferFakeFrontRight:
+	case DRI2BufferBackLeft:
+	case DRI2BufferBackRight:
+	    hint = INTEL_CREATE_PIXMAP_TILING_X;
+	    break;
+	}
+
+	if (!pI830->tiling ||
+	    (!IS_I965G(pI830) && !pI830->kernel_exec_fencing))
+	    hint = 0;
+
+	pPixmap = (*pScreen->CreatePixmap)(pScreen,
+					   pDraw->width,
+					   pDraw->height,
+					   format,
+					   hint);
+
+    }
+
+
+    buffers->attachment = attachment;
+    buffers->pitch = pPixmap->devKind;
+    buffers->cpp = pPixmap->drawable.bitsPerPixel / 8;
+    buffers->driverPrivate = privates;
+    buffers->format = format;
+    buffers->flags = 0; /* not tiled */
+    privates->pPixmap = pPixmap;
+    privates->attachment = attachment;
+
+    bo = i830_get_pixmap_bo (pPixmap);
+    if (dri_bo_flink(bo, &buffers->name) != 0) {
+	/* failed to name buffer */
+    }
+
+    return buffers;
+}
+
+#endif
+
+#ifndef USE_DRI2_1_1_0
+
 static void
 I830DRI2DestroyBuffers(DrawablePtr pDraw, DRI2BufferPtr buffers, int count)
 {
@@ -1635,6 +1724,24 @@ I830DRI2DestroyBuffers(DrawablePtr pDraw, DRI2BufferPtr buffers, int count)
     }
 }
 
+#else
+
+static void
+I830DRI2DestroyBuffer(DrawablePtr pDraw, DRI2BufferPtr buffer)
+{
+    if (buffer) {
+	I830DRI2BufferPrivatePtr private = buffer->driverPrivate;
+	ScreenPtr pScreen = pDraw->pScreen;
+
+	(*pScreen->DestroyPixmap)(private->pPixmap);
+
+	xfree(private);
+	xfree(buffer);
+    }
+}
+
+#endif
+
 static void
 I830DRI2CopyRegion(DrawablePtr pDraw, RegionPtr pRegion,
 		   DRI2BufferPtr pDstBuffer, DRI2BufferPtr pSrcBuffer)
@@ -1686,12 +1793,28 @@ Bool I830DRI2ScreenInit(ScreenPtr pScreen)
     int i;
     struct stat sbuf;
     dev_t d;
+#ifdef USE_DRI2_1_1_0
+    int dri2_major = 1;
+    int dri2_minor = 0;
+#endif
 
     if (pI830->accel != ACCEL_UXA) {
 	xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "DRI2 requires UXA\n");
 	return FALSE;
     }
 
+#ifdef USE_DRI2_1_1_0
+    if (xf86LoaderCheckSymbol("DRI2Version")) {
+	DRI2Version(& dri2_major, & dri2_minor);
+    }
+
+    if (dri2_minor < 1) {
+	xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+		   "DRI2 requires DRI2 module version 1.1.0 or later\n");
+	return FALSE;
+    }
+#endif
+
     sprintf(buf, "pci:%04x:%02x:%02x.%d",
 	    pI830->PciInfo->domain,
 	    pI830->PciInfo->bus,
@@ -1736,10 +1859,19 @@ Bool I830DRI2ScreenInit(ScreenPtr pScreen)
 
     info.driverName = IS_I965G(pI830) ? "i965" : "i915";
     info.deviceName = p;
-    info.version = 1;
 
+#ifdef USE_DRI2_1_1_0
+    info.version = 2;
+    info.CreateBuffers = NULL;
+    info.DestroyBuffers = NULL;
+    info.CreateBuffer = I830DRI2CreateBuffer;
+    info.DestroyBuffer = I830DRI2DestroyBuffer;
+#else
+    info.version = 1;
     info.CreateBuffers = I830DRI2CreateBuffers;
     info.DestroyBuffers = I830DRI2DestroyBuffers;
+#endif
+
     info.CopyRegion = I830DRI2CopyRegion;
 
     pI830->drmSubFD = info.fd;
commit 35d18fceadf82aee6109c8d34c37bdb000503fc0
Author: Ian Romanick <ian.d.romanick at intel.com>
Date:   Fri Apr 17 20:59:04 2009 -0700

    DRI2: Respect the src and dst parameters of CopyRegion.
    
    Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
    (cherry picked from commit 5a07ab502fe1e58e7e37fe554fb42d8d2c8c53ec)

diff --git a/src/i830_dri.c b/src/i830_dri.c
index 6a32492..e60af09 100644
--- a/src/i830_dri.c
+++ b/src/i830_dri.c
@@ -1529,6 +1529,7 @@ I830DRIUnlock(ScrnInfoPtr pScrn)
 
 typedef struct {
     PixmapPtr pPixmap;
+    unsigned int attachment;
 } I830DRI2BufferPrivateRec, *I830DRI2BufferPrivatePtr;
 
 static DRI2BufferPtr
@@ -1602,6 +1603,7 @@ I830DRI2CreateBuffers(DrawablePtr pDraw, unsigned int *attachments, int count)
 	buffers[i].driverPrivate = &privates[i];
 	buffers[i].flags = 0; /* not tiled */
 	privates[i].pPixmap = pPixmap;
+	privates[i].attachment = attachments[i];
 
 	bo = i830_get_pixmap_bo (pPixmap);
 	if (dri_bo_flink(bo, &buffers[i].name) != 0) {
@@ -1635,13 +1637,17 @@ I830DRI2DestroyBuffers(DrawablePtr pDraw, DRI2BufferPtr buffers, int count)
 
 static void
 I830DRI2CopyRegion(DrawablePtr pDraw, RegionPtr pRegion,
-		   DRI2BufferPtr pDestBuffer, DRI2BufferPtr pSrcBuffer)
+		   DRI2BufferPtr pDstBuffer, DRI2BufferPtr pSrcBuffer)
 {
-    I830DRI2BufferPrivatePtr private = pSrcBuffer->driverPrivate;
+    I830DRI2BufferPrivatePtr srcPrivate = pSrcBuffer->driverPrivate;
+    I830DRI2BufferPrivatePtr dstPrivate = pDstBuffer->driverPrivate;
     ScreenPtr pScreen = pDraw->pScreen;
     ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
     I830Ptr pI830 = I830PTR(pScrn);
-    PixmapPtr pPixmap = private->pPixmap;
+    PixmapPtr pSrcPixmap = (srcPrivate->attachment == DRI2BufferFrontLeft)
+	? (PixmapPtr) pDraw : srcPrivate->pPixmap;
+    PixmapPtr pDstPixmap = (dstPrivate->attachment == DRI2BufferFrontLeft)
+	? (PixmapPtr) pDraw : dstPrivate->pPixmap;
     RegionPtr pCopyClip;
     GCPtr pGC;
 
@@ -1649,9 +1655,9 @@ I830DRI2CopyRegion(DrawablePtr pDraw, RegionPtr pRegion,
     pCopyClip = REGION_CREATE(pScreen, NULL, 0);
     REGION_COPY(pScreen, pCopyClip, pRegion);
     (*pGC->funcs->ChangeClip) (pGC, CT_REGION, pCopyClip, 0);
-    ValidateGC(pDraw, pGC);
-    (*pGC->ops->CopyArea)(&pPixmap->drawable,
-			  pDraw, pGC, 0, 0, pDraw->width, pDraw->height, 0, 0);
+    ValidateGC(&pDstPixmap->drawable, pGC);
+    (*pGC->ops->CopyArea)(&pSrcPixmap->drawable, &pDstPixmap->drawable,
+			  pGC, 0, 0, pDraw->width, pDraw->height, 0, 0);
     FreeScratchGC(pGC);
 
     /* Emit a flush of the rendering cache, or on the 965 and beyond


More information about the xorg-commit mailing list