From 941a49f91eac02e256706d8821a2cb069ff7ffef Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 28 Apr 2006 14:57:03 -0700 Subject: Commit what applied from Jesse Barnes's i830-exa-latest.patch. --- man/i810.man | 9 +- src/i830.h | 22 +- src/i830_accel.c | 586 ++----------------------------------------------- src/i830_dga.c | 6 + src/i830_dri.c | 5 +- src/i830_driver.c | 124 +++++++++-- src/i830_exa.c | 418 +++++++++++++++++++++++++++++++++++ src/i830_memory.c | 24 +++ src/i830_video.c | 2 - src/i830_xaa.c | 636 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 10 files changed, 1240 insertions(+), 592 deletions(-) create mode 100644 src/i830_exa.c create mode 100644 src/i830_xaa.c diff --git a/man/i810.man b/man/i810.man index 099e1f8a..62d6b73d 100644 --- a/man/i810.man +++ b/man/i810.man @@ -204,6 +204,12 @@ Allows more memory for the offscreen allocator. This usually helps in situations where HDTV movies are required to play but not enough offscreen memory is usually available. Set this to 6144 for upto 1920x1080 HDTV support. Default 0KB (off). +.TP +.BI "Option \*qAccelMethod\*q \*q" string \*q +Choose acceleration architecture, either "XAA" or "EXA". XAA is the old +(but stable) XFree86 based acceleration architecture. EXA is a newer and +simpler acceleration architecture designed to better accelerate the X Render +extension. Default: "XAA". .SH "SEE ALSO" __xservername__(__appmansuffix__), __xconfigfile__(__filemansuffix__), xorgconfig(__appmansuffix__), Xserver(__appmansuffix__), X(__miscmansuffix__) @@ -213,4 +219,5 @@ Jeff Hartmann, Mark Vojkovich, Alan Hourihane, H. J. Lu. 830M and 845G support reworked for XFree86 4.3 by David Dawes and Keith Whitwell. 852GM, 855GM, and 865G support added by David Dawes and Keith Whitwell. 915G and 915GM support added by Alan Hourihane and Keith Whitwell. -Dual Head, Clone and lid status support added by Alan Hourihane. +Dual Head, Clone and lid status support added by Alan Hourihane. EXA support +added by Jesse Barnes. diff --git a/src/i830.h b/src/i830.h index d2276629..edc485be 100644 --- a/src/i830.h +++ b/src/i830.h @@ -68,6 +68,15 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "i830_dri.h" #endif +#ifdef I830_USE_EXA +#include "exa.h" +Bool I830EXAInit(ScreenPtr pScreen); +#endif + +#ifdef I830_USE_XAA +Bool I830XAAInit(ScreenPtr pScreen); +#endif + #include "common.h" /* I830 Video BIOS support */ @@ -203,7 +212,9 @@ typedef struct _I830Rec { I830MemRange FrontBuffer2; I830MemRange Scratch; I830MemRange Scratch2; - +#ifdef I830_USE_EXA + I830MemRange Offscreen; +#endif /* Regions allocated either from the above pools, or from agpgart. */ I830MemRange *CursorMem; I830MemRange *CursorMemARGB; @@ -279,13 +290,22 @@ typedef struct _I830Rec { I830RegRec SavedReg; I830RegRec ModeReg; + Bool useEXA; Bool noAccel; Bool SWCursor; Bool cursorOn; +#ifdef I830_USE_XAA XAAInfoRecPtr AccelInfoRec; +#endif xf86CursorInfoPtr CursorInfoRec; CloseScreenProcPtr CloseScreen; +#ifdef I830_USE_EXA + unsigned int copy_src_pitch; + unsigned int copy_src_off; + ExaDriverPtr EXADriverPtr; +#endif + I830WriteIndexedByteFunc writeControl; I830ReadIndexedByteFunc readControl; I830WriteByteFunc writeStandard; diff --git a/src/i830_accel.c b/src/i830_accel.c index a11f64b9..a1a64880 100644 --- a/src/i830_accel.c +++ b/src/i830_accel.c @@ -7,10 +7,6 @@ #include "config.h" #endif -#ifndef DO_SCANLINE_IMAGE_WRITE -#define DO_SCANLINE_IMAGE_WRITE 0 -#endif - /************************************************************************** Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. @@ -111,7 +107,9 @@ I830WaitLpRing(ScrnInfoPtr pScrn, int n, int timeout_millis) DRICloseScreen(screenInfo.screens[pScrn->scrnIndex]); } #endif +#ifdef I830_USE_XAA pI830->AccelInfoRec = NULL; /* Stops recursive behavior */ +#endif FatalError("lockup\n"); } @@ -210,46 +208,11 @@ I830RefreshRing(ScrnInfoPtr pScrn) pI830->LpRing->space = pI830->LpRing->head - (pI830->LpRing->tail + 8); if (pI830->LpRing->space < 0) pI830->LpRing->space += pI830->LpRing->mem.Size; - +#ifdef I830_USE_XAA if (pI830->AccelInfoRec) pI830->AccelInfoRec->NeedToSync = TRUE; -} - -/* I830 Accel Functions */ - -static void I830SetupForMono8x8PatternFill(ScrnInfoPtr pScrn, - int pattx, int patty, - int fg, int bg, int rop, - unsigned int planemask); -static void I830SubsequentMono8x8PatternFillRect(ScrnInfoPtr pScrn, - int pattx, int patty, - int x, int y, int w, int h); - -static void I830SetupForScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, - int fg, int bg, - int rop, - unsigned int mask); - -static void I830SubsequentScanlineCPUToScreenColorExpandFill(ScrnInfoPtr - pScrn, int x, - int y, int w, - int h, - int skipleft); - -static void I830SubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno); - -#if DO_SCANLINE_IMAGE_WRITE -static void I830SetupForScanlineImageWrite(ScrnInfoPtr pScrn, int rop, - unsigned int planemask, - int trans_color, int bpp, - int depth); -static void I830SubsequentScanlineImageWriteRect(ScrnInfoPtr pScrn, - int x, int y, int w, int h, - int skipleft); -static void I830SubsequentImageWriteScanline(ScrnInfoPtr pScrn, int bufno); #endif -static void I830RestoreAccelState(ScrnInfoPtr pScrn); - +} /* The following function sets up the supported acceleration. Call it * from the FbInit() function in the SVGA driver, or before ScreenInit @@ -258,539 +221,16 @@ static void I830RestoreAccelState(ScrnInfoPtr pScrn); Bool I830AccelInit(ScreenPtr pScreen) { - XAAInfoRecPtr infoPtr; - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - I830Ptr pI830 = I830PTR(pScrn); - int i; - int width = 0; - int nr_buffers = 0; - unsigned char *ptr = NULL; - - if (I810_DEBUG & DEBUG_VERBOSE_ACCEL) - ErrorF("I830AccelInit\n"); - - pI830->AccelInfoRec = infoPtr = XAACreateInfoRec(); - if (!infoPtr) - return FALSE; - - pI830->bufferOffset = 0; - infoPtr->Flags = LINEAR_FRAMEBUFFER | OFFSCREEN_PIXMAPS | PIXMAP_CACHE; - - /* Use the same sync function as the I830. - */ - infoPtr->Sync = I830Sync; - - /* Everything else is different enough to justify different functions */ - { - infoPtr->SolidFillFlags = NO_PLANEMASK; - infoPtr->SetupForSolidFill = I830SetupForSolidFill; - infoPtr->SubsequentSolidFillRect = I830SubsequentSolidFillRect; - } - - { - infoPtr->ScreenToScreenCopyFlags = (NO_PLANEMASK | NO_TRANSPARENCY); - - infoPtr->SetupForScreenToScreenCopy = I830SetupForScreenToScreenCopy; - infoPtr->SubsequentScreenToScreenCopy = - I830SubsequentScreenToScreenCopy; - } - - { - infoPtr->SetupForMono8x8PatternFill = I830SetupForMono8x8PatternFill; - infoPtr->SubsequentMono8x8PatternFillRect = - I830SubsequentMono8x8PatternFillRect; - - infoPtr->Mono8x8PatternFillFlags = (HARDWARE_PATTERN_PROGRAMMED_BITS | - HARDWARE_PATTERN_SCREEN_ORIGIN | - HARDWARE_PATTERN_PROGRAMMED_ORIGIN | - BIT_ORDER_IN_BYTE_MSBFIRST | - NO_PLANEMASK); - - } +#ifdef I830_USE_EXA + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + I830Ptr pI830 = I830PTR(pScrn); - /* On the primary screen */ - if (pI830->init == 0) { - if (pI830->Scratch.Size != 0) { - width = ((pScrn->displayWidth + 31) & ~31) / 8; - nr_buffers = pI830->Scratch.Size / width; - ptr = pI830->FbBase + pI830->Scratch.Start; - } - } else { - /* On the secondary screen */ - I830Ptr pI8301 = I830PTR(pI830->entityPrivate->pScrn_1); - if (pI8301->Scratch2.Size != 0) { - width = ((pScrn->displayWidth + 31) & ~31) / 8; - nr_buffers = pI8301->Scratch2.Size / width; - /* We have to use the primary screen's FbBase, as that's where - * we allocated Scratch2, so we get the correct pointer */ - ptr = pI8301->FbBase + pI8301->Scratch2.Start; - } - } - - if (nr_buffers) { - pI830->NumScanlineColorExpandBuffers = nr_buffers; - pI830->ScanlineColorExpandBuffers = (unsigned char **) - xnfcalloc(nr_buffers, sizeof(unsigned char *)); - - for (i = 0; i < nr_buffers; i++, ptr += width) - pI830->ScanlineColorExpandBuffers[i] = ptr; - - infoPtr->ScanlineCPUToScreenColorExpandFillFlags = - (NO_PLANEMASK | ROP_NEEDS_SOURCE | BIT_ORDER_IN_BYTE_MSBFIRST); - - infoPtr->ScanlineColorExpandBuffers = (unsigned char **) - xnfcalloc(1, sizeof(unsigned char *)); - infoPtr->NumScanlineColorExpandBuffers = 1; - - infoPtr->ScanlineColorExpandBuffers[0] = - pI830->ScanlineColorExpandBuffers[0]; - pI830->nextColorExpandBuf = 0; - - infoPtr->SetupForScanlineCPUToScreenColorExpandFill = - I830SetupForScanlineCPUToScreenColorExpandFill; - - infoPtr->SubsequentScanlineCPUToScreenColorExpandFill = - I830SubsequentScanlineCPUToScreenColorExpandFill; - - infoPtr->SubsequentColorExpandScanline = - I830SubsequentColorExpandScanline; - -#if DO_SCANLINE_IMAGE_WRITE - infoPtr->NumScanlineImageWriteBuffers = 1; - infoPtr->ScanlineImageWriteBuffers = infoPtr->ScanlineColorExpandBuffers; - infoPtr->SetupForScanlineImageWrite = I830SetupForScanlineImageWrite; - infoPtr->SubsequentScanlineImageWriteRect = - I830SubsequentScanlineImageWriteRect; - infoPtr->SubsequentImageWriteScanline = I830SubsequentImageWriteScanline; - infoPtr->ScanlineImageWriteFlags = NO_GXCOPY | - NO_PLANEMASK | - ROP_NEEDS_SOURCE | - SCANLINE_PAD_DWORD; + if (pI830->useEXA) + return I830EXAInit(pScreen); #endif - } - - { - Bool shared_accel = FALSE; - int i; - - for(i = 0; i < pScrn->numEntities; i++) { - if(xf86IsEntityShared(pScrn->entityList[i])) - shared_accel = TRUE; - } - if(shared_accel == TRUE) - infoPtr->RestoreAccelState = I830RestoreAccelState; - } - - I830SelectBuffer(pScrn, I830_SELECT_FRONT); - - return XAAInit(pScreen, infoPtr); -} - -void -I830SetupForSolidFill(ScrnInfoPtr pScrn, int color, int rop, - unsigned int planemask) -{ - I830Ptr pI830 = I830PTR(pScrn); - - if (I810_DEBUG & DEBUG_VERBOSE_ACCEL) - ErrorF("I830SetupForFillRectSolid color: %x rop: %x mask: %x\n", - color, rop, planemask); - - pI830->BR[13] = ((XAAGetPatternROP(rop) << 16) | - (pScrn->displayWidth * pI830->cpp)); - - pI830->BR[16] = color; - - switch (pScrn->bitsPerPixel) { - case 8: - break; - case 16: - pI830->BR[13] |= (1 << 24); - break; - case 32: - pI830->BR[13] |= ((1 << 25) | (1 << 24)); - break; - } -} - -void -I830SubsequentSolidFillRect(ScrnInfoPtr pScrn, int x, int y, int w, int h) -{ - I830Ptr pI830 = I830PTR(pScrn); - - if (I810_DEBUG & DEBUG_VERBOSE_ACCEL) - ErrorF("I830SubsequentFillRectSolid %d,%d %dx%d\n", x, y, w, h); - - { - BEGIN_LP_RING(6); - - if (pScrn->bitsPerPixel == 32) { - OUT_RING(COLOR_BLT_CMD | COLOR_BLT_WRITE_ALPHA | - COLOR_BLT_WRITE_RGB); - } else { - OUT_RING(COLOR_BLT_CMD); - } - OUT_RING(pI830->BR[13]); - OUT_RING((h << 16) | (w * pI830->cpp)); - OUT_RING(pI830->bufferOffset + (y * pScrn->displayWidth + x) * - pI830->cpp); - OUT_RING(pI830->BR[16]); - OUT_RING(0); - - ADVANCE_LP_RING(); - } -} - -void -I830SetupForScreenToScreenCopy(ScrnInfoPtr pScrn, int xdir, int ydir, int rop, - unsigned int planemask, int transparency_color) -{ - I830Ptr pI830 = I830PTR(pScrn); - - if (I810_DEBUG & DEBUG_VERBOSE_ACCEL) - ErrorF("I830SetupForScreenToScreenCopy %d %d %x %x %d\n", - xdir, ydir, rop, planemask, transparency_color); - - pI830->BR[13] = (pScrn->displayWidth * pI830->cpp); - pI830->BR[13] |= XAAGetCopyROP(rop) << 16; - - switch (pScrn->bitsPerPixel) { - case 8: - break; - case 16: - pI830->BR[13] |= (1 << 24); - break; - case 32: - pI830->BR[13] |= ((1 << 25) | (1 << 24)); - break; - } - -} - -void -I830SubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, int src_x1, int src_y1, - int dst_x1, int dst_y1, int w, int h) -{ - I830Ptr pI830 = I830PTR(pScrn); - int dst_x2, dst_y2; - - if (I810_DEBUG & DEBUG_VERBOSE_ACCEL) - ErrorF("I830SubsequentScreenToScreenCopy %d,%d - %d,%d %dx%d\n", - src_x1, src_y1, dst_x1, dst_y1, w, h); - - dst_x2 = dst_x1 + w; - dst_y2 = dst_y1 + h; - - { - BEGIN_LP_RING(8); - - if (pScrn->bitsPerPixel == 32) { - OUT_RING(XY_SRC_COPY_BLT_CMD | XY_SRC_COPY_BLT_WRITE_ALPHA | - XY_SRC_COPY_BLT_WRITE_RGB); - } else { - OUT_RING(XY_SRC_COPY_BLT_CMD); - } - OUT_RING(pI830->BR[13]); - OUT_RING((dst_y1 << 16) | (dst_x1 & 0xffff)); - OUT_RING((dst_y2 << 16) | (dst_x2 & 0xffff)); - OUT_RING(pI830->bufferOffset); - OUT_RING((src_y1 << 16) | (src_x1 & 0xffff)); - OUT_RING(pI830->BR[13] & 0xFFFF); - OUT_RING(pI830->bufferOffset); - - ADVANCE_LP_RING(); - } -} - -static void -I830SetupForMono8x8PatternFill(ScrnInfoPtr pScrn, int pattx, int patty, - int fg, int bg, int rop, - unsigned int planemask) -{ - I830Ptr pI830 = I830PTR(pScrn); - - if (I810_DEBUG & DEBUG_VERBOSE_ACCEL) - ErrorF("I830SetupForMono8x8PatternFill\n"); - - pI830->BR[16] = pattx; - pI830->BR[17] = patty; - pI830->BR[18] = bg; - pI830->BR[19] = fg; - - pI830->BR[13] = (pScrn->displayWidth * pI830->cpp); /* In bytes */ - pI830->BR[13] |= XAAGetPatternROP(rop) << 16; - if (bg == -1) - pI830->BR[13] |= (1 << 28); - - switch (pScrn->bitsPerPixel) { - case 8: - break; - case 16: - pI830->BR[13] |= (1 << 24); - break; - case 32: - pI830->BR[13] |= ((1 << 25) | (1 << 24)); - break; - } - -} - -static void -I830SubsequentMono8x8PatternFillRect(ScrnInfoPtr pScrn, int pattx, int patty, - int x, int y, int w, int h) -{ - I830Ptr pI830 = I830PTR(pScrn); - int x1, x2, y1, y2; - - x1 = x; - x2 = x + w; - y1 = y; - y2 = y + h; - - if (I810_DEBUG & DEBUG_VERBOSE_ACCEL) - ErrorF("I830SubsequentMono8x8PatternFillRect\n"); - - { - BEGIN_LP_RING(10); - - if (pScrn->bitsPerPixel == 32) { - OUT_RING(XY_MONO_PAT_BLT_CMD | XY_MONO_PAT_BLT_WRITE_ALPHA | - XY_MONO_PAT_BLT_WRITE_RGB | - ((patty << 8) & XY_MONO_PAT_VERT_SEED) | - ((pattx << 12) & XY_MONO_PAT_HORT_SEED)); - } else { - OUT_RING(XY_MONO_PAT_BLT_CMD | - ((patty << 8) & XY_MONO_PAT_VERT_SEED) | - ((pattx << 12) & XY_MONO_PAT_HORT_SEED)); - } - OUT_RING(pI830->BR[13]); - OUT_RING((y1 << 16) | x1); - OUT_RING((y2 << 16) | x2); - OUT_RING(pI830->bufferOffset); - OUT_RING(pI830->BR[18]); /* bg */ - OUT_RING(pI830->BR[19]); /* fg */ - OUT_RING(pI830->BR[16]); /* pattern data */ - OUT_RING(pI830->BR[17]); - OUT_RING(0); - ADVANCE_LP_RING(); - } -} - -static void -I830GetNextScanlineColorExpandBuffer(ScrnInfoPtr pScrn) -{ - I830Ptr pI830 = I830PTR(pScrn); - XAAInfoRecPtr infoPtr = pI830->AccelInfoRec; - - if (pI830->nextColorExpandBuf == pI830->NumScanlineColorExpandBuffers) - I830Sync(pScrn); - - infoPtr->ScanlineColorExpandBuffers[0] = - pI830->ScanlineColorExpandBuffers[pI830->nextColorExpandBuf]; - - if (I810_DEBUG & DEBUG_VERBOSE_ACCEL) - ErrorF("using color expand buffer %d\n", pI830->nextColorExpandBuf); - - pI830->nextColorExpandBuf++; -} - -static void -I830SetupForScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, - int fg, int bg, int rop, - unsigned int planemask) -{ - I830Ptr pI830 = I830PTR(pScrn); - - if (I810_DEBUG & DEBUG_VERBOSE_ACCEL) - ErrorF("I830SetupForScanlineScreenToScreenColorExpand %d %d %x %x\n", - fg, bg, rop, planemask); - - /* Fill out register values */ - pI830->BR[13] = (pScrn->displayWidth * pI830->cpp); - pI830->BR[13] |= XAAGetCopyROP(rop) << 16; - if (bg == -1) - pI830->BR[13] |= (1 << 29); - - switch (pScrn->bitsPerPixel) { - case 8: - break; - case 16: - pI830->BR[13] |= (1 << 24); - break; - case 32: - pI830->BR[13] |= ((1 << 25) | (1 << 24)); - break; - } - - pI830->BR[18] = bg; - pI830->BR[19] = fg; - - I830GetNextScanlineColorExpandBuffer(pScrn); -} - -static void -I830SubsequentScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, - int x, int y, - int w, int h, int skipleft) -{ - I830Ptr pI830 = I830PTR(pScrn); - - if (I810_DEBUG & DEBUG_VERBOSE_ACCEL) - ErrorF("I830SubsequentScanlineCPUToScreenColorExpandFill " - "%d,%d %dx%x %d\n", x, y, w, h, skipleft); - - /* Fill out register values */ - pI830->BR[9] = (pI830->bufferOffset + - (y * pScrn->displayWidth + x) * pI830->cpp); - pI830->BR[11] = ((1 << 16) | w); -} - -static void -I830SubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno) -{ - I830Ptr pI830 = I830PTR(pScrn); - - if (pI830->init == 0) { - pI830->BR[12] = (pI830->AccelInfoRec->ScanlineColorExpandBuffers[0] - - pI830->FbBase); - } else { - I830Ptr pI8301 = I830PTR(pI830->entityPrivate->pScrn_1); - - /* We have to use the primary screen's FbBase, as that's where - * we allocated Scratch2, so we get the correct pointer */ - pI830->BR[12] = (pI830->AccelInfoRec->ScanlineColorExpandBuffers[0] - - pI8301->FbBase); - } - - if (I810_DEBUG & DEBUG_VERBOSE_ACCEL) - ErrorF("I830SubsequentColorExpandScanline %d (addr %x)\n", - bufno, pI830->BR[12]); - - { - BEGIN_LP_RING(8); - - if (pScrn->bitsPerPixel == 32) { - OUT_RING(XY_MONO_SRC_BLT_CMD | XY_MONO_SRC_BLT_WRITE_ALPHA | - XY_MONO_SRC_BLT_WRITE_RGB); - } else { - OUT_RING(XY_MONO_SRC_BLT_CMD); - } - OUT_RING(pI830->BR[13]); - OUT_RING(0); /* x1 = 0, y1 = 0 */ - OUT_RING(pI830->BR[11]); /* x2 = w, y2 = 1 */ - OUT_RING(pI830->BR[9]); /* dst addr */ - OUT_RING(pI830->BR[12]); /* src addr */ - OUT_RING(pI830->BR[18]); /* bg */ - OUT_RING(pI830->BR[19]); /* fg */ - - ADVANCE_LP_RING(); - } - - /* Advance to next scanline. - */ - pI830->BR[9] += pScrn->displayWidth * pI830->cpp; - I830GetNextScanlineColorExpandBuffer(pScrn); -} - -#if DO_SCANLINE_IMAGE_WRITE -static void -I830SetupForScanlineImageWrite(ScrnInfoPtr pScrn, int rop, - unsigned int planemask, int trans_color, - int bpp, int depth) -{ - I830Ptr pI830 = I830PTR(pScrn); - - if (I810_DEBUG & DEBUG_VERBOSE_ACCEL) - ErrorF("I830SetupForScanlineImageWrite %x %x\n", rop, planemask); - - /* Fill out register values */ - pI830->BR[13] = (pScrn->displayWidth * pI830->cpp); - pI830->BR[13] |= XAAGetCopyROP(rop) << 16; - - switch (pScrn->bitsPerPixel) { - case 8: - break; - case 16: - pI830->BR[13] |= (1 << 24); - break; - case 32: - pI830->BR[13] |= ((1 << 25) | (1 << 24)); - break; - } - - I830GetNextScanlineColorExpandBuffer(pScrn); -} - -static void -I830SubsequentScanlineImageWriteRect(ScrnInfoPtr pScrn, int x, int y, - int w, int h, int skipleft) -{ - I830Ptr pI830 = I830PTR(pScrn); - - if (I810_DEBUG & DEBUG_VERBOSE_ACCEL) - ErrorF("I830SubsequentScanlineImageWriteRect " - "%d,%d %dx%x %d\n", x, y, w, h, skipleft); - - /* Fill out register values */ - pI830->BR[9] = (pI830->bufferOffset + - (y * pScrn->displayWidth + x) * pI830->cpp); - pI830->BR[11] = ((1 << 16) | w); -} - -static void -I830SubsequentImageWriteScanline(ScrnInfoPtr pScrn, int bufno) -{ - I830Ptr pI830 = I830PTR(pScrn); - - if (pI830->init == 0) { - pI830->BR[12] = (pI830->AccelInfoRec->ScanlineColorExpandBuffers[0] - - pI830->FbBase); - } else { - I830Ptr pI8301 = I830PTR(pI830->entityPrivate->pScrn_1); - - /* We have to use the primary screen's FbBase, as that's where - * we allocated Scratch2, so we get the correct pointer */ - pI830->BR[12] = (pI830->AccelInfoRec->ScanlineColorExpandBuffers[0] - - pI8301->FbBase); - } - - if (I810_DEBUG & DEBUG_VERBOSE_ACCEL) - ErrorF("I830SubsequentImageWriteScanline %d (addr %x)\n", - bufno, pI830->BR[12]); - - { - BEGIN_LP_RING(8); - - if (pScrn->bitsPerPixel == 32) { - OUT_RING(XY_SRC_COPY_BLT_CMD | XY_SRC_COPY_BLT_WRITE_ALPHA | - XY_SRC_COPY_BLT_WRITE_RGB); - } else { - OUT_RING(XY_SRC_COPY_BLT_CMD); - } - OUT_RING(pI830->BR[13]); - OUT_RING(0); /* x1 = 0, y1 = 0 */ - OUT_RING(pI830->BR[11]); /* x2 = w, y2 = 1 */ - OUT_RING(pI830->BR[9]); /* dst addr */ - OUT_RING(0); /* source origin (0,0) */ - OUT_RING(pI830->BR[11] & 0xffff); /* source pitch */ - OUT_RING(pI830->BR[12]); /* src addr */ - - ADVANCE_LP_RING(); - } - - /* Advance to next scanline. - */ - pI830->BR[9] += pScrn->displayWidth * pI830->cpp; - I830GetNextScanlineColorExpandBuffer(pScrn); -} -#endif - -/* Support for multiscreen */ -static void -I830RestoreAccelState(ScrnInfoPtr pScrn) -{ -#if 0 - /* might be needed, but everything is on a ring, so I don't think so */ - I830Sync(pScrn); +#ifdef I830_USE_XAA + return I830XAAInit(pScreen); #endif + return FALSE; } + diff --git a/src/i830_dga.c b/src/i830_dga.c index 1129fa31..08207d39 100644 --- a/src/i830_dga.c +++ b/src/i830_dga.c @@ -238,6 +238,7 @@ static void I830_FillRect(ScrnInfoPtr pScrn, int x, int y, int w, int h, unsigned long color) { +#ifdef I830_USE_XAA I830Ptr pI830 = I830PTR(pScrn); MARKER(); @@ -247,11 +248,13 @@ I830_FillRect(ScrnInfoPtr pScrn, (*pI830->AccelInfoRec->SubsequentSolidFillRect) (pScrn, x, y, w, h); SET_SYNC_FLAG(pI830->AccelInfoRec); } +#endif } static void I830_Sync(ScrnInfoPtr pScrn) { +#ifdef I830_USE_XAA I830Ptr pI830 = I830PTR(pScrn); MARKER(); @@ -259,12 +262,14 @@ I830_Sync(ScrnInfoPtr pScrn) if (pI830->AccelInfoRec) { (*pI830->AccelInfoRec->Sync) (pScrn); } +#endif } static void I830_BlitRect(ScrnInfoPtr pScrn, int srcx, int srcy, int w, int h, int dstx, int dsty) { +#ifdef I830_USE_XAA I830Ptr pI830 = I830PTR(pScrn); MARKER(); @@ -279,6 +284,7 @@ I830_BlitRect(ScrnInfoPtr pScrn, dstx, dsty, w, h); SET_SYNC_FLAG(pI830->AccelInfoRec); } +#endif } #if 0 diff --git a/src/i830_dri.c b/src/i830_dri.c index 13d2cfdd..c1596861 100644 --- a/src/i830_dri.c +++ b/src/i830_dri.c @@ -1017,7 +1017,9 @@ I830DRIInitBuffers(WindowPtr pWin, RegionPtr prgn, CARD32 index) } I830SelectBuffer(pScrn, I830_SELECT_FRONT); +#ifdef I830_USE_XAA pI830->AccelInfoRec->NeedToSync = TRUE; +#endif } /* This routine is a modified form of XAADoBitBlt with the calls to @@ -1178,8 +1180,9 @@ I830DRIMoveBuffers(WindowPtr pParent, DDXPointRec ptOldOrg, DEALLOCATE_LOCAL(pptNew1); DEALLOCATE_LOCAL(pboxNew1); } - +#ifdef I830_USE_XAA pI830->AccelInfoRec->NeedToSync = TRUE; +#endif } /* Initialize the first context */ diff --git a/src/i830_driver.c b/src/i830_driver.c index 053ccd1d..de510e69 100644 --- a/src/i830_driver.c +++ b/src/i830_driver.c @@ -189,6 +189,17 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "dri.h" #endif +#ifdef I830_USE_EXA +const char *I830exaSymbols[] = { + "exaGetVersion", + "exaDriverInit", + "exaDriverFini", + "exaOffscreenAlloc", + "exaOffscreenFree", + NULL +}; +#endif + #define BIT(x) (1 << (x)) #define MAX(a,b) ((a) > (b) ? (a) : (b)) #define NB_OF(x) (sizeof (x) / sizeof (*x)) @@ -227,6 +238,9 @@ static PciChipsets I830BIOSPciChipsets[] = { */ typedef enum { +#if defined(I830_USE_XAA) && defined(I830_USE_EXA) + OPTION_ACCELMETHOD, +#endif OPTION_NOACCEL, OPTION_SW_CURSOR, OPTION_CACHE_LINES, @@ -248,6 +262,9 @@ typedef enum { } I830Opts; static OptionInfoRec I830BIOSOptions[] = { +#if defined(I830_USE_XAA) && defined(I830_USE_EXA) + {OPTION_ACCELMETHOD, "AccelMethod", OPTV_ANYSTR, {0}, FALSE}, +#endif {OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE}, {OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE}, {OPTION_CACHE_LINES, "CacheLines", OPTV_INTEGER, {0}, FALSE}, @@ -2448,6 +2465,42 @@ I830BIOSPreInit(ScrnInfoPtr pScrn, int flags) if (xf86ReturnOptValBool(pI830->Options, OPTION_NOACCEL, FALSE)) { pI830->noAccel = TRUE; } + + /* + * The ugliness below: + * If either XAA or EXA (exclusive) is compiled in, default to it. + * + * If both are compiled in, and the user didn't specify noAccel, use the + * config option AccelMethod to determine which to use, defaulting to XAA + * if none is specified, or if the string was unrecognized. + * + * All this *could* go away if we removed XAA support from this driver, + * for example. :) + */ + if (!pI830->noAccel) { +#if (defined(I830_USE_EXA) && defined(I830_USE_XAA)) || !defined(I830_USE_EXA) + pI830->useEXA = FALSE; +#else + pI830->useEXA = TRUE; +#endif +#if defined(I830_USE_XAA) && defined(I830_USE_EXA) + int from = X_DEFAULT; + if ((s = (char *)xf86GetOptValString(pI830->Options, + OPTION_ACCELMETHOD))) { + if (!xf86NameCmp(s, "EXA")) { + from = X_CONFIG; + pI830->useEXA = TRUE; + } + else if (!xf86NameCmp(s, "XAA")) { + from = X_CONFIG; + pI830->useEXA = FALSE; + } + } +#endif + xf86DrvMsg(pScrn->scrnIndex, from, "Using %s for acceleration\n", + pI830->useEXA ? "EXA" : "XAA"); + } + if (xf86ReturnOptValBool(pI830->Options, OPTION_SW_CURSOR, FALSE)) { pI830->SWCursor = TRUE; } @@ -3468,14 +3521,25 @@ I830BIOSPreInit(ScrnInfoPtr pScrn, int flags) xf86LoaderReqSymLists(I810fbSymbols, NULL); - if (!pI830->noAccel) { +#ifdef I830_USE_XAA + if (!pI830->noAccel && !pI830->useEXA) { if (!xf86LoadSubModule(pScrn, "xaa")) { PreInitCleanup(pScrn); return FALSE; } xf86LoaderReqSymLists(I810xaaSymbols, NULL); } +#endif +#ifdef I830_USE_EXA + if (!pI830->noAccel && pI830->useEXA) { + if (!xf86LoadSubModule(pScrn, "exa")) { + PreInitCleanup(pScrn); + return FALSE; + } + xf86LoaderReqSymLists(I830exaSymbols, NULL); + } +#endif if (!pI830->SWCursor) { if (!xf86LoadSubModule(pScrn, "ramdac")) { PreInitCleanup(pScrn); @@ -3622,16 +3686,25 @@ ResetState(ScrnInfoPtr pScrn, Bool flush) /* Reset the fence registers to 0 */ for (i = 0; i < 8; i++) OUTREG(FENCE + i * 4, 0); - /* Flush the ring buffer (if enabled), then disable it. */ - if (pI830->AccelInfoRec != NULL && flush) { - temp = INREG(LP_RING + RING_LEN); - if (temp & 1) { - I830RefreshRing(pScrn); - I830Sync(pScrn); - DO_RING_IDLE(); - } - } + /* God this is ugly */ +#define flush_ring() do { \ + temp = INREG(LP_RING + RING_LEN); \ + if (temp & 1) { \ + I830RefreshRing(pScrn); \ + I830Sync(pScrn); \ + DO_RING_IDLE(); \ + } \ + } while(0) +#ifdef I830_USE_XAA + if (!pI830->useEXA && flush && pI830->AccelInfoRec) + flush_ring(); +#endif +#ifdef I830_USE_XAA + if (pI830->useEXA && flush && pI830->EXADriverPtr) + flush_ring(); +#endif + OUTREG(LP_RING + RING_LEN, 0); OUTREG(LP_RING + RING_HEAD, 0); OUTREG(LP_RING + RING_TAIL, 0); @@ -5309,8 +5382,14 @@ I830BIOSLeaveVT(int scrnIndex, int flags) RestoreBIOSMemSize(pScrn); if (I830IsPrimary(pScrn)) I830UnbindAGPMemory(pScrn); - if (pI830->AccelInfoRec) +#ifdef I830_USE_XAA + if (!pI830->useEXA && pI830->AccelInfoRec) pI830->AccelInfoRec->NeedToSync = FALSE; +#endif +#ifdef I830_USE_EXA + if (pI830->useEXA && pI830->EXADriverPtr) + pI830->EXADriverPtr->card.needsSync = TRUE; +#endif /* DO IT AGAIN! AS IT SEEMS THAT SOME LFPs FLICKER OTHERWISE */ if (I830IsPrimary(pScrn)) { @@ -5644,10 +5723,18 @@ I830BIOSSwitchMode(int scrnIndex, DisplayModePtr mode, int flags) #endif /* Sync the engine before mode switch */ - if (pI830->AccelInfoRec && pI830->AccelInfoRec->NeedToSync) { +#ifdef I830_USE_XAA + if (!pI830->noAccel && !pI830->useEXA) (*pI830->AccelInfoRec->Sync)(pScrn); pI830->AccelInfoRec->NeedToSync = FALSE; } +#endif +#ifdef I830_USE_EXA + if (!pI830->noAccel && pI830->useEXA) { + ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex]; + (*pI830->EXADriverPtr->accel.WaitMarker)(pScreen, 0); + } +#endif /* Check if our currentmode is about to change. We do this so if we * are rotating, we don't need to call the mode setup again. @@ -5801,7 +5888,9 @@ I830BIOSCloseScreen(int scrnIndex, ScreenPtr pScreen) { ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; I830Ptr pI830 = I830PTR(pScrn); +#ifdef I830_USE_XAA XAAInfoRecPtr infoPtr = pI830->AccelInfoRec; +#endif pI830->closing = TRUE; #ifdef XF86DRI @@ -5827,14 +5916,21 @@ I830BIOSCloseScreen(int scrnIndex, ScreenPtr pScreen) xfree(pI830->ScanlineColorExpandBuffers); pI830->ScanlineColorExpandBuffers = 0; } - +#ifdef I830_USE_XAA if (infoPtr) { if (infoPtr->ScanlineColorExpandBuffers) xfree(infoPtr->ScanlineColorExpandBuffers); XAADestroyInfoRec(infoPtr); pI830->AccelInfoRec = NULL; } - +#endif +#ifdef I830_USE_EXA + if (pI830->useEXA && pI830->EXADriverPtr) { + exaDriverFini(pScreen); + xfree(pI830->EXADriverPtr); + pI830->EXADriverPtr = NULL; + } +#endif if (pI830->CursorInfoRec) { xf86DestroyCursorInfoRec(pI830->CursorInfoRec); pI830->CursorInfoRec = 0; diff --git a/src/i830_exa.c b/src/i830_exa.c new file mode 100644 index 00000000..a6aa6a79 --- /dev/null +++ b/src/i830_exa.c @@ -0,0 +1,418 @@ +/************************************************************************** + +Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. +All Rights Reserved. +Copyright (c) 2005 Jesse Barnes + Based on code from i830_xaa.c. + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sub license, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice (including the +next paragraph) shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. +IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +**************************************************************************/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "xf86_ansic.h" +#include "xf86.h" +#include "xaarop.h" +#include "i830.h" +#include "i810_reg.h" + +int I830CopyROP[16] = +{ + ROP_0, /* GXclear */ + ROP_DSa, /* GXand */ + ROP_SDna, /* GXandReverse */ + ROP_S, /* GXcopy */ + ROP_DSna, /* GXandInverted */ + ROP_D, /* GXnoop */ + ROP_DSx, /* GXxor */ + ROP_DSo, /* GXor */ + ROP_DSon, /* GXnor */ + ROP_DSxn, /* GXequiv */ + ROP_Dn, /* GXinvert*/ + ROP_SDno, /* GXorReverse */ + ROP_Sn, /* GXcopyInverted */ + ROP_DSno, /* GXorInverted */ + ROP_DSan, /* GXnand */ + ROP_1 /* GXset */ +}; + +static int I830PatternROP[16] = +{ + ROP_0, + ROP_DPa, + ROP_PDna, + ROP_P, + ROP_DPna, + ROP_D, + ROP_DPx, + ROP_DPo, + ROP_DPon, + ROP_PDxn, + ROP_Dn, + ROP_PDno, + ROP_Pn, + ROP_DPno, + ROP_DPan, + ROP_1 +}; + +void i830ScratchSave(ScreenPtr pScreen, ExaOffscreenArea *area); +Bool i830UploadToScreen(PixmapPtr pDst, char *src, int src_pitch); +Bool i830UploadToScratch(PixmapPtr pSrc, PixmapPtr pDst); +Bool i830DownloadFromScreen(PixmapPtr pSrc, int x, int y, int w, int h, + char *dst, int dst_pitch); + +/** + * I830EXASync - wait for a command to finish + * @pScreen: current screen + * @marker: marker command to wait for + * + * Wait for the command specified by @marker to finish, then return. + */ +static void +I830EXASync(ScreenPtr pScreen, int marker) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + I830Ptr pI830 = I830PTR(pScrn); + +#ifdef XF86DRI + /* VT switching tries to do this. */ + if (!pI830->LockHeld && pI830->directRenderingEnabled) + return; +#endif + + if (pI830->entityPrivate && !pI830->entityPrivate->RingRunning) + return; + + /* Send a flush instruction and then wait till the ring is empty. + * This is stronger than waiting for the blitter to finish as it also + * flushes the internal graphics caches. + */ + { + BEGIN_LP_RING(2); + OUT_RING(MI_FLUSH | MI_WRITE_DIRTY_STATE | MI_INVALIDATE_MAP_CACHE); + OUT_RING(MI_NOOP); /* pad to quadword */ + ADVANCE_LP_RING(); + } + + I830WaitLpRing(pScrn, pI830->LpRing->mem.Size - 8, 0); + + pI830->LpRing->space = pI830->LpRing->mem.Size - 8; + pI830->nextColorExpandBuf = 0; +} + +/** + * I830EXAPrepareSolid - prepare for a Solid operation, if possible + * + * TODO: + * - support planemask using FILL_MONO_SRC_BLT_CMD? + */ +static Bool +I830EXAPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planemask, Pixel fg) +{ + ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum]; + I830Ptr pI830 = I830PTR(pScrn); + + if (planemask != (Pixel)~0) + return FALSE; + + pI830->BR[13] = exaGetPixmapPitch(pPixmap); + pI830->BR[13] |= I830PatternROP[alu] << 16; + + pI830->BR[16] = fg; + + /* + * Depth: 00 - 8 bit, 01 - 16 bit, 10 - 24 bit, 11 - 32 bit + */ + switch (pScrn->bitsPerPixel) { + case 8: + pI830->BR[13] |= ((0 << 25) | (0 << 24)); + break; + case 16: + pI830->BR[13] |= ((0 << 25) | (1 << 24)); + break; + case 32: + pI830->BR[13] |= ((1 << 25) | (1 << 24)); + break; + } + return TRUE; +} + +static void +I830EXASolid(PixmapPtr pPixmap, int x1, int y1, int x2, int y2) +{ + ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum]; + I830Ptr pI830 = I830PTR(pScrn); + int h, w; + unsigned int offset; + + offset = exaGetPixmapOffset(pPixmap) + y1 * exaGetPixmapPitch(pPixmap) + + x1 * (pPixmap->drawable.bitsPerPixel / 8); + + h = y2 - y1; + w = x2 - x1; + + { + BEGIN_LP_RING(6); + + if (pScrn->bitsPerPixel == 32) + OUT_RING(COLOR_BLT_CMD | COLOR_BLT_WRITE_ALPHA | + COLOR_BLT_WRITE_RGB); + else + OUT_RING(COLOR_BLT_CMD); + + OUT_RING(pI830->BR[13]); + OUT_RING((h << 16) | (w * (pPixmap->drawable.bitsPerPixel/8))); + OUT_RING(offset); + OUT_RING(pI830->BR[16]); + OUT_RING(0); + + ADVANCE_LP_RING(); + } +} + +static void +I830EXADoneSolid(PixmapPtr pPixmap) +{ + return; +} + +/** + * TODO: + * - support planemask using FULL_BLT_CMD? + */ +static Bool +I830EXAPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int xdir, + int ydir, int alu, Pixel planemask) +{ + ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum]; + I830Ptr pI830 = I830PTR(pScrn); + + if (planemask != (Pixel)~0) + return FALSE; + + pI830->copy_src_pitch = exaGetPixmapPitch(pSrcPixmap); + pI830->copy_src_off = exaGetPixmapOffset(pSrcPixmap); + + pI830->BR[13] = exaGetPixmapPitch(pDstPixmap); + pI830->BR[13] |= I830CopyROP[alu] << 16; + + switch (pScrn->bitsPerPixel) { + case 8: + break; + case 16: + pI830->BR[13] |= (1 << 24); + break; + case 32: + pI830->BR[13] |= ((1 << 25) | (1 << 24)); + break; + } + return TRUE; +} + +static void +I830EXACopy(PixmapPtr pDstPixmap, int src_x1, int src_y1, int dst_x1, + int dst_y1, int w, int h) +{ + ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum]; + I830Ptr pI830 = I830PTR(pScrn); + int dst_x2, dst_y2; + unsigned int src_off, dst_off; + + dst_x2 = dst_x1 + w; + dst_y2 = dst_y1 + h; + + src_off = pI830->copy_src_off; + dst_off = exaGetPixmapOffset(pDstPixmap); + + { + BEGIN_LP_RING(8); + + if (pScrn->bitsPerPixel == 32) + OUT_RING(XY_SRC_COPY_BLT_CMD | XY_SRC_COPY_BLT_WRITE_ALPHA | + XY_SRC_COPY_BLT_WRITE_RGB); + else + OUT_RING(XY_SRC_COPY_BLT_CMD); + + OUT_RING(pI830->BR[13]); + OUT_RING((dst_y1 << 16) | (dst_x1 & 0xffff)); + OUT_RING((dst_y2 << 16) | (dst_x2 & 0xffff)); + OUT_RING(dst_off); + OUT_RING((src_y1 << 16) | (src_x1 & 0xffff)); + OUT_RING(pI830->copy_src_pitch); + OUT_RING(src_off); + + ADVANCE_LP_RING(); + } +} + +static void +I830EXADoneCopy(PixmapPtr pDstPixmap) +{ + return; +} + +#if 0 /* Not done (or even started for that matter) */ +static Bool +I830EXAUploadToScreen(PixmapPtr pDst, char *src, int src_pitch) +{ + ScrnInfoPtr pScrn = xf86Screens[pDst->drawable.pScreen->myNum]; + I830Ptr pI830 = I830PTR(pScrn); + unsigned char *dst = pDst->devPrivate.ptr; + int dst_pitch = exaGetPixmapPitch(pDst); + int size = src_pitch < dst_pitch ? src_pitch : dst_pitch; + int h = pDst->drawable.height; + + I830Sync(pScrn); + + while(h--) { + i830MemCopyToVideoRam(pI830, dst, (unsigned char *)src, size); + src += src_pitch; + dst += dst_pitch; + } + + return TRUE; +} + +static Bool +I830EXADownloadFromScreen(PixmapPtr pSrc, int x, int y, int w, int h, + char *dst, int dst_pitch) +{ + ScrnInfoPtr pScrn = xf86Screens[pSrc->drawable.pScreen->myNum]; + I830Ptr pI830 = I830PTR(pScrn); + unsigned char *src = pSrc->devPrivate.ptr; + int src_pitch = exaGetPixmapPitch(pSrc); + int size = src_pitch < dst_pitch ? src_pitch : dst_pitch; + + I830Sync(pScrn); + + while(h--) { + i830MemCopyFromVideoRam(pI830, (unsigned char *)dst, src, size); + src += src_pitch; + dst += dst_pitch; + } + + return TRUE; +} + +static Bool +I830EXACheckComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture, + PicturePtr pDstPicture) +{ + return FALSE; /* no Composite yet */ +} + +static Bool +I830EXAPrepareComposite(int op, PicturePtr pSrcPicture, + PicturePtr pMaskPicture, PicturePtr pDstPicture, + PixmapPtr pSrc, PixmapPtr pMask, PixmapPtr pDst) +{ + return FALSE; /* no Composite yet */ +} + +static void +I830EXAComposite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY, + int dstX, int dstY, int width, int height) +{ + return; /* no Composite yet */ +} + +static void +I830EXADoneComposite(PixmapPtr pDst) +{ + return; /* no Composite yet */ +} +#endif + +/* + * TODO: + * - Dual head? + * - Upload/Download + * - Composite + */ +Bool +I830EXAInit(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + I830Ptr pI830 = I830PTR(pScrn); + + if(pI830->useEXA) { + if(!(pI830->EXADriverPtr = xnfcalloc(sizeof(ExaDriverRec), 1))) { + pI830->noAccel = TRUE; + return FALSE; + } + } + + pI830->bufferOffset = 0; + pI830->EXADriverPtr->card.memoryBase = pI830->FbBase; + pI830->EXADriverPtr->card.offScreenBase = pI830->Offscreen.Start; + pI830->EXADriverPtr->card.memorySize = pI830->Offscreen.Size; + + if(pI830->EXADriverPtr->card.memorySize > + pI830->EXADriverPtr->card.offScreenBase) + pI830->EXADriverPtr->card.flags = EXA_OFFSCREEN_PIXMAPS; + else { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Not enough video RAM for " + "offscreen memory manager. Xv disabled\n"); + /* disable Xv here... */ + } + + pI830->EXADriverPtr->card.pixmapOffsetAlign = 256; + pI830->EXADriverPtr->card.pixmapPitchAlign = 64; + pI830->EXADriverPtr->card.maxX = 4095; + pI830->EXADriverPtr->card.maxY = 4095; + + /* Sync */ + pI830->EXADriverPtr->accel.WaitMarker = I830EXASync; + + /* Solid fill */ + pI830->EXADriverPtr->accel.PrepareSolid = I830EXAPrepareSolid; + pI830->EXADriverPtr->accel.Solid = I830EXASolid; + pI830->EXADriverPtr->accel.DoneSolid = I830EXADoneSolid; + + /* Copy */ + pI830->EXADriverPtr->accel.PrepareCopy = I830EXAPrepareCopy; + pI830->EXADriverPtr->accel.Copy = I830EXACopy; + pI830->EXADriverPtr->accel.DoneCopy = I830EXADoneCopy; +#if 0 + /* Upload, download to/from Screen */ + pI830->EXADriverPtr->accel.UploadToScreen = I830EXAUploadToScreen; + pI830->EXADriverPtr->accel.DownloadFromScreen = I830EXADownloadFromScreen; + + /* Composite */ + pI830->EXADriverPtr->accel.CheckComposite = I830EXACheckComposite; + pI830->EXADriverPtr->accel.PrepareComposite = I830EXAPrepareComposite; + pI830->EXADriverPtr->accel.Composite = I830EXAComposite; + pI830->EXADriverPtr->accel.DoneComposite = I830EXADoneComposite; +#endif + + if(!exaDriverInit(pScreen, pI830->EXADriverPtr)) { + pI830->noAccel = TRUE; + return FALSE; + } + + I830SelectBuffer(pScrn, I830_SELECT_FRONT); + + return TRUE; +} diff --git a/src/i830_memory.c b/src/i830_memory.c index 433aa47d..5fbc8cff 100644 --- a/src/i830_memory.c +++ b/src/i830_memory.c @@ -850,6 +850,30 @@ I830Allocate2DMemory(ScrnInfoPtr pScrn, const int flags) } return FALSE; } +#ifdef I830_USE_EXA + size = lineSize * pScrn->virtualY; + size = ROUND_TO_PAGE(size); + + if (tileable) { + align = KB(512); + alignflags = ALIGN_BOTH_ENDS; + } else { + align = KB(64); + alignflags = 0; + } + + alloced = I830AllocVidMem(pScrn, &(pI830->Offscreen), + &(pI830->StolenPool), size, align, + flags | alignflags | + FROM_ANYWHERE | ALLOCATE_AT_BOTTOM); + if (alloced < size) { + if (!dryrun) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Failed to allocate " + "offscreen memory. Not enough VRAM?\n"); + } + return FALSE; + } +#endif } else { long lineSize; long extra = 0; diff --git a/src/i830_video.c b/src/i830_video.c index 0ae68607..e6f63414 100644 --- a/src/i830_video.c +++ b/src/i830_video.c @@ -1830,8 +1830,6 @@ I830AllocateMemory(ScrnInfoPtr pScrn, FBLinearPtr linear, int size) ScreenPtr pScreen; FBLinearPtr new_linear = NULL; - DPRINTF(PFX, "I830AllocateMemory\n"); - if (linear) { if (linear->size >= size) return linear; diff --git a/src/i830_xaa.c b/src/i830_xaa.c new file mode 100644 index 00000000..68ba4c7f --- /dev/null +++ b/src/i830_xaa.c @@ -0,0 +1,636 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "xf86_ansic.h" +#include "xf86.h" +#include "xaarop.h" +#include "i830.h" +#include "i810_reg.h" + +#ifndef DO_SCANLINE_IMAGE_WRITE +#define DO_SCANLINE_IMAGE_WRITE 0 +#endif + +/************************************************************************** + +Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. +All Rights Reserved. + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sub license, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice (including the +next paragraph) shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. +IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +**************************************************************************/ + +/* + * Reformatted with GNU indent (2.2.8), using the following options: + * + * -bad -bap -c41 -cd0 -ncdb -ci6 -cli0 -cp0 -ncs -d0 -di3 -i3 -ip3 -l78 + * -lp -npcs -psl -sob -ss -br -ce -sc -hnl + * + * This provides a good match with the original i810 code and preferred + * XFree86 formatting conventions. + * + * When editing this driver, please follow the existing formatting, and edit + * with characters expanded at 8-column intervals. + */ + +/* + * Authors: + * Keith Whitwell + * + */ + +/* I830 Accel Functions */ +static void I830SetupForMono8x8PatternFill(ScrnInfoPtr pScrn, + int pattx, int patty, + int fg, int bg, int rop, + unsigned int planemask); +static void I830SubsequentMono8x8PatternFillRect(ScrnInfoPtr pScrn, + int pattx, int patty, + int x, int y, int w, int h); + +static void I830SetupForScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, + int fg, int bg, + int rop, + unsigned int mask); + +static void I830SubsequentScanlineCPUToScreenColorExpandFill(ScrnInfoPtr + pScrn, int x, + int y, int w, + int h, + int skipleft); + +static void I830SubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno); + +#if DO_SCANLINE_IMAGE_WRITE +static void I830SetupForScanlineImageWrite(ScrnInfoPtr pScrn, int rop, + unsigned int planemask, + int trans_color, int bpp, + int depth); +static void I830SubsequentScanlineImageWriteRect(ScrnInfoPtr pScrn, + int x, int y, int w, int h, + int skipleft); +static void I830SubsequentImageWriteScanline(ScrnInfoPtr pScrn, int bufno); +#endif +static void I830RestoreAccelState(ScrnInfoPtr pScrn); + +Bool +I830XAAInit(ScreenPtr pScreen) +{ + XAAInfoRecPtr infoPtr; + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + I830Ptr pI830 = I830PTR(pScrn); + int i; + int width = 0; + int nr_buffers = 0; + unsigned char *ptr = NULL; + + if (I810_DEBUG & DEBUG_VERBOSE_ACCEL) + ErrorF("I830XAAInit\n"); + + pI830->AccelInfoRec = infoPtr = XAACreateInfoRec(); + if (!infoPtr) + return FALSE; + + pI830->bufferOffset = 0; + infoPtr->Flags = LINEAR_FRAMEBUFFER | OFFSCREEN_PIXMAPS | PIXMAP_CACHE; + + /* Use the same sync function as the I830. + */ + infoPtr->Sync = I830Sync; + + /* Everything else is different enough to justify different functions */ + { + infoPtr->SolidFillFlags = NO_PLANEMASK; + infoPtr->SetupForSolidFill = I830SetupForSolidFill; + infoPtr->SubsequentSolidFillRect = I830SubsequentSolidFillRect; + } + + { + infoPtr->ScreenToScreenCopyFlags = (NO_PLANEMASK | NO_TRANSPARENCY); + + infoPtr->SetupForScreenToScreenCopy = I830SetupForScreenToScreenCopy; + infoPtr->SubsequentScreenToScreenCopy = + I830SubsequentScreenToScreenCopy; + } + + { + infoPtr->SetupForMono8x8PatternFill = I830SetupForMono8x8PatternFill; + infoPtr->SubsequentMono8x8PatternFillRect = + I830SubsequentMono8x8PatternFillRect; + + infoPtr->Mono8x8PatternFillFlags = (HARDWARE_PATTERN_PROGRAMMED_BITS | + HARDWARE_PATTERN_SCREEN_ORIGIN | + HARDWARE_PATTERN_PROGRAMMED_ORIGIN| + BIT_ORDER_IN_BYTE_MSBFIRST | + NO_PLANEMASK); + + } + + /* On the primary screen */ + if (pI830->init == 0) { + if (pI830->Scratch.Size != 0) { + width = ((pScrn->displayWidth + 31) & ~31) / 8; + nr_buffers = pI830->Scratch.Size / width; + ptr = pI830->FbBase + pI830->Scratch.Start; + } + } else { + /* On the secondary screen */ + I830Ptr pI8301 = I830PTR(pI830->entityPrivate->pScrn_1); + if (pI8301->Scratch2.Size != 0) { + width = ((pScrn->displayWidth + 31) & ~31) / 8; + nr_buffers = pI8301->Scratch2.Size / width; + /* We have to use the primary screen's FbBase, as that's where + * we allocated Scratch2, so we get the correct pointer */ + ptr = pI8301->FbBase + pI8301->Scratch2.Start; + } + } + + if (nr_buffers) { + pI830->NumScanlineColorExpandBuffers = nr_buffers; + pI830->ScanlineColorExpandBuffers = (unsigned char **) + xnfcalloc(nr_buffers, sizeof(unsigned char *)); + + for (i = 0; i < nr_buffers; i++, ptr += width) + pI830->ScanlineColorExpandBuffers[i] = ptr; + + infoPtr->ScanlineCPUToScreenColorExpandFillFlags = + (NO_PLANEMASK | ROP_NEEDS_SOURCE | BIT_ORDER_IN_BYTE_MSBFIRST); + + infoPtr->ScanlineColorExpandBuffers = (unsigned char **) + xnfcalloc(1, sizeof(unsigned char *)); + infoPtr->NumScanlineColorExpandBuffers = 1; + + infoPtr->ScanlineColorExpandBuffers[0] = + pI830->ScanlineColorExpandBuffers[0]; + pI830->nextColorExpandBuf = 0; + + infoPtr->SetupForScanlineCPUToScreenColorExpandFill = + I830SetupForScanlineCPUToScreenColorExpandFill; + + infoPtr->SubsequentScanlineCPUToScreenColorExpandFill = + I830SubsequentScanlineCPUToScreenColorExpandFill; + + infoPtr->SubsequentColorExpandScanline = + I830SubsequentColorExpandScanline; + +#if DO_SCANLINE_IMAGE_WRITE + infoPtr->NumScanlineImageWriteBuffers = 1; + infoPtr->ScanlineImageWriteBuffers = + infoPtr->ScanlineColorExpandBuffers; + infoPtr->SetupForScanlineImageWrite = I830SetupForScanlineImageWrite; + infoPtr->SubsequentScanlineImageWriteRect = + I830SubsequentScanlineImageWriteRect; + infoPtr->SubsequentImageWriteScanline = + I830SubsequentImageWriteScanline; + infoPtr->ScanlineImageWriteFlags = NO_GXCOPY | + NO_PLANEMASK | + ROP_NEEDS_SOURCE | + SCANLINE_PAD_DWORD; +#endif + } + + { + Bool shared_accel = FALSE; + int i; + + for(i = 0; i < pScrn->numEntities; i++) { + if(xf86IsEntityShared(pScrn->entityList[i])) + shared_accel = TRUE; + } + if(shared_accel == TRUE) + infoPtr->RestoreAccelState = I830RestoreAccelState; + } + + I830SelectBuffer(pScrn, I830_SELECT_FRONT); + + return XAAInit(pScreen, infoPtr); +} + +void +I830SetupForSolidFill(ScrnInfoPtr pScrn, int color, int rop, + unsigned int planemask) +{ + I830Ptr pI830 = I830PTR(pScrn); + + if (I810_DEBUG & DEBUG_VERBOSE_ACCEL) + ErrorF("I830SetupForFillRectSolid color: %x rop: %x mask: %x\n", + color, rop, planemask); + + pI830->BR[13] = ((XAAGetPatternROP(rop) << 16) | + (pScrn->displayWidth * pI830->cpp)); + + pI830->BR[16] = color; + + switch (pScrn->bitsPerPixel) { + case 8: + break; + case 16: + pI830->BR[13] |= (1 << 24); + break; + case 32: + pI830->BR[13] |= ((1 << 25) | (1 << 24)); + break; + } +} + +void +I830SubsequentSolidFillRect(ScrnInfoPtr pScrn, int x, int y, int w, int h) +{ + I830Ptr pI830 = I830PTR(pScrn); + + if (I810_DEBUG & DEBUG_VERBOSE_ACCEL) + ErrorF("I830SubsequentFillRectSolid %d,%d %dx%d\n", x, y, w, h); + + { + BEGIN_LP_RING(6); + + if (pScrn->bitsPerPixel == 32) { + OUT_RING(COLOR_BLT_CMD | COLOR_BLT_WRITE_ALPHA | + COLOR_BLT_WRITE_RGB); + } else { + OUT_RING(COLOR_BLT_CMD); + } + OUT_RING(pI830->BR[13]); + OUT_RING((h << 16) | (w * pI830->cpp)); + OUT_RING(pI830->bufferOffset + (y * pScrn->displayWidth + x) * + pI830->cpp); + OUT_RING(pI830->BR[16]); + OUT_RING(0); + + ADVANCE_LP_RING(); + } +} + +void +I830SetupForScreenToScreenCopy(ScrnInfoPtr pScrn, int xdir, int ydir, int rop, + unsigned int planemask, int transparency_color) +{ + I830Ptr pI830 = I830PTR(pScrn); + + if (I810_DEBUG & DEBUG_VERBOSE_ACCEL) + ErrorF("I830SetupForScreenToScreenCopy %d %d %x %x %d\n", + xdir, ydir, rop, planemask, transparency_color); + + pI830->BR[13] = (pScrn->displayWidth * pI830->cpp); + pI830->BR[13] |= XAAGetCopyROP(rop) << 16; + + switch (pScrn->bitsPerPixel) { + case 8: + break; + case 16: + pI830->BR[13] |= (1 << 24); + break; + case 32: + pI830->BR[13] |= ((1 << 25) | (1 << 24)); + break; + } + +} + +void +I830SubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, int src_x1, int src_y1, + int dst_x1, int dst_y1, int w, int h) +{ + I830Ptr pI830 = I830PTR(pScrn); + int dst_x2, dst_y2; + + if (I810_DEBUG & DEBUG_VERBOSE_ACCEL) + ErrorF("I830SubsequentScreenToScreenCopy %d,%d - %d,%d %dx%d\n", + src_x1, src_y1, dst_x1, dst_y1, w, h); + + dst_x2 = dst_x1 + w; + dst_y2 = dst_y1 + h; + + { + BEGIN_LP_RING(8); + + if (pScrn->bitsPerPixel == 32) { + OUT_RING(XY_SRC_COPY_BLT_CMD | XY_SRC_COPY_BLT_WRITE_ALPHA | + XY_SRC_COPY_BLT_WRITE_RGB); + } else { + OUT_RING(XY_SRC_COPY_BLT_CMD); + } + OUT_RING(pI830->BR[13]); + OUT_RING((dst_y1 << 16) | (dst_x1 & 0xffff)); + OUT_RING((dst_y2 << 16) | (dst_x2 & 0xffff)); + OUT_RING(pI830->bufferOffset); + OUT_RING((src_y1 << 16) | (src_x1 & 0xffff)); + OUT_RING(pI830->BR[13] & 0xFFFF); + OUT_RING(pI830->bufferOffset); + + ADVANCE_LP_RING(); + } +} + +static void +I830SetupForMono8x8PatternFill(ScrnInfoPtr pScrn, int pattx, int patty, + int fg, int bg, int rop, + unsigned int planemask) +{ + I830Ptr pI830 = I830PTR(pScrn); + + if (I810_DEBUG & DEBUG_VERBOSE_ACCEL) + ErrorF("I830SetupForMono8x8PatternFill\n"); + + pI830->BR[16] = pattx; + pI830->BR[17] = patty; + pI830->BR[18] = bg; + pI830->BR[19] = fg; + + pI830->BR[13] = (pScrn->displayWidth * pI830->cpp); /* In bytes */ + pI830->BR[13] |= XAAGetPatternROP(rop) << 16; + if (bg == -1) + pI830->BR[13] |= (1 << 28); + + switch (pScrn->bitsPerPixel) { + case 8: + break; + case 16: + pI830->BR[13] |= (1 << 24); + break; + case 32: + pI830->BR[13] |= ((1 << 25) | (1 << 24)); + break; + } + +} + +static void +I830SubsequentMono8x8PatternFillRect(ScrnInfoPtr pScrn, int pattx, int patty, + int x, int y, int w, int h) +{ + I830Ptr pI830 = I830PTR(pScrn); + int x1, x2, y1, y2; + + x1 = x; + x2 = x + w; + y1 = y; + y2 = y + h; + + if (I810_DEBUG & DEBUG_VERBOSE_ACCEL) + ErrorF("I830SubsequentMono8x8PatternFillRect\n"); + + { + BEGIN_LP_RING(10); + + if (pScrn->bitsPerPixel == 32) { + OUT_RING(XY_MONO_PAT_BLT_CMD | XY_MONO_PAT_BLT_WRITE_ALPHA | + XY_MONO_PAT_BLT_WRITE_RGB | + ((patty << 8) & XY_MONO_PAT_VERT_SEED) | + ((pattx << 12) & XY_MONO_PAT_HORT_SEED)); + } else { + OUT_RING(XY_MONO_PAT_BLT_CMD | + ((patty << 8) & XY_MONO_PAT_VERT_SEED) | + ((pattx << 12) & XY_MONO_PAT_HORT_SEED)); + } + OUT_RING(pI830->BR[13]); + OUT_RING((y1 << 16) | x1); + OUT_RING((y2 << 16) | x2); + OUT_RING(pI830->bufferOffset); + OUT_RING(pI830->BR[18]); /* bg */ + OUT_RING(pI830->BR[19]); /* fg */ + OUT_RING(pI830->BR[16]); /* pattern data */ + OUT_RING(pI830->BR[17]); + OUT_RING(0); + ADVANCE_LP_RING(); + } +} + +static void +I830GetNextScanlineColorExpandBuffer(ScrnInfoPtr pScrn) +{ + I830Ptr pI830 = I830PTR(pScrn); + XAAInfoRecPtr infoPtr = pI830->AccelInfoRec; + + if (pI830->nextColorExpandBuf == pI830->NumScanlineColorExpandBuffers) + I830Sync(pScrn); + + infoPtr->ScanlineColorExpandBuffers[0] = + pI830->ScanlineColorExpandBuffers[pI830->nextColorExpandBuf]; + + if (I810_DEBUG & DEBUG_VERBOSE_ACCEL) + ErrorF("using color expand buffer %d\n", pI830->nextColorExpandBuf); + + pI830->nextColorExpandBuf++; +} + +static void +I830SetupForScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask) +{ + I830Ptr pI830 = I830PTR(pScrn); + + if (I810_DEBUG & DEBUG_VERBOSE_ACCEL) + ErrorF("I830SetupForScanlineScreenToScreenColorExpand %d %d %x %x\n", + fg, bg, rop, planemask); + + /* Fill out register values */ + pI830->BR[13] = (pScrn->displayWidth * pI830->cpp); + pI830->BR[13] |= XAAGetCopyROP(rop) << 16; + if (bg == -1) + pI830->BR[13] |= (1 << 29); + + switch (pScrn->bitsPerPixel) { + case 8: + break; + case 16: + pI830->BR[13] |= (1 << 24); + break; + case 32: + pI830->BR[13] |= ((1 << 25) | (1 << 24)); + break; + } + + pI830->BR[18] = bg; + pI830->BR[19] = fg; + + I830GetNextScanlineColorExpandBuffer(pScrn); +} + +static void +I830SubsequentScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, + int x, int y, + int w, int h, int skipleft) +{ + I830Ptr pI830 = I830PTR(pScrn); + + if (I810_DEBUG & DEBUG_VERBOSE_ACCEL) + ErrorF("I830SubsequentScanlineCPUToScreenColorExpandFill " + "%d,%d %dx%x %d\n", x, y, w, h, skipleft); + + /* Fill out register values */ + pI830->BR[9] = (pI830->bufferOffset + + (y * pScrn->displayWidth + x) * pI830->cpp); + pI830->BR[11] = ((1 << 16) | w); +} + +static void +I830SubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno) +{ + I830Ptr pI830 = I830PTR(pScrn); + + if (pI830->init == 0) { + pI830->BR[12] = (pI830->AccelInfoRec->ScanlineColorExpandBuffers[0] - + pI830->FbBase); + } else { + I830Ptr pI8301 = I830PTR(pI830->entityPrivate->pScrn_1); + + /* We have to use the primary screen's FbBase, as that's where + * we allocated Scratch2, so we get the correct pointer */ + pI830->BR[12] = (pI830->AccelInfoRec->ScanlineColorExpandBuffers[0] - + pI8301->FbBase); + } + + if (I810_DEBUG & DEBUG_VERBOSE_ACCEL) + ErrorF("I830SubsequentColorExpandScanline %d (addr %x)\n", + bufno, pI830->BR[12]); + + { + BEGIN_LP_RING(8); + + if (pScrn->bitsPerPixel == 32) { + OUT_RING(XY_MONO_SRC_BLT_CMD | XY_MONO_SRC_BLT_WRITE_ALPHA | + XY_MONO_SRC_BLT_WRITE_RGB); + } else { + OUT_RING(XY_MONO_SRC_BLT_CMD); + } + OUT_RING(pI830->BR[13]); + OUT_RING(0); /* x1 = 0, y1 = 0 */ + OUT_RING(pI830->BR[11]); /* x2 = w, y2 = 1 */ + OUT_RING(pI830->BR[9]); /* dst addr */ + OUT_RING(pI830->BR[12]); /* src addr */ + OUT_RING(pI830->BR[18]); /* bg */ + OUT_RING(pI830->BR[19]); /* fg */ + + ADVANCE_LP_RING(); + } + + /* Advance to next scanline. + */ + pI830->BR[9] += pScrn->displayWidth * pI830->cpp; + I830GetNextScanlineColorExpandBuffer(pScrn); +} + +#if DO_SCANLINE_IMAGE_WRITE +static void +I830SetupForScanlineImageWrite(ScrnInfoPtr pScrn, int rop, + unsigned int planemask, int trans_color, + int bpp, int depth) +{ + I830Ptr pI830 = I830PTR(pScrn); + + if (I810_DEBUG & DEBUG_VERBOSE_ACCEL) + ErrorF("I830SetupForScanlineImageWrite %x %x\n", rop, planemask); + + /* Fill out register values */ + pI830->BR[13] = (pScrn->displayWidth * pI830->cpp); + pI830->BR[13] |= XAAGetCopyROP(rop) << 16; + + switch (pScrn->bitsPerPixel) { + case 8: + break; + case 16: + pI830->BR[13] |= (1 << 24); + break; + case 32: + pI830->BR[13] |= ((1 << 25) | (1 << 24)); + break; + } + + I830GetNextScanlineColorExpandBuffer(pScrn); +} + +static void +I830SubsequentScanlineImageWriteRect(ScrnInfoPtr pScrn, int x, int y, + int w, int h, int skipleft) +{ + I830Ptr pI830 = I830PTR(pScrn); + + if (I810_DEBUG & DEBUG_VERBOSE_ACCEL) + ErrorF("I830SubsequentScanlineImageWriteRect " + "%d,%d %dx%x %d\n", x, y, w, h, skipleft); + + /* Fill out register values */ + pI830->BR[9] = (pI830->bufferOffset + + (y * pScrn->displayWidth + x) * pI830->cpp); + pI830->BR[11] = ((1 << 16) | w); +} + +static void +I830SubsequentImageWriteScanline(ScrnInfoPtr pScrn, int bufno) +{ + I830Ptr pI830 = I830PTR(pScrn); + + if (pI830->init == 0) { + pI830->BR[12] = (pI830->AccelInfoRec->ScanlineColorExpandBuffers[0] - + pI830->FbBase); + } else { + I830Ptr pI8301 = I830PTR(pI830->entityPrivate->pScrn_1); + + /* We have to use the primary screen's FbBase, as that's where + * we allocated Scratch2, so we get the correct pointer */ + pI830->BR[12] = (pI830->AccelInfoRec->ScanlineColorExpandBuffers[0] - + pI8301->FbBase); + } + + if (I810_DEBUG & DEBUG_VERBOSE_ACCEL) + ErrorF("I830SubsequentImageWriteScanline %d (addr %x)\n", + bufno, pI830->BR[12]); + + { + BEGIN_LP_RING(8); + + if (pScrn->bitsPerPixel == 32) { + OUT_RING(XY_SRC_COPY_BLT_CMD | XY_SRC_COPY_BLT_WRITE_ALPHA | + XY_SRC_COPY_BLT_WRITE_RGB); + } else { + OUT_RING(XY_SRC_COPY_BLT_CMD); + } + OUT_RING(pI830->BR[13]); + OUT_RING(0); /* x1 = 0, y1 = 0 */ + OUT_RING(pI830->BR[11]); /* x2 = w, y2 = 1 */ + OUT_RING(pI830->BR[9]); /* dst addr */ + OUT_RING(0); /* source origin (0,0) */ + OUT_RING(pI830->BR[11] & 0xffff); /* source pitch */ + OUT_RING(pI830->BR[12]); /* src addr */ + + ADVANCE_LP_RING(); + } + + /* Advance to next scanline. + */ + pI830->BR[9] += pScrn->displayWidth * pI830->cpp; + I830GetNextScanlineColorExpandBuffer(pScrn); +} +#endif /* DO_SCANLINE_IMAGE_WRITE */ +/* Support for multiscreen */ + +static void +I830RestoreAccelState(ScrnInfoPtr pScrn) +{ +#if 0 + /* might be needed, but everything is on a ring, so I don't think so */ + I830Sync(pScrn); +#endif +} + -- cgit v1.2.3 From a4a4ced50cc235e79013ce8dd78e35c6eb4c98ca Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 28 Apr 2006 14:59:52 -0700 Subject: Get it to compile. --- src/Makefile.am | 6 ++++-- src/i830_driver.c | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index c64c2036..83025fa3 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -24,7 +24,7 @@ SUBDIRS = xvmc # -avoid-version prevents gratuitous .0.0.0 version numbers on the end # _ladir passes a dummy rpath to libtool so the thing will actually link # TODO: -nostdlib/-Bstatic/-lgcc platform magic, not installing the .a, etc. -AM_CFLAGS = @XORG_CFLAGS@ @DRI_CFLAGS@ -DI830_XV +AM_CFLAGS = @XORG_CFLAGS@ @DRI_CFLAGS@ -DI830_XV -DI830_USE_XAA -DI830_USE_EXA i810_drv_la_LTLIBRARIES = i810_drv.la i810_drv_la_LDFLAGS = -module -avoid-version @@ -54,7 +54,9 @@ i810_drv_la_SOURCES = \ i830_modes.c \ i830_video.c \ i830_rotate.c \ - i830_randr.c + i830_randr.c \ + i830_exa.c \ + i830_xaa.c if DRI i810_drv_la_SOURCES += \ diff --git a/src/i830_driver.c b/src/i830_driver.c index de510e69..d6f686da 100644 --- a/src/i830_driver.c +++ b/src/i830_driver.c @@ -5724,7 +5724,7 @@ I830BIOSSwitchMode(int scrnIndex, DisplayModePtr mode, int flags) /* Sync the engine before mode switch */ #ifdef I830_USE_XAA - if (!pI830->noAccel && !pI830->useEXA) + if (!pI830->noAccel && !pI830->useEXA) { (*pI830->AccelInfoRec->Sync)(pScrn); pI830->AccelInfoRec->NeedToSync = FALSE; } -- cgit v1.2.3 From c94cc67bcc507e8256ae4b51b84dfe3f4aa12ab5 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 28 Apr 2006 15:33:57 -0700 Subject: Update to EXA 2.0 API. --- src/i830_driver.c | 18 ++++++++++++++---- src/i830_exa.c | 57 ++++++++++++++++++++++++++++--------------------------- 2 files changed, 43 insertions(+), 32 deletions(-) diff --git a/src/i830_driver.c b/src/i830_driver.c index d6f686da..6b03c0f5 100644 --- a/src/i830_driver.c +++ b/src/i830_driver.c @@ -3533,7 +3533,15 @@ I830BIOSPreInit(ScrnInfoPtr pScrn, int flags) #ifdef I830_USE_EXA if (!pI830->noAccel && pI830->useEXA) { - if (!xf86LoadSubModule(pScrn, "exa")) { + XF86ModReqInfo req; + int errmaj, errmin; + + memset(&req, 0, sizeof(req)); + req.majorversion = 2; + req.minorversion = 0; + if (!LoadSubModule(pScrn->module, "exa", NULL, NULL, NULL, &req, + &errmaj, &errmin)) { + LoaderErrorMsg(NULL, "exa", errmaj, errmin); PreInitCleanup(pScrn); return FALSE; } @@ -5387,8 +5395,10 @@ I830BIOSLeaveVT(int scrnIndex, int flags) pI830->AccelInfoRec->NeedToSync = FALSE; #endif #ifdef I830_USE_EXA - if (pI830->useEXA && pI830->EXADriverPtr) - pI830->EXADriverPtr->card.needsSync = TRUE; + if (pI830->useEXA && pI830->EXADriverPtr) { + ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex]; + exaMarkSync(pScreen); + } #endif /* DO IT AGAIN! AS IT SEEMS THAT SOME LFPs FLICKER OTHERWISE */ @@ -5732,7 +5742,7 @@ I830BIOSSwitchMode(int scrnIndex, DisplayModePtr mode, int flags) #ifdef I830_USE_EXA if (!pI830->noAccel && pI830->useEXA) { ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex]; - (*pI830->EXADriverPtr->accel.WaitMarker)(pScreen, 0); + exaWaitSync(pScreen); } #endif diff --git a/src/i830_exa.c b/src/i830_exa.c index a6aa6a79..6db94d97 100644 --- a/src/i830_exa.c +++ b/src/i830_exa.c @@ -357,54 +357,55 @@ I830EXAInit(ScreenPtr pScreen) ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; I830Ptr pI830 = I830PTR(pScrn); - if(pI830->useEXA) { - if(!(pI830->EXADriverPtr = xnfcalloc(sizeof(ExaDriverRec), 1))) { - pI830->noAccel = TRUE; - return FALSE; - } + pI830->EXADriverPtr = exaDriverAlloc(); + if (pI830->EXADriverPtr == NULL) { + pI830->noAccel = TRUE; + return FALSE; } pI830->bufferOffset = 0; - pI830->EXADriverPtr->card.memoryBase = pI830->FbBase; - pI830->EXADriverPtr->card.offScreenBase = pI830->Offscreen.Start; - pI830->EXADriverPtr->card.memorySize = pI830->Offscreen.Size; + pI830->EXADriverPtr->exa_major = 2; + pI830->EXADriverPtr->exa_minor = 0; + pI830->EXADriverPtr->memoryBase = pI830->FbBase; + pI830->EXADriverPtr->offScreenBase = pI830->Offscreen.Start; + pI830->EXADriverPtr->memorySize = pI830->Offscreen.Size; - if(pI830->EXADriverPtr->card.memorySize > - pI830->EXADriverPtr->card.offScreenBase) - pI830->EXADriverPtr->card.flags = EXA_OFFSCREEN_PIXMAPS; + if(pI830->EXADriverPtr->memorySize > + pI830->EXADriverPtr->offScreenBase) + pI830->EXADriverPtr->flags = EXA_OFFSCREEN_PIXMAPS; else { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Not enough video RAM for " "offscreen memory manager. Xv disabled\n"); /* disable Xv here... */ } - pI830->EXADriverPtr->card.pixmapOffsetAlign = 256; - pI830->EXADriverPtr->card.pixmapPitchAlign = 64; - pI830->EXADriverPtr->card.maxX = 4095; - pI830->EXADriverPtr->card.maxY = 4095; + pI830->EXADriverPtr->pixmapOffsetAlign = 256; + pI830->EXADriverPtr->pixmapPitchAlign = 64; + pI830->EXADriverPtr->maxX = 4095; + pI830->EXADriverPtr->maxY = 4095; /* Sync */ - pI830->EXADriverPtr->accel.WaitMarker = I830EXASync; + pI830->EXADriverPtr->WaitMarker = I830EXASync; /* Solid fill */ - pI830->EXADriverPtr->accel.PrepareSolid = I830EXAPrepareSolid; - pI830->EXADriverPtr->accel.Solid = I830EXASolid; - pI830->EXADriverPtr->accel.DoneSolid = I830EXADoneSolid; + pI830->EXADriverPtr->PrepareSolid = I830EXAPrepareSolid; + pI830->EXADriverPtr->Solid = I830EXASolid; + pI830->EXADriverPtr->DoneSolid = I830EXADoneSolid; /* Copy */ - pI830->EXADriverPtr->accel.PrepareCopy = I830EXAPrepareCopy; - pI830->EXADriverPtr->accel.Copy = I830EXACopy; - pI830->EXADriverPtr->accel.DoneCopy = I830EXADoneCopy; + pI830->EXADriverPtr->PrepareCopy = I830EXAPrepareCopy; + pI830->EXADriverPtr->Copy = I830EXACopy; + pI830->EXADriverPtr->DoneCopy = I830EXADoneCopy; #if 0 /* Upload, download to/from Screen */ - pI830->EXADriverPtr->accel.UploadToScreen = I830EXAUploadToScreen; - pI830->EXADriverPtr->accel.DownloadFromScreen = I830EXADownloadFromScreen; + pI830->EXADriverPtr->UploadToScreen = I830EXAUploadToScreen; + pI830->EXADriverPtr->DownloadFromScreen = I830EXADownloadFromScreen; /* Composite */ - pI830->EXADriverPtr->accel.CheckComposite = I830EXACheckComposite; - pI830->EXADriverPtr->accel.PrepareComposite = I830EXAPrepareComposite; - pI830->EXADriverPtr->accel.Composite = I830EXAComposite; - pI830->EXADriverPtr->accel.DoneComposite = I830EXADoneComposite; + pI830->EXADriverPtr->CheckComposite = I830EXACheckComposite; + pI830->EXADriverPtr->PrepareComposite = I830EXAPrepareComposite; + pI830->EXADriverPtr->Composite = I830EXAComposite; + pI830->EXADriverPtr->DoneComposite = I830EXADoneComposite; #endif if(!exaDriverInit(pScreen, pI830->EXADriverPtr)) { -- cgit v1.2.3 From a00a3d198aee7c173c2c36858f4447e13c86eb7f Mon Sep 17 00:00:00 2001 From: Wang Zhenyu Date: Sat, 29 Apr 2006 10:52:45 +0800 Subject: fix I830BIOSAdjustFrame() sync in I830_USE_EXA case, use exaWaitSync() helper. --- src/i830_driver.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/i830_driver.c b/src/i830_driver.c index 6b03c0f5..50f20594 100644 --- a/src/i830_driver.c +++ b/src/i830_driver.c @@ -196,6 +196,7 @@ const char *I830exaSymbols[] = { "exaDriverFini", "exaOffscreenAlloc", "exaOffscreenFree", + "exaWaitSync", NULL }; #endif @@ -5257,11 +5258,18 @@ I830BIOSAdjustFrame(int scrnIndex, int x, int y, int flags) x, pI830->xoffset, y, pI830->yoffset); /* Sync the engine before adjust frame */ - if (pI830->AccelInfoRec && pI830->AccelInfoRec->NeedToSync) { +#ifdef I830_USE_XAA + if (!pI830->noAccel && !pI830->useEXA && pI830->AccelInfoRec->NeedToSync) { (*pI830->AccelInfoRec->Sync)(pScrn); pI830->AccelInfoRec->NeedToSync = FALSE; } - +#endif +#ifdef I830_USE_EXA + if (!pI830->noAccel && pI830->useEXA) { + ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex]; + exaWaitSync(pScreen); + } +#endif if (I830IsPrimary(pScrn)) Start = pI830->FrontBuffer.Start; else { -- cgit v1.2.3 From 0be9bc604420e4433697cc31e8ac58c9f36185e1 Mon Sep 17 00:00:00 2001 From: Wang Zhenyu Date: Sat, 29 Apr 2006 10:54:02 +0800 Subject: I830CheckDevicesTimer() sync should be in I830_USE_XAA case. --- src/i830_driver.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/i830_driver.c b/src/i830_driver.c index 50f20594..5cfb6fcc 100644 --- a/src/i830_driver.c +++ b/src/i830_driver.c @@ -6122,13 +6122,14 @@ I830CheckDevicesTimer(OsTimerPtr timer, CARD32 now, pointer arg) xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Hotkey switch to 0x%lx.\n", (unsigned long) temp); - if (pI830->AccelInfoRec && pI830->AccelInfoRec->NeedToSync) { +#ifdef I830_USE_XAA + if (!pI830->useEXA && pI830->AccelInfoRec && pI830->AccelInfoRec->NeedToSync) { (*pI830->AccelInfoRec->Sync)(pScrn); pI830->AccelInfoRec->NeedToSync = FALSE; if (xf86IsEntityShared(pScrn->entityList[0])) pI8302->AccelInfoRec->NeedToSync = FALSE; } - +#endif GetAttachableDisplayDeviceList(pScrn); pI8301->lastDevice0 = pI8301->lastDevice1; -- cgit v1.2.3 From fcec956807038a2e90287850df8b4410b1f8b3c2 Mon Sep 17 00:00:00 2001 From: Wang Zhenyu Date: Sat, 29 Apr 2006 10:55:25 +0800 Subject: Save initialize EXADriverPtr, and free it in failure. --- src/i830_exa.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/i830_exa.c b/src/i830_exa.c index 6db94d97..59c2d51d 100644 --- a/src/i830_exa.c +++ b/src/i830_exa.c @@ -362,7 +362,8 @@ I830EXAInit(ScreenPtr pScreen) pI830->noAccel = TRUE; return FALSE; } - + memset(pI830->EXADriverPtr, 0, sizeof(*pI830->EXADriverPtr)); + pI830->bufferOffset = 0; pI830->EXADriverPtr->exa_major = 2; pI830->EXADriverPtr->exa_minor = 0; @@ -409,6 +410,7 @@ I830EXAInit(ScreenPtr pScreen) #endif if(!exaDriverInit(pScreen, pI830->EXADriverPtr)) { + xfree(pI830->EXADriverPtr); pI830->noAccel = TRUE; return FALSE; } -- cgit v1.2.3 From 011a1c99d49c1c69b5fa81ade6a2ed73e84276ae Mon Sep 17 00:00:00 2001 From: Wang Zhenyu Date: Wed, 17 May 2006 11:16:00 +0800 Subject: Fix memorySize to enable offscreen mem manage. --- src/i830_exa.c | 2 +- src/i830_memory.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/i830_exa.c b/src/i830_exa.c index 59c2d51d..6acc00cc 100644 --- a/src/i830_exa.c +++ b/src/i830_exa.c @@ -369,7 +369,7 @@ I830EXAInit(ScreenPtr pScreen) pI830->EXADriverPtr->exa_minor = 0; pI830->EXADriverPtr->memoryBase = pI830->FbBase; pI830->EXADriverPtr->offScreenBase = pI830->Offscreen.Start; - pI830->EXADriverPtr->memorySize = pI830->Offscreen.Size; + pI830->EXADriverPtr->memorySize = pScrn->videoRam*1024; if(pI830->EXADriverPtr->memorySize > pI830->EXADriverPtr->offScreenBase) diff --git a/src/i830_memory.c b/src/i830_memory.c index 5fbc8cff..50bbde53 100644 --- a/src/i830_memory.c +++ b/src/i830_memory.c @@ -872,6 +872,10 @@ I830Allocate2DMemory(ScrnInfoPtr pScrn, const int flags) "offscreen memory. Not enough VRAM?\n"); } return FALSE; + } else { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Successful allocate " + "offscreen memory at 0x%lx, size %d KB\n", + pI830->Offscreen.Start, pI830->Offscreen.Size/1024); } #endif } else { -- cgit v1.2.3 From fdb52a8c6da0f3d3f4cfbf1583b2dc4d91f7e933 Mon Sep 17 00:00:00 2001 From: Wang Zhenyu Date: Thu, 18 May 2006 11:24:46 +0800 Subject: Solid planemask in PrepareSolid/Copy might be 0xffffffff or bits up to the depth. This should save some fallback case, noticed by Eric. --- src/i830_exa.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/i830_exa.c b/src/i830_exa.c index 6acc00cc..6726a0e8 100644 --- a/src/i830_exa.c +++ b/src/i830_exa.c @@ -134,7 +134,7 @@ I830EXAPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planemask, Pixel fg) ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum]; I830Ptr pI830 = I830PTR(pScrn); - if (planemask != (Pixel)~0) + if (planemask != (Pixel)~0 && !EXA_PM_IS_SOLID(pPixmap, planemask)) return FALSE; pI830->BR[13] = exaGetPixmapPitch(pPixmap); @@ -209,7 +209,7 @@ I830EXAPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int xdir, ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum]; I830Ptr pI830 = I830PTR(pScrn); - if (planemask != (Pixel)~0) + if (planemask != (Pixel)~0 && !EXA_PM_IS_SOLID(pScrPixmap, planemask)) return FALSE; pI830->copy_src_pitch = exaGetPixmapPitch(pSrcPixmap); -- cgit v1.2.3 From 52af679c94a25c0c6e5df5f3647f62fdd256c826 Mon Sep 17 00:00:00 2001 From: Wang Zhenyu Date: Thu, 18 May 2006 11:31:14 +0800 Subject: Check alignment require in PrepareSolid, noticed by Eric, as pixmap offset align set is violated in Solid. --- src/i830_exa.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/i830_exa.c b/src/i830_exa.c index 6726a0e8..b250fb21 100644 --- a/src/i830_exa.c +++ b/src/i830_exa.c @@ -133,11 +133,20 @@ I830EXAPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planemask, Pixel fg) { ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum]; I830Ptr pI830 = I830PTR(pScrn); + unsigned long offset, pitch; if (planemask != (Pixel)~0 && !EXA_PM_IS_SOLID(pPixmap, planemask)) return FALSE; - pI830->BR[13] = exaGetPixmapPitch(pPixmap); + offset = exaGetPixmapOffset(pPixmap); + pitch = exaGetPixmapPitch(pPixmap); + + if ( offset % pI830->EXADriverPtr->pixmapOffsetAlign != 0) + return FALSE; + if ( pitch % pI830->EXADriverPtr->pixmapPitchAlign != 0) + return FALSE; + + pI830->BR[13] = pitch; pI830->BR[13] |= I830PatternROP[alu] << 16; pI830->BR[16] = fg; @@ -165,8 +174,10 @@ I830EXASolid(PixmapPtr pPixmap, int x1, int y1, int x2, int y2) ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum]; I830Ptr pI830 = I830PTR(pScrn); int h, w; - unsigned int offset; + unsigned long offset; + /* pixmap's offset and pitch is aligned, + otherwise it falls back in PrepareSolid */ offset = exaGetPixmapOffset(pPixmap) + y1 * exaGetPixmapPitch(pPixmap) + x1 * (pPixmap->drawable.bitsPerPixel / 8); -- cgit v1.2.3 From 33ad959323f70f76c494c66ec35a04d7d839f612 Mon Sep 17 00:00:00 2001 From: Wang Zhenyu Date: Thu, 18 May 2006 11:32:59 +0800 Subject: Add DEBUG_I830FALLBACK for easier tracking --- src/i830_exa.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/i830_exa.c b/src/i830_exa.c index b250fb21..5d95ea75 100644 --- a/src/i830_exa.c +++ b/src/i830_exa.c @@ -37,6 +37,20 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "i830.h" #include "i810_reg.h" +#ifdef I830DEBUG +#define DEBUG_I830FALLBACK 0 +#endif + +#ifdef DEBUG_I830FALLBACK +#define I830FALLBACK(s, arg...) \ +do { \ + DPRINTF(PFX, "EXA fallback: " s "\n", ##arg); \ + return FALSE; \ +} while(0) +#else +#define I830FALLBACK(x) { return FALSE; } +#endif + int I830CopyROP[16] = { ROP_0, /* GXclear */ @@ -136,15 +150,15 @@ I830EXAPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planemask, Pixel fg) unsigned long offset, pitch; if (planemask != (Pixel)~0 && !EXA_PM_IS_SOLID(pPixmap, planemask)) - return FALSE; + I830FALLBACK("planemask is not solid"); offset = exaGetPixmapOffset(pPixmap); pitch = exaGetPixmapPitch(pPixmap); if ( offset % pI830->EXADriverPtr->pixmapOffsetAlign != 0) - return FALSE; + I830FALLBACK("pixmap offset not aligned"); if ( pitch % pI830->EXADriverPtr->pixmapPitchAlign != 0) - return FALSE; + I830FALLBACK("pixmap pitch not aligned"); pI830->BR[13] = pitch; pI830->BR[13] |= I830PatternROP[alu] << 16; @@ -221,7 +235,7 @@ I830EXAPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int xdir, I830Ptr pI830 = I830PTR(pScrn); if (planemask != (Pixel)~0 && !EXA_PM_IS_SOLID(pScrPixmap, planemask)) - return FALSE; + I830FALLBACK("planemask is not solid"); pI830->copy_src_pitch = exaGetPixmapPitch(pSrcPixmap); pI830->copy_src_off = exaGetPixmapOffset(pSrcPixmap); -- cgit v1.2.3 From b3d79ad9ecc70e9f841092fc75b7e23576b685dd Mon Sep 17 00:00:00 2001 From: Wang Zhenyu Date: Thu, 18 May 2006 16:31:40 +0800 Subject: oop I830FALLBACK define error --- src/i830_exa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/i830_exa.c b/src/i830_exa.c index 5d95ea75..a37be398 100644 --- a/src/i830_exa.c +++ b/src/i830_exa.c @@ -48,7 +48,7 @@ do { \ return FALSE; \ } while(0) #else -#define I830FALLBACK(x) { return FALSE; } +#define I830FALLBACK(s, arg...) { return FALSE; } #endif int I830CopyROP[16] = -- cgit v1.2.3 From e70d99d51edc39ea53536c2f4d62ac622ba3e0d9 Mon Sep 17 00:00:00 2001 From: Wang Zhenyu Date: Fri, 19 May 2006 15:47:19 +0800 Subject: revert wrong setting for memorySize, which should be at the range of pI830->Offscreen. --- src/i830_exa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/i830_exa.c b/src/i830_exa.c index a37be398..a67e5498 100644 --- a/src/i830_exa.c +++ b/src/i830_exa.c @@ -394,7 +394,7 @@ I830EXAInit(ScreenPtr pScreen) pI830->EXADriverPtr->exa_minor = 0; pI830->EXADriverPtr->memoryBase = pI830->FbBase; pI830->EXADriverPtr->offScreenBase = pI830->Offscreen.Start; - pI830->EXADriverPtr->memorySize = pScrn->videoRam*1024; + pI830->EXADriverPtr->memorySize = pI830->Offscreen.End; if(pI830->EXADriverPtr->memorySize > pI830->EXADriverPtr->offScreenBase) -- cgit v1.2.3 From bc42dbe07cbd61b357d8eed02608e026c4cf4485 Mon Sep 17 00:00:00 2001 From: Wang Zhenyu Date: Mon, 22 May 2006 11:22:03 +0800 Subject: fix a typo --- src/i830_exa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/i830_exa.c b/src/i830_exa.c index a67e5498..b22430a7 100644 --- a/src/i830_exa.c +++ b/src/i830_exa.c @@ -234,7 +234,7 @@ I830EXAPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int xdir, ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum]; I830Ptr pI830 = I830PTR(pScrn); - if (planemask != (Pixel)~0 && !EXA_PM_IS_SOLID(pScrPixmap, planemask)) + if (planemask != (Pixel)~0 && !EXA_PM_IS_SOLID(pSrcPixmap, planemask)) I830FALLBACK("planemask is not solid"); pI830->copy_src_pitch = exaGetPixmapPitch(pSrcPixmap); -- cgit v1.2.3 From f2ab3aa3199e1c4b0edec72b5acea6d725cc514a Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Sun, 18 Jun 2006 00:32:01 -0700 Subject: Fix DRI in EXA mode: Don't attempt to use XAA symbols (use the driver's internal ones for EXA support when available). Also, add an abstraction of XAA/EXA MarkSync and WaitSync functionality so we don't need to sprinkle the ifdefs all over, and correctly use them. --- src/i830.h | 2 ++ src/i830_accel.c | 5 +--- src/i830_dri.c | 10 ++----- src/i830_driver.c | 80 +++++++++++++++++++++++++++++-------------------------- src/i830_exa.c | 4 +-- src/i830_xaa.c | 22 +++++++++++++++ 6 files changed, 71 insertions(+), 52 deletions(-) diff --git a/src/i830.h b/src/i830.h index edc485be..9a8ecf88 100644 --- a/src/i830.h +++ b/src/i830.h @@ -491,6 +491,8 @@ extern Bool I830CheckModeSupport(ScrnInfoPtr pScrn, int x, int y, int mode); extern Bool I830Rotate(ScrnInfoPtr pScrn, DisplayModePtr mode); extern Bool I830FixOffset(ScrnInfoPtr pScrn, I830MemRange *mem); +extern void i830MarkSync(ScrnInfoPtr pScrn); +extern void i830WaitSync(ScrnInfoPtr pScrn); /* * 12288 is set as the maximum, chosen because it is enough for * 1920x1440@32bpp with a 2048 pixel line pitch with some to spare. diff --git a/src/i830_accel.c b/src/i830_accel.c index a1a64880..f2993985 100644 --- a/src/i830_accel.c +++ b/src/i830_accel.c @@ -208,10 +208,7 @@ I830RefreshRing(ScrnInfoPtr pScrn) pI830->LpRing->space = pI830->LpRing->head - (pI830->LpRing->tail + 8); if (pI830->LpRing->space < 0) pI830->LpRing->space += pI830->LpRing->mem.Size; -#ifdef I830_USE_XAA - if (pI830->AccelInfoRec) - pI830->AccelInfoRec->NeedToSync = TRUE; -#endif + i830MarkSync(pScrn); } /* The following function sets up the supported acceleration. Call it diff --git a/src/i830_dri.c b/src/i830_dri.c index c1596861..76298a3a 100644 --- a/src/i830_dri.c +++ b/src/i830_dri.c @@ -979,7 +979,6 @@ I830DRIInitBuffers(WindowPtr pWin, RegionPtr prgn, CARD32 index) { ScreenPtr pScreen = pWin->drawable.pScreen; ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - I830Ptr pI830 = I830PTR(pScrn); BoxPtr pbox = REGION_RECTS(prgn); int nbox = REGION_NUM_RECTS(prgn); @@ -1017,9 +1016,7 @@ I830DRIInitBuffers(WindowPtr pWin, RegionPtr prgn, CARD32 index) } I830SelectBuffer(pScrn, I830_SELECT_FRONT); -#ifdef I830_USE_XAA - pI830->AccelInfoRec->NeedToSync = TRUE; -#endif + i830MarkSync(pScrn); } /* This routine is a modified form of XAADoBitBlt with the calls to @@ -1033,7 +1030,6 @@ I830DRIMoveBuffers(WindowPtr pParent, DDXPointRec ptOldOrg, { ScreenPtr pScreen = pParent->drawable.pScreen; ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - I830Ptr pI830 = I830PTR(pScrn); BoxPtr pboxTmp, pboxNext, pboxBase; DDXPointPtr pptTmp, pptNew2; int xdir, ydir; @@ -1180,9 +1176,7 @@ I830DRIMoveBuffers(WindowPtr pParent, DDXPointRec ptOldOrg, DEALLOCATE_LOCAL(pptNew1); DEALLOCATE_LOCAL(pboxNew1); } -#ifdef I830_USE_XAA - pI830->AccelInfoRec->NeedToSync = TRUE; -#endif + i830MarkSync(pScrn); } /* Initialize the first context */ diff --git a/src/i830_driver.c b/src/i830_driver.c index 5cfb6fcc..fe61884a 100644 --- a/src/i830_driver.c +++ b/src/i830_driver.c @@ -5258,18 +5258,8 @@ I830BIOSAdjustFrame(int scrnIndex, int x, int y, int flags) x, pI830->xoffset, y, pI830->yoffset); /* Sync the engine before adjust frame */ -#ifdef I830_USE_XAA - if (!pI830->noAccel && !pI830->useEXA && pI830->AccelInfoRec->NeedToSync) { - (*pI830->AccelInfoRec->Sync)(pScrn); - pI830->AccelInfoRec->NeedToSync = FALSE; - } -#endif -#ifdef I830_USE_EXA - if (!pI830->noAccel && pI830->useEXA) { - ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex]; - exaWaitSync(pScreen); - } -#endif + i830WaitSync(pScrn); + if (I830IsPrimary(pScrn)) Start = pI830->FrontBuffer.Start; else { @@ -5398,16 +5388,11 @@ I830BIOSLeaveVT(int scrnIndex, int flags) RestoreBIOSMemSize(pScrn); if (I830IsPrimary(pScrn)) I830UnbindAGPMemory(pScrn); + #ifdef I830_USE_XAA if (!pI830->useEXA && pI830->AccelInfoRec) pI830->AccelInfoRec->NeedToSync = FALSE; #endif -#ifdef I830_USE_EXA - if (pI830->useEXA && pI830->EXADriverPtr) { - ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex]; - exaMarkSync(pScreen); - } -#endif /* DO IT AGAIN! AS IT SEEMS THAT SOME LFPs FLICKER OTHERWISE */ if (I830IsPrimary(pScrn)) { @@ -5741,18 +5726,7 @@ I830BIOSSwitchMode(int scrnIndex, DisplayModePtr mode, int flags) #endif /* Sync the engine before mode switch */ -#ifdef I830_USE_XAA - if (!pI830->noAccel && !pI830->useEXA) { - (*pI830->AccelInfoRec->Sync)(pScrn); - pI830->AccelInfoRec->NeedToSync = FALSE; - } -#endif -#ifdef I830_USE_EXA - if (!pI830->noAccel && pI830->useEXA) { - ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex]; - exaWaitSync(pScreen); - } -#endif + i830WaitSync(pScrn); /* Check if our currentmode is about to change. We do this so if we * are rotating, we don't need to call the mode setup again. @@ -6122,14 +6096,8 @@ I830CheckDevicesTimer(OsTimerPtr timer, CARD32 now, pointer arg) xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Hotkey switch to 0x%lx.\n", (unsigned long) temp); -#ifdef I830_USE_XAA - if (!pI830->useEXA && pI830->AccelInfoRec && pI830->AccelInfoRec->NeedToSync) { - (*pI830->AccelInfoRec->Sync)(pScrn); - pI830->AccelInfoRec->NeedToSync = FALSE; - if (xf86IsEntityShared(pScrn->entityList[0])) - pI8302->AccelInfoRec->NeedToSync = FALSE; - } -#endif + i830WaitSync(pScrn); + GetAttachableDisplayDeviceList(pScrn); pI8301->lastDevice0 = pI8301->lastDevice1; @@ -6398,6 +6366,42 @@ I830CheckDevicesTimer(OsTimerPtr timer, CARD32 now, pointer arg) return 1000; } +void +i830WaitSync(ScrnInfoPtr pScrn) +{ + I830Ptr pI830 = I830PTR(pScrn); + +#ifdef I830_USE_XAA + if (!pI830->noAccel && !pI830->useEXA && pI830->AccelInfoRec->NeedToSync) { + (*pI830->AccelInfoRec->Sync)(pScrn); + pI830->AccelInfoRec->NeedToSync = FALSE; + } +#endif +#ifdef I830_USE_EXA + if (!pI830->noAccel && pI830->useEXA && pI830->EXADriverPtr) { + ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex]; + exaWaitSync(pScreen); + } +#endif +} + +void +i830MarkSync(ScrnInfoPtr pScrn) +{ + I830Ptr pI830 = I830PTR(pScrn); + +#ifdef I830_USE_XAA + if (!pI830->useEXA && pI830->AccelInfoRec) + pI830->AccelInfoRec->NeedToSync = FALSE; +#endif +#ifdef I830_USE_EXA + if (pI830->useEXA && pI830->EXADriverPtr) { + ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex]; + exaMarkSync(pScreen); + } +#endif +} + void I830InitpScrn(ScrnInfoPtr pScrn) { diff --git a/src/i830_exa.c b/src/i830_exa.c index b22430a7..7212972a 100644 --- a/src/i830_exa.c +++ b/src/i830_exa.c @@ -51,7 +51,7 @@ do { \ #define I830FALLBACK(s, arg...) { return FALSE; } #endif -int I830CopyROP[16] = +const int I830CopyROP[16] = { ROP_0, /* GXclear */ ROP_DSa, /* GXand */ @@ -71,7 +71,7 @@ int I830CopyROP[16] = ROP_1 /* GXset */ }; -static int I830PatternROP[16] = +const int I830PatternROP[16] = { ROP_0, ROP_DPa, diff --git a/src/i830_xaa.c b/src/i830_xaa.c index 68ba4c7f..9f3a3910 100644 --- a/src/i830_xaa.c +++ b/src/i830_xaa.c @@ -92,6 +92,11 @@ static void I830SubsequentImageWriteScanline(ScrnInfoPtr pScrn, int bufno); #endif static void I830RestoreAccelState(ScrnInfoPtr pScrn); +#ifdef I830_USE_EXA +extern const int I830PatternROP[16]; +extern const int I830CopyROP[16]; +#endif + Bool I830XAAInit(ScreenPtr pScreen) { @@ -235,8 +240,17 @@ I830SetupForSolidFill(ScrnInfoPtr pScrn, int color, int rop, ErrorF("I830SetupForFillRectSolid color: %x rop: %x mask: %x\n", color, rop, planemask); +#ifdef I830_USE_EXA + /* This function gets used by I830DRIInitBuffers(), and we might not have + * XAAGetPatternROP() available. So just use the ROPs from our EXA code + * if available. + */ + pI830->BR[13] = ((I830PatternROP[rop] << 16) | + (pScrn->displayWidth * pI830->cpp)); +#else pI830->BR[13] = ((XAAGetPatternROP(rop) << 16) | (pScrn->displayWidth * pI830->cpp)); +#endif pI830->BR[16] = color; @@ -291,7 +305,15 @@ I830SetupForScreenToScreenCopy(ScrnInfoPtr pScrn, int xdir, int ydir, int rop, xdir, ydir, rop, planemask, transparency_color); pI830->BR[13] = (pScrn->displayWidth * pI830->cpp); +#ifdef I830_USE_EXA + /* This function gets used by I830DRIInitBuffers(), and we might not have + * XAAGetCopyROP() available. So just use the ROPs from our EXA code + * if available. + */ + pI830->BR[13] |= I830CopyROP[rop] << 16; +#else pI830->BR[13] |= XAAGetCopyROP(rop) << 16; +#endif switch (pScrn->bitsPerPixel) { case 8: -- cgit v1.2.3 From 89a5a0024a7e077a0726ffe1427e573df3bcbef5 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Sun, 18 Jun 2006 00:25:34 -0700 Subject: Fix crash with EXA during randr, when XAA structures were being accessed. EXA shouldn't have any issues with there also being pixmaps in framebuffer while rotation is active. --- src/i830_rotate.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/src/i830_rotate.c b/src/i830_rotate.c index e4a80645..ad4c484b 100644 --- a/src/i830_rotate.c +++ b/src/i830_rotate.c @@ -959,21 +959,26 @@ I830Rotate(ScrnInfoPtr pScrn, DisplayModePtr mode) } } - /* Don't allow pixmap cache or offscreen pixmaps when rotated */ - /* XAA needs some serious fixing for this to happen */ - if (pI830->rotation == RR_Rotate_0) { - pI830->AccelInfoRec->Flags = LINEAR_FRAMEBUFFER | OFFSCREEN_PIXMAPS | PIXMAP_CACHE; - pI830->AccelInfoRec->UsingPixmapCache = TRUE; - /* funny as it seems this will enable XAA's createpixmap */ - pI830->AccelInfoRec->maxOffPixWidth = 0; - pI830->AccelInfoRec->maxOffPixHeight = 0; - } else { - pI830->AccelInfoRec->Flags = LINEAR_FRAMEBUFFER; - pI830->AccelInfoRec->UsingPixmapCache = FALSE; - /* funny as it seems this will disable XAA's createpixmap */ - pI830->AccelInfoRec->maxOffPixWidth = 1; - pI830->AccelInfoRec->maxOffPixHeight = 1; +#ifdef I830_USE_XAA + if (pI830->AccelInfoRec != NULL) { + /* Don't allow pixmap cache or offscreen pixmaps when rotated */ + /* XAA needs some serious fixing for this to happen */ + if (pI830->rotation == RR_Rotate_0) { + pI830->AccelInfoRec->Flags = LINEAR_FRAMEBUFFER | OFFSCREEN_PIXMAPS | + PIXMAP_CACHE; + pI830->AccelInfoRec->UsingPixmapCache = TRUE; + /* funny as it seems this will enable XAA's createpixmap */ + pI830->AccelInfoRec->maxOffPixWidth = 0; + pI830->AccelInfoRec->maxOffPixHeight = 0; + } else { + pI830->AccelInfoRec->Flags = LINEAR_FRAMEBUFFER; + pI830->AccelInfoRec->UsingPixmapCache = FALSE; + /* funny as it seems this will disable XAA's createpixmap */ + pI830->AccelInfoRec->maxOffPixWidth = 1; + pI830->AccelInfoRec->maxOffPixHeight = 1; + } } +#endif return TRUE; -- cgit v1.2.3 From 3cdc53797bf6fdbfbcb53e07b269a5071f5ec97d Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 26 Jun 2006 16:23:55 +0200 Subject: Fix build with new EXA headers. --- src/i830_exa.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/i830_exa.c b/src/i830_exa.c index 7212972a..665c4d72 100644 --- a/src/i830_exa.c +++ b/src/i830_exa.c @@ -149,7 +149,7 @@ I830EXAPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planemask, Pixel fg) I830Ptr pI830 = I830PTR(pScrn); unsigned long offset, pitch; - if (planemask != (Pixel)~0 && !EXA_PM_IS_SOLID(pPixmap, planemask)) + if (!EXA_PM_IS_SOLID(&pPixmap->drawable, planemask)) I830FALLBACK("planemask is not solid"); offset = exaGetPixmapOffset(pPixmap); @@ -234,7 +234,7 @@ I830EXAPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int xdir, ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum]; I830Ptr pI830 = I830PTR(pScrn); - if (planemask != (Pixel)~0 && !EXA_PM_IS_SOLID(pSrcPixmap, planemask)) + if (!EXA_PM_IS_SOLID(&pSrcPixmap->drawable, planemask)) I830FALLBACK("planemask is not solid"); pI830->copy_src_pitch = exaGetPixmapPitch(pSrcPixmap); -- cgit v1.2.3 From b85f268051a785f90e4c55bd1cac80d673388f16 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 26 Jun 2006 16:26:58 +0200 Subject: Fix remaining warning. --- src/i830_memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/i830_memory.c b/src/i830_memory.c index 50bbde53..c1c7cb73 100644 --- a/src/i830_memory.c +++ b/src/i830_memory.c @@ -874,7 +874,7 @@ I830Allocate2DMemory(ScrnInfoPtr pScrn, const int flags) return FALSE; } else { xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Successful allocate " - "offscreen memory at 0x%lx, size %d KB\n", + "offscreen memory at 0x%lx, size %ld KB\n", pI830->Offscreen.Start, pI830->Offscreen.Size/1024); } #endif -- cgit v1.2.3 From 04d1584737fd0d14e99608a97281fd7b1549ae0e Mon Sep 17 00:00:00 2001 From: Wang Zhenyu Date: Fri, 14 Jul 2006 16:14:18 +0800 Subject: Current exa render implement for i830 and i915, test on 865GM and 915G. There is issue in picture 'repeat' support. And also stop recursive behavior in I830WaitLpRing to allow server to abort instead of system hang. --- src/Makefile.am | 4 +- src/i830_accel.c | 3 + src/i830_exa.c | 285 +++++++++++++++++++++----- src/i830_exa_render.c | 537 ++++++++++++++++++++++++++++++++++++++++++++++++ src/i830_reg.h | 101 ++++++++- src/i915_exa_render.c | 553 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/i915_reg.h | 3 + 7 files changed, 1433 insertions(+), 53 deletions(-) create mode 100644 src/i830_exa_render.c create mode 100644 src/i915_exa_render.c diff --git a/src/Makefile.am b/src/Makefile.am index c9e8780b..9c2a5c21 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -60,7 +60,9 @@ i810_drv_la_SOURCES = \ i915_3d.c \ i915_reg.h \ i830_exa.c \ - i830_xaa.c + i830_xaa.c \ + i830_exa_render.c \ + i915_exa_render.c if DRI i810_drv_la_SOURCES += \ diff --git a/src/i830_accel.c b/src/i830_accel.c index f2993985..6b338879 100644 --- a/src/i830_accel.c +++ b/src/i830_accel.c @@ -109,6 +109,9 @@ I830WaitLpRing(ScrnInfoPtr pScrn, int n, int timeout_millis) #endif #ifdef I830_USE_XAA pI830->AccelInfoRec = NULL; /* Stops recursive behavior */ +#endif +#ifdef I830_USE_EXA + pI830->EXADriverPtr = NULL; #endif FatalError("lockup\n"); } diff --git a/src/i830_exa.c b/src/i830_exa.c index 665c4d72..83601dc3 100644 --- a/src/i830_exa.c +++ b/src/i830_exa.c @@ -36,9 +36,10 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "xaarop.h" #include "i830.h" #include "i810_reg.h" +#include "i830_reg.h" #ifdef I830DEBUG -#define DEBUG_I830FALLBACK 0 +#define DEBUG_I830FALLBACK 1 #endif #ifdef DEBUG_I830FALLBACK @@ -48,9 +49,15 @@ do { \ return FALSE; \ } while(0) #else -#define I830FALLBACK(s, arg...) { return FALSE; } +#define I830FALLBACK(s, arg...) \ +do { \ + return FALSE; \ +} while(0) #endif +float scale_units[2][2]; +int draw_coords[3][2]; + const int I830CopyROP[16] = { ROP_0, /* GXclear */ @@ -91,12 +98,33 @@ const int I830PatternROP[16] = ROP_1 }; -void i830ScratchSave(ScreenPtr pScreen, ExaOffscreenArea *area); -Bool i830UploadToScreen(PixmapPtr pDst, char *src, int src_pitch); -Bool i830UploadToScratch(PixmapPtr pSrc, PixmapPtr pDst); +/* move to common.h */ +union intfloat { + float f; + unsigned int ui; +}; + +#define OUT_RING_F(x) do { \ + union intfloat tmp; \ + tmp.f = (float)(x); \ + OUT_RING(tmp.ui); \ +} while(0) + +Bool is_transform[2]; +PictTransform *transform[2]; + +Bool i830UploadToScreen(PixmapPtr pDst, int x, int y, int w, int h, + char *src, int src_pitch); Bool i830DownloadFromScreen(PixmapPtr pSrc, int x, int y, int w, int h, char *dst, int dst_pitch); +extern Bool I830EXACheckComposite(int, PicturePtr, PicturePtr, PicturePtr); +extern Bool I830EXAPrepareComposite(int, PicturePtr, PicturePtr, PicturePtr, + PixmapPtr, PixmapPtr, PixmapPtr); +extern Bool I915EXACheckComposite(int, PicturePtr, PicturePtr, PicturePtr); +extern Bool I915EXAPrepareComposite(int, PicturePtr, PicturePtr, PicturePtr, + PixmapPtr, PixmapPtr, PixmapPtr); + /** * I830EXASync - wait for a command to finish * @pScreen: current screen @@ -295,27 +323,69 @@ I830EXACopy(PixmapPtr pDstPixmap, int src_x1, int src_y1, int dst_x1, static void I830EXADoneCopy(PixmapPtr pDstPixmap) { - return; + return; } -#if 0 /* Not done (or even started for that matter) */ +//#define UPLOAD_USE_BLIT 1 + static Bool -I830EXAUploadToScreen(PixmapPtr pDst, char *src, int src_pitch) +I830EXAUploadToScreen(PixmapPtr pDst, int x, int y, int w, int h, + char *src, int src_pitch) { ScrnInfoPtr pScrn = xf86Screens[pDst->drawable.pScreen->myNum]; I830Ptr pI830 = I830PTR(pScrn); - unsigned char *dst = pDst->devPrivate.ptr; int dst_pitch = exaGetPixmapPitch(pDst); - int size = src_pitch < dst_pitch ? src_pitch : dst_pitch; - int h = pDst->drawable.height; + int dst_offset = exaGetPixmapOffset(pDst); + unsigned char *dst; I830Sync(pScrn); + ErrorF("Up->Screen: dst offset 0x%x, dst pitch %d, x %d, y %d, src %p, src pitch %d\n", + dst_offset, dst_pitch, x, y, src, src_pitch); +#ifndef UPLOAD_USE_BLIT + dst = pI830->FbBase + dst_offset + y*dst_pitch + + x* (pDst->drawable.bitsPerPixel/8); + w *= pDst->drawable.bitsPerPixel/8; while(h--) { - i830MemCopyToVideoRam(pI830, dst, (unsigned char *)src, size); + memcpy(dst, src, w); src += src_pitch; dst += dst_pitch; } +#else + /* setup blit engine to copy one pixel data by one */ + { + int x1, x2, y1, y2, i, j; + CARD32 d, len, *srcp; + x1 = x; + y1 = y; + x2 = x + w; + y2 = y + h; + + len = (w * (pDst->drawable.bitsPerPixel/8)) >> 2; + + pI830->BR[13] = (1 << 24) | (1 << 25); + pI830->BR[13] |= I830CopyROP[GXcopy]<<16; + pI830->BR[13] |= dst_pitch & 0xffff; + for (i = 0; i < h; i++) { + srcp = (CARD32*)src; + for ( j = len; j > 0; j--) { + d = *srcp; + BEGIN_LP_RING(6); + OUT_RING(XY_COLOR_BLT_CMD | XY_COLOR_BLT_WRITE_ALPHA | + XY_COLOR_BLT_WRITE_RGB); + OUT_RING(pI830->BR[13]); + OUT_RING((y1 << 16) | x1); + OUT_RING((y2 << 16) | x2); + OUT_RING(dst_offset); + OUT_RING(d); + ADVANCE_LP_RING(); + srcp++; + } + src += src_pitch; + } + + } +#endif return TRUE; } @@ -326,14 +396,18 @@ I830EXADownloadFromScreen(PixmapPtr pSrc, int x, int y, int w, int h, { ScrnInfoPtr pScrn = xf86Screens[pSrc->drawable.pScreen->myNum]; I830Ptr pI830 = I830PTR(pScrn); - unsigned char *src = pSrc->devPrivate.ptr; int src_pitch = exaGetPixmapPitch(pSrc); - int size = src_pitch < dst_pitch ? src_pitch : dst_pitch; + int src_offset = exaGetPixmapOffset(pSrc); + unsigned char *src = pI830->FbBase + src_offset + y*src_pitch + + x*(pSrc->drawable.bitsPerPixel/8); I830Sync(pScrn); + ErrorF("Screen->Mem: src offset 0x%x, src %p, src pitch %d, x %d, y %d, dst %p, dst_pitch %d\n", + src_offset, src, src_pitch, x, y, dst, dst_pitch); + w *= pSrc->drawable.bitsPerPixel/8; while(h--) { - i830MemCopyFromVideoRam(pI830, (unsigned char *)dst, src, size); + memcpy(dst, src, w); src += src_pitch; dst += dst_pitch; } @@ -341,40 +415,145 @@ I830EXADownloadFromScreen(PixmapPtr pSrc, int x, int y, int w, int h, return TRUE; } -static Bool -I830EXACheckComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture, - PicturePtr pDstPicture) +static void +IntelEXAComposite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY, + int dstX, int dstY, int w, int h) { - return FALSE; /* no Composite yet */ -} + /* should be same like I830Composite */ + ScrnInfoPtr pScrn = xf86Screens[pDst->drawable.pScreen->myNum]; + I830Ptr pI830 = I830PTR(pScrn); + int srcXend, srcYend, maskXend, maskYend; + PictVector v; + int pMask = 1; + +ErrorF("Composite: srcX %d, srcY %d\n\t maskX %d, maskY %d\n\t" + "dstX %d, dstY %d\n\twidth %d, height %d\n\t" + "src_scale_x %f, src_scale_y %f, mask_scale_x %f, mask_scale_y %f\n""\tdx0 %d, dy0 %x, dx1 %d dy1 %x\n", + srcX, srcY, maskX, maskY, dstX, dstY, w, h, + scale_units[0][0], scale_units[0][1], + scale_units[1][0], scale_units[1][1], + draw_coords[0][0], draw_coords[0][1], + draw_coords[1][0], draw_coords[1][1]); + + if (scale_units[1][0] == -1 || scale_units[1][1] == -1) { + ErrorF("mask is null\n"); + pMask = 0; + } -static Bool -I830EXAPrepareComposite(int op, PicturePtr pSrcPicture, - PicturePtr pMaskPicture, PicturePtr pDstPicture, - PixmapPtr pSrc, PixmapPtr pMask, PixmapPtr pDst) -{ - return FALSE; /* no Composite yet */ -} + srcXend = srcX + w; + srcYend = srcY + h; + maskXend = maskX + w; + maskYend = maskY + h; + if (is_transform[0]) { + v.vector[0] = IntToxFixed(srcX); + v.vector[1] = IntToxFixed(srcY); + v.vector[2] = xFixed1; + PictureTransformPoint(transform[0], &v); + srcX = xFixedToInt(v.vector[0]); + srcY = xFixedToInt(v.vector[1]); + v.vector[0] = IntToxFixed(srcXend); + v.vector[1] = IntToxFixed(srcYend); + v.vector[2] = xFixed1; + PictureTransformPoint(transform[0], &v); + srcXend = xFixedToInt(v.vector[0]); + srcYend = xFixedToInt(v.vector[1]); + } + if (is_transform[1]) { + v.vector[0] = IntToxFixed(maskX); + v.vector[1] = IntToxFixed(maskY); + v.vector[2] = xFixed1; + PictureTransformPoint(transform[1], &v); + maskX = xFixedToInt(v.vector[0]); + maskY = xFixedToInt(v.vector[1]); + v.vector[0] = IntToxFixed(maskXend); + v.vector[1] = IntToxFixed(maskYend); + v.vector[2] = xFixed1; + PictureTransformPoint(transform[1], &v); + maskXend = xFixedToInt(v.vector[0]); + maskYend = xFixedToInt(v.vector[1]); + } +DPRINTF(PFX, "After transform: srcX %d, srcY %d,srcXend %d, srcYend %d\n\t" + "maskX %d, maskY %d, maskXend %d, maskYend %d\n\t" + "dstX %d, dstY %d\n", srcX, srcY, srcXend, srcYend, + maskX, maskY, maskXend, maskYend, dstX, dstY); + + draw_coords[0][0] -= draw_coords[2][0]; + draw_coords[0][1] -= draw_coords[2][1]; + if (pMask) { + draw_coords[1][0] -= draw_coords[2][0]; + draw_coords[1][1] -= draw_coords[2][1]; + } + + { + int vertex_count; + + if (pMask) + vertex_count = 4*6; + else + vertex_count = 4*4; + + BEGIN_LP_RING(6+vertex_count); + + OUT_RING(MI_NOOP); + OUT_RING(MI_NOOP); + OUT_RING(MI_NOOP); + OUT_RING(MI_NOOP); + OUT_RING(MI_NOOP); + + OUT_RING(PRIM3D_INLINE | PRIM3D_TRIFAN | (vertex_count-1)); + + OUT_RING(dstX); + OUT_RING(dstY); + OUT_RING_F(((srcX - draw_coords[0][0]) / scale_units[0][0])); + OUT_RING_F(((srcY - draw_coords[0][1]) / scale_units[0][1])); + if (pMask) { + OUT_RING_F(((maskX - draw_coords[1][0]) / scale_units[1][0])); + OUT_RING_F(((maskY - draw_coords[1][1]) / scale_units[1][1])); + } + + OUT_RING(dstX); + OUT_RING((dstY+h)); + OUT_RING_F(((srcX - draw_coords[0][0]) / scale_units[0][0])); + OUT_RING_F(((srcYend - draw_coords[0][1]) / scale_units[0][1])); + if (pMask) { + OUT_RING_F(((maskX - draw_coords[1][0]) / scale_units[1][0])); + OUT_RING_F(((maskYend - draw_coords[1][1]) / scale_units[1][1])); + } + + OUT_RING((dstX+w)); + OUT_RING((dstY+h)); + OUT_RING_F(((srcXend - draw_coords[0][0]) / scale_units[0][0])); + OUT_RING_F(((srcYend - draw_coords[0][1]) / scale_units[0][1])); + if (pMask) { + OUT_RING_F(((maskXend - draw_coords[1][0]) / scale_units[1][0])); + OUT_RING_F(((maskYend - draw_coords[1][1]) / scale_units[1][1])); + } + + OUT_RING((dstX+w)); + OUT_RING((dstY)); + OUT_RING_F(((srcXend - draw_coords[0][0]) / scale_units[0][0])); + OUT_RING_F(((srcY - draw_coords[0][1]) / scale_units[0][1])); + if (pMask) { + OUT_RING_F(((maskXend - draw_coords[1][0]) / scale_units[1][0])); + OUT_RING_F(((maskY - draw_coords[1][1]) / scale_units[1][1])); + } + ADVANCE_LP_RING(); + } +#ifdef I830DEBUG + ErrorF("sync after 3dprimitive"); + I830Sync(pScrn); +#endif -static void -I830EXAComposite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY, - int dstX, int dstY, int width, int height) -{ - return; /* no Composite yet */ } static void -I830EXADoneComposite(PixmapPtr pDst) +IntelEXADoneComposite(PixmapPtr pDst) { - return; /* no Composite yet */ + return; } -#endif - /* * TODO: * - Dual head? - * - Upload/Download - * - Composite */ Bool I830EXAInit(ScreenPtr pScreen) @@ -396,6 +575,12 @@ I830EXAInit(ScreenPtr pScreen) pI830->EXADriverPtr->offScreenBase = pI830->Offscreen.Start; pI830->EXADriverPtr->memorySize = pI830->Offscreen.End; + DPRINTF(PFX, "EXA Mem: memoryBase 0x%x, end 0x%x, offscreen base 0x%x, memorySize 0x%x\n", + pI830->EXADriverPtr->memoryBase, + pI830->EXADriverPtr->memoryBase + pI830->EXADriverPtr->memorySize, + pI830->EXADriverPtr->offScreenBase, + pI830->EXADriverPtr->memorySize); + if(pI830->EXADriverPtr->memorySize > pI830->EXADriverPtr->offScreenBase) pI830->EXADriverPtr->flags = EXA_OFFSCREEN_PIXMAPS; @@ -422,17 +607,23 @@ I830EXAInit(ScreenPtr pScreen) pI830->EXADriverPtr->PrepareCopy = I830EXAPrepareCopy; pI830->EXADriverPtr->Copy = I830EXACopy; pI830->EXADriverPtr->DoneCopy = I830EXADoneCopy; -#if 0 - /* Upload, download to/from Screen */ - pI830->EXADriverPtr->UploadToScreen = I830EXAUploadToScreen; - pI830->EXADriverPtr->DownloadFromScreen = I830EXADownloadFromScreen; /* Composite */ - pI830->EXADriverPtr->CheckComposite = I830EXACheckComposite; - pI830->EXADriverPtr->PrepareComposite = I830EXAPrepareComposite; - pI830->EXADriverPtr->Composite = I830EXAComposite; - pI830->EXADriverPtr->DoneComposite = I830EXADoneComposite; -#endif + if (IS_I9XX(pI830)) { + pI830->EXADriverPtr->CheckComposite = I915EXACheckComposite; + pI830->EXADriverPtr->PrepareComposite = I915EXAPrepareComposite; + pI830->EXADriverPtr->Composite = IntelEXAComposite; + pI830->EXADriverPtr->DoneComposite = IntelEXADoneComposite; + } else if (IS_I865G(pI830) || IS_I855(pI830) || IS_845G(pI830) || IS_I830(pI830)) { + pI830->EXADriverPtr->CheckComposite = I830EXACheckComposite; + pI830->EXADriverPtr->PrepareComposite = I830EXAPrepareComposite; + pI830->EXADriverPtr->Composite = IntelEXAComposite; + pI830->EXADriverPtr->DoneComposite = IntelEXADoneComposite; + } + + /* Upload, download to/from Screen, experimental!! */ + pI830->EXADriverPtr->UploadToScreen = I830EXAUploadToScreen; + pI830->EXADriverPtr->DownloadFromScreen = I830EXADownloadFromScreen; if(!exaDriverInit(pScreen, pI830->EXADriverPtr)) { xfree(pI830->EXADriverPtr); diff --git a/src/i830_exa_render.c b/src/i830_exa_render.c new file mode 100644 index 00000000..9b4835bc --- /dev/null +++ b/src/i830_exa_render.c @@ -0,0 +1,537 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "xf86.h" +#include "i830.h" +#include "i830_reg.h" + +#ifdef I830DEBUG +#define DEBUG_I830FALLBACK 1 +#endif + +#ifdef DEBUG_I830FALLBACK +#define I830FALLBACK(s, arg...) \ +do { \ + DPRINTF(PFX, "EXA fallback: " s "\n", ##arg); \ + return FALSE; \ +} while(0) +#else +#define I830FALLBACK(s, arg...) \ +do { \ + return FALSE; \ +} while(0) +#endif + +extern float scale_units[2][2]; +extern int draw_coords[3][2]; +extern Bool is_transform[2]; +extern PictTransform *transform[2]; + +struct blendinfo { + Bool dst_alpha; + Bool src_alpha; + CARD32 blend_cntl; +}; + +struct formatinfo { + int fmt; + CARD32 card_fmt; +}; + +extern Bool +I830EXACheckComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture, + PicturePtr pDstPicture); + +extern Bool +I830EXAPrepareComposite(int op, PicturePtr pSrcPicture, + PicturePtr pMaskPicture, PicturePtr pDstPicture, + PixmapPtr pSrc, PixmapPtr pMask, PixmapPtr pDst); + +/* I830's Blend factor definition, LOAD_STATE_IMMEDIATE_1 */ +/* move to header...*/ +#define I830_SRC_BLENDFACTOR_ZERO (1 << 4) +#define I830_SRC_BLENDFACTOR_ONE (2 << 4) +#define I830_SRC_BLENDFACTOR_SRC_COLOR (3 << 4) +#define I830_SRC_BLENDFACTOR_INV_SRC_COLOR (4 << 4) +#define I830_SRC_BLENDFACTOR_SRC_ALPHA (5 << 4) +#define I830_SRC_BLENDFACTOR_INV_SRC_ALPHA (6 << 4) +#define I830_SRC_BLENDFACTOR_DST_ALPHA (7 << 4) +#define I830_SRC_BLENDFACTOR_INV_DST_ALPHA (8 << 4) +#define I830_SRC_BLENDFACTOR_DST_COLOR (9 << 4) +#define I830_SRC_BLENDFACTOR_INV_DST_COLOR (0xa << 4) +#define I830_SRC_BLENDFACTOR_SRC_ALPHA_SATURATE (0xb << 4) +#define I830_SRC_BLENDFACTOR_CONST_COLOR (0xc << 4) +#define I830_SRC_BLENDFACTOR_INV_CONST_COLOR (0xd << 4) +#define I830_SRC_BLENDFACTOR_CONST_ALPHA (0xe << 4) +#define I830_SRC_BLENDFACTOR_INV_CONST_ALPHA (0xf << 4) +#define I830_SRC_BLENDFACTOR_MASK (0xf << 4) + +#define I830_DST_BLENDFACTOR_ZERO (1) +#define I830_DST_BLENDFACTOR_ONE (2) +#define I830_DST_BLENDFACTOR_SRC_COLOR (3) +#define I830_DST_BLENDFACTOR_INV_SRC_COLOR (4) +#define I830_DST_BLENDFACTOR_SRC_ALPHA (5) +#define I830_DST_BLENDFACTOR_INV_SRC_ALPHA (6) +#define I830_DST_BLENDFACTOR_DST_ALPHA (7) +#define I830_DST_BLENDFACTOR_INV_DST_ALPHA (8) +#define I830_DST_BLENDFACTOR_DST_COLOR (9) +#define I830_DST_BLENDFACTOR_INV_DST_COLOR (0xa) +#define I830_DST_BLENDFACTOR_SRC_ALPHA_SATURATE (0xb) +#define I830_DST_BLENDFACTOR_CONST_COLOR (0xc) +#define I830_DST_BLENDFACTOR_INV_CONST_COLOR (0xd) +#define I830_DST_BLENDFACTOR_CONST_ALPHA (0xe) +#define I830_DST_BLENDFACTOR_INV_CONST_ALPHA (0xf) +#define I830_DST_BLENDFACTOR_MASK (0xf) + +#define TB0C_LAST_STAGE (1 << 31) +#define TB0C_RESULT_SCALE_1X (0 << 29) +#define TB0C_RESULT_SCALE_2X (1 << 29) +#define TB0C_RESULT_SCALE_4X (2 << 29) +#define TB0C_OP_MODULE (3 << 25) +#define TB0C_OUTPUT_WRITE_CURRENT (0 << 24) +#define TB0C_OUTPUT_WRITE_ACCUM (1 << 24) +#define TB0C_ARG3_REPLICATE_ALPHA (1<<23) +#define TB0C_ARG3_INVERT (1<<22) +#define TB0C_ARG3_SEL_XXX +#define TB0C_ARG2_REPLICATE_ALPHA (1<<17) +#define TB0C_ARG2_INVERT (1<<16) +#define TB0C_ARG2_SEL_ONE (0 << 12) +#define TB0C_ARG2_SEL_FACTOR (1 << 12) +#define TB0C_ARG2_SEL_TEXEL0 (6 << 12) +#define TB0C_ARG2_SEL_TEXEL1 (7 << 12) +#define TB0C_ARG2_SEL_TEXEL2 (8 << 12) +#define TB0C_ARG2_SEL_TEXEL3 (9 << 12) +#define TB0C_ARG1_REPLICATE_ALPHA (1<<11) +#define TB0C_ARG1_INVERT (1<<10) +#define TB0C_ARG1_SEL_TEXEL0 (6 << 6) +#define TB0C_ARG1_SEL_TEXEL1 (7 << 6) +#define TB0C_ARG1_SEL_TEXEL2 (8 << 6) +#define TB0C_ARG1_SEL_TEXEL3 (9 << 6) +#define TB0C_ARG0_REPLICATE_ALPHA (1<<5) +#define TB0C_ARG0_SEL_XXX + +#define TB0A_CTR_STAGE_ENABLE (1<<31) +#define TB0A_RESULT_SCALE_1X (0 << 29) +#define TB0A_RESULT_SCALE_2X (1 << 29) +#define TB0A_RESULT_SCALE_4X (2 << 29) +#define TB0A_OP_MODULE (3 << 25) +#define TB0A_OUTPUT_WRITE_CURRENT (0<<24) +#define TB0A_OUTPUT_WRITE_ACCUM (1<<24) +#define TB0A_CTR_STAGE_SEL_BITS_XXX +#define TB0A_ARG3_SEL_XXX +#define TB0A_ARG3_INVERT (1<<17) +#define TB0A_ARG2_INVERT (1<<16) +#define TB0A_ARG2_SEL_ONE (0 << 12) +#define TB0A_ARG2_SEL_TEXEL0 (6 << 12) +#define TB0A_ARG2_SEL_TEXEL1 (7 << 12) +#define TB0A_ARG2_SEL_TEXEL2 (8 << 12) +#define TB0A_ARG2_SEL_TEXEL3 (9 << 12) +#define TB0A_ARG1_INVERT (1<<10) +#define TB0A_ARG1_SEL_TEXEL0 (6 << 6) +#define TB0A_ARG1_SEL_TEXEL1 (7 << 6) +#define TB0A_ARG1_SEL_TEXEL2 (8 << 6) +#define TB0A_ARG1_SEL_TEXEL3 (9 << 6) +#define TB0A_ARG0_SEL_XXX + +/* end */ + + +static struct blendinfo I830BlendOp[] = { + /* Clear */ + {0, 0, I830_SRC_BLENDFACTOR_ZERO | I830_DST_BLENDFACTOR_ZERO}, + /* Src */ + {0, 0, I830_SRC_BLENDFACTOR_ONE | I830_DST_BLENDFACTOR_ZERO}, + /* Dst */ + {0, 0, I830_SRC_BLENDFACTOR_ZERO | I830_DST_BLENDFACTOR_ONE}, + /* Over */ + {0, 1, I830_SRC_BLENDFACTOR_ONE | I830_DST_BLENDFACTOR_INV_SRC_ALPHA}, + /* OverReverse */ + {1, 0, I830_SRC_BLENDFACTOR_INV_DST_ALPHA | I830_DST_BLENDFACTOR_ONE}, + /* In */ + {1, 0, I830_SRC_BLENDFACTOR_DST_ALPHA | I830_DST_BLENDFACTOR_ZERO}, + /* InReverse */ + {0, 1, I830_SRC_BLENDFACTOR_ZERO | I830_DST_BLENDFACTOR_SRC_ALPHA}, + /* Out */ + {1, 0, I830_SRC_BLENDFACTOR_INV_DST_ALPHA | I830_DST_BLENDFACTOR_ZERO}, + /* OutReverse */ + {0, 1, I830_SRC_BLENDFACTOR_ZERO | I830_DST_BLENDFACTOR_INV_SRC_ALPHA}, + /* Atop */ + {1, 1, I830_SRC_BLENDFACTOR_DST_ALPHA | I830_DST_BLENDFACTOR_INV_SRC_ALPHA}, + /* AtopReverse */ + {1, 1, I830_SRC_BLENDFACTOR_INV_DST_ALPHA | I830_DST_BLENDFACTOR_SRC_ALPHA}, + /* Xor */ + {1, 1, I830_SRC_BLENDFACTOR_INV_DST_ALPHA | I830_DST_BLENDFACTOR_INV_SRC_ALPHA}, + /* Add */ + {0, 0, I830_SRC_BLENDFACTOR_ONE | I830_DST_BLENDFACTOR_ONE}, +}; + + +static struct formatinfo I830TexFormats[] = { + {PICT_a8r8g8b8, MT_32BIT_ARGB8888 }, + {PICT_x8r8g8b8, MT_32BIT_ARGB8888 }, + {PICT_a8b8g8r8, MT_32BIT_ABGR8888 }, + {PICT_x8b8g8r8, MT_32BIT_ABGR8888 }, + {PICT_r5g6b5, MT_16BIT_RGB565 }, + {PICT_a1r5g5b5, MT_16BIT_ARGB1555 }, + {PICT_x1r5g5b5, MT_16BIT_ARGB1555 }, + {PICT_a8, MT_8BIT_I8 }, +}; + +static Bool I830GetDestFormat(PicturePtr pDstPicture, CARD32 *dst_format) +{ + /* XXX: color buffer format for i830 */ + switch (pDstPicture->format) { + case PICT_a8r8g8b8: + case PICT_x8r8g8b8: + *dst_format = COLR_BUF_ARGB8888; + break; + case PICT_r5g6b5: + *dst_format = COLR_BUF_RGB565; + break; + case PICT_a1r5g5b5: + case PICT_x1r5g5b5: + *dst_format = COLR_BUF_ARGB1555; + break; + case PICT_a8: + *dst_format = COLR_BUF_8BIT; + break; + case PICT_a4r4g4b4: + case PICT_x4r4g4b4: + *dst_format = COLR_BUF_ARGB4444; + break; + default: + I830FALLBACK("Unsupported dest format 0x%x\n", + (int)pDstPicture->format); + } + + return TRUE; +} + + +static CARD32 I830GetBlendCntl(int op, PicturePtr pMask, CARD32 dst_format) +{ + CARD32 sblend, dblend; + + sblend = I830BlendOp[op].blend_cntl & I830_SRC_BLENDFACTOR_MASK; + dblend = I830BlendOp[op].blend_cntl & I830_DST_BLENDFACTOR_MASK; + + /* If there's no dst alpha channel, adjust the blend op so that we'll treat + * it as always 1. + */ + if (PICT_FORMAT_A(dst_format) == 0 && I830BlendOp[op].dst_alpha) { + if (sblend == I830_SRC_BLENDFACTOR_DST_ALPHA) + sblend = I830_SRC_BLENDFACTOR_ONE; + else if (sblend == I830_SRC_BLENDFACTOR_INV_DST_ALPHA) + sblend = I830_SRC_BLENDFACTOR_ZERO; + } + + /* If the source alpha is being used, then we should only be in a case where + * the source blend factor is 0, and the source blend value is the mask + * channels multiplied by the source picture's alpha. + */ + if (pMask && pMask->componentAlpha && I830BlendOp[op].src_alpha) { + if (dblend == I830_DST_BLENDFACTOR_SRC_ALPHA) { + dblend = I830_DST_BLENDFACTOR_SRC_COLOR; + } else if (dblend == I830_DST_BLENDFACTOR_INV_SRC_ALPHA) { + dblend = I830_DST_BLENDFACTOR_INV_SRC_COLOR; + } + } + + return sblend | dblend; +} + +static Bool I830CheckCompositeTexture(PicturePtr pPict, int unit) +{ + int w = pPict->pDrawable->width; + int h = pPict->pDrawable->height; + int i; + + if ((w > 0x7ff) || (h > 0x7ff)) + I830FALLBACK("Picture w/h too large (%dx%d)\n", w, h); + + for (i = 0; i < sizeof(I830TexFormats) / sizeof(I830TexFormats[0]); i++) + { + if (I830TexFormats[i].fmt == pPict->format) + break; + } + if (i == sizeof(I830TexFormats) / sizeof(I830TexFormats[0])) + I830FALLBACK("Unsupported picture format 0x%x\n", + (int)pPict->format); + + /* FIXME: fix repeat support */ + if (pPict->repeat) + I830FALLBACK("repeat unsupport now\n"); + + if (pPict->filter != PictFilterNearest && + pPict->filter != PictFilterBilinear) + I830FALLBACK("Unsupported filter 0x%x\n", pPict->filter); + + return TRUE; +} + +static Bool +I830TextureSetup(PicturePtr pPict, PixmapPtr pPix, int unit) +{ + + ScrnInfoPtr pScrn = xf86Screens[pPict->pDrawable->pScreen->myNum]; + I830Ptr pI830 = I830PTR(pScrn); + CARD32 format, offset, pitch, filter; + int w, h, i; + CARD32 wrap_mode = TEXCOORDMODE_CLAMP; + + offset = exaGetPixmapOffset(pPix); + pitch = exaGetPixmapPitch(pPix); + w = pPict->pDrawable->width; + h = pPict->pDrawable->height; + scale_units[unit][0] = pPix->drawable.width; + scale_units[unit][1] = pPix->drawable.height; + draw_coords[unit][0] = pPix->drawable.x; + draw_coords[unit][1] = pPix->drawable.y; + + for (i = 0; i < sizeof(I830TexFormats) / sizeof(I830TexFormats[0]); i++) { + if (I830TexFormats[i].fmt == pPict->format) + break; + } + if ( i == sizeof(I830TexFormats)/ sizeof(I830TexFormats[0]) ) + I830FALLBACK("unknown texture format\n"); + format = I830TexFormats[i].card_fmt; + + if (pPict->repeat) + wrap_mode = TEXCOORDMODE_WRAP; /* XXX: correct ? */ + + switch (pPict->filter) { + case PictFilterNearest: + filter = ((FILTER_NEAREST<filter); + } + + { + if (pI830->cpp == 1) + format |= MAP_SURFACE_8BIT; + else if (pI830->cpp == 2) + format |= MAP_SURFACE_16BIT; + else + format |= MAP_SURFACE_32BIT; + + BEGIN_LP_RING(6); + OUT_RING(_3DSTATE_MAP_INFO_CMD); + OUT_RING(format | TEXMAP_INDEX(unit) | MAP_FORMAT_2D); + OUT_RING((pPix->drawable.height<<16)|pPix->drawable.width); /* height, width */ + OUT_RING(offset<<2); /* map address */ + OUT_RING(pitch<<2); /* map pitch */ + OUT_RING(0); + ADVANCE_LP_RING(); + } + + { + BEGIN_LP_RING(2); + /* coord sets */ + OUT_RING(_3DSTATE_MAP_COORD_SET_CMD | TEXCOORD_SET(unit) | + ENABLE_TEXCOORD_PARAMS | TEXCOORDS_ARE_NORMAL | /*XXX, check this, and fix vertex tex coord*/ + TEXCOORDTYPE_CARTESIAN | ENABLE_ADDR_V_CNTL | TEXCOORD_ADDR_V_MODE(wrap_mode) | + ENABLE_ADDR_U_CNTL | TEXCOORD_ADDR_U_MODE(wrap_mode)); + OUT_RING(MI_NOOP); + + /* XXX: filter seems hang engine...*/ +#if 0 + OUT_RING(I830_STATE3D_MAP_FILTER | FILTER_MAP_INDEX(unit) | ENABLE_KEYS| DISABLE_COLOR_KEY | DISABLE_CHROMA_KEY | DISABLE_KILL_PIXEL |ENABLE_MIP_MODE_FILTER | MIPFILTER_NONE | filter); + OUT_RING(0); +#endif + + /* max & min mip level ? or base mip level? */ + + ADVANCE_LP_RING(); + } + + /* XXX */ + if (pPict->transform != 0) { + is_transform[unit] = TRUE; + transform[unit] = pPict->transform; + } else { + is_transform[unit] = FALSE; + } + +#ifdef I830DEBUG + ErrorF("try to sync to show any errors..."); + I830Sync(pScrn); +#endif + + return TRUE; +} + +Bool +I830EXACheckComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture, + PicturePtr pDstPicture) +{ + CARD32 tmp1; + + /* Check for unsupported compositing operations. */ + if (op >= sizeof(I830BlendOp) / sizeof(I830BlendOp[0])) + I830FALLBACK("Unsupported Composite op 0x%x\n", op); + + if (pMaskPicture != NULL && pMaskPicture->componentAlpha) { + /* Check if it's component alpha that relies on a source alpha and on + * the source value. We can only get one of those into the single + * source value that we get to blend with. + */ + if (I830BlendOp[op].src_alpha && + (I830BlendOp[op].blend_cntl & I830_SRC_BLENDFACTOR_MASK) != + I830_SRC_BLENDFACTOR_ZERO) + I830FALLBACK("Component alpha not supported with source " + "alpha and source value blending.\n"); + } + + if (!I830CheckCompositeTexture(pSrcPicture, 0)) + I830FALLBACK("Check Src picture texture\n"); + if (pMaskPicture != NULL && !I830CheckCompositeTexture(pMaskPicture, 1)) + I830FALLBACK("Check Mask picture texture\n"); + + if (!I830GetDestFormat(pDstPicture, &tmp1)) + I830FALLBACK("Get Color buffer format\n"); + + return TRUE; +} + + +static void +I830DefCtxSetup(ScrnInfoPtr pScrn) +{ + /* coord binding */ + CARD32 mcb; + I830Ptr pI830 = I830PTR(pScrn); + + BEGIN_LP_RING(2); + OUT_RING(_3DSTATE_MAP_COORD_SETBIND_CMD); + mcb = TEXBIND_SET3(TEXCOORDSRC_VTXSET_3); + mcb |= TEXBIND_SET2(TEXCOORDSRC_VTXSET_2); + mcb |= TEXBIND_SET1(TEXCOORDSRC_VTXSET_1); + mcb |= TEXBIND_SET0(TEXCOORDSRC_VTXSET_0); + OUT_RING(mcb); + ADVANCE_LP_RING(); +} + + +Bool +I830EXAPrepareComposite(int op, PicturePtr pSrcPicture, + PicturePtr pMaskPicture, PicturePtr pDstPicture, + PixmapPtr pSrc, PixmapPtr pMask, PixmapPtr pDst) +{ +/* XXX: setup texture map from pixmap, vertex format, blend cntl */ + ScrnInfoPtr pScrn = xf86Screens[pSrcPicture->pDrawable->pScreen->myNum]; + I830Ptr pI830 = I830PTR(pScrn); + CARD32 dst_format, dst_offset, dst_pitch; + + I830GetDestFormat(pDstPicture, &dst_format); + dst_offset = exaGetPixmapOffset(pDst); + dst_pitch = exaGetPixmapPitch(pDst); + draw_coords[2][0] = pDst->drawable.x; + draw_coords[2][1] = pDst->drawable.y; + + I830DefCtxSetup(pScrn); + + if (!I830TextureSetup(pSrcPicture, pSrc, 0)) + I830FALLBACK("fail to setup src texture\n"); + if (pMask != NULL) { + if (!I830TextureSetup(pMaskPicture, pMask, 1)) + I830FALLBACK("fail to setup mask texture\n"); + } else { + is_transform[1] = FALSE; + scale_units[1][0] = -1; + scale_units[1][1] = -1; + } + + { + + CARD32 cblend, ablend, blendctl, vf2; + + BEGIN_LP_RING(22); + + /*color buffer*/ + OUT_RING(_3DSTATE_BUF_INFO_CMD); + OUT_RING(BUF_3D_ID_COLOR_BACK| BUF_3D_PITCH(dst_pitch)); + OUT_RING(BUF_3D_ADDR(dst_offset)); + OUT_RING(MI_NOOP); + + OUT_RING(_3DSTATE_DST_BUF_VARS_CMD); + OUT_RING(dst_format); + + /* defaults */ + OUT_RING(_3DSTATE_DFLT_Z_CMD); + OUT_RING(0); + + OUT_RING(_3DSTATE_DFLT_DIFFUSE_CMD); + OUT_RING(0); + + OUT_RING(_3DSTATE_DFLT_SPEC_CMD); + OUT_RING(0); + + OUT_RING(_3DSTATE_LOAD_STATE_IMMEDIATE_1|I1_LOAD_S(3)|0); + OUT_RING((1<componentAlpha && pDstPicture->format != PICT_a8) + cblend |= TB0C_ARG2_SEL_TEXEL1; + else + cblend |= (TB0C_ARG2_SEL_TEXEL1 | TB0C_ARG2_REPLICATE_ALPHA); + ablend |= TB0A_ARG2_SEL_TEXEL1; + } else { + cblend |= TB0C_ARG2_SEL_ONE; + ablend |= TB0A_ARG2_SEL_ONE; + } + + OUT_RING(_3DSTATE_LOAD_STATE_IMMEDIATE_2 | LOAD_TEXTURE_BLEND_STAGE(0)|1); + OUT_RING(cblend); + OUT_RING(ablend); + OUT_RING(0); + + blendctl = I830GetBlendCntl(op, pMaskPicture, pDstPicture->format); + OUT_RING(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | I1_LOAD_S(8) | 0); + OUT_RING(S8_ENABLE_COLOR_BLEND | S8_BLENDFUNC_ADD |(blendctl<<4) | + S8_ENABLE_COLOR_BUFFER_WRITE); + ADVANCE_LP_RING(); + } + +#ifdef I830DEBUG + Error("try to sync to show any errors..."); + I830Sync(pScrn); +#endif + + return TRUE; +} + diff --git a/src/i830_reg.h b/src/i830_reg.h index be12e760..ae68a2e9 100644 --- a/src/i830_reg.h +++ b/src/i830_reg.h @@ -31,6 +31,23 @@ #define I830_SET_FIELD( var, mask, value ) (var &= ~(mask), var |= value) +#define CMD_3D (0x3<<29) + +#define PRIM3D_INLINE (CMD_3D | (0x1f<<24)) +#define PRIM3D_TRILIST (0x0<<18) +#define PRIM3D_TRISTRIP (0x1<<18) +#define PRIM3D_TRISTRIP_RVRSE (0x2<<18) +#define PRIM3D_TRIFAN (0x3<<18) +#define PRIM3D_POLY (0x4<<18) +#define PRIM3D_LINELIST (0x5<<18) +#define PRIM3D_LINESTRIP (0x6<<18) +#define PRIM3D_RECTLIST (0x7<<18) +#define PRIM3D_POINTLIST (0x8<<18) +#define PRIM3D_DIB (0x9<<18) +#define PRIM3D_CLEAR_RECT (0xa<<18) +#define PRIM3D_ZONE_INIT (0xd<<18) +#define PRIM3D_MASK (0x1f<<18) + #define _3DSTATE_AA_CMD (CMD_3D | (0x06<<24)) #define AA_LINE_ECAAR_WIDTH_ENABLE (1<<16) #define AA_LINE_ECAAR_WIDTH_0_5 0 @@ -85,6 +102,8 @@ #define COLR_BUF_RGB555 (1<<8) #define COLR_BUF_RGB565 (2<<8) #define COLR_BUF_ARGB8888 (3<<8) +#define COLR_BUF_ARGB4444 (8<<8) +#define COLR_BUF_ARGB1555 (9<<8) #define DEPTH_IS_Z 0 #define DEPTH_IS_W (1<<6) #define DEPTH_FRMT_16_FIXED 0 @@ -301,6 +320,7 @@ /* _3DSTATE_MAP_COORD_SETS, p164 */ #define _3DSTATE_MAP_COORD_SET_CMD (CMD_3D|(0x1c<<24)|(0x01<<19)) +#define TEXCOORD_SET(n) ((n)<<16) #define ENABLE_TEXCOORD_PARAMS (1<<15) #define TEXCOORDS_ARE_NORMAL (1<<14) #define TEXCOORDS_ARE_IN_TEXELUNITS 0 @@ -329,6 +349,13 @@ #define CUBE_NEGZ_ENABLE (1<<1) #define CUBE_POSZ_ENABLE (1<<0) +#define _3DSTATE_MAP_INFO_CMD (CMD_3D|(0x1d<<24)|(0x0<<16)|3) +#define TEXMAP_INDEX(x) ((x)<<28) +#define MAP_SURFACE_8BIT (1<<24) +#define MAP_SURFACE_16BIT (2<<24) +#define MAP_SURFACE_32BIT (3<<24) +#define MAP_FORMAT_2D (0) +#define MAP_FORMAT_3D_CUBE (1<<11) /* _3DSTATE_MODES_1, p190 */ #define _3DSTATE_MODES_1_CMD (CMD_3D|(0x08<<24)) @@ -523,14 +550,57 @@ /* Stipple command, carried over from the i810, apparently: */ -#define _3DSTATE_STIPPLE ((0x3<<29)|(0x1d<<24)|(0x83<<16)) +#define _3DSTATE_STIPPLE (CMD_3D|(0x1d<<24)|(0x83<<16)) #define ST1_ENABLE (1<<16) #define ST1_MASK (0xffff) - - -#define _3DSTATE_LOAD_STATE_IMMEDIATE_2 ((0x3<<29)|(0x1d<<24)|(0x03<<16)) -#define LOAD_TEXTURE_MAP0 (1<<11) +#define _3DSTATE_LOAD_STATE_IMMEDIATE_1 (CMD_3D|(0x1d<<24)|(0x04<<16)) +#define I1_LOAD_S(n) (1<<((n)+4)) +#define S3_POINT_WIDTH_SHIFT 23 +#define S3_LINE_WIDTH_SHIFT 19 +#define S3_ALPHA_SHADE_MODE_SHIFT 18 +#define S3_FOG_SHADE_MODE_SHIFT 17 +#define S3_SPEC_SHADE_MODE_SHIFT 16 +#define S3_COLOR_SHADE_MODE_SHIFT 15 +#define S3_CULL_MODE_SHIFT 13 +#define S3_CULLMODE_BOTH (0) +#define S3_CULLMODE_NONE (1<<13) +#define S3_CULLMODE_CW (2<<13) +#define S3_CULLMODE_CCW (3<<13) +#define S3_POINT_WIDTH_PRESENT (1<<12) +#define S3_SPEC_FOG_PRESENT (1<<11) +#define S3_DIFFUSE_PRESENT (1<<10) +#define S3_DEPTH_OFFSET_PRESENT (1<<9) +#define S3_POSITION_SHIFT 6 +#define S3_VERTEXHAS_XYZ (1<<6) +#define S3_VERTEXHAS_XYZW (2<<6) +#define S3_VERTEXHAS_XY (3<<6) +#define S3_VERTEXHAS_XYW (4<<6) +#define S3_ENABLE_SPEC_ADD (1<<5) +#define S3_ENABLE_FOG (1<<4) +#define S3_ENABLE_LOCAL_DEPTH_BIAS (1<<3) +#define S3_ENABLE_SPRITE_POINT (1<<1) +#define S3_ENABLE_ANTIALIASING 1 +#define S8_ENABLE_ALPHA_TEST (1<<31) +#define S8_ALPHA_TEST_FUNC_SHIFT 28 +#define S8_ALPHA_REFVALUE_SHIFT 20 +#define S8_ENABLE_DEPTH_TEST (1<<19) +#define S8_DEPTH_TEST_FUNC_SHIFT 16 +#define S8_ENABLE_COLOR_BLEND (1<<15) +#define S8_COLOR_BLEND_FUNC_SHIFT 12 +#define S8_BLENDFUNC_ADD (0) +#define S8_BLENDFUNC_SUB (1<<12) +#define S8_BLENDFUNC_RVRSE_SUB (2<<12) +#define S8_BLENDFUNC_MIN (3<<12) +#define S8_BLENDFUNC_MAX (4<<12) +#define S8_SRC_BLEND_FACTOR_SHIFT 8 +#define S8_DST_BLEND_FACTOR_SHIFT 4 +#define S8_ENABLE_DEPTH_BUFFER_WRITE (1<<3) +#define S8_ENABLE_COLOR_BUFFER_WRITE (1<<2) + +#define _3DSTATE_LOAD_STATE_IMMEDIATE_2 (CMD_3D|(0x1d<<24)|(0x03<<16)) +#define LOAD_TEXTURE_MAP(x) (1<<((x)+11)) +#define LOAD_TEXTURE_BLEND_STAGE(x) (1<<((x)+7)) #define LOAD_GLOBAL_COLOR_FACTOR (1<<6) #define TM0S0_ADDRESS_MASK 0xfffffffc @@ -591,6 +661,8 @@ #define TM0S2_CUBE_FACE_ENA_SHIFT 15 #define TM0S2_CUBE_FACE_ENA_MASK (1<<15) #define TM0S2_MAP_FORMAT (1<<14) +#define TM0S2_MAP_2D (0<<14) +#define TM0S2_MAP_3D_CUBE (1<<14) #define TM0S2_VERTICAL_LINE_STRIDE (1<<13) #define TM0S2_VERITCAL_LINE_STRIDE_OFF (1<<12) #define TM0S2_OUTPUT_CHAN_SHIFT 10 @@ -634,4 +706,23 @@ #define FLUSH_MAP_CACHE (1<<0) +#define _3DSTATE_MAP_FILTER_CMD (CMD_3D|(0x1c<<24)|(0x02<<19)) +#define FILTER_TEXMAP_INDEX(x) ((x) << 16) +#define MAG_MODE_FILTER_ENABLE (1 << 5) +#define MIN_MODE_FILTER_ENABLE (1 << 2) +#define MAG_MAPFILTER_NEAREST (0 << 3) +#define MAG_MAPFILTER_LINEAR (1 << 3) +#define MAG_MAPFILTER_ANISOTROPIC (2 << 3) +#define MIN_MAPFILTER_NEAREST (0) +#define MIN_MAPFILTER_LINEAR (1) +#define MIN_MAPFILTER_ANISOTROPIC (2) +#define ENABLE_KEYS (1<<15) +#define DISABLE_COLOR_KEY 0 +#define DISABLE_CHROMA_KEY 0 +#define DISABLE_KILL_PIXEL 0 +#define ENABLE_MIP_MODE_FILTER (1 << 9) +#define MIPFILTER_NONE 0 +#define MIPFILTER_NEAREST 1 +#define MIPFILTER_LINEAR 3 + #endif diff --git a/src/i915_exa_render.c b/src/i915_exa_render.c new file mode 100644 index 00000000..68c929ea --- /dev/null +++ b/src/i915_exa_render.c @@ -0,0 +1,553 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "xf86.h" +#include "i830.h" +#include "i915_reg.h" + +#ifdef I830DEBUG +#define DEBUG_I830FALLBACK 1 +#endif + +#ifdef DEBUG_I830FALLBACK +#define I830FALLBACK(s, arg...) \ +do { \ + DPRINTF(PFX, "EXA fallback: " s "\n", ##arg); \ + return FALSE; \ +} while(0) +#else +#define I830FALLBACK(s, arg...) \ +do { \ + return FALSE; \ +} while(0) +#endif + +extern float scale_units[2][2]; +extern int draw_coords[3][2]; +extern Bool is_transform[2]; +extern PictTransform *transform[2]; + +struct formatinfo { + int fmt; + CARD32 card_fmt; +}; + +struct blendinfo { + Bool dst_alpha; + Bool src_alpha; + CARD32 blend_cntl; +}; + +extern Bool +I915EXACheckComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture, + PicturePtr pDstPicture); + +extern Bool +I915EXAPrepareComposite(int op, PicturePtr pSrcPicture, + PicturePtr pMaskPicture, PicturePtr pDstPicture, + PixmapPtr pSrc, PixmapPtr pMask, PixmapPtr pDst); + +/* copy from Eric's texture-video branch, move to header.. */ +#define OUT_DCL(type, nr) do { \ + CARD32 chans = 0; \ + if (REG_TYPE_##type == REG_TYPE_T) \ + chans = D0_CHANNEL_ALL; \ + else if (REG_TYPE_##type != REG_TYPE_S) \ + FatalError("wrong reg type %d to declare\n", REG_TYPE_##type); \ + OUT_RING(D0_DCL | \ + (REG_TYPE_##type << D0_TYPE_SHIFT) | (nr << D0_NR_SHIFT) | \ + chans); \ + OUT_RING(0x00000000); \ + OUT_RING(0x00000000); \ +} while (0) + +#define OUT_TEXLD(dest_type, dest_nr, sampler_nr, addr_type, addr_nr) \ +do { \ + OUT_RING(T0_TEXLD | \ + (REG_TYPE_##dest_type << T0_DEST_TYPE_SHIFT) | \ + (dest_nr << T0_DEST_NR_SHIFT) | \ + (sampler_nr << T0_SAMPLER_NR_SHIFT)); \ + OUT_RING((REG_TYPE_##addr_type << T1_ADDRESS_REG_TYPE_SHIFT) | \ + (addr_nr << T1_ADDRESS_REG_NR_SHIFT)); \ + OUT_RING(0x00000000); \ +} while (0) + +/* XXX: It seems that offset of 915's blendfactor in Load_immediate_1 + is _different_ with i830, so I should just define plain value + and use it with shift bits*/ + +#define I915_SRC_BLENDFACTOR_ZERO (1 << 8) +#define I915_SRC_BLENDFACTOR_ONE (2 << 8) +#define I915_SRC_BLENDFACTOR_SRC_COLOR (3 << 8) +#define I915_SRC_BLENDFACTOR_INV_SRC_COLOR (4 << 8) +#define I915_SRC_BLENDFACTOR_SRC_ALPHA (5 << 8) +#define I915_SRC_BLENDFACTOR_INV_SRC_ALPHA (6 << 8) +#define I915_SRC_BLENDFACTOR_DST_ALPHA (7 << 8) +#define I915_SRC_BLENDFACTOR_INV_DST_ALPHA (8 << 8) +#define I915_SRC_BLENDFACTOR_DST_COLOR (9 << 8) +#define I915_SRC_BLENDFACTOR_INV_DST_COLOR (0xa << 8) +#define I915_SRC_BLENDFACTOR_SRC_ALPHA_SATURATE (0xb << 8) +#define I915_SRC_BLENDFACTOR_CONST_COLOR (0xc << 8) +#define I915_SRC_BLENDFACTOR_INV_CONST_COLOR (0xd << 8) +#define I915_SRC_BLENDFACTOR_CONST_ALPHA (0xe << 8) +#define I915_SRC_BLENDFACTOR_INV_CONST_ALPHA (0xf << 8) +#define I915_SRC_BLENDFACTOR_MASK (0xf << 8) + +#define I915_DST_BLENDFACTOR_ZERO (1 << 4) +#define I915_DST_BLENDFACTOR_ONE (2 << 4) +#define I915_DST_BLENDFACTOR_SRC_COLOR (3 << 4) +#define I915_DST_BLENDFACTOR_INV_SRC_COLOR (4 << 4) +#define I915_DST_BLENDFACTOR_SRC_ALPHA (5 << 4) +#define I915_DST_BLENDFACTOR_INV_SRC_ALPHA (6 << 4) +#define I915_DST_BLENDFACTOR_DST_ALPHA (7 << 4) +#define I915_DST_BLENDFACTOR_INV_DST_ALPHA (8 << 4) +#define I915_DST_BLENDFACTOR_DST_COLOR (9 << 4) +#define I915_DST_BLENDFACTOR_INV_DST_COLOR (0xa << 4) +#define I915_DST_BLENDFACTOR_SRC_ALPHA_SATURATE (0xb << 4) +#define I915_DST_BLENDFACTOR_CONST_COLOR (0xc << 4) +#define I915_DST_BLENDFACTOR_INV_CONST_COLOR (0xd << 4) +#define I915_DST_BLENDFACTOR_CONST_ALPHA (0xe << 4) +#define I915_DST_BLENDFACTOR_INV_CONST_ALPHA (0xf << 4) +#define I915_DST_BLENDFACTOR_MASK (0xf << 4) + +static struct blendinfo I915BlendOp[] = { + /* Clear */ + {0, 0, I915_SRC_BLENDFACTOR_ZERO | I915_DST_BLENDFACTOR_ZERO}, + /* Src */ + {0, 0, I915_SRC_BLENDFACTOR_ONE | I915_DST_BLENDFACTOR_ZERO}, + /* Dst */ + {0, 0, I915_SRC_BLENDFACTOR_ZERO | I915_DST_BLENDFACTOR_ONE}, + /* Over */ + {0, 1, I915_SRC_BLENDFACTOR_ONE | I915_DST_BLENDFACTOR_INV_SRC_ALPHA}, + /* OverReverse */ + {1, 0, I915_SRC_BLENDFACTOR_INV_DST_ALPHA | I915_DST_BLENDFACTOR_ONE}, + /* In */ + {1, 0, I915_SRC_BLENDFACTOR_DST_ALPHA | I915_DST_BLENDFACTOR_ZERO}, + /* InReverse */ + {0, 1, I915_SRC_BLENDFACTOR_ZERO | I915_DST_BLENDFACTOR_SRC_ALPHA}, + /* Out */ + {1, 0, I915_SRC_BLENDFACTOR_INV_DST_ALPHA | I915_DST_BLENDFACTOR_ZERO}, + /* OutReverse */ + {0, 1, I915_SRC_BLENDFACTOR_ZERO | I915_DST_BLENDFACTOR_INV_SRC_ALPHA}, + /* Atop */ + {1, 1, I915_SRC_BLENDFACTOR_DST_ALPHA | I915_DST_BLENDFACTOR_INV_SRC_ALPHA}, + /* AtopReverse */ + {1, 1, I915_SRC_BLENDFACTOR_INV_DST_ALPHA | I915_DST_BLENDFACTOR_SRC_ALPHA}, + /* Xor */ + {1, 1, I915_SRC_BLENDFACTOR_INV_DST_ALPHA | I915_DST_BLENDFACTOR_INV_SRC_ALPHA}, + /* Add */ + {0, 0, I915_SRC_BLENDFACTOR_ONE | I915_DST_BLENDFACTOR_ONE}, +}; + +static struct formatinfo I915TexFormats[] = { + {PICT_a8r8g8b8, MT_32BIT_ARGB8888 }, + {PICT_x8r8g8b8, MT_32BIT_XRGB8888 }, + {PICT_a8b8g8r8, MT_32BIT_ABGR8888 }, + {PICT_x8b8g8r8, MT_32BIT_XBGR8888 }, + {PICT_r5g6b5, MT_16BIT_RGB565 }, + {PICT_a1r5g5b5, MT_16BIT_ARGB1555 }, + {PICT_x1r5g5b5, MT_16BIT_ARGB1555 }, + {PICT_a8, MT_8BIT_I8 }, +}; + +static CARD32 I915GetBlendCntl(int op, PicturePtr pMask, CARD32 dst_format) +{ + CARD32 sblend, dblend; + + sblend = I915BlendOp[op].blend_cntl & I915_SRC_BLENDFACTOR_MASK; + dblend = I915BlendOp[op].blend_cntl & I915_DST_BLENDFACTOR_MASK; + + /* If there's no dst alpha channel, adjust the blend op so that we'll treat + * it as always 1. + */ + if (PICT_FORMAT_A(dst_format) == 0 && I915BlendOp[op].dst_alpha) { + if (sblend == I915_SRC_BLENDFACTOR_DST_ALPHA) + sblend = I915_SRC_BLENDFACTOR_ONE; + else if (sblend == I915_SRC_BLENDFACTOR_INV_DST_ALPHA) + sblend = I915_SRC_BLENDFACTOR_ZERO; + } + + /* If the source alpha is being used, then we should only be in a case where + * the source blend factor is 0, and the source blend value is the mask + * channels multiplied by the source picture's alpha. + */ + if (pMask && pMask->componentAlpha && I915BlendOp[op].src_alpha) { + if (dblend == I915_DST_BLENDFACTOR_SRC_ALPHA) { + dblend = I915_DST_BLENDFACTOR_SRC_COLOR; + } else if (dblend == I915_DST_BLENDFACTOR_INV_SRC_ALPHA) { + dblend = I915_DST_BLENDFACTOR_INV_SRC_COLOR; + } + } + + return sblend | dblend; +} + +static Bool I915GetDestFormat(PicturePtr pDstPicture, CARD32 *dst_format) +{ + switch (pDstPicture->format) { + case PICT_a8r8g8b8: + case PICT_x8r8g8b8: + *dst_format = COLR_BUF_ARGB8888; + break; + case PICT_r5g6b5: + *dst_format = COLR_BUF_RGB565; + break; + case PICT_a1r5g5b5: + case PICT_x1r5g5b5: + *dst_format = COLR_BUF_ARGB1555; + break; + case PICT_a8: + *dst_format = COLR_BUF_8BIT; + break; + case PICT_a4r4g4b4: + case PICT_x4r4g4b4: + *dst_format = COLR_BUF_ARGB4444; + break; + default: + I830FALLBACK("Unsupported dest format 0x%x\n", + (int)pDstPicture->format); + } + + return TRUE; +} + +static Bool I915CheckCompositeTexture(PicturePtr pPict, int unit) +{ + int w = pPict->pDrawable->width; + int h = pPict->pDrawable->height; + int i; + + if ((w > 0x7ff) || (h > 0x7ff)) + I830FALLBACK("Picture w/h too large (%dx%d)\n", w, h); + + for (i = 0; i < sizeof(I915TexFormats) / sizeof(I915TexFormats[0]); i++) + { + if (I915TexFormats[i].fmt == pPict->format) + break; + } + if (i == sizeof(I915TexFormats) / sizeof(I915TexFormats[0])) + I830FALLBACK("Unsupported picture format 0x%x\n", + (int)pPict->format); + + /* FIXME: fix repeat support */ + if (pPict->repeat && ((w&(w-1)) != 0) && ((h&(h-1)) != 0)) + I830FALLBACK("repeat non log2 aligned!\n"); + + if (pPict->filter != PictFilterNearest && + pPict->filter != PictFilterBilinear) + I830FALLBACK("Unsupported filter 0x%x\n", pPict->filter); + + return TRUE; +} + +Bool +I915EXACheckComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture, + PicturePtr pDstPicture) +{ + CARD32 tmp1; + + /* Check for unsupported compositing operations. */ + if (op >= sizeof(I915BlendOp) / sizeof(I915BlendOp[0])) + I830FALLBACK("Unsupported Composite op 0x%x\n", op); + + if (pMaskPicture != NULL && pMaskPicture->componentAlpha) { + /* Check if it's component alpha that relies on a source alpha and on + * the source value. We can only get one of those into the single + * source value that we get to blend with. + */ + if (I915BlendOp[op].src_alpha && + (I915BlendOp[op].blend_cntl & I915_SRC_BLENDFACTOR_MASK) != + I915_SRC_BLENDFACTOR_ZERO) + I830FALLBACK("Component alpha not supported with source " + "alpha and source value blending.\n"); + } + + if (!I915CheckCompositeTexture(pSrcPicture, 0)) + I830FALLBACK("Check Src picture texture\n"); + if (pMaskPicture != NULL && !I915CheckCompositeTexture(pMaskPicture, 1)) + I830FALLBACK("Check Mask picture texture\n"); + + if (!I915GetDestFormat(pDstPicture, &tmp1)) + I830FALLBACK("Get Color buffer format\n"); + + return TRUE; +} + +static Bool +I915TextureSetup(PicturePtr pPict, PixmapPtr pPix, int unit) +{ + ScrnInfoPtr pScrn = xf86Screens[pPict->pDrawable->pScreen->myNum]; + I830Ptr pI830 = I830PTR(pScrn); + CARD32 format, offset, pitch, filter; + int w, h, i; + CARD32 wrap_mode = TEXCOORDMODE_CLAMP_EDGE; + + offset = exaGetPixmapOffset(pPix); + pitch = exaGetPixmapPitch(pPix); + w = pPict->pDrawable->width; + h = pPict->pDrawable->height; + scale_units[unit][0] = pPix->drawable.width; + scale_units[unit][1] = pPix->drawable.height; + draw_coords[unit][0] = pPix->drawable.x; + draw_coords[unit][1] = pPix->drawable.y; + + for (i = 0; i < sizeof(I915TexFormats) / sizeof(I915TexFormats[0]); i++) { + if (I915TexFormats[i].fmt == pPict->format) + break; + } + if ( i == sizeof(I915TexFormats)/ sizeof(I915TexFormats[0]) ) + I830FALLBACK("unknown texture format\n"); + format = I915TexFormats[i].card_fmt; + + if (pPict->repeat) + wrap_mode = TEXCOORDMODE_WRAP; /* XXX:correct ? */ + + switch (pPict->filter) { + case PictFilterNearest: + filter = (FILTER_NEAREST << SS2_MAG_FILTER_SHIFT) | + (FILTER_NEAREST << SS2_MIN_FILTER_SHIFT); + break; + case PictFilterBilinear: + filter = (FILTER_LINEAR << SS2_MAG_FILTER_SHIFT) | + (FILTER_LINEAR << SS2_MIN_FILTER_SHIFT); + break; + default: + filter = 0; + I830FALLBACK("Bad filter 0x%x\n", pPict->filter); + } + + { + CARD32 ms3; + if (pI830->cpp == 1) + format |= MAPSURF_8BIT; + else if (pI830->cpp == 2) + format |= MAPSURF_16BIT; + else + format |= MAPSURF_32BIT; + + BEGIN_LP_RING(6); + OUT_RING(_3DSTATE_MAP_STATE | (3 * (1 << unit))); + OUT_RING(1<drawable.height << MS3_HEIGHT_SHIFT) | + (pPix->drawable.width << MS3_WIDTH_SHIFT) | format; + if (!pI830->disableTiling) + ms3 |= MS3_USE_FENCE_REGS; + OUT_RING(ms3); + OUT_RING(pitch<transform != 0) { + is_transform[unit] = TRUE; + transform[unit] = pPict->transform; + } else { + is_transform[unit] = FALSE; + } + +#ifdef I830DEBUG + ErrorF("try to sync to show any errors..."); + I830Sync(pScrn); +#endif + + return TRUE; +} + +static void +I915DefCtxSetup(ScrnInfoPtr pScrn) +{ + I830Ptr pI830 = I830PTR(pScrn); + + BEGIN_LP_RING(2); + /* set default texture binding, may be in prepare better */ + OUT_RING(_3DSTATE_COORD_SET_BINDINGS | CSB_TCB(0,0) | CSB_TCB(1,1) | + CSB_TCB(2,2) | CSB_TCB(3,3) | CSB_TCB(4,4) | CSB_TCB(5,5) | + CSB_TCB(6,6) | CSB_TCB(7,7)); + OUT_RING(0); + ADVANCE_LP_RING(); +} + +Bool +I915EXAPrepareComposite(int op, PicturePtr pSrcPicture, + PicturePtr pMaskPicture, PicturePtr pDstPicture, + PixmapPtr pSrc, PixmapPtr pMask, PixmapPtr pDst) +{ + ScrnInfoPtr pScrn = xf86Screens[pSrcPicture->pDrawable->pScreen->myNum]; + I830Ptr pI830 = I830PTR(pScrn); + CARD32 dst_format, dst_offset, dst_pitch; + CARD32 blendctl; + +ErrorF("i915 prepareComposite\n"); + + I915GetDestFormat(pDstPicture, &dst_format); + dst_offset = exaGetPixmapOffset(pDst); + dst_pitch = exaGetPixmapPitch(pDst); + draw_coords[2][0] = pDst->drawable.x; + draw_coords[2][1] = pDst->drawable.y; + + I915DefCtxSetup(pScrn); + + if (!I915TextureSetup(pSrcPicture, pSrc, 0)) + I830FALLBACK("fail to setup src texture\n"); + if (pMask != NULL) { + if (!I915TextureSetup(pMaskPicture, pMask, 1)) + I830FALLBACK("fail to setup mask texture\n"); + } else { + is_transform[1] = FALSE; + scale_units[1][0] = -1; + scale_units[1][1] = -1; + } + + { + CARD32 ss2; + BEGIN_LP_RING(24); + /*color buffer*/ + OUT_RING(_3DSTATE_BUF_INFO_CMD); + OUT_RING(BUF_3D_ID_COLOR_BACK| BUF_3D_PITCH(dst_pitch)); /* fence, tile? */ + OUT_RING(BUF_3D_ADDR(dst_offset)); + OUT_RING(MI_NOOP); + + OUT_RING(_3DSTATE_DST_BUF_VARS_CMD); + OUT_RING(dst_format); + + /* XXX: defaults */ + OUT_RING(_3DSTATE_DFLT_Z_CMD); + OUT_RING(0); + + OUT_RING(_3DSTATE_DFLT_DIFFUSE_CMD); + OUT_RING(0); + + OUT_RING(_3DSTATE_DFLT_SPEC_CMD); + OUT_RING(0); + + /* XXX:S3? define vertex format with tex coord sets number*/ + OUT_RING(_3DSTATE_LOAD_STATE_IMMEDIATE_1|I1_LOAD_S(2)|I1_LOAD_S(3)| + I1_LOAD_S(4)|1); + ss2 = S2_TEXCOORD_FMT(0, TEXCOORDFMT_2D); + if (pMask) + ss2 |= S2_TEXCOORD_FMT(1, TEXCOORDFMT_2D); + else + ss2 |= S2_TEXCOORD_FMT(1, TEXCOORDFMT_NOT_PRESENT); + ss2 |= S2_TEXCOORD_FMT(2, TEXCOORDFMT_NOT_PRESENT); + ss2 |= S2_TEXCOORD_FMT(3, TEXCOORDFMT_NOT_PRESENT); + ss2 |= S2_TEXCOORD_FMT(4, TEXCOORDFMT_NOT_PRESENT); + ss2 |= S2_TEXCOORD_FMT(5, TEXCOORDFMT_NOT_PRESENT); + ss2 |= S2_TEXCOORD_FMT(6, TEXCOORDFMT_NOT_PRESENT); + ss2 |= S2_TEXCOORD_FMT(7, TEXCOORDFMT_NOT_PRESENT); + OUT_RING(ss2); + OUT_RING(0x00000000); /*XXX: does ss3 needed? */ + OUT_RING((1<virtualY-1) | DRAW_XMAX(pScrn->virtualX-1)); + OUT_RING(0x00000000); /* yorig, xorig (relate to color buffer?)*/ + OUT_RING(0); + ADVANCE_LP_RING(); + } + + /* For (src In mask) operation */ + /* IN operator: Multiply src by mask components or mask alpha.*/ + /* TEXBLENDOP_MODULE: arg1*arg2 */ + + /* LOAD_IMMEDIATE_1 ss6 ??*/ + + /**** + shader program prototype: + dcl t0.xy + dcl t1.xy + dcl_2d s0 + dcl_2d s1 + texld t0, s0 + texld t1, s1 + mul oC, t0, t1 () + ***/ + if (!pMask) { + BEGIN_LP_RING(1+3+3+3); + OUT_RING(_3DSTATE_PIXEL_SHADER_PROGRAM |(3*3-1)); + OUT_DCL(S, 0); + OUT_DCL(T, 0); + OUT_TEXLD(OC, 0, 0, T, 0); + ADVANCE_LP_RING(); + } else { + BEGIN_LP_RING(1+3*6+3); + OUT_RING(_3DSTATE_PIXEL_SHADER_PROGRAM |(3*7-1)); + OUT_DCL(S, 0); + OUT_DCL(S, 1); + OUT_DCL(T, 0); + OUT_DCL(T, 1); + OUT_TEXLD(R, 0, 0, T, 0); + OUT_TEXLD(R, 1, 1, T, 1); + if (pMaskPicture->componentAlpha && pDstPicture->format != PICT_a8) { + /* then just mul */ + OUT_RING(A0_MUL | (REG_TYPE_OC << A0_DEST_TYPE_SHIFT) | + (0 << A0_DEST_NR_SHIFT) | A0_DEST_CHANNEL_ALL | + (REG_TYPE_R << A0_SRC0_TYPE_SHIFT) | (0 << A0_SRC0_NR_SHIFT)); + OUT_RING((SRC_X << A1_SRC0_CHANNEL_X_SHIFT)|(SRC_Y << A1_SRC0_CHANNEL_Y_SHIFT)| + (SRC_Z << A1_SRC0_CHANNEL_Z_SHIFT)|(SRC_W << A1_SRC0_CHANNEL_W_SHIFT)| + (REG_TYPE_R << A1_SRC1_TYPE_SHIFT) | (1 << A1_SRC1_NR_SHIFT) | + (SRC_X << A1_SRC1_CHANNEL_X_SHIFT) | (SRC_Y << A1_SRC1_CHANNEL_Y_SHIFT)); + OUT_RING((SRC_Z << A2_SRC1_CHANNEL_Z_SHIFT) | (SRC_W << A2_SRC1_CHANNEL_W_SHIFT)); + } else { + /* we should duplicate R1's w for all channel, Arithemic can choose channel to use! */ + OUT_RING(A0_MUL | (REG_TYPE_OC << A0_DEST_TYPE_SHIFT) | + (0 << A0_DEST_NR_SHIFT) | A0_DEST_CHANNEL_ALL | + (REG_TYPE_R << A0_SRC0_TYPE_SHIFT) | (0 << A0_SRC0_NR_SHIFT)); + OUT_RING((SRC_X << A1_SRC0_CHANNEL_X_SHIFT) | (SRC_Y << A1_SRC0_CHANNEL_Y_SHIFT) | + (SRC_Z << A1_SRC0_CHANNEL_Z_SHIFT) | (SRC_W << A1_SRC0_CHANNEL_W_SHIFT) | + (REG_TYPE_R << A1_SRC1_TYPE_SHIFT) | (1 << A1_SRC1_NR_SHIFT) | + (SRC_W << A1_SRC1_CHANNEL_X_SHIFT) | (SRC_W << A1_SRC1_CHANNEL_Y_SHIFT)); + OUT_RING((SRC_W << A2_SRC1_CHANNEL_Z_SHIFT) | (SRC_W << A2_SRC1_CHANNEL_W_SHIFT)); + } + ADVANCE_LP_RING(); + } + + { + CARD32 ss6; + blendctl = I915GetBlendCntl(op, pMaskPicture, pDstPicture->format); + + BEGIN_LP_RING(2); + OUT_RING(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | I1_LOAD_S(6) | 0); + ss6 = S6_CBUF_BLEND_ENABLE | S6_COLOR_WRITE_ENABLE; + OUT_RING(ss6 | (0 << S6_CBUF_BLEND_FUNC_SHIFT) | blendctl); + ADVANCE_LP_RING(); + } + +#ifdef I830DEBUG + ErrorF("try to sync to show any errors..."); + I830Sync(pScrn); +#endif + + return TRUE; +} diff --git a/src/i915_reg.h b/src/i915_reg.h index 886ae815..e2d7b9d9 100644 --- a/src/i915_reg.h +++ b/src/i915_reg.h @@ -161,6 +161,9 @@ #define COLR_BUF_RGB555 (1<<8) #define COLR_BUF_RGB565 (2<<8) #define COLR_BUF_ARGB8888 (3<<8) +#define COLR_BUF_ARGB4444 (8<<8) +#define COLR_BUF_ARGB1555 (9<<8) +#define COLR_BUF_ARGB2AAA (0xa<<8) #define DEPTH_FRMT_16_FIXED 0 #define DEPTH_FRMT_16_FLOAT (1<<2) #define DEPTH_FRMT_24_FIXED_8_OTHER (2<<2) -- cgit v1.2.3 From 855a9f13cb7fd4f6c489ff280bf389475bbd9bbe Mon Sep 17 00:00:00 2001 From: Wang Zhenyu Date: Tue, 18 Jul 2006 10:02:47 +0800 Subject: fallback in 'repeat' case for now --- src/i830_exa.c | 8 ++++++-- src/i915_exa_render.c | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/i830_exa.c b/src/i830_exa.c index 83601dc3..40f68683 100644 --- a/src/i830_exa.c +++ b/src/i830_exa.c @@ -340,8 +340,10 @@ I830EXAUploadToScreen(PixmapPtr pDst, int x, int y, int w, int h, I830Sync(pScrn); +#ifdef I830DEBUG ErrorF("Up->Screen: dst offset 0x%x, dst pitch %d, x %d, y %d, src %p, src pitch %d\n", dst_offset, dst_pitch, x, y, src, src_pitch); +#endif #ifndef UPLOAD_USE_BLIT dst = pI830->FbBase + dst_offset + y*dst_pitch + x* (pDst->drawable.bitsPerPixel/8); @@ -403,8 +405,10 @@ I830EXADownloadFromScreen(PixmapPtr pSrc, int x, int y, int w, int h, I830Sync(pScrn); +#ifdef I830DEBUG ErrorF("Screen->Mem: src offset 0x%x, src %p, src pitch %d, x %d, y %d, dst %p, dst_pitch %d\n", src_offset, src, src_pitch, x, y, dst, dst_pitch); +#endif w *= pSrc->drawable.bitsPerPixel/8; while(h--) { memcpy(dst, src, w); @@ -426,7 +430,7 @@ IntelEXAComposite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY, PictVector v; int pMask = 1; -ErrorF("Composite: srcX %d, srcY %d\n\t maskX %d, maskY %d\n\t" + DPRINTF(PFX, "Composite: srcX %d, srcY %d\n\t maskX %d, maskY %d\n\t" "dstX %d, dstY %d\n\twidth %d, height %d\n\t" "src_scale_x %f, src_scale_y %f, mask_scale_x %f, mask_scale_y %f\n""\tdx0 %d, dy0 %x, dx1 %d dy1 %x\n", srcX, srcY, maskX, maskY, dstX, dstY, w, h, @@ -472,7 +476,7 @@ ErrorF("Composite: srcX %d, srcY %d\n\t maskX %d, maskY %d\n\t" maskXend = xFixedToInt(v.vector[0]); maskYend = xFixedToInt(v.vector[1]); } -DPRINTF(PFX, "After transform: srcX %d, srcY %d,srcXend %d, srcYend %d\n\t" + DPRINTF(PFX, "After transform: srcX %d, srcY %d,srcXend %d, srcYend %d\n\t" "maskX %d, maskY %d, maskXend %d, maskYend %d\n\t" "dstX %d, dstY %d\n", srcX, srcY, srcXend, srcYend, maskX, maskY, maskXend, maskYend, dstX, dstY); diff --git a/src/i915_exa_render.c b/src/i915_exa_render.c index 68c929ea..acec69f3 100644 --- a/src/i915_exa_render.c +++ b/src/i915_exa_render.c @@ -231,8 +231,8 @@ static Bool I915CheckCompositeTexture(PicturePtr pPict, int unit) (int)pPict->format); /* FIXME: fix repeat support */ - if (pPict->repeat && ((w&(w-1)) != 0) && ((h&(h-1)) != 0)) - I830FALLBACK("repeat non log2 aligned!\n"); + if (pPict->repeat) + I830FALLBACK("repeat not support now!\n"); if (pPict->filter != PictFilterNearest && pPict->filter != PictFilterBilinear) -- cgit v1.2.3 From 433cb6ba82698676f6f72e09834aba4d64611d54 Mon Sep 17 00:00:00 2001 From: Wang Zhenyu Date: Tue, 18 Jul 2006 17:00:50 +0800 Subject: Fix several size error with STATE3D_LOAD_STATE_IMMEDIATE cmd. Issue texture coord set with proper scale value. --- src/i830_exa.c | 58 ++++++++++++++++++++++++++++----------------------- src/i915_exa_render.c | 6 ++++-- 2 files changed, 36 insertions(+), 28 deletions(-) diff --git a/src/i830_exa.c b/src/i830_exa.c index 40f68683..3975e6df 100644 --- a/src/i830_exa.c +++ b/src/i830_exa.c @@ -55,7 +55,7 @@ do { \ } while(0) #endif -float scale_units[2][2]; +float scale_units[3][2]; int draw_coords[3][2]; const int I830CopyROP[16] = @@ -101,7 +101,7 @@ const int I830PatternROP[16] = /* move to common.h */ union intfloat { float f; - unsigned int ui; + CARD32 ui; }; #define OUT_RING_F(x) do { \ @@ -429,6 +429,7 @@ IntelEXAComposite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY, int srcXend, srcYend, maskXend, maskYend; PictVector v; int pMask = 1; + float src_scale_x, src_scale_y, mask_scale_x, mask_scale_y; DPRINTF(PFX, "Composite: srcX %d, srcY %d\n\t maskX %d, maskY %d\n\t" "dstX %d, dstY %d\n\twidth %d, height %d\n\t" @@ -483,9 +484,14 @@ IntelEXAComposite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY, draw_coords[0][0] -= draw_coords[2][0]; draw_coords[0][1] -= draw_coords[2][1]; + src_scale_x = (float)scale_units[0][0] / (float)scale_units[2][0]; + src_scale_y = (float)scale_units[0][1] / (float)scale_units[2][1]; + if (pMask) { draw_coords[1][0] -= draw_coords[2][0]; draw_coords[1][1] -= draw_coords[2][1]; + mask_scale_x = (float)scale_units[1][0] / (float)scale_units[2][0]; + mask_scale_y = (float)scale_units[1][1] / (float)scale_units[2][1]; } { @@ -506,40 +512,40 @@ IntelEXAComposite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY, OUT_RING(PRIM3D_INLINE | PRIM3D_TRIFAN | (vertex_count-1)); - OUT_RING(dstX); - OUT_RING(dstY); - OUT_RING_F(((srcX - draw_coords[0][0]) / scale_units[0][0])); - OUT_RING_F(((srcY - draw_coords[0][1]) / scale_units[0][1])); + OUT_RING_F(dstX); + OUT_RING_F(dstY); + OUT_RING_F(((srcX - draw_coords[0][0]) * src_scale_x)); + OUT_RING_F(((srcY - draw_coords[0][1]) * src_scale_y)); if (pMask) { - OUT_RING_F(((maskX - draw_coords[1][0]) / scale_units[1][0])); - OUT_RING_F(((maskY - draw_coords[1][1]) / scale_units[1][1])); + OUT_RING_F(((maskX - draw_coords[1][0]) * mask_scale_x)); + OUT_RING_F(((maskY - draw_coords[1][1]) * mask_scale_y)); } - OUT_RING(dstX); - OUT_RING((dstY+h)); - OUT_RING_F(((srcX - draw_coords[0][0]) / scale_units[0][0])); - OUT_RING_F(((srcYend - draw_coords[0][1]) / scale_units[0][1])); + OUT_RING_F(dstX); + OUT_RING_F((dstY+h)); + OUT_RING_F(((srcX - draw_coords[0][0]) * src_scale_x)); + OUT_RING_F(((srcYend - draw_coords[0][1]) * src_scale_y)); if (pMask) { - OUT_RING_F(((maskX - draw_coords[1][0]) / scale_units[1][0])); - OUT_RING_F(((maskYend - draw_coords[1][1]) / scale_units[1][1])); + OUT_RING_F(((maskX - draw_coords[1][0]) * mask_scale_x)); + OUT_RING_F(((maskYend - draw_coords[1][1]) * mask_scale_y)); } - OUT_RING((dstX+w)); - OUT_RING((dstY+h)); - OUT_RING_F(((srcXend - draw_coords[0][0]) / scale_units[0][0])); - OUT_RING_F(((srcYend - draw_coords[0][1]) / scale_units[0][1])); + OUT_RING_F((dstX+w)); + OUT_RING_F((dstY+h)); + OUT_RING_F(((srcXend - draw_coords[0][0]) * src_scale_x)); + OUT_RING_F(((srcYend - draw_coords[0][1]) * src_scale_y)); if (pMask) { - OUT_RING_F(((maskXend - draw_coords[1][0]) / scale_units[1][0])); - OUT_RING_F(((maskYend - draw_coords[1][1]) / scale_units[1][1])); + OUT_RING_F(((maskXend - draw_coords[1][0]) * mask_scale_x)); + OUT_RING_F(((maskYend - draw_coords[1][1]) * mask_scale_y)); } - OUT_RING((dstX+w)); - OUT_RING((dstY)); - OUT_RING_F(((srcXend - draw_coords[0][0]) / scale_units[0][0])); - OUT_RING_F(((srcY - draw_coords[0][1]) / scale_units[0][1])); + OUT_RING_F((dstX+w)); + OUT_RING_F((dstY)); + OUT_RING_F(((srcXend - draw_coords[0][0]) * src_scale_x)); + OUT_RING_F(((srcY - draw_coords[0][1]) * src_scale_y)); if (pMask) { - OUT_RING_F(((maskXend - draw_coords[1][0]) / scale_units[1][0])); - OUT_RING_F(((maskY - draw_coords[1][1]) / scale_units[1][1])); + OUT_RING_F(((maskXend - draw_coords[1][0]) * mask_scale_x)); + OUT_RING_F(((maskY - draw_coords[1][1]) * mask_scale_y)); } ADVANCE_LP_RING(); } diff --git a/src/i915_exa_render.c b/src/i915_exa_render.c index acec69f3..60b8125e 100644 --- a/src/i915_exa_render.c +++ b/src/i915_exa_render.c @@ -408,6 +408,8 @@ ErrorF("i915 prepareComposite\n"); dst_pitch = exaGetPixmapPitch(pDst); draw_coords[2][0] = pDst->drawable.x; draw_coords[2][1] = pDst->drawable.y; + scale_units[2][0] = pDst->drawable.width; + scale_units[2][1] = pDst->drawable.height; I915DefCtxSetup(pScrn); @@ -446,7 +448,7 @@ ErrorF("i915 prepareComposite\n"); /* XXX:S3? define vertex format with tex coord sets number*/ OUT_RING(_3DSTATE_LOAD_STATE_IMMEDIATE_1|I1_LOAD_S(2)|I1_LOAD_S(3)| - I1_LOAD_S(4)|1); + I1_LOAD_S(4)|3); ss2 = S2_TEXCOORD_FMT(0, TEXCOORDFMT_2D); if (pMask) ss2 |= S2_TEXCOORD_FMT(1, TEXCOORDFMT_2D); @@ -538,7 +540,7 @@ ErrorF("i915 prepareComposite\n"); blendctl = I915GetBlendCntl(op, pMaskPicture, pDstPicture->format); BEGIN_LP_RING(2); - OUT_RING(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | I1_LOAD_S(6) | 0); + OUT_RING(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | I1_LOAD_S(6) | 1); ss6 = S6_CBUF_BLEND_ENABLE | S6_COLOR_WRITE_ENABLE; OUT_RING(ss6 | (0 << S6_CBUF_BLEND_FUNC_SHIFT) | blendctl); ADVANCE_LP_RING(); -- cgit v1.2.3 From f1b62d890ca22e12d61f7ef67bc4e35d68cde019 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 19 Jul 2006 13:02:24 -0400 Subject: Replace hand register setting with new i915 fragmet program API. --- src/i915_3d.h | 7 ++ src/i915_exa_render.c | 175 +++++++++++++++----------------------------------- 2 files changed, 58 insertions(+), 124 deletions(-) diff --git a/src/i915_3d.h b/src/i915_3d.h index fc4ca603..f254c86c 100644 --- a/src/i915_3d.h +++ b/src/i915_3d.h @@ -375,6 +375,13 @@ do { \ i915_fs_operand_none())); \ } while (0) +/** Add operand0 and operand1 and put the result in dest_reg */ +#define i915_fs_mul(dest_reg, operand0, operand1) \ +do { \ + FS_OUT(i915_fs_arith(MUL, dest_reg, operand0, operand1, \ + i915_fs_operand_none())); \ +} while (0) + /** * Perform a 3-component dot-product of operand0 and operand1 and put the * resulting scalar in the channels of dest_reg specified by the dest_mask. diff --git a/src/i915_exa_render.c b/src/i915_exa_render.c index 60b8125e..4249869d 100644 --- a/src/i915_exa_render.c +++ b/src/i915_exa_render.c @@ -1,3 +1,5 @@ +/* -*- c-basic-offset: 4 -*- */ + #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -5,6 +7,7 @@ #include "xf86.h" #include "i830.h" #include "i915_reg.h" +#include "i915_3d.h" #ifdef I830DEBUG #define DEBUG_I830FALLBACK 1 @@ -36,7 +39,8 @@ struct formatinfo { struct blendinfo { Bool dst_alpha; Bool src_alpha; - CARD32 blend_cntl; + CARD32 src_blend; + CARD32 dst_blend; }; extern Bool @@ -48,96 +52,33 @@ I915EXAPrepareComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture, PicturePtr pDstPicture, PixmapPtr pSrc, PixmapPtr pMask, PixmapPtr pDst); -/* copy from Eric's texture-video branch, move to header.. */ -#define OUT_DCL(type, nr) do { \ - CARD32 chans = 0; \ - if (REG_TYPE_##type == REG_TYPE_T) \ - chans = D0_CHANNEL_ALL; \ - else if (REG_TYPE_##type != REG_TYPE_S) \ - FatalError("wrong reg type %d to declare\n", REG_TYPE_##type); \ - OUT_RING(D0_DCL | \ - (REG_TYPE_##type << D0_TYPE_SHIFT) | (nr << D0_NR_SHIFT) | \ - chans); \ - OUT_RING(0x00000000); \ - OUT_RING(0x00000000); \ -} while (0) - -#define OUT_TEXLD(dest_type, dest_nr, sampler_nr, addr_type, addr_nr) \ -do { \ - OUT_RING(T0_TEXLD | \ - (REG_TYPE_##dest_type << T0_DEST_TYPE_SHIFT) | \ - (dest_nr << T0_DEST_NR_SHIFT) | \ - (sampler_nr << T0_SAMPLER_NR_SHIFT)); \ - OUT_RING((REG_TYPE_##addr_type << T1_ADDRESS_REG_TYPE_SHIFT) | \ - (addr_nr << T1_ADDRESS_REG_NR_SHIFT)); \ - OUT_RING(0x00000000); \ -} while (0) - -/* XXX: It seems that offset of 915's blendfactor in Load_immediate_1 - is _different_ with i830, so I should just define plain value - and use it with shift bits*/ - -#define I915_SRC_BLENDFACTOR_ZERO (1 << 8) -#define I915_SRC_BLENDFACTOR_ONE (2 << 8) -#define I915_SRC_BLENDFACTOR_SRC_COLOR (3 << 8) -#define I915_SRC_BLENDFACTOR_INV_SRC_COLOR (4 << 8) -#define I915_SRC_BLENDFACTOR_SRC_ALPHA (5 << 8) -#define I915_SRC_BLENDFACTOR_INV_SRC_ALPHA (6 << 8) -#define I915_SRC_BLENDFACTOR_DST_ALPHA (7 << 8) -#define I915_SRC_BLENDFACTOR_INV_DST_ALPHA (8 << 8) -#define I915_SRC_BLENDFACTOR_DST_COLOR (9 << 8) -#define I915_SRC_BLENDFACTOR_INV_DST_COLOR (0xa << 8) -#define I915_SRC_BLENDFACTOR_SRC_ALPHA_SATURATE (0xb << 8) -#define I915_SRC_BLENDFACTOR_CONST_COLOR (0xc << 8) -#define I915_SRC_BLENDFACTOR_INV_CONST_COLOR (0xd << 8) -#define I915_SRC_BLENDFACTOR_CONST_ALPHA (0xe << 8) -#define I915_SRC_BLENDFACTOR_INV_CONST_ALPHA (0xf << 8) -#define I915_SRC_BLENDFACTOR_MASK (0xf << 8) - -#define I915_DST_BLENDFACTOR_ZERO (1 << 4) -#define I915_DST_BLENDFACTOR_ONE (2 << 4) -#define I915_DST_BLENDFACTOR_SRC_COLOR (3 << 4) -#define I915_DST_BLENDFACTOR_INV_SRC_COLOR (4 << 4) -#define I915_DST_BLENDFACTOR_SRC_ALPHA (5 << 4) -#define I915_DST_BLENDFACTOR_INV_SRC_ALPHA (6 << 4) -#define I915_DST_BLENDFACTOR_DST_ALPHA (7 << 4) -#define I915_DST_BLENDFACTOR_INV_DST_ALPHA (8 << 4) -#define I915_DST_BLENDFACTOR_DST_COLOR (9 << 4) -#define I915_DST_BLENDFACTOR_INV_DST_COLOR (0xa << 4) -#define I915_DST_BLENDFACTOR_SRC_ALPHA_SATURATE (0xb << 4) -#define I915_DST_BLENDFACTOR_CONST_COLOR (0xc << 4) -#define I915_DST_BLENDFACTOR_INV_CONST_COLOR (0xd << 4) -#define I915_DST_BLENDFACTOR_CONST_ALPHA (0xe << 4) -#define I915_DST_BLENDFACTOR_INV_CONST_ALPHA (0xf << 4) -#define I915_DST_BLENDFACTOR_MASK (0xf << 4) - static struct blendinfo I915BlendOp[] = { /* Clear */ - {0, 0, I915_SRC_BLENDFACTOR_ZERO | I915_DST_BLENDFACTOR_ZERO}, + {0, 0, BLENDFACT_ZERO, BLENDFACT_ZERO}, /* Src */ - {0, 0, I915_SRC_BLENDFACTOR_ONE | I915_DST_BLENDFACTOR_ZERO}, + {0, 0, BLENDFACT_ONE, BLENDFACT_ZERO}, /* Dst */ - {0, 0, I915_SRC_BLENDFACTOR_ZERO | I915_DST_BLENDFACTOR_ONE}, + {0, 0, BLENDFACT_ZERO, BLENDFACT_ONE}, /* Over */ - {0, 1, I915_SRC_BLENDFACTOR_ONE | I915_DST_BLENDFACTOR_INV_SRC_ALPHA}, + {0, 1, BLENDFACT_ONE, BLENDFACT_INV_SRC_ALPHA}, /* OverReverse */ - {1, 0, I915_SRC_BLENDFACTOR_INV_DST_ALPHA | I915_DST_BLENDFACTOR_ONE}, + {1, 0, BLENDFACT_INV_DST_ALPHA, BLENDFACT_ONE}, /* In */ - {1, 0, I915_SRC_BLENDFACTOR_DST_ALPHA | I915_DST_BLENDFACTOR_ZERO}, + {1, 0, BLENDFACT_DST_ALPHA, BLENDFACT_ZERO}, /* InReverse */ - {0, 1, I915_SRC_BLENDFACTOR_ZERO | I915_DST_BLENDFACTOR_SRC_ALPHA}, + {0, 1, BLENDFACT_ZERO, BLENDFACT_SRC_ALPHA}, /* Out */ - {1, 0, I915_SRC_BLENDFACTOR_INV_DST_ALPHA | I915_DST_BLENDFACTOR_ZERO}, + {1, 0, BLENDFACT_INV_DST_ALPHA, BLENDFACT_ZERO}, /* OutReverse */ - {0, 1, I915_SRC_BLENDFACTOR_ZERO | I915_DST_BLENDFACTOR_INV_SRC_ALPHA}, + {0, 1, BLENDFACT_ZERO, BLENDFACT_INV_SRC_ALPHA}, /* Atop */ - {1, 1, I915_SRC_BLENDFACTOR_DST_ALPHA | I915_DST_BLENDFACTOR_INV_SRC_ALPHA}, + {1, 1, BLENDFACT_DST_ALPHA, BLENDFACT_INV_SRC_ALPHA}, /* AtopReverse */ - {1, 1, I915_SRC_BLENDFACTOR_INV_DST_ALPHA | I915_DST_BLENDFACTOR_SRC_ALPHA}, + {1, 1, BLENDFACT_INV_DST_ALPHA, BLENDFACT_SRC_ALPHA}, /* Xor */ - {1, 1, I915_SRC_BLENDFACTOR_INV_DST_ALPHA | I915_DST_BLENDFACTOR_INV_SRC_ALPHA}, + {1, 1, BLENDFACT_INV_DST_ALPHA, BLENDFACT_INV_SRC_ALPHA}, /* Add */ - {0, 0, I915_SRC_BLENDFACTOR_ONE | I915_DST_BLENDFACTOR_ONE}, + {0, 0, BLENDFACT_ONE, BLENDFACT_ONE}, }; static struct formatinfo I915TexFormats[] = { @@ -155,17 +96,17 @@ static CARD32 I915GetBlendCntl(int op, PicturePtr pMask, CARD32 dst_format) { CARD32 sblend, dblend; - sblend = I915BlendOp[op].blend_cntl & I915_SRC_BLENDFACTOR_MASK; - dblend = I915BlendOp[op].blend_cntl & I915_DST_BLENDFACTOR_MASK; + sblend = I915BlendOp[op].src_blend; + dblend = I915BlendOp[op].dst_blend; /* If there's no dst alpha channel, adjust the blend op so that we'll treat * it as always 1. */ if (PICT_FORMAT_A(dst_format) == 0 && I915BlendOp[op].dst_alpha) { - if (sblend == I915_SRC_BLENDFACTOR_DST_ALPHA) - sblend = I915_SRC_BLENDFACTOR_ONE; - else if (sblend == I915_SRC_BLENDFACTOR_INV_DST_ALPHA) - sblend = I915_SRC_BLENDFACTOR_ZERO; + if (sblend == BLENDFACT_DST_ALPHA) + sblend = BLENDFACT_ONE; + else if (sblend == BLENDFACT_INV_DST_ALPHA) + sblend = BLENDFACT_ZERO; } /* If the source alpha is being used, then we should only be in a case where @@ -173,14 +114,15 @@ static CARD32 I915GetBlendCntl(int op, PicturePtr pMask, CARD32 dst_format) * channels multiplied by the source picture's alpha. */ if (pMask && pMask->componentAlpha && I915BlendOp[op].src_alpha) { - if (dblend == I915_DST_BLENDFACTOR_SRC_ALPHA) { - dblend = I915_DST_BLENDFACTOR_SRC_COLOR; - } else if (dblend == I915_DST_BLENDFACTOR_INV_SRC_ALPHA) { - dblend = I915_DST_BLENDFACTOR_INV_SRC_COLOR; + if (dblend == BLENDFACT_SRC_ALPHA) { + dblend = BLENDFACT_SRC_COLR; + } else if (dblend == BLENDFACT_INV_SRC_ALPHA) { + dblend = BLENDFACT_INV_SRC_COLR; } } - return sblend | dblend; + return (sblend <drawable.y; scale_units[2][0] = pDst->drawable.width; scale_units[2][1] = pDst->drawable.height; + FS_LOCALS(20); I915DefCtxSetup(pScrn); @@ -426,6 +368,7 @@ ErrorF("i915 prepareComposite\n"); { CARD32 ss2; + BEGIN_LP_RING(24); /*color buffer*/ OUT_RING(_3DSTATE_BUF_INFO_CMD); @@ -495,46 +438,30 @@ ErrorF("i915 prepareComposite\n"); texld t1, s1 mul oC, t0, t1 () ***/ + FS_BEGIN(); + if (!pMask) { - BEGIN_LP_RING(1+3+3+3); - OUT_RING(_3DSTATE_PIXEL_SHADER_PROGRAM |(3*3-1)); - OUT_DCL(S, 0); - OUT_DCL(T, 0); - OUT_TEXLD(OC, 0, 0, T, 0); - ADVANCE_LP_RING(); + i915_fs_dcl(FS_S0); + i915_fs_dcl(FS_T0); + i915_fs_texld(FS_OC, FS_S0, FS_T0); } else { - BEGIN_LP_RING(1+3*6+3); - OUT_RING(_3DSTATE_PIXEL_SHADER_PROGRAM |(3*7-1)); - OUT_DCL(S, 0); - OUT_DCL(S, 1); - OUT_DCL(T, 0); - OUT_DCL(T, 1); - OUT_TEXLD(R, 0, 0, T, 0); - OUT_TEXLD(R, 1, 1, T, 1); + i915_fs_dcl(FS_S0); + i915_fs_dcl(FS_S1); + i915_fs_dcl(FS_T0); + i915_fs_dcl(FS_T1); + i915_fs_texld(FS_R0, FS_S0, FS_T0); + i915_fs_texld(FS_R1, FS_S1, FS_T1); + if (pMaskPicture->componentAlpha && pDstPicture->format != PICT_a8) { - /* then just mul */ - OUT_RING(A0_MUL | (REG_TYPE_OC << A0_DEST_TYPE_SHIFT) | - (0 << A0_DEST_NR_SHIFT) | A0_DEST_CHANNEL_ALL | - (REG_TYPE_R << A0_SRC0_TYPE_SHIFT) | (0 << A0_SRC0_NR_SHIFT)); - OUT_RING((SRC_X << A1_SRC0_CHANNEL_X_SHIFT)|(SRC_Y << A1_SRC0_CHANNEL_Y_SHIFT)| - (SRC_Z << A1_SRC0_CHANNEL_Z_SHIFT)|(SRC_W << A1_SRC0_CHANNEL_W_SHIFT)| - (REG_TYPE_R << A1_SRC1_TYPE_SHIFT) | (1 << A1_SRC1_NR_SHIFT) | - (SRC_X << A1_SRC1_CHANNEL_X_SHIFT) | (SRC_Y << A1_SRC1_CHANNEL_Y_SHIFT)); - OUT_RING((SRC_Z << A2_SRC1_CHANNEL_Z_SHIFT) | (SRC_W << A2_SRC1_CHANNEL_W_SHIFT)); + i915_fs_mul(FS_OC, i915_fs_operand_reg(FS_R0), + i915_fs_operand_reg(FS_R1)); } else { - /* we should duplicate R1's w for all channel, Arithemic can choose channel to use! */ - OUT_RING(A0_MUL | (REG_TYPE_OC << A0_DEST_TYPE_SHIFT) | - (0 << A0_DEST_NR_SHIFT) | A0_DEST_CHANNEL_ALL | - (REG_TYPE_R << A0_SRC0_TYPE_SHIFT) | (0 << A0_SRC0_NR_SHIFT)); - OUT_RING((SRC_X << A1_SRC0_CHANNEL_X_SHIFT) | (SRC_Y << A1_SRC0_CHANNEL_Y_SHIFT) | - (SRC_Z << A1_SRC0_CHANNEL_Z_SHIFT) | (SRC_W << A1_SRC0_CHANNEL_W_SHIFT) | - (REG_TYPE_R << A1_SRC1_TYPE_SHIFT) | (1 << A1_SRC1_NR_SHIFT) | - (SRC_W << A1_SRC1_CHANNEL_X_SHIFT) | (SRC_W << A1_SRC1_CHANNEL_Y_SHIFT)); - OUT_RING((SRC_W << A2_SRC1_CHANNEL_Z_SHIFT) | (SRC_W << A2_SRC1_CHANNEL_W_SHIFT)); + i915_fs_mul(FS_OC, i915_fs_operand_reg(FS_R0), + i915_fs_operand(FS_R1, W, W, W, W)); } - ADVANCE_LP_RING(); } - + FS_END(); + { CARD32 ss6; blendctl = I915GetBlendCntl(op, pMaskPicture, pDstPicture->format); -- cgit v1.2.3 From 449e4be503c8b938d5bd46ee810244f8bcf54ceb Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 19 Jul 2006 13:34:06 -0400 Subject: Correct the DWORD count of several 3D instructions. --- src/i915_3d.c | 4 +--- src/i915_exa_render.c | 10 +++++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/i915_3d.c b/src/i915_3d.c index d8edb181..942dbd17 100644 --- a/src/i915_3d.c +++ b/src/i915_3d.c @@ -77,9 +77,7 @@ void I915EmitInvarientState( ScrnInfoPtr pScrn ) /* Need to initialize this to zero. */ - OUT_RING(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | - I1_LOAD_S(3) | - (1)); + OUT_RING(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | I1_LOAD_S(3) | 0); OUT_RING(0); /* XXX: Use this */ diff --git a/src/i915_exa_render.c b/src/i915_exa_render.c index 4249869d..181fb89b 100644 --- a/src/i915_exa_render.c +++ b/src/i915_exa_render.c @@ -268,7 +268,7 @@ I915TextureSetup(PicturePtr pPict, PixmapPtr pPix, int unit) format |= MAPSURF_32BIT; BEGIN_LP_RING(6); - OUT_RING(_3DSTATE_MAP_STATE | (3 * (1 << unit))); + OUT_RING(_3DSTATE_MAP_STATE | 3); OUT_RING(1<drawable.height << MS3_HEIGHT_SHIFT) | @@ -286,7 +286,7 @@ I915TextureSetup(PicturePtr pPict, PixmapPtr pPix, int unit) BEGIN_LP_RING(6); /* max & min mip level ? or base mip level? */ - OUT_RING(_3DSTATE_SAMPLER_STATE | (3*(1<format); BEGIN_LP_RING(2); - OUT_RING(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | I1_LOAD_S(6) | 1); + OUT_RING(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | I1_LOAD_S(6) | 0); ss6 = S6_CBUF_BLEND_ENABLE | S6_COLOR_WRITE_ENABLE; OUT_RING(ss6 | (0 << S6_CBUF_BLEND_FUNC_SHIFT) | blendctl); ADVANCE_LP_RING(); -- cgit v1.2.3 From 4e409ea44180f7ef2780d70c9d2f54629bbd0fc3 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 19 Jul 2006 15:57:09 -0400 Subject: The map bits per pixel must come from the drawable, not the visible screen. --- src/i915_exa_render.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/i915_exa_render.c b/src/i915_exa_render.c index 181fb89b..0b20e66d 100644 --- a/src/i915_exa_render.c +++ b/src/i915_exa_render.c @@ -260,9 +260,9 @@ I915TextureSetup(PicturePtr pPict, PixmapPtr pPix, int unit) { CARD32 ms3; - if (pI830->cpp == 1) + if (pPix->drawable.bitsPerPixel == 8) format |= MAPSURF_8BIT; - else if (pI830->cpp == 2) + else if (pPix->drawable.bitsPerPixel == 16) format |= MAPSURF_16BIT; else format |= MAPSURF_32BIT; -- cgit v1.2.3 From adce6bd0fc9533156da09da7d029ba0d76606b4f Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 19 Jul 2006 16:21:49 -0400 Subject: Add a trailing MI_NOOP to frag shader output for alignment if necessary. --- src/i915_3d.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/i915_3d.h b/src/i915_3d.h index f254c86c..e9b01944 100644 --- a/src/i915_3d.h +++ b/src/i915_3d.h @@ -434,5 +434,7 @@ do { \ (_cur_shader_commands * 3 - 1)); \ for (_i = 0; _i < _cur_shader_commands * 3; _i++) \ OUT_RING(_shader_buf[_i]); \ + if ((_cur_shader_commands & 0x1) == 0) \ + OUT_RING(MI_NOOP); \ ADVANCE_LP_RING(); \ } while (0); -- cgit v1.2.3 From 36aa43bf73ee1268f0a250788eb637a4123f08eb Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 19 Jul 2006 16:22:46 -0400 Subject: Force texture alpha channels to 1 if not present. --- src/i915_3d.h | 10 +++++++++- src/i915_exa_render.c | 54 +++++++++++++++++++++++++++------------------------ 2 files changed, 38 insertions(+), 26 deletions(-) diff --git a/src/i915_3d.h b/src/i915_3d.h index e9b01944..5a458829 100644 --- a/src/i915_3d.h +++ b/src/i915_3d.h @@ -350,8 +350,16 @@ _i915_fs_arith(int cmd, int dest_reg, return op; } +/** Move operand0 to dest_reg */ +#define i915_fs_mov(dest_reg, operand0) \ +do { \ + FS_OUT(i915_fs_arith(MOV, dest_reg, operand0, \ + i915_fs_operand_none(), \ + i915_fs_operand_none())); \ +} while (0) + /** - * Move the values in operand0 to the dest reg with the masking/saturation + * Move the value in operand0 to the dest reg with the masking/saturation * specified. */ #define i915_fs_mov_masked(dest_reg, dest_mask, operand0) \ diff --git a/src/i915_exa_render.c b/src/i915_exa_render.c index 0b20e66d..a5703829 100644 --- a/src/i915_exa_render.c +++ b/src/i915_exa_render.c @@ -422,36 +422,40 @@ ErrorF("i915 prepareComposite\n"); ADVANCE_LP_RING(); } - /* For (src In mask) operation */ - /* IN operator: Multiply src by mask components or mask alpha.*/ - /* TEXBLENDOP_MODULE: arg1*arg2 */ - - /* LOAD_IMMEDIATE_1 ss6 ??*/ - - /**** - shader program prototype: - dcl t0.xy - dcl t1.xy - dcl_2d s0 - dcl_2d s1 - texld t0, s0 - texld t1, s1 - mul oC, t0, t1 () - ***/ FS_BEGIN(); - if (!pMask) { - i915_fs_dcl(FS_S0); - i915_fs_dcl(FS_T0); - i915_fs_texld(FS_OC, FS_S0, FS_T0); - } else { - i915_fs_dcl(FS_S0); + /* Declare the registers necessary for our program. I don't think the + * S then T ordering is necessary. + */ + i915_fs_dcl(FS_S0); + if (pMask) i915_fs_dcl(FS_S1); - i915_fs_dcl(FS_T0); + i915_fs_dcl(FS_T0); + if (pMask) i915_fs_dcl(FS_T1); - i915_fs_texld(FS_R0, FS_S0, FS_T0); - i915_fs_texld(FS_R1, FS_S1, FS_T1); + /* Load the pSrcPicture texel */ + i915_fs_texld(FS_R0, FS_S0, FS_T0); + /* If the texture lacks an alpha channel, force the alpha to 1. */ + if (PICT_FORMAT_A(pSrcPicture->format) == 0) + i915_fs_mov_masked(FS_R0, MASK_W, i915_fs_operand_one()); + + if (!pMask) { + /* No mask, so move to output color */ + i915_fs_mov(FS_OC, i915_fs_operand_reg(FS_R0)); + } else { + /* Load the pMaskPicture texel */ + i915_fs_texld(FS_R1, FS_S1, FS_T1); + /* If the texture lacks an alpha channel, force the alpha to 1. */ + if (PICT_FORMAT_A(pMaskPicture->format) == 0) + i915_fs_mov_masked(FS_R1, MASK_W, i915_fs_operand_one()); + + /* If component alpha is set in the mask, then we need to provide + * the source alpha component (channelwise multiplication) as the + * output color. If it isn't set, then we need to provide the + * source value component, which is the multipliction of the source + * by the mask alpha. + */ if (pMaskPicture->componentAlpha && pDstPicture->format != PICT_a8) { i915_fs_mul(FS_OC, i915_fs_operand_reg(FS_R0), i915_fs_operand_reg(FS_R1)); -- cgit v1.2.3 From da5efb09d55291ce5bcabff7db8d1490bb5e838b Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 19 Jul 2006 16:36:52 -0400 Subject: Fix the alignment padding fix (didn't bump BEGIN_LP_RING count). --- src/i915_3d.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/i915_3d.h b/src/i915_3d.h index 5a458829..c1162000 100644 --- a/src/i915_3d.h +++ b/src/i915_3d.h @@ -436,13 +436,13 @@ do { \ #define FS_END() \ do { \ - int _i; \ - BEGIN_LP_RING(_cur_shader_commands * 3 + 1); \ + int _i, _pad = (_cur_shader_commands & 0x1) ? 0 : 1; \ + BEGIN_LP_RING(_cur_shader_commands * 3 + 1 + _pad); \ OUT_RING(_3DSTATE_PIXEL_SHADER_PROGRAM | \ (_cur_shader_commands * 3 - 1)); \ for (_i = 0; _i < _cur_shader_commands * 3; _i++) \ OUT_RING(_shader_buf[_i]); \ - if ((_cur_shader_commands & 0x1) == 0) \ + if (_pad != 0) \ OUT_RING(MI_NOOP); \ ADVANCE_LP_RING(); \ } while (0); -- cgit v1.2.3 From 13e372c2095fde94ae41bea959fba0ad95a59c08 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 19 Jul 2006 16:42:57 -0400 Subject: Fix the texture map pitch setting as documented, and as used by the 3d driver. --- src/i915_exa_render.c | 4 ++-- src/i915_reg.h | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/i915_exa_render.c b/src/i915_exa_render.c index a5703829..4cc9e546 100644 --- a/src/i915_exa_render.c +++ b/src/i915_exa_render.c @@ -270,13 +270,13 @@ I915TextureSetup(PicturePtr pPict, PixmapPtr pPix, int unit) BEGIN_LP_RING(6); OUT_RING(_3DSTATE_MAP_STATE | 3); OUT_RING(1<drawable.height << MS3_HEIGHT_SHIFT) | (pPix->drawable.width << MS3_WIDTH_SHIFT) | format; if (!pI830->disableTiling) ms3 |= MS3_USE_FENCE_REGS; OUT_RING(ms3); - OUT_RING(pitch< Date: Wed, 19 Jul 2006 19:27:53 -0400 Subject: The height and width of texture maps are one more than the programmed values. --- src/i915_exa_render.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/i915_exa_render.c b/src/i915_exa_render.c index 4cc9e546..4912d971 100644 --- a/src/i915_exa_render.c +++ b/src/i915_exa_render.c @@ -271,8 +271,8 @@ I915TextureSetup(PicturePtr pPict, PixmapPtr pPix, int unit) OUT_RING(_3DSTATE_MAP_STATE | 3); OUT_RING(1<drawable.height << MS3_HEIGHT_SHIFT) | - (pPix->drawable.width << MS3_WIDTH_SHIFT) | format; + ms3 = ((pPix->drawable.height - 1) << MS3_HEIGHT_SHIFT) | + ((pPix->drawable.width - 1) << MS3_WIDTH_SHIFT) | format; if (!pI830->disableTiling) ms3 |= MS3_USE_FENCE_REGS; OUT_RING(ms3); -- cgit v1.2.3 From 5c945bf9eb9f5bedd34d98dcc7abc3f1ea3cb962 Mon Sep 17 00:00:00 2001 From: Wang Zhenyu Date: Thu, 20 Jul 2006 13:40:39 +0800 Subject: Revert "Fix several size error with STATE3D_LOAD_STATE_IMMEDIATE cmd." This reverts commit 433cb6ba82698676f6f72e09834aba4d64611d54. --- src/i830_exa.c | 58 ++++++++++++++++++++++++++-------------------------------- 1 file changed, 26 insertions(+), 32 deletions(-) diff --git a/src/i830_exa.c b/src/i830_exa.c index 3975e6df..40f68683 100644 --- a/src/i830_exa.c +++ b/src/i830_exa.c @@ -55,7 +55,7 @@ do { \ } while(0) #endif -float scale_units[3][2]; +float scale_units[2][2]; int draw_coords[3][2]; const int I830CopyROP[16] = @@ -101,7 +101,7 @@ const int I830PatternROP[16] = /* move to common.h */ union intfloat { float f; - CARD32 ui; + unsigned int ui; }; #define OUT_RING_F(x) do { \ @@ -429,7 +429,6 @@ IntelEXAComposite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY, int srcXend, srcYend, maskXend, maskYend; PictVector v; int pMask = 1; - float src_scale_x, src_scale_y, mask_scale_x, mask_scale_y; DPRINTF(PFX, "Composite: srcX %d, srcY %d\n\t maskX %d, maskY %d\n\t" "dstX %d, dstY %d\n\twidth %d, height %d\n\t" @@ -484,14 +483,9 @@ IntelEXAComposite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY, draw_coords[0][0] -= draw_coords[2][0]; draw_coords[0][1] -= draw_coords[2][1]; - src_scale_x = (float)scale_units[0][0] / (float)scale_units[2][0]; - src_scale_y = (float)scale_units[0][1] / (float)scale_units[2][1]; - if (pMask) { draw_coords[1][0] -= draw_coords[2][0]; draw_coords[1][1] -= draw_coords[2][1]; - mask_scale_x = (float)scale_units[1][0] / (float)scale_units[2][0]; - mask_scale_y = (float)scale_units[1][1] / (float)scale_units[2][1]; } { @@ -512,40 +506,40 @@ IntelEXAComposite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY, OUT_RING(PRIM3D_INLINE | PRIM3D_TRIFAN | (vertex_count-1)); - OUT_RING_F(dstX); - OUT_RING_F(dstY); - OUT_RING_F(((srcX - draw_coords[0][0]) * src_scale_x)); - OUT_RING_F(((srcY - draw_coords[0][1]) * src_scale_y)); + OUT_RING(dstX); + OUT_RING(dstY); + OUT_RING_F(((srcX - draw_coords[0][0]) / scale_units[0][0])); + OUT_RING_F(((srcY - draw_coords[0][1]) / scale_units[0][1])); if (pMask) { - OUT_RING_F(((maskX - draw_coords[1][0]) * mask_scale_x)); - OUT_RING_F(((maskY - draw_coords[1][1]) * mask_scale_y)); + OUT_RING_F(((maskX - draw_coords[1][0]) / scale_units[1][0])); + OUT_RING_F(((maskY - draw_coords[1][1]) / scale_units[1][1])); } - OUT_RING_F(dstX); - OUT_RING_F((dstY+h)); - OUT_RING_F(((srcX - draw_coords[0][0]) * src_scale_x)); - OUT_RING_F(((srcYend - draw_coords[0][1]) * src_scale_y)); + OUT_RING(dstX); + OUT_RING((dstY+h)); + OUT_RING_F(((srcX - draw_coords[0][0]) / scale_units[0][0])); + OUT_RING_F(((srcYend - draw_coords[0][1]) / scale_units[0][1])); if (pMask) { - OUT_RING_F(((maskX - draw_coords[1][0]) * mask_scale_x)); - OUT_RING_F(((maskYend - draw_coords[1][1]) * mask_scale_y)); + OUT_RING_F(((maskX - draw_coords[1][0]) / scale_units[1][0])); + OUT_RING_F(((maskYend - draw_coords[1][1]) / scale_units[1][1])); } - OUT_RING_F((dstX+w)); - OUT_RING_F((dstY+h)); - OUT_RING_F(((srcXend - draw_coords[0][0]) * src_scale_x)); - OUT_RING_F(((srcYend - draw_coords[0][1]) * src_scale_y)); + OUT_RING((dstX+w)); + OUT_RING((dstY+h)); + OUT_RING_F(((srcXend - draw_coords[0][0]) / scale_units[0][0])); + OUT_RING_F(((srcYend - draw_coords[0][1]) / scale_units[0][1])); if (pMask) { - OUT_RING_F(((maskXend - draw_coords[1][0]) * mask_scale_x)); - OUT_RING_F(((maskYend - draw_coords[1][1]) * mask_scale_y)); + OUT_RING_F(((maskXend - draw_coords[1][0]) / scale_units[1][0])); + OUT_RING_F(((maskYend - draw_coords[1][1]) / scale_units[1][1])); } - OUT_RING_F((dstX+w)); - OUT_RING_F((dstY)); - OUT_RING_F(((srcXend - draw_coords[0][0]) * src_scale_x)); - OUT_RING_F(((srcY - draw_coords[0][1]) * src_scale_y)); + OUT_RING((dstX+w)); + OUT_RING((dstY)); + OUT_RING_F(((srcXend - draw_coords[0][0]) / scale_units[0][0])); + OUT_RING_F(((srcY - draw_coords[0][1]) / scale_units[0][1])); if (pMask) { - OUT_RING_F(((maskXend - draw_coords[1][0]) * mask_scale_x)); - OUT_RING_F(((maskY - draw_coords[1][1]) * mask_scale_y)); + OUT_RING_F(((maskXend - draw_coords[1][0]) / scale_units[1][0])); + OUT_RING_F(((maskY - draw_coords[1][1]) / scale_units[1][1])); } ADVANCE_LP_RING(); } -- cgit v1.2.3 From 3e86bf4273241daa23645f5a8104913e4205a74b Mon Sep 17 00:00:00 2001 From: Wang Zhenyu Date: Thu, 20 Jul 2006 13:43:27 +0800 Subject: remove i915 default ctx setup. --- src/i915_exa_render.c | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/i915_exa_render.c b/src/i915_exa_render.c index 4912d971..ba54d538 100644 --- a/src/i915_exa_render.c +++ b/src/i915_exa_render.c @@ -318,20 +318,6 @@ I915TextureSetup(PicturePtr pPict, PixmapPtr pPix, int unit) return TRUE; } -static void -I915DefCtxSetup(ScrnInfoPtr pScrn) -{ - I830Ptr pI830 = I830PTR(pScrn); - - BEGIN_LP_RING(2); - /* set default texture binding, may be in prepare better */ - OUT_RING(_3DSTATE_COORD_SET_BINDINGS | CSB_TCB(0,0) | CSB_TCB(1,1) | - CSB_TCB(2,2) | CSB_TCB(3,3) | CSB_TCB(4,4) | CSB_TCB(5,5) | - CSB_TCB(6,6) | CSB_TCB(7,7)); - OUT_RING(0); - ADVANCE_LP_RING(); -} - Bool I915EXAPrepareComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture, PicturePtr pDstPicture, @@ -353,8 +339,6 @@ ErrorF("i915 prepareComposite\n"); scale_units[2][1] = pDst->drawable.height; FS_LOCALS(20); - I915DefCtxSetup(pScrn); - if (!I915TextureSetup(pSrcPicture, pSrc, 0)) I830FALLBACK("fail to setup src texture\n"); if (pMask != NULL) { -- cgit v1.2.3 From ac34a37cb60d763cbd99b6e2f6fdcb639592b99b Mon Sep 17 00:00:00 2001 From: Wang Zhenyu Date: Fri, 21 Jul 2006 00:52:59 +0800 Subject: Take instruction fixes into i830, with indent changes. --- src/i830_exa_render.c | 53 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/src/i830_exa_render.c b/src/i830_exa_render.c index 9b4835bc..cd5e69c2 100644 --- a/src/i830_exa_render.c +++ b/src/i830_exa_render.c @@ -315,9 +315,9 @@ I830TextureSetup(PicturePtr pPict, PixmapPtr pPix, int unit) } { - if (pI830->cpp == 1) + if (pPix->drawable.bitsPerPixel == 8) format |= MAP_SURFACE_8BIT; - else if (pI830->cpp == 2) + else if (pPix->drawable.bitsPerPixel == 16) format |= MAP_SURFACE_16BIT; else format |= MAP_SURFACE_32BIT; @@ -325,9 +325,10 @@ I830TextureSetup(PicturePtr pPict, PixmapPtr pPix, int unit) BEGIN_LP_RING(6); OUT_RING(_3DSTATE_MAP_INFO_CMD); OUT_RING(format | TEXMAP_INDEX(unit) | MAP_FORMAT_2D); - OUT_RING((pPix->drawable.height<<16)|pPix->drawable.width); /* height, width */ - OUT_RING(offset<<2); /* map address */ - OUT_RING(pitch<<2); /* map pitch */ + OUT_RING(((pPix->drawable.height - 1) << 16) | + (pPix->drawable.width - 1)); /* height, width */ + OUT_RING(offset); /* map address */ + OUT_RING(((pitch / 4) - 1) << 2); /* map pitch */ OUT_RING(0); ADVANCE_LP_RING(); } @@ -336,8 +337,9 @@ I830TextureSetup(PicturePtr pPict, PixmapPtr pPix, int unit) BEGIN_LP_RING(2); /* coord sets */ OUT_RING(_3DSTATE_MAP_COORD_SET_CMD | TEXCOORD_SET(unit) | - ENABLE_TEXCOORD_PARAMS | TEXCOORDS_ARE_NORMAL | /*XXX, check this, and fix vertex tex coord*/ - TEXCOORDTYPE_CARTESIAN | ENABLE_ADDR_V_CNTL | TEXCOORD_ADDR_V_MODE(wrap_mode) | + ENABLE_TEXCOORD_PARAMS | TEXCOORDS_ARE_NORMAL | + TEXCOORDTYPE_CARTESIAN | ENABLE_ADDR_V_CNTL | + TEXCOORD_ADDR_V_MODE(wrap_mode) | ENABLE_ADDR_U_CNTL | TEXCOORD_ADDR_U_MODE(wrap_mode)); OUT_RING(MI_NOOP); @@ -453,7 +455,7 @@ I830EXAPrepareComposite(int op, PicturePtr pSrcPicture, CARD32 cblend, ablend, blendctl, vf2; - BEGIN_LP_RING(22); + BEGIN_LP_RING(22+6); /*color buffer*/ OUT_RING(_3DSTATE_BUF_INFO_CMD); @@ -464,6 +466,8 @@ I830EXAPrepareComposite(int op, PicturePtr pSrcPicture, OUT_RING(_3DSTATE_DST_BUF_VARS_CMD); OUT_RING(dst_format); + OUT_RING(MI_FLUSH | MI_WRITE_DIRTY_STATE | MI_INVALIDATE_MAP_CACHE); + OUT_RING(MI_NOOP); /* pad to quadword */ /* defaults */ OUT_RING(_3DSTATE_DFLT_Z_CMD); OUT_RING(0); @@ -474,18 +478,19 @@ I830EXAPrepareComposite(int op, PicturePtr pSrcPicture, OUT_RING(_3DSTATE_DFLT_SPEC_CMD); OUT_RING(0); - OUT_RING(_3DSTATE_LOAD_STATE_IMMEDIATE_1|I1_LOAD_S(3)|0); - OUT_RING((1<componentAlpha && pDstPicture->format != PICT_a8) - cblend |= TB0C_ARG2_SEL_TEXEL1; - else - cblend |= (TB0C_ARG2_SEL_TEXEL1 | TB0C_ARG2_REPLICATE_ALPHA); - ablend |= TB0A_ARG2_SEL_TEXEL1; + if (pMaskPicture->componentAlpha && pDstPicture->format != PICT_a8) + cblend |= TB0C_ARG2_SEL_TEXEL1; + else + cblend |= (TB0C_ARG2_SEL_TEXEL1 | TB0C_ARG2_REPLICATE_ALPHA); + ablend |= TB0A_ARG2_SEL_TEXEL1; } else { cblend |= TB0C_ARG2_SEL_ONE; ablend |= TB0A_ARG2_SEL_ONE; @@ -520,6 +528,9 @@ I830EXAPrepareComposite(int op, PicturePtr pSrcPicture, OUT_RING(ablend); OUT_RING(0); + OUT_RING(MI_FLUSH | MI_WRITE_DIRTY_STATE | MI_INVALIDATE_MAP_CACHE); + OUT_RING(MI_NOOP); /* pad to quadword */ + blendctl = I830GetBlendCntl(op, pMaskPicture, pDstPicture->format); OUT_RING(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | I1_LOAD_S(8) | 0); OUT_RING(S8_ENABLE_COLOR_BLEND | S8_BLENDFUNC_ADD |(blendctl<<4) | -- cgit v1.2.3 From a7e30bb051bc03063fe699473610a57054a64973 Mon Sep 17 00:00:00 2001 From: Wang Zhenyu Date: Fri, 21 Jul 2006 00:56:58 +0800 Subject: Take from i915, blend ctl code cleanup. --- src/i830_exa_render.c | 94 +++++++++++++++------------------------------------ src/i830_reg.h | 16 +++++++++ 2 files changed, 44 insertions(+), 66 deletions(-) diff --git a/src/i830_exa_render.c b/src/i830_exa_render.c index cd5e69c2..f51e6a4e 100644 --- a/src/i830_exa_render.c +++ b/src/i830_exa_render.c @@ -31,7 +31,8 @@ extern PictTransform *transform[2]; struct blendinfo { Bool dst_alpha; Bool src_alpha; - CARD32 blend_cntl; + CARD32 src_blend; + CARD32 dst_blend; }; struct formatinfo { @@ -48,41 +49,6 @@ I830EXAPrepareComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture, PicturePtr pDstPicture, PixmapPtr pSrc, PixmapPtr pMask, PixmapPtr pDst); -/* I830's Blend factor definition, LOAD_STATE_IMMEDIATE_1 */ -/* move to header...*/ -#define I830_SRC_BLENDFACTOR_ZERO (1 << 4) -#define I830_SRC_BLENDFACTOR_ONE (2 << 4) -#define I830_SRC_BLENDFACTOR_SRC_COLOR (3 << 4) -#define I830_SRC_BLENDFACTOR_INV_SRC_COLOR (4 << 4) -#define I830_SRC_BLENDFACTOR_SRC_ALPHA (5 << 4) -#define I830_SRC_BLENDFACTOR_INV_SRC_ALPHA (6 << 4) -#define I830_SRC_BLENDFACTOR_DST_ALPHA (7 << 4) -#define I830_SRC_BLENDFACTOR_INV_DST_ALPHA (8 << 4) -#define I830_SRC_BLENDFACTOR_DST_COLOR (9 << 4) -#define I830_SRC_BLENDFACTOR_INV_DST_COLOR (0xa << 4) -#define I830_SRC_BLENDFACTOR_SRC_ALPHA_SATURATE (0xb << 4) -#define I830_SRC_BLENDFACTOR_CONST_COLOR (0xc << 4) -#define I830_SRC_BLENDFACTOR_INV_CONST_COLOR (0xd << 4) -#define I830_SRC_BLENDFACTOR_CONST_ALPHA (0xe << 4) -#define I830_SRC_BLENDFACTOR_INV_CONST_ALPHA (0xf << 4) -#define I830_SRC_BLENDFACTOR_MASK (0xf << 4) - -#define I830_DST_BLENDFACTOR_ZERO (1) -#define I830_DST_BLENDFACTOR_ONE (2) -#define I830_DST_BLENDFACTOR_SRC_COLOR (3) -#define I830_DST_BLENDFACTOR_INV_SRC_COLOR (4) -#define I830_DST_BLENDFACTOR_SRC_ALPHA (5) -#define I830_DST_BLENDFACTOR_INV_SRC_ALPHA (6) -#define I830_DST_BLENDFACTOR_DST_ALPHA (7) -#define I830_DST_BLENDFACTOR_INV_DST_ALPHA (8) -#define I830_DST_BLENDFACTOR_DST_COLOR (9) -#define I830_DST_BLENDFACTOR_INV_DST_COLOR (0xa) -#define I830_DST_BLENDFACTOR_SRC_ALPHA_SATURATE (0xb) -#define I830_DST_BLENDFACTOR_CONST_COLOR (0xc) -#define I830_DST_BLENDFACTOR_INV_CONST_COLOR (0xd) -#define I830_DST_BLENDFACTOR_CONST_ALPHA (0xe) -#define I830_DST_BLENDFACTOR_INV_CONST_ALPHA (0xf) -#define I830_DST_BLENDFACTOR_MASK (0xf) #define TB0C_LAST_STAGE (1 << 31) #define TB0C_RESULT_SCALE_1X (0 << 29) @@ -132,38 +98,34 @@ I830EXAPrepareComposite(int op, PicturePtr pSrcPicture, #define TB0A_ARG1_SEL_TEXEL1 (7 << 6) #define TB0A_ARG1_SEL_TEXEL2 (8 << 6) #define TB0A_ARG1_SEL_TEXEL3 (9 << 6) -#define TB0A_ARG0_SEL_XXX - -/* end */ - static struct blendinfo I830BlendOp[] = { /* Clear */ - {0, 0, I830_SRC_BLENDFACTOR_ZERO | I830_DST_BLENDFACTOR_ZERO}, + {0, 0, BLENDFACTOR_ZERO, BLENDFACTOR_ZERO}, /* Src */ - {0, 0, I830_SRC_BLENDFACTOR_ONE | I830_DST_BLENDFACTOR_ZERO}, + {0, 0, BLENDFACTOR_ONE, BLENDFACTOR_ZERO}, /* Dst */ - {0, 0, I830_SRC_BLENDFACTOR_ZERO | I830_DST_BLENDFACTOR_ONE}, + {0, 0, BLENDFACTOR_ZERO, BLENDFACTOR_ONE}, /* Over */ - {0, 1, I830_SRC_BLENDFACTOR_ONE | I830_DST_BLENDFACTOR_INV_SRC_ALPHA}, + {0, 1, BLENDFACTOR_ONE, BLENDFACTOR_INV_SRC_ALPHA}, /* OverReverse */ - {1, 0, I830_SRC_BLENDFACTOR_INV_DST_ALPHA | I830_DST_BLENDFACTOR_ONE}, + {1, 0, BLENDFACTOR_INV_DST_ALPHA, BLENDFACTOR_ONE}, /* In */ - {1, 0, I830_SRC_BLENDFACTOR_DST_ALPHA | I830_DST_BLENDFACTOR_ZERO}, + {1, 0, BLENDFACTOR_DST_ALPHA, BLENDFACTOR_ZERO}, /* InReverse */ - {0, 1, I830_SRC_BLENDFACTOR_ZERO | I830_DST_BLENDFACTOR_SRC_ALPHA}, + {0, 1, BLENDFACTOR_ZERO, BLENDFACTOR_SRC_ALPHA}, /* Out */ - {1, 0, I830_SRC_BLENDFACTOR_INV_DST_ALPHA | I830_DST_BLENDFACTOR_ZERO}, + {1, 0, BLENDFACTOR_INV_DST_ALPHA, BLENDFACTOR_ZERO}, /* OutReverse */ - {0, 1, I830_SRC_BLENDFACTOR_ZERO | I830_DST_BLENDFACTOR_INV_SRC_ALPHA}, + {0, 1, BLENDFACTOR_ZERO, BLENDFACTOR_INV_SRC_ALPHA}, /* Atop */ - {1, 1, I830_SRC_BLENDFACTOR_DST_ALPHA | I830_DST_BLENDFACTOR_INV_SRC_ALPHA}, + {1, 1, BLENDFACTOR_DST_ALPHA, BLENDFACTOR_INV_SRC_ALPHA}, /* AtopReverse */ - {1, 1, I830_SRC_BLENDFACTOR_INV_DST_ALPHA | I830_DST_BLENDFACTOR_SRC_ALPHA}, + {1, 1, BLENDFACTOR_INV_DST_ALPHA, BLENDFACTOR_SRC_ALPHA}, /* Xor */ - {1, 1, I830_SRC_BLENDFACTOR_INV_DST_ALPHA | I830_DST_BLENDFACTOR_INV_SRC_ALPHA}, + {1, 1, BLENDFACTOR_INV_DST_ALPHA, BLENDFACTOR_INV_SRC_ALPHA}, /* Add */ - {0, 0, I830_SRC_BLENDFACTOR_ONE | I830_DST_BLENDFACTOR_ONE}, + {0, 0, BLENDFACTOR_ONE, BLENDFACTOR_ONE}, }; @@ -213,17 +175,17 @@ static CARD32 I830GetBlendCntl(int op, PicturePtr pMask, CARD32 dst_format) { CARD32 sblend, dblend; - sblend = I830BlendOp[op].blend_cntl & I830_SRC_BLENDFACTOR_MASK; - dblend = I830BlendOp[op].blend_cntl & I830_DST_BLENDFACTOR_MASK; + sblend = I830BlendOp[op].src_blend; + dblend = I830BlendOp[op].dst_blend; /* If there's no dst alpha channel, adjust the blend op so that we'll treat * it as always 1. */ if (PICT_FORMAT_A(dst_format) == 0 && I830BlendOp[op].dst_alpha) { - if (sblend == I830_SRC_BLENDFACTOR_DST_ALPHA) - sblend = I830_SRC_BLENDFACTOR_ONE; - else if (sblend == I830_SRC_BLENDFACTOR_INV_DST_ALPHA) - sblend = I830_SRC_BLENDFACTOR_ZERO; + if (sblend == BLENDFACTOR_DST_ALPHA) + sblend = BLENDFACTOR_ONE; + else if (sblend == BLENDFACTOR_INV_DST_ALPHA) + sblend = BLENDFACTOR_ZERO; } /* If the source alpha is being used, then we should only be in a case where @@ -231,14 +193,15 @@ static CARD32 I830GetBlendCntl(int op, PicturePtr pMask, CARD32 dst_format) * channels multiplied by the source picture's alpha. */ if (pMask && pMask->componentAlpha && I830BlendOp[op].src_alpha) { - if (dblend == I830_DST_BLENDFACTOR_SRC_ALPHA) { - dblend = I830_DST_BLENDFACTOR_SRC_COLOR; - } else if (dblend == I830_DST_BLENDFACTOR_INV_SRC_ALPHA) { - dblend = I830_DST_BLENDFACTOR_INV_SRC_COLOR; + if (dblend == BLENDFACTOR_SRC_ALPHA) { + dblend = BLENDFACTOR_SRC_COLR; + } else if (dblend == BLENDFACTOR_INV_SRC_ALPHA) { + dblend = BLENDFACTOR_INV_SRC_COLR; } } - return sblend | dblend; + return (sblend << S8_SRC_BLEND_FACTOR_SHIFT) | + (dblend << S8_DST_BLEND_FACTOR_SHIFT); } static Bool I830CheckCompositeTexture(PicturePtr pPict, int unit) @@ -386,8 +349,7 @@ I830EXACheckComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture, * source value that we get to blend with. */ if (I830BlendOp[op].src_alpha && - (I830BlendOp[op].blend_cntl & I830_SRC_BLENDFACTOR_MASK) != - I830_SRC_BLENDFACTOR_ZERO) + (I830BlendOp[op].src_blend != BLENDFACTOR_ZERO)) I830FALLBACK("Component alpha not supported with source " "alpha and source value blending.\n"); } diff --git a/src/i830_reg.h b/src/i830_reg.h index ae68a2e9..f9c1df9f 100644 --- a/src/i830_reg.h +++ b/src/i830_reg.h @@ -221,6 +221,22 @@ #define ENABLE_DST_ABLEND_FACTOR (1<<5) #define DST_ABLEND_FACT(x) (x) +#define BLENDFACTOR_ZERO 0x01 +#define BLENDFACTOR_ONE 0x02 +#define BLENDFACTOR_SRC_COLR 0x03 +#define BLENDFACTOR_INV_SRC_COLR 0x04 +#define BLENDFACTOR_SRC_ALPHA 0x05 +#define BLENDFACTOR_INV_SRC_ALPHA 0x06 +#define BLENDFACTOR_DST_ALPHA 0x07 +#define BLENDFACTOR_INV_DST_ALPHA 0x08 +#define BLENDFACTOR_DST_COLR 0x09 +#define BLENDFACTOR_INV_DST_COLR 0x0a +#define BLENDFACTOR_SRC_ALPHA_SATURATE 0x0b +#define BLENDFACTOR_CONST_COLOR 0x0c +#define BLENDFACTOR_INV_CONST_COLOR 0x0d +#define BLENDFACTOR_CONST_ALPHA 0x0e +#define BLENDFACTOR_INV_CONST_ALPHA 0x0f +#define BLENDFACTOR_MASK 0x0f /* _3DSTATE_MAP_BLEND_ARG, p152 */ #define _3DSTATE_MAP_BLEND_ARG_CMD(stage) (CMD_3D|(0x0e<<24)|((stage)<<20)) -- cgit v1.2.3 From 4737955a62c39177e7a7ce7749a2f20e111afc68 Mon Sep 17 00:00:00 2001 From: Wang Zhenyu Date: Fri, 21 Jul 2006 01:02:38 +0800 Subject: move i830 default coord set into I830EmitInvarientState --- src/i830_3d.c | 10 +++++++--- src/i830_exa_render.c | 21 --------------------- 2 files changed, 7 insertions(+), 24 deletions(-) diff --git a/src/i830_3d.c b/src/i830_3d.c index 0efd6e43..214beb60 100644 --- a/src/i830_3d.c +++ b/src/i830_3d.c @@ -33,13 +33,11 @@ #include "i830_reg.h" -#define CMD_3D (0x3<<29) - void I830EmitInvarientState( ScrnInfoPtr pScrn ) { I830Ptr pI830 = I830PTR(pScrn); - BEGIN_LP_RING(38); + BEGIN_LP_RING(40); OUT_RING(_3DSTATE_MAP_CUBE | MAP_UNIT(0)); OUT_RING(_3DSTATE_MAP_CUBE | MAP_UNIT(1)); @@ -98,6 +96,12 @@ void I830EmitInvarientState( ScrnInfoPtr pScrn ) OUT_RING(_3DSTATE_MAP_COORD_TRANSFORM); OUT_RING(DISABLE_TEX_TRANSFORM | TEXTURE_SET(3)); + OUT_RING(_3DSTATE_MAP_COORD_SETBIND_CMD); + OUT_RING(TEXBIND_SET3(TEXCOORDSRC_VTXSET_3) | + TEXBIND_SET2(TEXCOORDSRC_VTXSET_2) | + TEXBIND_SET1(TEXCOORDSRC_VTXSET_1) | + TEXBIND_SET0(TEXCOORDSRC_VTXSET_0)); + OUT_RING(_3DSTATE_RASTER_RULES_CMD | ENABLE_POINT_RASTER_RULE | OGL_POINT_RASTER_RULE | diff --git a/src/i830_exa_render.c b/src/i830_exa_render.c index f51e6a4e..7a22e7d5 100644 --- a/src/i830_exa_render.c +++ b/src/i830_exa_render.c @@ -365,25 +365,6 @@ I830EXACheckComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture, return TRUE; } - -static void -I830DefCtxSetup(ScrnInfoPtr pScrn) -{ - /* coord binding */ - CARD32 mcb; - I830Ptr pI830 = I830PTR(pScrn); - - BEGIN_LP_RING(2); - OUT_RING(_3DSTATE_MAP_COORD_SETBIND_CMD); - mcb = TEXBIND_SET3(TEXCOORDSRC_VTXSET_3); - mcb |= TEXBIND_SET2(TEXCOORDSRC_VTXSET_2); - mcb |= TEXBIND_SET1(TEXCOORDSRC_VTXSET_1); - mcb |= TEXBIND_SET0(TEXCOORDSRC_VTXSET_0); - OUT_RING(mcb); - ADVANCE_LP_RING(); -} - - Bool I830EXAPrepareComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture, PicturePtr pDstPicture, @@ -400,8 +381,6 @@ I830EXAPrepareComposite(int op, PicturePtr pSrcPicture, draw_coords[2][0] = pDst->drawable.x; draw_coords[2][1] = pDst->drawable.y; - I830DefCtxSetup(pScrn); - if (!I830TextureSetup(pSrcPicture, pSrc, 0)) I830FALLBACK("fail to setup src texture\n"); if (pMask != NULL) { -- cgit v1.2.3 From 9f1cec83e0aef36c7d3482e62e8f01595f1fd076 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 20 Jul 2006 11:05:49 -0400 Subject: The vertex data are all floats, so write the dest coords as floats. --- src/i830_exa.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/i830_exa.c b/src/i830_exa.c index 40f68683..f7c79c29 100644 --- a/src/i830_exa.c +++ b/src/i830_exa.c @@ -506,8 +506,8 @@ IntelEXAComposite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY, OUT_RING(PRIM3D_INLINE | PRIM3D_TRIFAN | (vertex_count-1)); - OUT_RING(dstX); - OUT_RING(dstY); + OUT_RING_F(dstX); + OUT_RING_F(dstY); OUT_RING_F(((srcX - draw_coords[0][0]) / scale_units[0][0])); OUT_RING_F(((srcY - draw_coords[0][1]) / scale_units[0][1])); if (pMask) { @@ -515,8 +515,8 @@ IntelEXAComposite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY, OUT_RING_F(((maskY - draw_coords[1][1]) / scale_units[1][1])); } - OUT_RING(dstX); - OUT_RING((dstY+h)); + OUT_RING_F(dstX); + OUT_RING_F((dstY+h)); OUT_RING_F(((srcX - draw_coords[0][0]) / scale_units[0][0])); OUT_RING_F(((srcYend - draw_coords[0][1]) / scale_units[0][1])); if (pMask) { @@ -524,8 +524,8 @@ IntelEXAComposite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY, OUT_RING_F(((maskYend - draw_coords[1][1]) / scale_units[1][1])); } - OUT_RING((dstX+w)); - OUT_RING((dstY+h)); + OUT_RING_F((dstX+w)); + OUT_RING_F((dstY+h)); OUT_RING_F(((srcXend - draw_coords[0][0]) / scale_units[0][0])); OUT_RING_F(((srcYend - draw_coords[0][1]) / scale_units[0][1])); if (pMask) { @@ -533,8 +533,8 @@ IntelEXAComposite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY, OUT_RING_F(((maskYend - draw_coords[1][1]) / scale_units[1][1])); } - OUT_RING((dstX+w)); - OUT_RING((dstY)); + OUT_RING_F((dstX+w)); + OUT_RING_F((dstY)); OUT_RING_F(((srcXend - draw_coords[0][0]) / scale_units[0][0])); OUT_RING_F(((srcY - draw_coords[0][1]) / scale_units[0][1])); if (pMask) { -- cgit v1.2.3 From 2b2173c618c080b1678990d65fe49b52bd8001b4 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 20 Jul 2006 11:15:18 -0400 Subject: The pixmap's drawable x/y coordinates are always 0, so don't bother using them. --- src/i830_exa.c | 63 ++++++++++++++++++++++----------------------------- src/i830_exa_render.c | 7 +----- src/i915_exa_render.c | 5 ---- 3 files changed, 28 insertions(+), 47 deletions(-) diff --git a/src/i830_exa.c b/src/i830_exa.c index f7c79c29..de12c338 100644 --- a/src/i830_exa.c +++ b/src/i830_exa.c @@ -56,7 +56,6 @@ do { \ #endif float scale_units[2][2]; -int draw_coords[3][2]; const int I830CopyROP[16] = { @@ -431,13 +430,12 @@ IntelEXAComposite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY, int pMask = 1; DPRINTF(PFX, "Composite: srcX %d, srcY %d\n\t maskX %d, maskY %d\n\t" - "dstX %d, dstY %d\n\twidth %d, height %d\n\t" - "src_scale_x %f, src_scale_y %f, mask_scale_x %f, mask_scale_y %f\n""\tdx0 %d, dy0 %x, dx1 %d dy1 %x\n", - srcX, srcY, maskX, maskY, dstX, dstY, w, h, - scale_units[0][0], scale_units[0][1], - scale_units[1][0], scale_units[1][1], - draw_coords[0][0], draw_coords[0][1], - draw_coords[1][0], draw_coords[1][1]); + "dstX %d, dstY %d\n\twidth %d, height %d\n\t" + "src_scale_x %f, src_scale_y %f, " + "mask_scale_x %f, mask_scale_y %f\n", + srcX, srcY, maskX, maskY, dstX, dstY, w, h, + scale_units[0][0], scale_units[0][1], + scale_units[1][0], scale_units[1][1]); if (scale_units[1][0] == -1 || scale_units[1][1] == -1) { ErrorF("mask is null\n"); @@ -481,13 +479,6 @@ IntelEXAComposite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY, "dstX %d, dstY %d\n", srcX, srcY, srcXend, srcYend, maskX, maskY, maskXend, maskYend, dstX, dstY); - draw_coords[0][0] -= draw_coords[2][0]; - draw_coords[0][1] -= draw_coords[2][1]; - if (pMask) { - draw_coords[1][0] -= draw_coords[2][0]; - draw_coords[1][1] -= draw_coords[2][1]; - } - { int vertex_count; @@ -508,38 +499,38 @@ IntelEXAComposite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY, OUT_RING_F(dstX); OUT_RING_F(dstY); - OUT_RING_F(((srcX - draw_coords[0][0]) / scale_units[0][0])); - OUT_RING_F(((srcY - draw_coords[0][1]) / scale_units[0][1])); + OUT_RING_F(srcX / scale_units[0][0]); + OUT_RING_F(srcY / scale_units[0][1]); if (pMask) { - OUT_RING_F(((maskX - draw_coords[1][0]) / scale_units[1][0])); - OUT_RING_F(((maskY - draw_coords[1][1]) / scale_units[1][1])); + OUT_RING_F(maskX / scale_units[1][0]); + OUT_RING_F(maskY / scale_units[1][1]); } OUT_RING_F(dstX); - OUT_RING_F((dstY+h)); - OUT_RING_F(((srcX - draw_coords[0][0]) / scale_units[0][0])); - OUT_RING_F(((srcYend - draw_coords[0][1]) / scale_units[0][1])); + OUT_RING_F(dstY + h); + OUT_RING_F(srcX / scale_units[0][0]); + OUT_RING_F(srcYend / scale_units[0][1]); if (pMask) { - OUT_RING_F(((maskX - draw_coords[1][0]) / scale_units[1][0])); - OUT_RING_F(((maskYend - draw_coords[1][1]) / scale_units[1][1])); + OUT_RING_F(maskX / scale_units[1][0]); + OUT_RING_F(maskYend / scale_units[1][1]); } - OUT_RING_F((dstX+w)); - OUT_RING_F((dstY+h)); - OUT_RING_F(((srcXend - draw_coords[0][0]) / scale_units[0][0])); - OUT_RING_F(((srcYend - draw_coords[0][1]) / scale_units[0][1])); + OUT_RING_F(dstX + w); + OUT_RING_F(dstY + h); + OUT_RING_F(srcXend / scale_units[0][0]); + OUT_RING_F(srcYend / scale_units[0][1]); if (pMask) { - OUT_RING_F(((maskXend - draw_coords[1][0]) / scale_units[1][0])); - OUT_RING_F(((maskYend - draw_coords[1][1]) / scale_units[1][1])); + OUT_RING_F(maskXend / scale_units[1][0]); + OUT_RING_F(maskYend / scale_units[1][1]); } - OUT_RING_F((dstX+w)); - OUT_RING_F((dstY)); - OUT_RING_F(((srcXend - draw_coords[0][0]) / scale_units[0][0])); - OUT_RING_F(((srcY - draw_coords[0][1]) / scale_units[0][1])); + OUT_RING_F(dstX + w); + OUT_RING_F(dstY); + OUT_RING_F(srcXend / scale_units[0][0]); + OUT_RING_F(srcY / scale_units[0][1]); if (pMask) { - OUT_RING_F(((maskXend - draw_coords[1][0]) / scale_units[1][0])); - OUT_RING_F(((maskY - draw_coords[1][1]) / scale_units[1][1])); + OUT_RING_F(maskXend / scale_units[1][0]); + OUT_RING_F(maskY / scale_units[1][1]); } ADVANCE_LP_RING(); } diff --git a/src/i830_exa_render.c b/src/i830_exa_render.c index 7a22e7d5..23a3c43b 100644 --- a/src/i830_exa_render.c +++ b/src/i830_exa_render.c @@ -24,7 +24,6 @@ do { \ #endif extern float scale_units[2][2]; -extern int draw_coords[3][2]; extern Bool is_transform[2]; extern PictTransform *transform[2]; @@ -249,8 +248,6 @@ I830TextureSetup(PicturePtr pPict, PixmapPtr pPix, int unit) h = pPict->pDrawable->height; scale_units[unit][0] = pPix->drawable.width; scale_units[unit][1] = pPix->drawable.height; - draw_coords[unit][0] = pPix->drawable.x; - draw_coords[unit][1] = pPix->drawable.y; for (i = 0; i < sizeof(I830TexFormats) / sizeof(I830TexFormats[0]); i++) { if (I830TexFormats[i].fmt == pPict->format) @@ -378,9 +375,7 @@ I830EXAPrepareComposite(int op, PicturePtr pSrcPicture, I830GetDestFormat(pDstPicture, &dst_format); dst_offset = exaGetPixmapOffset(pDst); dst_pitch = exaGetPixmapPitch(pDst); - draw_coords[2][0] = pDst->drawable.x; - draw_coords[2][1] = pDst->drawable.y; - + if (!I830TextureSetup(pSrcPicture, pSrc, 0)) I830FALLBACK("fail to setup src texture\n"); if (pMask != NULL) { diff --git a/src/i915_exa_render.c b/src/i915_exa_render.c index ba54d538..6246136c 100644 --- a/src/i915_exa_render.c +++ b/src/i915_exa_render.c @@ -27,7 +27,6 @@ do { \ #endif extern float scale_units[2][2]; -extern int draw_coords[3][2]; extern Bool is_transform[2]; extern PictTransform *transform[2]; @@ -230,8 +229,6 @@ I915TextureSetup(PicturePtr pPict, PixmapPtr pPix, int unit) h = pPict->pDrawable->height; scale_units[unit][0] = pPix->drawable.width; scale_units[unit][1] = pPix->drawable.height; - draw_coords[unit][0] = pPix->drawable.x; - draw_coords[unit][1] = pPix->drawable.y; for (i = 0; i < sizeof(I915TexFormats) / sizeof(I915TexFormats[0]); i++) { if (I915TexFormats[i].fmt == pPict->format) @@ -333,8 +330,6 @@ ErrorF("i915 prepareComposite\n"); I915GetDestFormat(pDstPicture, &dst_format); dst_offset = exaGetPixmapOffset(pDst); dst_pitch = exaGetPixmapPitch(pDst); - draw_coords[2][0] = pDst->drawable.x; - draw_coords[2][1] = pDst->drawable.y; scale_units[2][0] = pDst->drawable.width; scale_units[2][1] = pDst->drawable.height; FS_LOCALS(20); -- cgit v1.2.3 From d6d6a44c66446f34b57394e5ea9a8e32917f7569 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 20 Jul 2006 11:23:05 -0400 Subject: Try to fix up the basic RepeatNormal and RepeatNone support. With RepeatNone, access outside of the drawable should return 0 alpha values, which is done by using the border color. For RepeatNormal, we use the wrap mode (which requires that we use normalized texture coordinates). --- src/i915_exa_render.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/i915_exa_render.c b/src/i915_exa_render.c index 6246136c..deeac4a4 100644 --- a/src/i915_exa_render.c +++ b/src/i915_exa_render.c @@ -221,7 +221,7 @@ I915TextureSetup(PicturePtr pPict, PixmapPtr pPix, int unit) I830Ptr pI830 = I830PTR(pScrn); CARD32 format, offset, pitch, filter; int w, h, i; - CARD32 wrap_mode = TEXCOORDMODE_CLAMP_EDGE; + CARD32 wrap_mode = TEXCOORDMODE_CLAMP_BORDER; offset = exaGetPixmapOffset(pPix); pitch = exaGetPixmapPitch(pPix); @@ -239,8 +239,8 @@ I915TextureSetup(PicturePtr pPict, PixmapPtr pPix, int unit) format = I915TexFormats[i].card_fmt; if (pPict->repeat) - wrap_mode = TEXCOORDMODE_WRAP; /* XXX:correct ? */ - + wrap_mode = TEXCOORDMODE_WRAP; + switch (pPict->filter) { case PictFilterNearest: filter = (FILTER_NEAREST << SS2_MAG_FILTER_SHIFT) | @@ -289,12 +289,12 @@ I915TextureSetup(PicturePtr pPict, PixmapPtr pPix, int unit) ss2 |= filter; OUT_RING(ss2); /* repeat? */ - ss3 = TEXCOORDMODE_WRAP << SS3_TCX_ADDR_MODE_SHIFT; - ss3 |= (TEXCOORDMODE_WRAP << SS3_TCY_ADDR_MODE_SHIFT); + ss3 = wrap_mode << SS3_TCX_ADDR_MODE_SHIFT; + ss3 |= wrap_mode << SS3_TCY_ADDR_MODE_SHIFT; ss3 |= SS3_NORMALIZED_COORDS; ss3 |= (unit << SS3_TEXTUREMAP_INDEX_SHIFT); OUT_RING(ss3); - OUT_RING(0x00000000); /* default color */ + OUT_RING(0x00000000); /* border color */ OUT_RING(0); ADVANCE_LP_RING(); -- cgit v1.2.3 From fd6d825ae0780f3daf436f4224bf5f177cb8630e Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 20 Jul 2006 17:25:31 -0400 Subject: Move ss6 setting with other immediate state, and ensure that stencil is off. --- src/i915_exa_render.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/src/i915_exa_render.c b/src/i915_exa_render.c index deeac4a4..a063d8f8 100644 --- a/src/i915_exa_render.c +++ b/src/i915_exa_render.c @@ -348,7 +348,7 @@ ErrorF("i915 prepareComposite\n"); { CARD32 ss2; - BEGIN_LP_RING(24); + BEGIN_LP_RING(26); /*color buffer*/ OUT_RING(_3DSTATE_BUF_INFO_CMD); OUT_RING(BUF_3D_ID_COLOR_BACK| BUF_3D_PITCH(dst_pitch)); /* fence, tile? */ @@ -369,8 +369,8 @@ ErrorF("i915 prepareComposite\n"); OUT_RING(0); /* XXX:S3? define vertex format with tex coord sets number*/ - OUT_RING(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | I1_LOAD_S(2) | - I1_LOAD_S(3) | I1_LOAD_S(4) | 2); + OUT_RING(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | I1_LOAD_S(2) | + I1_LOAD_S(3) | I1_LOAD_S(4) | I1_LOAD_S(5) | I1_LOAD_S(6) | 4); ss2 = S2_TEXCOORD_FMT(0, TEXCOORDFMT_2D); if (pMask) ss2 |= S2_TEXCOORD_FMT(1, TEXCOORDFMT_2D); @@ -383,9 +383,13 @@ ErrorF("i915 prepareComposite\n"); ss2 |= S2_TEXCOORD_FMT(6, TEXCOORDFMT_NOT_PRESENT); ss2 |= S2_TEXCOORD_FMT(7, TEXCOORDFMT_NOT_PRESENT); OUT_RING(ss2); - OUT_RING(0x00000000); /*XXX: does ss3 needed? */ + OUT_RING(0x00000000); /* Disable texture coordinate wrap-shortest */ OUT_RING((1<format); + OUT_RING(0x00000000); /* Disable stencil buffer */ + OUT_RING(S6_CBUF_BLEND_ENABLE | S6_COLOR_WRITE_ENABLE | + (BLENDFUNC_ADD << S6_CBUF_BLEND_FUNC_SHIFT) | blendctl); /* issue a flush */ OUT_RING(MI_FLUSH | MI_WRITE_DIRTY_STATE | MI_INVALIDATE_MAP_CACHE); @@ -445,17 +449,6 @@ ErrorF("i915 prepareComposite\n"); } FS_END(); - { - CARD32 ss6; - blendctl = I915GetBlendCntl(op, pMaskPicture, pDstPicture->format); - - BEGIN_LP_RING(2); - OUT_RING(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | I1_LOAD_S(6) | 0); - ss6 = S6_CBUF_BLEND_ENABLE | S6_COLOR_WRITE_ENABLE; - OUT_RING(ss6 | (0 << S6_CBUF_BLEND_FUNC_SHIFT) | blendctl); - ADVANCE_LP_RING(); - } - #ifdef I830DEBUG ErrorF("try to sync to show any errors..."); I830Sync(pScrn); -- cgit v1.2.3 From 45cb032e2b7ac1e4c765fc29a2e4dd0cef19066d Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 20 Jul 2006 17:34:50 -0400 Subject: Use MT_8BIT_A8 so PICT_a8 expands to (0,0,0,a) not (a,a,a,a) --- src/i915_exa_render.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/i915_exa_render.c b/src/i915_exa_render.c index a063d8f8..795c0765 100644 --- a/src/i915_exa_render.c +++ b/src/i915_exa_render.c @@ -88,7 +88,7 @@ static struct formatinfo I915TexFormats[] = { {PICT_r5g6b5, MT_16BIT_RGB565 }, {PICT_a1r5g5b5, MT_16BIT_ARGB1555 }, {PICT_x1r5g5b5, MT_16BIT_ARGB1555 }, - {PICT_a8, MT_8BIT_I8 }, + {PICT_a8, MT_8BIT_A8 }, }; static CARD32 I915GetBlendCntl(int op, PicturePtr pMask, CARD32 dst_format) -- cgit v1.2.3 From 914327f40d07a3f7c069752ce005bf8e21352b03 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 20 Jul 2006 17:58:07 -0400 Subject: Disable drawing to PICT_a8, and turn on support for non-extended repeats. We don't know what COLOR_BUF_8BIT does, so it's disabled for now while we're stabilizing the code. The non-extended repeats appear to be working according to the rendercheck tests on a8 and a8r8g8b8 sources. Masks continue to hang the card, as before this change. --- src/i915_exa_render.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/i915_exa_render.c b/src/i915_exa_render.c index 795c0765..36e6c807 100644 --- a/src/i915_exa_render.c +++ b/src/i915_exa_render.c @@ -138,9 +138,16 @@ static Bool I915GetDestFormat(PicturePtr pDstPicture, CARD32 *dst_format) case PICT_x1r5g5b5: *dst_format = COLR_BUF_ARGB1555; break; + /* COLR_BUF_8BIT is special for YUV surfaces. While we may end up being + * able to use it depending on how the hardware implements it, disable it + * for now while we don't know what exactly it does (what channel does it + * read from? + */ + /* case PICT_a8: *dst_format = COLR_BUF_8BIT; break; + */ case PICT_a4r4g4b4: case PICT_x4r4g4b4: *dst_format = COLR_BUF_ARGB4444; @@ -171,9 +178,9 @@ static Bool I915CheckCompositeTexture(PicturePtr pPict, int unit) I830FALLBACK("Unsupported picture format 0x%x\n", (int)pPict->format); - /* FIXME: fix repeat support */ - if (pPict->repeat) - I830FALLBACK("repeat not support now!\n"); + if (pPict->repeat && pPict->repeatType != RepeatNormal) + I830FALLBACK("extended repeat (%d) not supported\n", + pPict->repeatType); if (pPict->filter != PictFilterNearest && pPict->filter != PictFilterBilinear) -- cgit v1.2.3 From 4f0ad337098eb0bacb1c11bc61d780ac18041e1d Mon Sep 17 00:00:00 2001 From: Wang Zhenyu Date: Fri, 21 Jul 2006 11:59:04 +0800 Subject: fixup segfault in xaa when xaa not initialized in i830WaitSync. --- src/i830_driver.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/i830_driver.c b/src/i830_driver.c index b7a8097e..ed855855 100644 --- a/src/i830_driver.c +++ b/src/i830_driver.c @@ -6425,7 +6425,8 @@ i830WaitSync(ScrnInfoPtr pScrn) I830Ptr pI830 = I830PTR(pScrn); #ifdef I830_USE_XAA - if (!pI830->noAccel && !pI830->useEXA && pI830->AccelInfoRec->NeedToSync) { + if (!pI830->noAccel && !pI830->useEXA && pI830->AccelInfoRec + && pI830->AccelInfoRec->NeedToSync) { (*pI830->AccelInfoRec->Sync)(pScrn); pI830->AccelInfoRec->NeedToSync = FALSE; } -- cgit v1.2.3 From 02c5c4cd1dd44058d80ec23cccfd45a13bc3bb2c Mon Sep 17 00:00:00 2001 From: Wang Zhenyu Date: Fri, 21 Jul 2006 12:54:06 +0800 Subject: add copyright info --- src/i830_exa_render.c | 28 ++++++++++++++++++++++++++++ src/i915_exa_render.c | 28 +++++++++++++++++++++++++++- 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/src/i830_exa_render.c b/src/i830_exa_render.c index 23a3c43b..86e11d21 100644 --- a/src/i830_exa_render.c +++ b/src/i830_exa_render.c @@ -1,3 +1,31 @@ +/* + * Copyright © 2006 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Authors: + * Wang Zhenyu + * Eric Anholt + * + */ + #ifdef HAVE_CONFIG_H #include "config.h" #endif diff --git a/src/i915_exa_render.c b/src/i915_exa_render.c index 36e6c807..08736ccd 100644 --- a/src/i915_exa_render.c +++ b/src/i915_exa_render.c @@ -1,4 +1,30 @@ -/* -*- c-basic-offset: 4 -*- */ +/* + * Copyright © 2006 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Authors: + * Wang Zhenyu + * Eric Anholt + * + */ #ifdef HAVE_CONFIG_H #include "config.h" -- cgit v1.2.3 From aec88cf4c66833f89afa5f8fa4f8bcf30b2b6b4b Mon Sep 17 00:00:00 2001 From: Wang Zhenyu Date: Mon, 24 Jul 2006 15:46:19 +0800 Subject: remove crap blit in UploadToScreen, we should find a more efficent way and implement blit correctly. --- src/i830_exa.c | 38 -------------------------------------- 1 file changed, 38 deletions(-) diff --git a/src/i830_exa.c b/src/i830_exa.c index de12c338..bb75b24a 100644 --- a/src/i830_exa.c +++ b/src/i830_exa.c @@ -325,8 +325,6 @@ I830EXADoneCopy(PixmapPtr pDstPixmap) return; } -//#define UPLOAD_USE_BLIT 1 - static Bool I830EXAUploadToScreen(PixmapPtr pDst, int x, int y, int w, int h, char *src, int src_pitch) @@ -343,7 +341,6 @@ I830EXAUploadToScreen(PixmapPtr pDst, int x, int y, int w, int h, ErrorF("Up->Screen: dst offset 0x%x, dst pitch %d, x %d, y %d, src %p, src pitch %d\n", dst_offset, dst_pitch, x, y, src, src_pitch); #endif -#ifndef UPLOAD_USE_BLIT dst = pI830->FbBase + dst_offset + y*dst_pitch + x* (pDst->drawable.bitsPerPixel/8); w *= pDst->drawable.bitsPerPixel/8; @@ -352,41 +349,6 @@ I830EXAUploadToScreen(PixmapPtr pDst, int x, int y, int w, int h, src += src_pitch; dst += dst_pitch; } -#else - /* setup blit engine to copy one pixel data by one */ - { - int x1, x2, y1, y2, i, j; - CARD32 d, len, *srcp; - x1 = x; - y1 = y; - x2 = x + w; - y2 = y + h; - - len = (w * (pDst->drawable.bitsPerPixel/8)) >> 2; - - pI830->BR[13] = (1 << 24) | (1 << 25); - pI830->BR[13] |= I830CopyROP[GXcopy]<<16; - pI830->BR[13] |= dst_pitch & 0xffff; - for (i = 0; i < h; i++) { - srcp = (CARD32*)src; - for ( j = len; j > 0; j--) { - d = *srcp; - BEGIN_LP_RING(6); - OUT_RING(XY_COLOR_BLT_CMD | XY_COLOR_BLT_WRITE_ALPHA | - XY_COLOR_BLT_WRITE_RGB); - OUT_RING(pI830->BR[13]); - OUT_RING((y1 << 16) | x1); - OUT_RING((y2 << 16) | x2); - OUT_RING(dst_offset); - OUT_RING(d); - ADVANCE_LP_RING(); - srcp++; - } - src += src_pitch; - } - - } -#endif return TRUE; } -- cgit v1.2.3 From 38d1a5e0dbe059f5c01bd5120a108a386ff10718 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 25 Jul 2006 21:09:12 -0700 Subject: Replace some OUT_RING(0)s with OUT_RING(MI_NOOP) to remind me why they're there. --- src/i915_exa_render.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/i915_exa_render.c b/src/i915_exa_render.c index 08736ccd..7555b41c 100644 --- a/src/i915_exa_render.c +++ b/src/i915_exa_render.c @@ -307,7 +307,7 @@ I915TextureSetup(PicturePtr pPict, PixmapPtr pPix, int unit) ms3 |= MS3_USE_FENCE_REGS; OUT_RING(ms3); OUT_RING(((pitch / 4) - 1) << MS4_PITCH_SHIFT); - OUT_RING(0); + OUT_RING(MI_NOOP); ADVANCE_LP_RING(); } @@ -328,7 +328,7 @@ I915TextureSetup(PicturePtr pPict, PixmapPtr pPix, int unit) ss3 |= (unit << SS3_TEXTUREMAP_INDEX_SHIFT); OUT_RING(ss3); OUT_RING(0x00000000); /* border color */ - OUT_RING(0); + OUT_RING(MI_NOOP); ADVANCE_LP_RING(); } @@ -393,13 +393,13 @@ ErrorF("i915 prepareComposite\n"); /* XXX: defaults */ OUT_RING(_3DSTATE_DFLT_Z_CMD); - OUT_RING(0); + OUT_RING(MI_NOOP); OUT_RING(_3DSTATE_DFLT_DIFFUSE_CMD); - OUT_RING(0); + OUT_RING(MI_NOOP); OUT_RING(_3DSTATE_DFLT_SPEC_CMD); - OUT_RING(0); + OUT_RING(MI_NOOP); /* XXX:S3? define vertex format with tex coord sets number*/ OUT_RING(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | I1_LOAD_S(2) | @@ -426,7 +426,7 @@ ErrorF("i915 prepareComposite\n"); /* issue a flush */ OUT_RING(MI_FLUSH | MI_WRITE_DIRTY_STATE | MI_INVALIDATE_MAP_CACHE); - OUT_RING(0); + OUT_RING(MI_NOOP); /* draw rect is unconditional */ OUT_RING(_3DSTATE_DRAW_RECT_CMD); @@ -434,7 +434,7 @@ ErrorF("i915 prepareComposite\n"); OUT_RING(0x00000000); /* ymin, xmin*/ OUT_RING(DRAW_YMAX(pScrn->virtualY-1) | DRAW_XMAX(pScrn->virtualX-1)); OUT_RING(0x00000000); /* yorig, xorig (relate to color buffer?)*/ - OUT_RING(0); + OUT_RING(MI_NOOP); ADVANCE_LP_RING(); } -- cgit v1.2.3 From 9c93d1498fa2363c52ef7fbe97d781560f67acf5 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 25 Jul 2006 21:17:05 -0700 Subject: Oops, partial revert of last commit. Some were obviously not NOOPS. --- src/i915_exa_render.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/i915_exa_render.c b/src/i915_exa_render.c index 7555b41c..74c85e01 100644 --- a/src/i915_exa_render.c +++ b/src/i915_exa_render.c @@ -393,13 +393,13 @@ ErrorF("i915 prepareComposite\n"); /* XXX: defaults */ OUT_RING(_3DSTATE_DFLT_Z_CMD); - OUT_RING(MI_NOOP); + OUT_RING(0x00000000); OUT_RING(_3DSTATE_DFLT_DIFFUSE_CMD); - OUT_RING(MI_NOOP); + OUT_RING(0x00000000); OUT_RING(_3DSTATE_DFLT_SPEC_CMD); - OUT_RING(MI_NOOP); + OUT_RING(0x00000000); /* XXX:S3? define vertex format with tex coord sets number*/ OUT_RING(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | I1_LOAD_S(2) | -- cgit v1.2.3 From 96754b822df7ac110a70b2d08dda2ebb299772be Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 26 Jul 2006 13:19:12 -0700 Subject: Fix a couple of typos from code review. --- src/i915_3d.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/i915_3d.h b/src/i915_3d.h index c1162000..10902186 100644 --- a/src/i915_3d.h +++ b/src/i915_3d.h @@ -33,7 +33,7 @@ #define MASK_Y 0x2 #define MASK_Z 0x4 #define MASK_W 0x8 -#define MASK_XYZ (MASK_X | MASK_Y | MASK_W) +#define MASK_XYZ (MASK_X | MASK_Y | MASK_Z) #define MASK_XYZW (MASK_XYZ | MASK_W) #define MASK_SATURATE 0x10 @@ -398,7 +398,7 @@ do { \ do { \ struct i915_fs_op op; \ \ - op = i915_fs_arith(DP3, dest_reg, operand0, i915_fs_operand_none(), \ + op = i915_fs_arith(DP3, dest_reg, operand0, operand1, \ i915_fs_operand_none()); \ op.ui[0] &= ~A0_DEST_CHANNEL_ALL; \ op.ui[0] |= ((dest_mask) & ~MASK_SATURATE) << A0_DEST_CHANNEL_SHIFT; \ -- cgit v1.2.3 From cffd2cd36d0437b38ac8164d66ea71be50b19330 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 26 Jul 2006 13:22:51 -0700 Subject: Fix hangs when compositing with a mask. The modify bits in the mask field for sampler/map state appear to actually be enable bits. So, prepare the state values in I915TextureSetup, then write the sampler/map state out all at once in PrepareComposite. --- src/i915_exa_render.c | 102 ++++++++++++++++++++++++++++---------------------- 1 file changed, 58 insertions(+), 44 deletions(-) diff --git a/src/i915_exa_render.c b/src/i915_exa_render.c index 74c85e01..7b2eada9 100644 --- a/src/i915_exa_render.c +++ b/src/i915_exa_render.c @@ -55,6 +55,8 @@ do { \ extern float scale_units[2][2]; extern Bool is_transform[2]; extern PictTransform *transform[2]; +static CARD32 mapstate[6]; +static CARD32 samplerstate[6]; struct formatinfo { int fmt; @@ -288,50 +290,27 @@ I915TextureSetup(PicturePtr pPict, PixmapPtr pPix, int unit) I830FALLBACK("Bad filter 0x%x\n", pPict->filter); } - { - CARD32 ms3; - if (pPix->drawable.bitsPerPixel == 8) - format |= MAPSURF_8BIT; - else if (pPix->drawable.bitsPerPixel == 16) - format |= MAPSURF_16BIT; - else - format |= MAPSURF_32BIT; - - BEGIN_LP_RING(6); - OUT_RING(_3DSTATE_MAP_STATE | 3); - OUT_RING(1<drawable.height - 1) << MS3_HEIGHT_SHIFT) | - ((pPix->drawable.width - 1) << MS3_WIDTH_SHIFT) | format; - if (!pI830->disableTiling) - ms3 |= MS3_USE_FENCE_REGS; - OUT_RING(ms3); - OUT_RING(((pitch / 4) - 1) << MS4_PITCH_SHIFT); - OUT_RING(MI_NOOP); - ADVANCE_LP_RING(); - } - - { - CARD32 ss2, ss3; - BEGIN_LP_RING(6); - /* max & min mip level ? or base mip level? */ - - OUT_RING(_3DSTATE_SAMPLER_STATE | 3); - OUT_RING(1<drawable.bitsPerPixel == 8) + format |= MAPSURF_8BIT; + else if (pPix->drawable.bitsPerPixel == 16) + format |= MAPSURF_16BIT; + else + format |= MAPSURF_32BIT; + + mapstate[unit * 3 + 0] = offset; + mapstate[unit * 3 + 1] = format | + ((pPix->drawable.height - 1) << MS3_HEIGHT_SHIFT) | + ((pPix->drawable.width - 1) << MS3_WIDTH_SHIFT); + if (!pI830->disableTiling) + samplerstate[unit * 3 + 1] |= MS3_USE_FENCE_REGS; + mapstate[unit * 3 + 2] = ((pitch / 4) - 1) << MS4_PITCH_SHIFT; + + samplerstate[unit * 3 + 0] = (MIPFILTER_NONE << SS2_MIP_FILTER_SHIFT) | filter; + samplerstate[unit * 3 + 1] = SS3_NORMALIZED_COORDS; + samplerstate[unit * 3 + 1] |= wrap_mode << SS3_TCX_ADDR_MODE_SHIFT; + samplerstate[unit * 3 + 1] |= wrap_mode << SS3_TCY_ADDR_MODE_SHIFT; + samplerstate[unit * 3 + 1] |= unit << SS3_TEXTUREMAP_INDEX_SHIFT; + samplerstate[unit * 3 + 2] = 0x00000000; /* border color */ if (pPict->transform != 0) { is_transform[unit] = TRUE; @@ -378,6 +357,41 @@ ErrorF("i915 prepareComposite\n"); scale_units[1][1] = -1; } + if (pMask == NULL) { + BEGIN_LP_RING(10); + OUT_RING(_3DSTATE_MAP_STATE | 3); + OUT_RING(0x00000001); /* map 0 */ + OUT_RING(mapstate[0]); + OUT_RING(mapstate[1]); + OUT_RING(mapstate[2]); + + OUT_RING(_3DSTATE_SAMPLER_STATE | 3); + OUT_RING(0x00000001); /* sampler 0 */ + OUT_RING(samplerstate[0]); + OUT_RING(samplerstate[1]); + OUT_RING(samplerstate[2]); + ADVANCE_LP_RING(); + } else { + BEGIN_LP_RING(16); + OUT_RING(_3DSTATE_MAP_STATE | 6); + OUT_RING(0x00000003); /* map 0,1 */ + OUT_RING(mapstate[0]); + OUT_RING(mapstate[1]); + OUT_RING(mapstate[2]); + OUT_RING(mapstate[3]); + OUT_RING(mapstate[4]); + OUT_RING(mapstate[5]); + + OUT_RING(_3DSTATE_SAMPLER_STATE | 6); + OUT_RING(0x00000003); /* sampler 0,1 */ + OUT_RING(samplerstate[0]); + OUT_RING(samplerstate[1]); + OUT_RING(samplerstate[2]); + OUT_RING(samplerstate[3]); + OUT_RING(samplerstate[4]); + OUT_RING(samplerstate[5]); + ADVANCE_LP_RING(); + } { CARD32 ss2; -- cgit v1.2.3 From 30952e58ed83e2e18d1007f662d2cc9a773c876c Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 26 Jul 2006 13:42:12 -0700 Subject: Limit drawing to the destination pixmap's boundaries, not the screen's. This shouldn't matter, as miComputeCompositeRegion shouldn't giving us anything that would draw outside the bounds, anyway. --- src/i915_exa_render.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/i915_exa_render.c b/src/i915_exa_render.c index 7b2eada9..9769765b 100644 --- a/src/i915_exa_render.c +++ b/src/i915_exa_render.c @@ -446,7 +446,8 @@ ErrorF("i915 prepareComposite\n"); OUT_RING(_3DSTATE_DRAW_RECT_CMD); OUT_RING(0x00000000); OUT_RING(0x00000000); /* ymin, xmin*/ - OUT_RING(DRAW_YMAX(pScrn->virtualY-1) | DRAW_XMAX(pScrn->virtualX-1)); + OUT_RING(DRAW_YMAX(pDst->drawable.height - 1) | + DRAW_XMAX(pDst->drawable.width - 1)); OUT_RING(0x00000000); /* yorig, xorig (relate to color buffer?)*/ OUT_RING(MI_NOOP); ADVANCE_LP_RING(); -- cgit v1.2.3 From 7ea74843bbdbf54b6804727be9b41d26832c8f76 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 31 Jul 2006 10:06:34 -0700 Subject: Whitespace cleanup. --- src/i915_exa_render.c | 50 ++++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/src/i915_exa_render.c b/src/i915_exa_render.c index 9769765b..24b5752e 100644 --- a/src/i915_exa_render.c +++ b/src/i915_exa_render.c @@ -49,7 +49,7 @@ do { \ #define I830FALLBACK(s, arg...) \ do { \ return FALSE; \ -} while(0) +} while(0) #endif extern float scale_units[2][2]; @@ -79,7 +79,7 @@ I915EXAPrepareComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture, PicturePtr pDstPicture, PixmapPtr pSrc, PixmapPtr pMask, PixmapPtr pDst); -static struct blendinfo I915BlendOp[] = { +static struct blendinfo I915BlendOp[] = { /* Clear */ {0, 0, BLENDFACT_ZERO, BLENDFACT_ZERO}, /* Src */ @@ -148,8 +148,8 @@ static CARD32 I915GetBlendCntl(int op, PicturePtr pMask, CARD32 dst_format) } } - return (sblend <pDrawable->width; int h = pPict->pDrawable->height; int i; - + if ((w > 0x7ff) || (h > 0x7ff)) I830FALLBACK("Picture w/h too large (%dx%d)\n", w, h); @@ -222,11 +222,10 @@ I915EXACheckComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture, PicturePtr pDstPicture) { CARD32 tmp1; - + /* Check for unsupported compositing operations. */ if (op >= sizeof(I915BlendOp) / sizeof(I915BlendOp[0])) I830FALLBACK("Unsupported Composite op 0x%x\n", op); - if (pMaskPicture != NULL && pMaskPicture->componentAlpha) { /* Check if it's component alpha that relies on a source alpha and on * the source value. We can only get one of those into the single @@ -243,7 +242,7 @@ I915EXACheckComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture, if (pMaskPicture != NULL && !I915CheckCompositeTexture(pMaskPicture, 1)) I830FALLBACK("Check Mask picture texture\n"); - if (!I915GetDestFormat(pDstPicture, &tmp1)) + if (!I915GetDestFormat(pDstPicture, &tmp1)) I830FALLBACK("Get Color buffer format\n"); return TRUE; @@ -269,20 +268,20 @@ I915TextureSetup(PicturePtr pPict, PixmapPtr pPix, int unit) if (I915TexFormats[i].fmt == pPict->format) break; } - if ( i == sizeof(I915TexFormats)/ sizeof(I915TexFormats[0]) ) + if (i == sizeof(I915TexFormats)/ sizeof(I915TexFormats[0])) I830FALLBACK("unknown texture format\n"); format = I915TexFormats[i].card_fmt; - if (pPict->repeat) + if (pPict->repeat) wrap_mode = TEXCOORDMODE_WRAP; switch (pPict->filter) { case PictFilterNearest: - filter = (FILTER_NEAREST << SS2_MAG_FILTER_SHIFT) | + filter = (FILTER_NEAREST << SS2_MAG_FILTER_SHIFT) | (FILTER_NEAREST << SS2_MIN_FILTER_SHIFT); break; case PictFilterBilinear: - filter = (FILTER_LINEAR << SS2_MAG_FILTER_SHIFT) | + filter = (FILTER_LINEAR << SS2_MAG_FILTER_SHIFT) | (FILTER_LINEAR << SS2_MIN_FILTER_SHIFT); break; default: @@ -305,7 +304,8 @@ I915TextureSetup(PicturePtr pPict, PixmapPtr pPix, int unit) samplerstate[unit * 3 + 1] |= MS3_USE_FENCE_REGS; mapstate[unit * 3 + 2] = ((pitch / 4) - 1) << MS4_PITCH_SHIFT; - samplerstate[unit * 3 + 0] = (MIPFILTER_NONE << SS2_MIP_FILTER_SHIFT) | filter; + samplerstate[unit * 3 + 0] = (MIPFILTER_NONE << SS2_MIP_FILTER_SHIFT); + samplerstate[unit * 3 + 0] |= filter; samplerstate[unit * 3 + 1] = SS3_NORMALIZED_COORDS; samplerstate[unit * 3 + 1] |= wrap_mode << SS3_TCX_ADDR_MODE_SHIFT; samplerstate[unit * 3 + 1] |= wrap_mode << SS3_TCY_ADDR_MODE_SHIFT; @@ -323,7 +323,7 @@ I915TextureSetup(PicturePtr pPict, PixmapPtr pPix, int unit) ErrorF("try to sync to show any errors..."); I830Sync(pScrn); #endif - + return TRUE; } @@ -337,7 +337,7 @@ I915EXAPrepareComposite(int op, PicturePtr pSrcPicture, CARD32 dst_format, dst_offset, dst_pitch; CARD32 blendctl; -ErrorF("i915 prepareComposite\n"); + ErrorF("i915 prepareComposite\n"); I915GetDestFormat(pDstPicture, &dst_format); dst_offset = exaGetPixmapOffset(pDst); @@ -345,7 +345,7 @@ ErrorF("i915 prepareComposite\n"); scale_units[2][0] = pDst->drawable.width; scale_units[2][1] = pDst->drawable.height; FS_LOCALS(20); - + if (!I915TextureSetup(pSrcPicture, pSrc, 0)) I830FALLBACK("fail to setup src texture\n"); if (pMask != NULL) { @@ -396,12 +396,15 @@ ErrorF("i915 prepareComposite\n"); CARD32 ss2; BEGIN_LP_RING(26); - /*color buffer*/ + /* color buffer + * XXX: Need to add USE_FENCE if we ever tile the X Server's pixmaps or + * visible screen. + */ OUT_RING(_3DSTATE_BUF_INFO_CMD); - OUT_RING(BUF_3D_ID_COLOR_BACK| BUF_3D_PITCH(dst_pitch)); /* fence, tile? */ + OUT_RING(BUF_3D_ID_COLOR_BACK| BUF_3D_PITCH(dst_pitch)); OUT_RING(BUF_3D_ADDR(dst_offset)); OUT_RING(MI_NOOP); - + OUT_RING(_3DSTATE_DST_BUF_VARS_CMD); OUT_RING(dst_format); @@ -414,9 +417,8 @@ ErrorF("i915 prepareComposite\n"); OUT_RING(_3DSTATE_DFLT_SPEC_CMD); OUT_RING(0x00000000); - - /* XXX:S3? define vertex format with tex coord sets number*/ - OUT_RING(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | I1_LOAD_S(2) | + + OUT_RING(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | I1_LOAD_S(2) | I1_LOAD_S(3) | I1_LOAD_S(4) | I1_LOAD_S(5) | I1_LOAD_S(6) | 4); ss2 = S2_TEXCOORD_FMT(0, TEXCOORDFMT_2D); if (pMask) @@ -431,8 +433,8 @@ ErrorF("i915 prepareComposite\n"); ss2 |= S2_TEXCOORD_FMT(7, TEXCOORDFMT_NOT_PRESENT); OUT_RING(ss2); OUT_RING(0x00000000); /* Disable texture coordinate wrap-shortest */ - OUT_RING((1<format); OUT_RING(0x00000000); /* Disable stencil buffer */ OUT_RING(S6_CBUF_BLEND_ENABLE | S6_COLOR_WRITE_ENABLE | -- cgit v1.2.3 From 7458a6adb5ea62f56bb3d4ab19ad7d1aa6ad2d19 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 31 Jul 2006 10:09:17 -0700 Subject: Move MAPSURF_XBIT settings into the texture formats structure. --- src/i915_exa_render.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/src/i915_exa_render.c b/src/i915_exa_render.c index 24b5752e..90240b82 100644 --- a/src/i915_exa_render.c +++ b/src/i915_exa_render.c @@ -109,14 +109,14 @@ static struct blendinfo I915BlendOp[] = { }; static struct formatinfo I915TexFormats[] = { - {PICT_a8r8g8b8, MT_32BIT_ARGB8888 }, - {PICT_x8r8g8b8, MT_32BIT_XRGB8888 }, - {PICT_a8b8g8r8, MT_32BIT_ABGR8888 }, - {PICT_x8b8g8r8, MT_32BIT_XBGR8888 }, - {PICT_r5g6b5, MT_16BIT_RGB565 }, - {PICT_a1r5g5b5, MT_16BIT_ARGB1555 }, - {PICT_x1r5g5b5, MT_16BIT_ARGB1555 }, - {PICT_a8, MT_8BIT_A8 }, + {PICT_a8r8g8b8, MAPSURF_32BIT | MT_32BIT_ARGB8888 }, + {PICT_x8r8g8b8, MAPSURF_32BIT | MT_32BIT_XRGB8888 }, + {PICT_a8b8g8r8, MAPSURF_32BIT | MT_32BIT_ABGR8888 }, + {PICT_x8b8g8r8, MAPSURF_32BIT | MT_32BIT_XBGR8888 }, + {PICT_r5g6b5, MAPSURF_16BIT | MT_16BIT_RGB565 }, + {PICT_a1r5g5b5, MAPSURF_16BIT | MT_16BIT_ARGB1555 }, + {PICT_x1r5g5b5, MAPSURF_16BIT | MT_16BIT_ARGB1555 }, + {PICT_a8, MAPSURF_8BIT | MT_8BIT_A8 }, }; static CARD32 I915GetBlendCntl(int op, PicturePtr pMask, CARD32 dst_format) @@ -289,13 +289,6 @@ I915TextureSetup(PicturePtr pPict, PixmapPtr pPix, int unit) I830FALLBACK("Bad filter 0x%x\n", pPict->filter); } - if (pPix->drawable.bitsPerPixel == 8) - format |= MAPSURF_8BIT; - else if (pPix->drawable.bitsPerPixel == 16) - format |= MAPSURF_16BIT; - else - format |= MAPSURF_32BIT; - mapstate[unit * 3 + 0] = offset; mapstate[unit * 3 + 1] = format | ((pPix->drawable.height - 1) << MS3_HEIGHT_SHIFT) | -- cgit v1.2.3 From cc79b3ec19a7e858972228a270ef774041eb8946 Mon Sep 17 00:00:00 2001 From: Wang Zhenyu Date: Thu, 24 Aug 2006 10:28:59 +0800 Subject: Current 915 render operations for 915G/945G only --- src/i830_exa.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/i830_exa.c b/src/i830_exa.c index bb75b24a..c2d3303f 100644 --- a/src/i830_exa.c +++ b/src/i830_exa.c @@ -566,12 +566,14 @@ I830EXAInit(ScreenPtr pScreen) pI830->EXADriverPtr->DoneCopy = I830EXADoneCopy; /* Composite */ - if (IS_I9XX(pI830)) { + if (IS_I915G(pI830) || IS_I915GM(pI830) || + IS_I945G(pI830) || IS_I945GM(pI830)) { pI830->EXADriverPtr->CheckComposite = I915EXACheckComposite; pI830->EXADriverPtr->PrepareComposite = I915EXAPrepareComposite; pI830->EXADriverPtr->Composite = IntelEXAComposite; pI830->EXADriverPtr->DoneComposite = IntelEXADoneComposite; - } else if (IS_I865G(pI830) || IS_I855(pI830) || IS_845G(pI830) || IS_I830(pI830)) { + } else if (IS_I865G(pI830) || IS_I855(pI830) || + IS_845G(pI830) || IS_I830(pI830)) { pI830->EXADriverPtr->CheckComposite = I830EXACheckComposite; pI830->EXADriverPtr->PrepareComposite = I830EXAPrepareComposite; pI830->EXADriverPtr->Composite = IntelEXAComposite; -- cgit v1.2.3 From b45f4b54b189a496255ddae12af38fc4c4408a51 Mon Sep 17 00:00:00 2001 From: Wang Zhenyu Date: Fri, 25 Aug 2006 16:23:18 +0800 Subject: Making render log a little quiet in normal --- src/i915_exa_render.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/i915_exa_render.c b/src/i915_exa_render.c index 90240b82..cb96898d 100644 --- a/src/i915_exa_render.c +++ b/src/i915_exa_render.c @@ -330,7 +330,9 @@ I915EXAPrepareComposite(int op, PicturePtr pSrcPicture, CARD32 dst_format, dst_offset, dst_pitch; CARD32 blendctl; - ErrorF("i915 prepareComposite\n"); +#ifdef I830DEBUG + ErrorF("Enter i915 prepareComposite\n"); +#endif I915GetDestFormat(pDstPicture, &dst_format); dst_offset = exaGetPixmapOffset(pDst); -- cgit v1.2.3 From c378328ece701756ddca966eb108e2b1f5c3ed6c Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 6 Sep 2006 11:15:17 -0700 Subject: Remove a debug printf. --- src/i915_exa_render.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/i915_exa_render.c b/src/i915_exa_render.c index 90240b82..ef3cf2a6 100644 --- a/src/i915_exa_render.c +++ b/src/i915_exa_render.c @@ -330,8 +330,6 @@ I915EXAPrepareComposite(int op, PicturePtr pSrcPicture, CARD32 dst_format, dst_offset, dst_pitch; CARD32 blendctl; - ErrorF("i915 prepareComposite\n"); - I915GetDestFormat(pDstPicture, &dst_format); dst_offset = exaGetPixmapOffset(pDst); dst_pitch = exaGetPixmapPitch(pDst); -- cgit v1.2.3 From 4ad577f83f7190df4d64e66fbf7c515ee6f411ce Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 7 Sep 2006 10:24:23 -0700 Subject: Remove the UTS/DFS implementations that just match the fallback versions. --- src/i830_exa.c | 64 ---------------------------------------------------------- 1 file changed, 64 deletions(-) diff --git a/src/i830_exa.c b/src/i830_exa.c index bb75b24a..0829c345 100644 --- a/src/i830_exa.c +++ b/src/i830_exa.c @@ -112,11 +112,6 @@ union intfloat { Bool is_transform[2]; PictTransform *transform[2]; -Bool i830UploadToScreen(PixmapPtr pDst, int x, int y, int w, int h, - char *src, int src_pitch); -Bool i830DownloadFromScreen(PixmapPtr pSrc, int x, int y, int w, int h, - char *dst, int dst_pitch); - extern Bool I830EXACheckComposite(int, PicturePtr, PicturePtr, PicturePtr); extern Bool I830EXAPrepareComposite(int, PicturePtr, PicturePtr, PicturePtr, PixmapPtr, PixmapPtr, PixmapPtr); @@ -325,61 +320,6 @@ I830EXADoneCopy(PixmapPtr pDstPixmap) return; } -static Bool -I830EXAUploadToScreen(PixmapPtr pDst, int x, int y, int w, int h, - char *src, int src_pitch) -{ - ScrnInfoPtr pScrn = xf86Screens[pDst->drawable.pScreen->myNum]; - I830Ptr pI830 = I830PTR(pScrn); - int dst_pitch = exaGetPixmapPitch(pDst); - int dst_offset = exaGetPixmapOffset(pDst); - unsigned char *dst; - - I830Sync(pScrn); - -#ifdef I830DEBUG - ErrorF("Up->Screen: dst offset 0x%x, dst pitch %d, x %d, y %d, src %p, src pitch %d\n", - dst_offset, dst_pitch, x, y, src, src_pitch); -#endif - dst = pI830->FbBase + dst_offset + y*dst_pitch + - x* (pDst->drawable.bitsPerPixel/8); - w *= pDst->drawable.bitsPerPixel/8; - while(h--) { - memcpy(dst, src, w); - src += src_pitch; - dst += dst_pitch; - } - - return TRUE; -} - -static Bool -I830EXADownloadFromScreen(PixmapPtr pSrc, int x, int y, int w, int h, - char *dst, int dst_pitch) -{ - ScrnInfoPtr pScrn = xf86Screens[pSrc->drawable.pScreen->myNum]; - I830Ptr pI830 = I830PTR(pScrn); - int src_pitch = exaGetPixmapPitch(pSrc); - int src_offset = exaGetPixmapOffset(pSrc); - unsigned char *src = pI830->FbBase + src_offset + y*src_pitch + - x*(pSrc->drawable.bitsPerPixel/8); - - I830Sync(pScrn); - -#ifdef I830DEBUG - ErrorF("Screen->Mem: src offset 0x%x, src %p, src pitch %d, x %d, y %d, dst %p, dst_pitch %d\n", - src_offset, src, src_pitch, x, y, dst, dst_pitch); -#endif - w *= pSrc->drawable.bitsPerPixel/8; - while(h--) { - memcpy(dst, src, w); - src += src_pitch; - dst += dst_pitch; - } - - return TRUE; -} - static void IntelEXAComposite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY, int dstX, int dstY, int w, int h) @@ -578,10 +518,6 @@ I830EXAInit(ScreenPtr pScreen) pI830->EXADriverPtr->DoneComposite = IntelEXADoneComposite; } - /* Upload, download to/from Screen, experimental!! */ - pI830->EXADriverPtr->UploadToScreen = I830EXAUploadToScreen; - pI830->EXADriverPtr->DownloadFromScreen = I830EXADownloadFromScreen; - if(!exaDriverInit(pScreen, pI830->EXADriverPtr)) { xfree(pI830->EXADriverPtr); pI830->noAccel = TRUE; -- cgit v1.2.3 From 099be52a3bb52516fb5e8d56c154a4d6b6707e09 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 7 Sep 2006 10:28:09 -0700 Subject: Re-remove xf86_ansic.h, and move copyright to the top of the file. --- src/i830_exa.c | 1 - src/i830_xaa.c | 27 +++++++++++++-------------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/i830_exa.c b/src/i830_exa.c index 0829c345..1074649b 100644 --- a/src/i830_exa.c +++ b/src/i830_exa.c @@ -31,7 +31,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "config.h" #endif -#include "xf86_ansic.h" #include "xf86.h" #include "xaarop.h" #include "i830.h" diff --git a/src/i830_xaa.c b/src/i830_xaa.c index 9f3a3910..d4cc7439 100644 --- a/src/i830_xaa.c +++ b/src/i830_xaa.c @@ -1,17 +1,3 @@ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "xf86_ansic.h" -#include "xf86.h" -#include "xaarop.h" -#include "i830.h" -#include "i810_reg.h" - -#ifndef DO_SCANLINE_IMAGE_WRITE -#define DO_SCANLINE_IMAGE_WRITE 0 -#endif - /************************************************************************** Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. @@ -58,6 +44,19 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "xf86.h" +#include "xaarop.h" +#include "i830.h" +#include "i810_reg.h" + +#ifndef DO_SCANLINE_IMAGE_WRITE +#define DO_SCANLINE_IMAGE_WRITE 0 +#endif + /* I830 Accel Functions */ static void I830SetupForMono8x8PatternFill(ScrnInfoPtr pScrn, int pattx, int patty, -- cgit v1.2.3 From e4cdc42a98dd1be74e5c2bf5d9566f7449523b14 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 7 Sep 2006 10:32:02 -0700 Subject: Remove another debug printf. --- src/i830_exa.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/i830_exa.c b/src/i830_exa.c index 1074649b..230c8a7f 100644 --- a/src/i830_exa.c +++ b/src/i830_exa.c @@ -339,7 +339,6 @@ IntelEXAComposite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY, scale_units[1][0], scale_units[1][1]); if (scale_units[1][0] == -1 || scale_units[1][1] == -1) { - ErrorF("mask is null\n"); pMask = 0; } -- cgit v1.2.3 From 59ce4180b95270432540624a1fdf7ae8dd18a7f3 Mon Sep 17 00:00:00 2001 From: Wang Zhenyu Date: Mon, 11 Sep 2006 22:57:23 +0800 Subject: reimplement Solid function Replace COLOR_BLT_CMD with XY_COLOR_BLT_CMD, by which device would care for direction and provide a (x,y) coord interface. This fixes pixmap artifacts even in no composite case. --- src/i830_exa.c | 61 +++++++++++++++++++++++----------------------------------- 1 file changed, 24 insertions(+), 37 deletions(-) diff --git a/src/i830_exa.c b/src/i830_exa.c index 2544760d..2bab0c7b 100644 --- a/src/i830_exa.c +++ b/src/i830_exa.c @@ -159,9 +159,6 @@ I830EXASync(ScreenPtr pScreen, int marker) /** * I830EXAPrepareSolid - prepare for a Solid operation, if possible - * - * TODO: - * - support planemask using FILL_MONO_SRC_BLT_CMD? */ static Bool I830EXAPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planemask, Pixel fg) @@ -173,6 +170,9 @@ I830EXAPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planemask, Pixel fg) if (!EXA_PM_IS_SOLID(&pPixmap->drawable, planemask)) I830FALLBACK("planemask is not solid"); + if (pPixmap->drawable.bitsPerPixel == 24) + I830FALLBACK("solid 24bpp unsupported!\n"); + offset = exaGetPixmapOffset(pPixmap); pitch = exaGetPixmapPitch(pPixmap); @@ -181,25 +181,21 @@ I830EXAPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planemask, Pixel fg) if ( pitch % pI830->EXADriverPtr->pixmapPitchAlign != 0) I830FALLBACK("pixmap pitch not aligned"); - pI830->BR[13] = pitch; - pI830->BR[13] |= I830PatternROP[alu] << 16; - - pI830->BR[16] = fg; - - /* - * Depth: 00 - 8 bit, 01 - 16 bit, 10 - 24 bit, 11 - 32 bit - */ - switch (pScrn->bitsPerPixel) { - case 8: - pI830->BR[13] |= ((0 << 25) | (0 << 24)); - break; - case 16: - pI830->BR[13] |= ((0 << 25) | (1 << 24)); - break; - case 32: - pI830->BR[13] |= ((1 << 25) | (1 << 24)); - break; + pI830->BR[13] = (pitch & 0xffff); + switch (pPixmap->drawable.bitsPerPixel) { + case 8: + break; + case 16: + /* RGB565 */ + pI830->BR[13] |= (1 << 24); + break; + case 32: + /* RGB8888 */ + pI830->BR[13] |= ((1 << 24) | (1 << 25)); + break; } + pI830->BR[13] |= (I830PatternROP[alu] & 0xff) << 16 ; + pI830->BR[16] = fg; return TRUE; } @@ -208,32 +204,23 @@ I830EXASolid(PixmapPtr pPixmap, int x1, int y1, int x2, int y2) { ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum]; I830Ptr pI830 = I830PTR(pScrn); - int h, w; unsigned long offset; - /* pixmap's offset and pitch is aligned, - otherwise it falls back in PrepareSolid */ - offset = exaGetPixmapOffset(pPixmap) + y1 * exaGetPixmapPitch(pPixmap) + - x1 * (pPixmap->drawable.bitsPerPixel / 8); + offset = exaGetPixmapOffset(pPixmap); - h = y2 - y1; - w = x2 - x1; - { BEGIN_LP_RING(6); - - if (pScrn->bitsPerPixel == 32) - OUT_RING(COLOR_BLT_CMD | COLOR_BLT_WRITE_ALPHA | - COLOR_BLT_WRITE_RGB); + if (pPixmap->drawable.bitsPerPixel == 32) + OUT_RING(XY_COLOR_BLT_CMD | XY_COLOR_BLT_WRITE_ALPHA + | XY_COLOR_BLT_WRITE_RGB); else - OUT_RING(COLOR_BLT_CMD); + OUT_RING(XY_COLOR_BLT_CMD); OUT_RING(pI830->BR[13]); - OUT_RING((h << 16) | (w * (pPixmap->drawable.bitsPerPixel/8))); + OUT_RING((y1 << 16) | x1); + OUT_RING((y2 << 16) | x2); OUT_RING(offset); OUT_RING(pI830->BR[16]); - OUT_RING(0); - ADVANCE_LP_RING(); } } -- cgit v1.2.3 From 71c2dd63361be9616c77db80a93445307d63dd41 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 14 Sep 2006 09:54:19 -0700 Subject: Replace duplicated sync code in exa with a call to I830Sync. The I830Sync version has additional code for the 965. --- src/i830_exa.c | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-) diff --git a/src/i830_exa.c b/src/i830_exa.c index 2bab0c7b..40093278 100644 --- a/src/i830_exa.c +++ b/src/i830_exa.c @@ -123,38 +123,16 @@ extern Bool I915EXAPrepareComposite(int, PicturePtr, PicturePtr, PicturePtr, * @pScreen: current screen * @marker: marker command to wait for * - * Wait for the command specified by @marker to finish, then return. + * Wait for the command specified by @marker to finish, then return. We don't + * actually do marker waits, though we might in the future. For now, just + * wait for a full idle. */ static void I830EXASync(ScreenPtr pScreen, int marker) { ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - I830Ptr pI830 = I830PTR(pScrn); - -#ifdef XF86DRI - /* VT switching tries to do this. */ - if (!pI830->LockHeld && pI830->directRenderingEnabled) - return; -#endif - - if (pI830->entityPrivate && !pI830->entityPrivate->RingRunning) - return; - - /* Send a flush instruction and then wait till the ring is empty. - * This is stronger than waiting for the blitter to finish as it also - * flushes the internal graphics caches. - */ - { - BEGIN_LP_RING(2); - OUT_RING(MI_FLUSH | MI_WRITE_DIRTY_STATE | MI_INVALIDATE_MAP_CACHE); - OUT_RING(MI_NOOP); /* pad to quadword */ - ADVANCE_LP_RING(); - } - I830WaitLpRing(pScrn, pI830->LpRing->mem.Size - 8, 0); - - pI830->LpRing->space = pI830->LpRing->mem.Size - 8; - pI830->nextColorExpandBuf = 0; + I830Sync(pScrn); } /** -- cgit v1.2.3 From ce00db054bf0b7f62ff0be312d7e3470141922dc Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 14 Sep 2006 10:00:06 -0700 Subject: Replace a couple of mis-uses of the screen's bpp when the pixmap's was needed. --- src/i830_exa.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/i830_exa.c b/src/i830_exa.c index 40093278..a2382ba3 100644 --- a/src/i830_exa.c +++ b/src/i830_exa.c @@ -229,7 +229,7 @@ I830EXAPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int xdir, pI830->BR[13] = exaGetPixmapPitch(pDstPixmap); pI830->BR[13] |= I830CopyROP[alu] << 16; - switch (pScrn->bitsPerPixel) { + switch (pSrcPixmap->drawable.bitsPerPixel) { case 8: break; case 16: @@ -260,7 +260,7 @@ I830EXACopy(PixmapPtr pDstPixmap, int src_x1, int src_y1, int dst_x1, { BEGIN_LP_RING(8); - if (pScrn->bitsPerPixel == 32) + if (pDstPixmap->drawable.bitsPerPixel == 32) OUT_RING(XY_SRC_COPY_BLT_CMD | XY_SRC_COPY_BLT_WRITE_ALPHA | XY_SRC_COPY_BLT_WRITE_RGB); else -- cgit v1.2.3 From f46c70e877a3432ba23696e1a16d5906183876af Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 14 Sep 2006 10:05:51 -0700 Subject: Add a note on maxX/maxY for the 2D rendering. --- src/i830_exa.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/i830_exa.c b/src/i830_exa.c index a2382ba3..6a7028fa 100644 --- a/src/i830_exa.c +++ b/src/i830_exa.c @@ -452,6 +452,8 @@ I830EXAInit(ScreenPtr pScreen) pI830->EXADriverPtr->pixmapOffsetAlign = 256; pI830->EXADriverPtr->pixmapPitchAlign = 64; + + /* i845 and i945 2D limits rendering to 65536 lines and pitch of 32768. */ pI830->EXADriverPtr->maxX = 4095; pI830->EXADriverPtr->maxY = 4095; -- cgit v1.2.3 From bd758030a6a59af32f9d73655cb691e018e94a7d Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 14 Sep 2006 11:12:03 -0700 Subject: Add a compile flag to enable syncing after each operation in EXA. This replaces other debug sync options sprinkled around the EXA code. It doesn't change the mis-rendering of text on the 915. --- src/i830_exa.c | 25 +++++++++++++++++-------- src/i915_exa_render.c | 10 ---------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/i830_exa.c b/src/i830_exa.c index 6a7028fa..c6337472 100644 --- a/src/i830_exa.c +++ b/src/i830_exa.c @@ -41,6 +41,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define DEBUG_I830FALLBACK 1 #endif +#define ALWAYS_SYNC 1 + #ifdef DEBUG_I830FALLBACK #define I830FALLBACK(s, arg...) \ do { \ @@ -206,7 +208,11 @@ I830EXASolid(PixmapPtr pPixmap, int x1, int y1, int x2, int y2) static void I830EXADoneSolid(PixmapPtr pPixmap) { - return; +#if ALWAYS_SYNC + ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum]; + + I830Sync(pScrn); +#endif } /** @@ -281,7 +287,11 @@ I830EXACopy(PixmapPtr pDstPixmap, int src_x1, int src_y1, int dst_x1, static void I830EXADoneCopy(PixmapPtr pDstPixmap) { - return; +#if ALWAYS_SYNC + ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum]; + + I830Sync(pScrn); +#endif } static void @@ -399,17 +409,16 @@ IntelEXAComposite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY, } ADVANCE_LP_RING(); } -#ifdef I830DEBUG - ErrorF("sync after 3dprimitive"); - I830Sync(pScrn); -#endif - } static void IntelEXADoneComposite(PixmapPtr pDst) { - return; +#if ALWAYS_SYNC + ScrnInfoPtr pScrn = xf86Screens[pDst->drawable.pScreen->myNum]; + + I830Sync(pScrn); +#endif } /* * TODO: diff --git a/src/i915_exa_render.c b/src/i915_exa_render.c index cb96898d..62b2507a 100644 --- a/src/i915_exa_render.c +++ b/src/i915_exa_render.c @@ -312,11 +312,6 @@ I915TextureSetup(PicturePtr pPict, PixmapPtr pPix, int unit) is_transform[unit] = FALSE; } -#ifdef I830DEBUG - ErrorF("try to sync to show any errors..."); - I830Sync(pScrn); -#endif - return TRUE; } @@ -494,10 +489,5 @@ I915EXAPrepareComposite(int op, PicturePtr pSrcPicture, } FS_END(); -#ifdef I830DEBUG - ErrorF("try to sync to show any errors..."); - I830Sync(pScrn); -#endif - return TRUE; } -- cgit v1.2.3 From 37429c3ecb97df8faf0f3f56128d7a2b22eb8a5e Mon Sep 17 00:00:00 2001 From: Wang Zhenyu Date: Tue, 19 Sep 2006 10:08:31 +0800 Subject: misc cleanup --- src/i830_exa.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/i830_exa.c b/src/i830_exa.c index c6337472..a1c75463 100644 --- a/src/i830_exa.c +++ b/src/i830_exa.c @@ -197,8 +197,8 @@ I830EXASolid(PixmapPtr pPixmap, int x1, int y1, int x2, int y2) OUT_RING(XY_COLOR_BLT_CMD); OUT_RING(pI830->BR[13]); - OUT_RING((y1 << 16) | x1); - OUT_RING((y2 << 16) | x2); + OUT_RING((y1 << 16) | (x1 & 0xffff)); + OUT_RING((y2 << 16) | (x2 & 0xffff)); OUT_RING(offset); OUT_RING(pI830->BR[16]); ADVANCE_LP_RING(); @@ -255,12 +255,11 @@ I830EXACopy(PixmapPtr pDstPixmap, int src_x1, int src_y1, int dst_x1, ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum]; I830Ptr pI830 = I830PTR(pScrn); int dst_x2, dst_y2; - unsigned int src_off, dst_off; + unsigned int dst_off; dst_x2 = dst_x1 + w; dst_y2 = dst_y1 + h; - src_off = pI830->copy_src_off; dst_off = exaGetPixmapOffset(pDstPixmap); { @@ -278,7 +277,7 @@ I830EXACopy(PixmapPtr pDstPixmap, int src_x1, int src_y1, int dst_x1, OUT_RING(dst_off); OUT_RING((src_y1 << 16) | (src_x1 & 0xffff)); OUT_RING(pI830->copy_src_pitch); - OUT_RING(src_off); + OUT_RING(pI830->copy_src_off); ADVANCE_LP_RING(); } @@ -298,7 +297,6 @@ static void IntelEXAComposite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY, int dstX, int dstY, int w, int h) { - /* should be same like I830Composite */ ScrnInfoPtr pScrn = xf86Screens[pDst->drawable.pScreen->myNum]; I830Ptr pI830 = I830PTR(pScrn); int srcXend, srcYend, maskXend, maskYend; -- cgit v1.2.3 From e3ab89b0327ef6ff790ab53bba29c721aef032cd Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 19 Sep 2006 10:27:36 +0800 Subject: shader program fix for component alpha set If CA is set and blend op needs src alpha, the src value is not needed and should be (src.A * mask.X). This is found in handling exa magic two pass composite. --- src/i915_exa_render.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/i915_exa_render.c b/src/i915_exa_render.c index 62b2507a..3bc2c0b9 100644 --- a/src/i915_exa_render.c +++ b/src/i915_exa_render.c @@ -473,15 +473,23 @@ I915EXAPrepareComposite(int op, PicturePtr pSrcPicture, if (PICT_FORMAT_A(pMaskPicture->format) == 0) i915_fs_mov_masked(FS_R1, MASK_W, i915_fs_operand_one()); - /* If component alpha is set in the mask, then we need to provide - * the source alpha component (channelwise multiplication) as the - * output color. If it isn't set, then we need to provide the - * source value component, which is the multipliction of the source - * by the mask alpha. + /* If component alpha is set in the mask and the blend operation + * uses the source alpha, then we know we don't need the source + * value (otherwise we would have hit a fallback earlier), so we + * provide the source alpha (src.A * mask.X) as output color. + * Conversely, if CA is set and we don't need the source alpha, then + * we produce the source value (src.X * mask.X) and the source alpha + * is unused.. Otherwise, we provide the non-CA source value + * (src.X * mask.A). */ - if (pMaskPicture->componentAlpha && pDstPicture->format != PICT_a8) { - i915_fs_mul(FS_OC, i915_fs_operand_reg(FS_R0), - i915_fs_operand_reg(FS_R1)); + if (pMaskPicture->componentAlpha) { + if (I915BlendOp[op].src_alpha) { + i915_fs_mul(FS_OC, i915_fs_operand(FS_R0, W, W, W, W), + i915_fs_operand_reg(FS_R1)); + } else { + i915_fs_mul(FS_OC, i915_fs_operand_reg(FS_R0), + i915_fs_operand_reg(FS_R1)); + } } else { i915_fs_mul(FS_OC, i915_fs_operand_reg(FS_R0), i915_fs_operand(FS_R1, W, W, W, W)); -- cgit v1.2.3 From 5adb05f0b82ee3a168142d803ab3434f75cf15a3 Mon Sep 17 00:00:00 2001 From: Wang Zhenyu Date: Tue, 19 Sep 2006 17:14:05 +0800 Subject: fix default tex wrap mode with clamp we don't set any 'default' border color, default tex wrap mode should be clamp to edge. --- src/i915_exa_render.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/i915_exa_render.c b/src/i915_exa_render.c index 3bc2c0b9..55d5c946 100644 --- a/src/i915_exa_render.c +++ b/src/i915_exa_render.c @@ -255,7 +255,7 @@ I915TextureSetup(PicturePtr pPict, PixmapPtr pPix, int unit) I830Ptr pI830 = I830PTR(pScrn); CARD32 format, offset, pitch, filter; int w, h, i; - CARD32 wrap_mode = TEXCOORDMODE_CLAMP_BORDER; + CARD32 wrap_mode = TEXCOORDMODE_CLAMP_EDGE; offset = exaGetPixmapOffset(pPix); pitch = exaGetPixmapPitch(pPix); -- cgit v1.2.3 From 1681fe6bb041385e5aefb11baa9afd1f614abc5b Mon Sep 17 00:00:00 2001 From: Wang Zhenyu Date: Wed, 20 Sep 2006 09:36:02 +0800 Subject: Revert "fix default tex wrap mode with clamp" oops, we've set border color to all zero, which should give us transparent in RepeatNone case. --- src/i915_exa_render.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/i915_exa_render.c b/src/i915_exa_render.c index 55d5c946..3bc2c0b9 100644 --- a/src/i915_exa_render.c +++ b/src/i915_exa_render.c @@ -255,7 +255,7 @@ I915TextureSetup(PicturePtr pPict, PixmapPtr pPix, int unit) I830Ptr pI830 = I830PTR(pScrn); CARD32 format, offset, pitch, filter; int w, h, i; - CARD32 wrap_mode = TEXCOORDMODE_CLAMP_EDGE; + CARD32 wrap_mode = TEXCOORDMODE_CLAMP_BORDER; offset = exaGetPixmapOffset(pPix); pitch = exaGetPixmapPitch(pPix); -- cgit v1.2.3 From ff202f8e2ae4117b464c94047001023d5d0531cc Mon Sep 17 00:00:00 2001 From: Wang Zhenyu Date: Fri, 22 Sep 2006 15:02:19 +0800 Subject: Fix a typo to mark sync for XAA. This should fix the scrolling screen corrupt in XAA method. --- src/i830_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/i830_driver.c b/src/i830_driver.c index 10a329c9..4d9de0cb 100644 --- a/src/i830_driver.c +++ b/src/i830_driver.c @@ -8900,7 +8900,7 @@ i830MarkSync(ScrnInfoPtr pScrn) #ifdef I830_USE_XAA if (!pI830->useEXA && pI830->AccelInfoRec) - pI830->AccelInfoRec->NeedToSync = FALSE; + pI830->AccelInfoRec->NeedToSync = TRUE; #endif #ifdef I830_USE_EXA if (pI830->useEXA && pI830->EXADriverPtr) { -- cgit v1.2.3 From c3666a968b1cfac61b7867874d5fbe2acd894720 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 26 Oct 2006 14:30:25 -0700 Subject: Don't write unused values beyond the end of scale_units array. --- src/i915_exa_render.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/i915_exa_render.c b/src/i915_exa_render.c index 3bc2c0b9..13fe3ee6 100644 --- a/src/i915_exa_render.c +++ b/src/i915_exa_render.c @@ -332,8 +332,6 @@ I915EXAPrepareComposite(int op, PicturePtr pSrcPicture, I915GetDestFormat(pDstPicture, &dst_format); dst_offset = exaGetPixmapOffset(pDst); dst_pitch = exaGetPixmapPitch(pDst); - scale_units[2][0] = pDst->drawable.width; - scale_units[2][1] = pDst->drawable.height; FS_LOCALS(20); if (!I915TextureSetup(pSrcPicture, pSrc, 0)) -- cgit v1.2.3 From 0bdcce2e4541c6e441c44aad49254ad3093cedb2 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 26 Oct 2006 14:30:46 -0700 Subject: Note alignment requirement for i915 3D (texturing). --- src/i830_exa.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/i830_exa.c b/src/i830_exa.c index a1c75463..7de56176 100644 --- a/src/i830_exa.c +++ b/src/i830_exa.c @@ -457,6 +457,7 @@ I830EXAInit(ScreenPtr pScreen) /* disable Xv here... */ } + /* i915 3D requires 16 byte alignment (4k if tiled) */ pI830->EXADriverPtr->pixmapOffsetAlign = 256; pI830->EXADriverPtr->pixmapPitchAlign = 64; -- cgit v1.2.3 From 25e6e497824a23eb231fc6fd6e483f601d612cee Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 26 Oct 2006 15:47:49 -0700 Subject: Major cleanup of 3D invariant state, fixing hangs with rotation and render. Now, the generic invariant state is always set while the X Server is active, and happens automatically when the X Server grabs the DRI lock. More 3D state is moved to the generic code. Then, the 3D consumers (video, rotation, render) set last_3d to their enum entry, and can update their own invariant state when another consumer was active. --- src/i830.h | 9 +++++ src/i830_dri.c | 2 + src/i830_driver.c | 13 +++++++ src/i830_exa_render.c | 2 + src/i830_rotate.c | 106 +++++++------------------------------------------- src/i915_3d.c | 34 +++++++++------- src/i915_exa_render.c | 18 ++------- src/i915_video.c | 53 ++----------------------- 8 files changed, 66 insertions(+), 171 deletions(-) diff --git a/src/i830.h b/src/i830.h index df1c171a..9c37068e 100644 --- a/src/i830.h +++ b/src/i830.h @@ -192,6 +192,13 @@ typedef struct _region { int x0,x1,y0,y1; } region; +/** enumeration of 3d consumers so some can maintain invariant state. */ +enum last_3d { + LAST_3D_OTHER, + LAST_3D_VIDEO, + LAST_3D_RENDER, + LAST_3D_ROTATION +}; typedef struct _I830Rec { unsigned char *MMIOBase; @@ -453,6 +460,8 @@ typedef struct _I830Rec { CARD32 savedAsurf; CARD32 savedBsurf; + + enum last_3d last_3d; } I830Rec; #define I830PTR(p) ((I830Ptr)((p)->driverPrivate)) diff --git a/src/i830_dri.c b/src/i830_dri.c index 8a52750f..b844d334 100644 --- a/src/i830_dri.c +++ b/src/i830_dri.c @@ -1000,6 +1000,8 @@ I830DRISwapContext(ScreenPtr pScreen, DRISyncType syncType, if (I810_DEBUG & DEBUG_VERBOSE_DRI) ErrorF("i830DRISwapContext (in)\n"); + pI830->last_3d = LAST_3D_OTHER; + if (!pScrn->vtSema) return; pI830->LockHeld = 1; diff --git a/src/i830_driver.c b/src/i830_driver.c index f9ca77cf..12fc5241 100644 --- a/src/i830_driver.c +++ b/src/i830_driver.c @@ -7041,10 +7041,23 @@ IntelEmitInvarientState(ScrnInfoPtr pScrn) { I830Ptr pI830 = I830PTR(pScrn); CARD32 ctx_addr; +#ifdef XF86DRI + drmI830Sarea *sarea; +#endif if (pI830->noAccel) return; +#ifdef XF86DRI + if (pI830->directRenderingEnabled) { + sarea = DRIGetSAREAPrivate(pScrn->pScreen); + + /* Mark that the X Server was the last holder of the context */ + if (sarea) + sarea->ctxOwner = DRIGetContext(pScrn->pScreen); + } +#endif + ctx_addr = pI830->ContextMem.Start; /* Align to a 2k boundry */ ctx_addr = ((ctx_addr + 2048 - 1) / 2048) * 2048; diff --git a/src/i830_exa_render.c b/src/i830_exa_render.c index 86e11d21..f63313f3 100644 --- a/src/i830_exa_render.c +++ b/src/i830_exa_render.c @@ -404,6 +404,8 @@ I830EXAPrepareComposite(int op, PicturePtr pSrcPicture, dst_offset = exaGetPixmapOffset(pDst); dst_pitch = exaGetPixmapPitch(pDst); + pI830->last_3d = LAST_3D_RENDER; + if (!I830TextureSetup(pSrcPicture, pSrc, 0)) I830FALLBACK("fail to setup src texture\n"); if (pMask != NULL) { diff --git a/src/i830_rotate.c b/src/i830_rotate.c index 76effa29..3cdb3aef 100644 --- a/src/i830_rotate.c +++ b/src/i830_rotate.c @@ -211,11 +211,6 @@ I915UpdateRotate (ScreenPtr pScreen, struct matrix23 rotMatrix; int j; int use_fence; - Bool updateInvarient = FALSE; -#ifdef XF86DRI - drmI830Sarea *sarea = NULL; - drm_context_t myContext = 0; -#endif Bool didLock = FALSE; if (I830IsPrimary(pScrn)) { @@ -246,58 +241,20 @@ I915UpdateRotate (ScreenPtr pScreen, } #ifdef XF86DRI - if (pI8301->directRenderingEnabled) { - sarea = DRIGetSAREAPrivate(pScrn1->pScreen); - myContext = DRIGetContext(pScrn1->pScreen); + if (pI8301->directRenderingEnabled) didLock = I830DRILock(pScrn1); - } #endif + /* If another screen was active, we don't know the current state. */ if (pScrn->scrnIndex != *pI830->used3D) - updateInvarient = TRUE; - -#ifdef XF86DRI - if (sarea && sarea->ctxOwner != myContext) - updateInvarient = TRUE; -#endif + pI830->last_3d = LAST_3D_OTHER; - if (updateInvarient) { + if (pI830->last_3d != LAST_3D_ROTATION) { FS_LOCALS(3); *pI830->used3D = pScrn->scrnIndex; -#ifdef XF86DRI - if (sarea) - sarea->ctxOwner = myContext; -#endif - BEGIN_LP_RING(54); - /* invarient state */ - OUT_RING(MI_NOOP); - OUT_RING(_3DSTATE_AA_CMD | - AA_LINE_ECAAR_WIDTH_ENABLE | AA_LINE_ECAAR_WIDTH_1_0 | - AA_LINE_REGION_WIDTH_ENABLE | AA_LINE_REGION_WIDTH_1_0); - - OUT_RING(_3DSTATE_DFLT_DIFFUSE_CMD); - OUT_RING(0x00000000); - - OUT_RING(_3DSTATE_DFLT_SPEC_CMD); - OUT_RING(0x00000000); - - OUT_RING(_3DSTATE_DFLT_Z_CMD); - OUT_RING(0x00000000); - - OUT_RING(_3DSTATE_COORD_SET_BINDINGS | - CSB_TCB(0, 0) | CSB_TCB(1, 1) | - CSB_TCB(2, 2) | CSB_TCB(3, 3) | - CSB_TCB(4, 4) | CSB_TCB(5, 5) | - CSB_TCB(6, 6) | CSB_TCB(7, 7)); - - OUT_RING(_3DSTATE_RASTER_RULES_CMD | - ENABLE_TRI_FAN_PROVOKE_VRTX | TRI_FAN_PROVOKE_VRTX(2) | - ENABLE_LINE_STRIP_PROVOKE_VRTX | LINE_STRIP_PROVOKE_VRTX(1) | - ENABLE_TEXKILL_3D_4D | TEXKILL_4D | - ENABLE_POINT_RASTER_RULE | OGL_POINT_RASTER_RULE); - OUT_RING(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | I1_LOAD_S(3) | 1); - OUT_RING(0x00000000); + BEGIN_LP_RING(34); + /* invarient state */ /* flush map & render cache */ OUT_RING(MI_FLUSH | MI_WRITE_DIRTY_STATE | MI_INVALIDATE_MAP_CACHE); @@ -313,24 +270,13 @@ I915UpdateRotate (ScreenPtr pScreen, OUT_RING(MI_NOOP); - OUT_RING(_3DSTATE_SCISSOR_ENABLE_CMD | DISABLE_SCISSOR_RECT); - OUT_RING(_3DSTATE_SCISSOR_RECT_0_CMD); - OUT_RING(0x00000000); /* ymin, xmin */ - OUT_RING(0x00000000); /* ymax, xmax */ - OUT_RING(0x7c000003); /* XXX: magic numbers */ OUT_RING(0x7d070000); OUT_RING(0x00000000); OUT_RING(0x68000002); - /* context setup */ - OUT_RING(_3DSTATE_MODES_4_CMD | - ENABLE_LOGIC_OP_FUNC | LOGIC_OP_FUNC(LOGICOP_COPY) | - MODE4_ENABLE_STENCIL_WRITE_MASK | - MODE4_ENABLE_STENCIL_TEST_MASK); - OUT_RING(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | - I1_LOAD_S(2) | I1_LOAD_S(4) | I1_LOAD_S(5) | I1_LOAD_S(6) | 4); + I1_LOAD_S(2) | I1_LOAD_S(4) | I1_LOAD_S(5) | I1_LOAD_S(6) | 3); OUT_RING(S2_TEXCOORD_FMT(0, TEXCOORDFMT_2D) | S2_TEXCOORD_FMT(1, TEXCOORDFMT_NOT_PRESENT) | @@ -349,14 +295,6 @@ I915UpdateRotate (ScreenPtr pScreen, (1 << S6_CBUF_DST_BLEND_FACT_SHIFT) | S6_COLOR_WRITE_ENABLE | (2 << S6_TRISTRIP_PV_SHIFT)); - OUT_RING(_3DSTATE_INDEPENDENT_ALPHA_BLEND_CMD | - IAB_MODIFY_ENABLE | - IAB_MODIFY_FUNC | (BLENDFUNC_ADD << IAB_FUNC_SHIFT) | - IAB_MODIFY_SRC_FACTOR | - (BLENDFACT_ONE << IAB_SRC_FACTOR_SHIFT) | - IAB_MODIFY_DST_FACTOR | - (BLENDFACT_ZERO << IAB_DST_FACTOR_SHIFT)); - OUT_RING(_3DSTATE_CONST_BLEND_COLOR_CMD); OUT_RING(0x00000000); @@ -373,9 +311,6 @@ I915UpdateRotate (ScreenPtr pScreen, DEPTH_FRMT_24_FIXED_8_OTHER); } - OUT_RING(_3DSTATE_STIPPLE); - OUT_RING(0x00000000); - /* texture sampler state */ OUT_RING(_3DSTATE_SAMPLER_STATE | 3); OUT_RING(0x00000001); @@ -493,13 +428,8 @@ I830UpdateRotate (ScreenPtr pScreen, CARD32 vb[32]; /* 32 dword vertex buffer */ float verts[4][2], tex[4][2]; struct matrix23 rotMatrix; - Bool updateInvarient = FALSE; int use_fence; int j; -#ifdef XF86DRI - drmI830Sarea *sarea = NULL; - drm_context_t myContext = 0; -#endif Bool didLock = FALSE; if (I830IsPrimary(pScrn)) { @@ -530,28 +460,18 @@ I830UpdateRotate (ScreenPtr pScreen, } #ifdef XF86DRI - if (pI8301->directRenderingEnabled) { - sarea = DRIGetSAREAPrivate(pScrn1->pScreen); - myContext = DRIGetContext(pScrn1->pScreen); + if (pI8301->directRenderingEnabled) didLock = I830DRILock(pScrn1); - } #endif if (pScrn->scrnIndex != *pI830->used3D) - updateInvarient = TRUE; - -#ifdef XF86DRI - if (sarea && sarea->ctxOwner != myContext) - updateInvarient = TRUE; -#endif + pI830->last_3d = LAST_3D_OTHER; - if (updateInvarient) { + if (pI830->last_3d != LAST_3D_ROTATION) { *pI830->used3D = pScrn->scrnIndex; -#ifdef XF86DRI - if (sarea) - sarea->ctxOwner = myContext; -#endif - + + pI830->last_3d = LAST_3D_ROTATION; + BEGIN_LP_RING(48); OUT_RING(0x682008a1); OUT_RING(0x6f402100); diff --git a/src/i915_3d.c b/src/i915_3d.c index e70bb24a..ff591716 100644 --- a/src/i915_3d.c +++ b/src/i915_3d.c @@ -38,7 +38,7 @@ void I915EmitInvarientState( ScrnInfoPtr pScrn ) { I830Ptr pI830 = I830PTR(pScrn); - BEGIN_LP_RING(20); + BEGIN_LP_RING(24); OUT_RING(_3DSTATE_AA_CMD | AA_LINE_ECAAR_WIDTH_ENABLE | @@ -46,6 +46,13 @@ void I915EmitInvarientState( ScrnInfoPtr pScrn ) AA_LINE_REGION_WIDTH_ENABLE | AA_LINE_REGION_WIDTH_1_0); + /* Disable independent alpha blend */ + OUT_RING(_3DSTATE_INDEPENDENT_ALPHA_BLEND_CMD | + IAB_MODIFY_ENABLE | + IAB_MODIFY_FUNC | (BLENDFUNC_ADD << IAB_FUNC_SHIFT) | + IAB_MODIFY_SRC_FACTOR | (BLENDFACT_ONE << IAB_SRC_FACTOR_SHIFT) | + IAB_MODIFY_DST_FACTOR | (BLENDFACT_ZERO << IAB_DST_FACTOR_SHIFT)); + OUT_RING(_3DSTATE_DFLT_DIFFUSE_CMD); OUT_RING(0); @@ -76,15 +83,15 @@ void I915EmitInvarientState( ScrnInfoPtr pScrn ) ENABLE_TEXKILL_3D_4D | TEXKILL_4D); - /* Need to initialize this to zero. - */ + OUT_RING(_3DSTATE_MODES_4_CMD | + ENABLE_LOGIC_OP_FUNC | LOGIC_OP_FUNC(LOGICOP_COPY) | + ENABLE_STENCIL_WRITE_MASK | STENCIL_WRITE_MASK(0xff) | + ENABLE_STENCIL_TEST_MASK | STENCIL_TEST_MASK(0xff)); + OUT_RING(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | I1_LOAD_S(3) | 0); - OUT_RING(0); - - /* XXX: Use this */ - OUT_RING(_3DSTATE_SCISSOR_ENABLE_CMD | - DISABLE_SCISSOR_RECT); + OUT_RING(0x00000000); /* Disable texture coordinate wrap-shortest */ + OUT_RING(_3DSTATE_SCISSOR_ENABLE_CMD | DISABLE_SCISSOR_RECT); OUT_RING(_3DSTATE_SCISSOR_RECT_0_CMD); OUT_RING(0); OUT_RING(0); @@ -94,12 +101,11 @@ void I915EmitInvarientState( ScrnInfoPtr pScrn ) OUT_RING(_3DSTATE_LOAD_INDIRECT | 0); /* disable indirect state */ OUT_RING(0); - /* Don't support twosided stencil yet */ - OUT_RING(_3DSTATE_BACKFACE_STENCIL_OPS | - BFO_ENABLE_STENCIL_TWO_SIDE | - 0 ); + OUT_RING(_3DSTATE_STIPPLE); + OUT_RING(0x00000000); + + OUT_RING(_3DSTATE_BACKFACE_STENCIL_OPS | BFO_ENABLE_STENCIL_TWO_SIDE | 0 ); + OUT_RING(MI_NOOP); - OUT_RING(0); - ADVANCE_LP_RING(); } diff --git a/src/i915_exa_render.c b/src/i915_exa_render.c index 13fe3ee6..eae8171e 100644 --- a/src/i915_exa_render.c +++ b/src/i915_exa_render.c @@ -329,6 +329,8 @@ I915EXAPrepareComposite(int op, PicturePtr pSrcPicture, ErrorF("Enter i915 prepareComposite\n"); #endif + pI830->last_3d = LAST_3D_RENDER; + I915GetDestFormat(pDstPicture, &dst_format); dst_offset = exaGetPixmapOffset(pDst); dst_pitch = exaGetPixmapPitch(pDst); @@ -383,7 +385,7 @@ I915EXAPrepareComposite(int op, PicturePtr pSrcPicture, { CARD32 ss2; - BEGIN_LP_RING(26); + BEGIN_LP_RING(18); /* color buffer * XXX: Need to add USE_FENCE if we ever tile the X Server's pixmaps or * visible screen. @@ -391,23 +393,12 @@ I915EXAPrepareComposite(int op, PicturePtr pSrcPicture, OUT_RING(_3DSTATE_BUF_INFO_CMD); OUT_RING(BUF_3D_ID_COLOR_BACK| BUF_3D_PITCH(dst_pitch)); OUT_RING(BUF_3D_ADDR(dst_offset)); - OUT_RING(MI_NOOP); OUT_RING(_3DSTATE_DST_BUF_VARS_CMD); OUT_RING(dst_format); - /* XXX: defaults */ - OUT_RING(_3DSTATE_DFLT_Z_CMD); - OUT_RING(0x00000000); - - OUT_RING(_3DSTATE_DFLT_DIFFUSE_CMD); - OUT_RING(0x00000000); - - OUT_RING(_3DSTATE_DFLT_SPEC_CMD); - OUT_RING(0x00000000); - OUT_RING(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | I1_LOAD_S(2) | - I1_LOAD_S(3) | I1_LOAD_S(4) | I1_LOAD_S(5) | I1_LOAD_S(6) | 4); + I1_LOAD_S(4) | I1_LOAD_S(5) | I1_LOAD_S(6) | 3); ss2 = S2_TEXCOORD_FMT(0, TEXCOORDFMT_2D); if (pMask) ss2 |= S2_TEXCOORD_FMT(1, TEXCOORDFMT_2D); @@ -420,7 +411,6 @@ I915EXAPrepareComposite(int op, PicturePtr pSrcPicture, ss2 |= S2_TEXCOORD_FMT(6, TEXCOORDFMT_NOT_PRESENT); ss2 |= S2_TEXCOORD_FMT(7, TEXCOORDFMT_NOT_PRESENT); OUT_RING(ss2); - OUT_RING(0x00000000); /* Disable texture coordinate wrap-shortest */ OUT_RING((1 << S4_POINT_WIDTH_SHIFT) | S4_LINE_WIDTH_ONE | S4_CULLMODE_NONE| S4_VFMT_XY); blendctl = I915GetBlendCntl(op, pMaskPicture, pDstPicture->format); diff --git a/src/i915_video.c b/src/i915_video.c index 0833d508..aa192aff 100644 --- a/src/i915_video.c +++ b/src/i915_video.c @@ -89,35 +89,9 @@ I915DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id, */ *pI830->used3D |= 1 << 30; - BEGIN_LP_RING(44); + pI830->last_3d = LAST_3D_VIDEO; - /* invarient state */ - OUT_RING(MI_NOOP); - OUT_RING(_3DSTATE_AA_CMD | - AA_LINE_ECAAR_WIDTH_ENABLE | AA_LINE_ECAAR_WIDTH_1_0 | - AA_LINE_REGION_WIDTH_ENABLE | AA_LINE_REGION_WIDTH_1_0); - - OUT_RING(_3DSTATE_DFLT_DIFFUSE_CMD); - OUT_RING(0x00000000); - - OUT_RING(_3DSTATE_DFLT_SPEC_CMD); - OUT_RING(0x00000000); - - OUT_RING(_3DSTATE_DFLT_Z_CMD); - OUT_RING(0x00000000); - - OUT_RING(_3DSTATE_COORD_SET_BINDINGS | CSB_TCB(0, 0) | CSB_TCB(1, 1) | - CSB_TCB(2,2) | CSB_TCB(3,3) | CSB_TCB(4,4) | CSB_TCB(5,5) | - CSB_TCB(6,6) | CSB_TCB(7,7)); - - OUT_RING(_3DSTATE_RASTER_RULES_CMD | - ENABLE_TRI_FAN_PROVOKE_VRTX | TRI_FAN_PROVOKE_VRTX(2) | - ENABLE_LINE_STRIP_PROVOKE_VRTX | LINE_STRIP_PROVOKE_VRTX(1) | - ENABLE_TEXKILL_3D_4D | TEXKILL_4D | - ENABLE_POINT_RASTER_RULE | OGL_POINT_RASTER_RULE); - - OUT_RING(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | I1_LOAD_S(3) | 1); - OUT_RING(0x00000000); /* texture coordinate wrap */ + BEGIN_LP_RING(24); /* flush map & render cache */ OUT_RING(MI_FLUSH | MI_WRITE_DIRTY_STATE | MI_INVALIDATE_MAP_CACHE); @@ -132,25 +106,13 @@ I915DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id, OUT_RING(0x00000000); /* yorigin, xorigin */ OUT_RING(MI_NOOP); - /* scissor */ - OUT_RING(_3DSTATE_SCISSOR_ENABLE_CMD | DISABLE_SCISSOR_RECT); - OUT_RING(_3DSTATE_SCISSOR_RECT_0_CMD); - OUT_RING(0x00000000); /* ymin, xmin */ - OUT_RING(0x00000000); /* ymax, xmax */ - OUT_RING(0x7c000003); /* unknown command */ OUT_RING(0x7d070000); OUT_RING(0x00000000); OUT_RING(0x68000002); - /* context setup */ - OUT_RING(_3DSTATE_MODES_4_CMD | - ENABLE_LOGIC_OP_FUNC | LOGIC_OP_FUNC(LOGICOP_COPY) | - ENABLE_STENCIL_WRITE_MASK | STENCIL_WRITE_MASK(0xff) | - ENABLE_STENCIL_TEST_MASK | STENCIL_TEST_MASK(0xff)); - OUT_RING(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | I1_LOAD_S(2) | - I1_LOAD_S(4) | I1_LOAD_S(5) | I1_LOAD_S(6) | 4); + I1_LOAD_S(4) | I1_LOAD_S(5) | I1_LOAD_S(6) | 3); s2 = S2_TEXCOORD_FMT(0, TEXCOORDFMT_2D); if (planar) s2 |= S2_TEXCOORD_FMT(1, TEXCOORDFMT_2D); @@ -171,12 +133,6 @@ I915DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id, (1 << S6_CBUF_DST_BLEND_FACT_SHIFT) | S6_COLOR_WRITE_ENABLE | (2 << S6_TRISTRIP_PV_SHIFT)); - OUT_RING(_3DSTATE_INDEPENDENT_ALPHA_BLEND_CMD | - IAB_MODIFY_ENABLE | - IAB_MODIFY_FUNC | (BLENDFUNC_ADD << IAB_FUNC_SHIFT) | - IAB_MODIFY_SRC_FACTOR | (BLENDFACT_ONE << IAB_SRC_FACTOR_SHIFT) | - IAB_MODIFY_DST_FACTOR | (BLENDFACT_ZERO << IAB_DST_FACTOR_SHIFT)); - OUT_RING(_3DSTATE_CONST_BLEND_COLOR_CMD); OUT_RING(0x00000000); @@ -189,9 +145,6 @@ I915DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id, OUT_RING(LOD_PRECLAMP_OGL | DSTORG_HORT_BIAS(0x80) | DSTORG_VERT_BIAS(0x80) | format); - OUT_RING(_3DSTATE_STIPPLE); - OUT_RING(0x00000000); - /* front buffer, pitch, offset */ OUT_RING(_3DSTATE_BUF_INFO_CMD); OUT_RING(BUF_3D_ID_COLOR_BACK | BUF_3D_USE_FENCE | -- cgit v1.2.3