Index: vmwarexaa.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/vmware/vmwarexaa.c,v retrieving revision 1.2 diff -a -u -8 -r1.2 vmwarexaa.c --- vmwarexaa.c 23 Apr 2004 19:53:57 -0000 1.2 +++ vmwarexaa.c 28 Sep 2004 22:35:32 -0000 @@ -46,36 +46,39 @@ int w, int h, int skipleft ); static void vmwareSubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno); #ifdef RENDER static Bool vmwareSetupForCPUToScreenAlphaTexture(ScrnInfoPtr pScrn, int op, CARD16 red, CARD16 green, CARD16 blue, CARD16 alpha, - int alphaType, CARD8 *alphaPtr, + CARD32 maskFormat, + CARD32 dstFormat, + CARD8 *alphaPtr, int alphaPitch, int width, int height, int flags); static Bool vmwareSetupForCPUToScreenTexture(ScrnInfoPtr pScrn, int op, - int texType, CARD8 *texPtr, - int texPitch, + CARD32 srcFormat, CARD32 dstFormat, + CARD8 *texPtr, int texPitch, int width, int height, int flags); static void vmwareSubsequentCPUToScreenTexture(ScrnInfoPtr pScrn, int dstx, int dsty, int srcx, int srcy, int width, int height); static void vmwareXAAEnableDisableFBAccess(int index, Bool enable); CARD32 vmwareAlphaTextureFormats[2] = {PICT_a8, 0}; CARD32 vmwareTextureFormats[2] = {PICT_a8r8g8b8, 0}; +CARD32 vmwareDstFormats[2] = {0, 0}; /* filled in at init time. */ #endif #define SCRATCH_SIZE_BYTES(pvmware) \ (((OFFSCREEN_SCRATCH_SIZE + (pvmware)->fbPitch - 1) / \ (pvmware)->fbPitch) * (pvmware)->fbPitch) static void vmwareXAACreateHeap(ScreenPtr pScreen, ScrnInfoPtr pScrn, @@ -100,17 +103,17 @@ pVMWARE->xaaInfo = NULL; } Bool vmwareXAAScreenInit(ScreenPtr pScreen) { ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; VMWAREPtr pVMWARE = VMWAREPTR(pScrn); XAAInfoRecPtr xaaInfo; - + pVMWARE->xaaInfo = XAACreateInfoRec(); if (!pVMWARE->xaaInfo) { return FALSE; } xaaInfo = pVMWARE->xaaInfo; xaaInfo->Sync = vmwareXAASync; @@ -159,39 +162,59 @@ box.x1 = 0; box.y1 = (pVMWARE->FbSize + pVMWARE->fbPitch - 1) / pVMWARE->fbPitch; box.x2 = pScrn->displayWidth; box.y2 = pVMWARE->videoRam / pVMWARE->fbPitch; #ifdef RENDER if (pVMWARE->vmwareCapability & SVGA_CAP_ALPHA_BLEND && pScrn->bitsPerPixel > 8) { - if (box.y2 - (scratchSizeBytes / pVMWARE->fbPitch) > box.y1 + 4) { + switch (pVMWARE->bitsPerPixel) { + case 16: + if (pVMWARE->depth == 15) { + vmwareDstFormats[0] = PICT_x1r5g5b5; + } else { + vmwareDstFormats[0] = PICT_r5g6b5; + } + break; + case 24: + vmwareDstFormats[0] = PICT_r8g8b8; + break; + case 32: + vmwareDstFormats[0] = PICT_x8r8g8b8; + break; + } + + if (vmwareDstFormats[0] != 0 && + box.y2 - (scratchSizeBytes / pVMWARE->fbPitch) > box.y1 + 4) { box.y2 -= scratchSizeBytes / pVMWARE->fbPitch; VmwareLog(("Allocated %d bytes at offset %d for alpha scratch\n", scratchSizeBytes, pVMWARE->videoRam - scratchSizeBytes)); vmwareXAACreateHeap(pScreen, pScrn, pVMWARE); - xaaInfo->SetupForCPUToScreenAlphaTexture = + xaaInfo->SetupForCPUToScreenAlphaTexture2 = vmwareSetupForCPUToScreenAlphaTexture; xaaInfo->SubsequentCPUToScreenAlphaTexture = vmwareSubsequentCPUToScreenTexture; - xaaInfo->CPUToScreenAlphaTextureFlags = XAA_RENDER_NO_TILE | - XAA_RENDER_NO_SRC_ALPHA; - xaaInfo->CPUToScreenAlphaTextureFormats = vmwareAlphaTextureFormats; + xaaInfo->CPUToScreenAlphaTextureFlags = + XAA_RENDER_NO_TILE | XAA_RENDER_NO_SRC_ALPHA; + xaaInfo->CPUToScreenAlphaTextureFormats = + vmwareAlphaTextureFormats; + xaaInfo->CPUToScreenAlphaTextureDstFormats = vmwareDstFormats; - xaaInfo->SetupForCPUToScreenTexture = + xaaInfo->SetupForCPUToScreenTexture2 = vmwareSetupForCPUToScreenTexture; - xaaInfo->SubsequentCPUToScreenTexture = + xaaInfo->SubsequentCPUToScreenTexture = vmwareSubsequentCPUToScreenTexture; xaaInfo->CPUToScreenTextureFlags = XAA_RENDER_NO_TILE; xaaInfo->CPUToScreenTextureFormats = vmwareTextureFormats; + xaaInfo->CPUToScreenTextureDstFormats = vmwareDstFormats; } else { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Allocation of offscreen " "scratch area for alpha blending failed\n"); } } #endif if (box.y2 > box.y1) { @@ -466,28 +489,27 @@ alphaPtr += alphaPitch; } } Bool vmwareSetupForCPUToScreenAlphaTexture(ScrnInfoPtr pScrn, int op, CARD16 red, CARD16 green, CARD16 blue, CARD16 alpha, - int alphaType, CARD8 *alphaPtr, - int alphaPitch, - int width, int height, - int flags) + CARD32 maskFormat, CARD32 dstFormat, + CARD8 *alphaPtr, int alphaPitch, + int width, int height, int flags) { VMWAREPtr pVMWARE = VMWAREPTR(pScrn); SVGASurface* surf; VmwareLog(("Setup alpha texture (op = %d, r = %d, g = %d, b = %d," - " a = %d, alphaType = %d, alphaPitch = %d, w = %d, h = %d," - " flags = %d)\n", op, red, green, blue, alpha, alphaType, - alphaPitch, width, height, flags)); + " a = %d, maskFormat = %d, dstFormat = %d, alphaPitch = %d," + " w = %d, h = %d, flags = %d)\n", op, red, green, blue, alpha, + maskFormat, dstFormat, alphaPitch, width, height, flags)); if (op > PictOpSaturate) { return FALSE; } surf = vmwareHeap_AllocSurface(pVMWARE->heap, width, height, width * 4, 32); if (!surf) { @@ -503,27 +525,26 @@ pVMWARE->curPict = surf; pVMWARE->op = op; return TRUE; } Bool vmwareSetupForCPUToScreenTexture(ScrnInfoPtr pScrn, int op, - int texType, CARD8 *texPtr, - int texPitch, - int width, int height, - int flags) + CARD32 srcFormat, CARD32 dstFormat, + CARD8 *texPtr, int texPitch, + int width, int height, int flags) { VMWAREPtr pVMWARE = VMWAREPTR(pScrn); SVGASurface* surf; - VmwareLog(("Setup texture (op = %d, texType = %d, texPitch = %d," - " w = %d, h = %d, flags = %d)\n", op, texType, texPitch, - width, height, flags)); + VmwareLog(("Setup texture (op = %d, srcFormat = %d, dstFormat = %d," + " texPitch = %d, w = %d, h = %d, flags = %d)\n", op, srcFormat, + dstFormat, texPitch, width, height, flags)); if (op > PictOpSaturate) { return FALSE; } surf = vmwareHeap_AllocSurface(pVMWARE->heap, width, height, texPitch, 32); if (!surf) {