diff options
author | Philip Langdale <philipl@fido2.homeip.net> | 2007-02-08 13:42:31 -0800 |
---|---|---|
committer | Philip Langdale <philipl@fido2.homeip.net> | 2007-02-08 13:42:31 -0800 |
commit | af8c0596a224ba8436d55c5dd6063fff688c7ad1 (patch) | |
tree | 06f205381214ce8bf4f893b48f25f213838fc15b | |
parent | 3dc1ebc7c2c76f575b5150f1890ec13f8bd3e8a1 (diff) |
Remove XAA 'acceleration'.
We have a lot of stale code to 'accelerate' certain operations
through XAA. However, in practice, this acceleration is
completely unhelpful because whenever we encounter an
unaccelerated action, we have to sync and flush the fifo
which kills any performance gain.
As such, the virtual hardware doesn't even advertise these
acceleration capabilities anymore, so the code is completely
unusued.
In addition, XAA is on the way out, so there's no point
leaving in dead code which will have to go in the fairly
near future.
The one operation we can meaningfully accelerate is a
front-only fill and when we get around to implementing
that, we'll use EXA instead.
-rw-r--r-- | src/Makefile.am | 3 | ||||
-rw-r--r-- | src/offscreen_manager.c | 136 | ||||
-rw-r--r-- | src/offscreen_manager.h | 25 | ||||
-rw-r--r-- | src/vmware.c | 42 | ||||
-rw-r--r-- | src/vmware.h | 35 | ||||
-rw-r--r-- | src/vmwarexaa.c | 589 |
6 files changed, 1 insertions, 829 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index b7857b9..97ab86e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -33,8 +33,6 @@ vmware_drv_la_SOURCES = \ bits2pixels.h \ guest_os.h \ includeCheck.h \ - offscreen_manager.c \ - offscreen_manager.h \ svga_limits.h \ svga_reg.h \ svga_struct.h \ @@ -43,7 +41,6 @@ vmware_drv_la_SOURCES = \ vmware.c \ vmwarecurs.c \ vmware.h \ - vmwarexaa.c \ vmwarectrl.c \ vmwarectrl.h \ vmwarectrlproto.h \ diff --git a/src/offscreen_manager.c b/src/offscreen_manager.c deleted file mode 100644 index 10e2e59..0000000 --- a/src/offscreen_manager.c +++ /dev/null @@ -1,136 +0,0 @@ -/* ********************************************************** - * Copyright (C) 1998-2002 VMware, Inc. - * All Rights Reserved - * **********************************************************/ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/vmware/offscreen_manager.c,v 1.1 2002/12/10 04:17:19 dawes Exp $ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "vmware.h" - -struct _Heap { - CARD8* ptr; - CARD32 size; - CARD32 maxSlots; - CARD32 startOffset; - SVGASurface* frontBuffer; - SVGASurface* slotsStart; - Bool clear; -}; - -static SVGASurface* FillInSurface(Heap* heap, SVGASurface* surface, - CARD32 width, CARD32 height, - CARD32 bpp, CARD32 pitch, CARD32 size, - CARD32 sizeUsed); - -Heap* -vmwareHeap_Create(CARD8* ptr, CARD32 size, CARD32 maxSlots, CARD32 startOffset, - CARD32 sWidth, CARD32 sHeight, CARD32 sBPP, CARD32 sPitch, - CARD32 sFbOffset) -{ - Heap* newHeap = malloc(sizeof (Heap)); - - newHeap->ptr = ptr; - newHeap->size = size - sizeof(SVGASurface); /* leave room for frontbuffer */ - newHeap->maxSlots = maxSlots; - newHeap->startOffset = startOffset; - - newHeap->frontBuffer = FillInSurface(newHeap, - (SVGASurface*)(ptr + newHeap->size), - sWidth, sHeight, sBPP, sPitch, - sHeight * sPitch, 0); - newHeap->frontBuffer->dataOffset = sFbOffset; - newHeap->frontBuffer->numQueued = newHeap->frontBuffer->numDequeued = 0; - - newHeap->slotsStart = (SVGASurface*)(newHeap->ptr + newHeap->size) - - newHeap->maxSlots; - newHeap->clear = FALSE; - vmwareHeap_Clear(newHeap); - - return newHeap; -} - -void -vmwareHeap_Destroy(Heap* heap) -{ - free(heap); -} - -void -vmwareHeap_Clear(Heap* heap) -{ - if (!heap->clear) { - memset(heap->slotsStart, 0, heap->maxSlots * sizeof (SVGASurface)); - heap->clear = TRUE; - } -} - -static SVGASurface* -FillInSurface(Heap* heap, SVGASurface* surface, CARD32 width, CARD32 height, - CARD32 bpp, CARD32 pitch, CARD32 size, CARD32 offset) -{ - surface->size = sizeof (SVGASurface); - surface->version = SVGA_SURFACE_VERSION_1; - surface->bpp = bpp; - surface->width = width; - surface->height = height; - surface->pitch = pitch; - if (surface->userData == 0) { - /* - * We allocate exactly what we need the first time we use a slot, so - * all reuses of this slot will be equal or smaller. - */ - surface->userData = size; - } - surface->dataOffset = offset + heap->startOffset; - - return surface; -} - -SVGASurface* -vmwareHeap_GetFrontBuffer(Heap* heap) -{ - return heap->frontBuffer; -} - -SVGASurface* -vmwareHeap_AllocSurface(Heap* heap, CARD32 width, CARD32 height, - CARD32 pitch, CARD32 bpp) -{ - CARD32 size = pitch * height; - CARD32 sizeUsed = 0; - SVGASurface* surface = heap->slotsStart; - int i; - - /* - * NOTE: we use SVGASurface::userData to store the largest this slot's - * size has ever been, since we don't ever compact anything. - */ - - /* find a free slot that's big enough */ - for (i = 0; i < heap->maxSlots; i++) { - if (surface[i].userData == 0) { /* this surface has never been used */ - if ((CARD8*)heap->slotsStart - heap->ptr - sizeUsed < size) { - /* no room left for data*/ - return NULL; - } - - heap->clear = FALSE; - return FillInSurface(heap, surface + i, width, height, bpp, - pitch, size, sizeUsed); - } - - if (surface[i].numQueued == surface[i].numDequeued && - surface[i].userData >= size) { /* free and big enough, sweet! */ - heap->clear = FALSE; - return FillInSurface(heap, surface + i, width, height, bpp, - pitch, size, sizeUsed); - } - - sizeUsed += surface[i].userData; - } - - return NULL; -} diff --git a/src/offscreen_manager.h b/src/offscreen_manager.h deleted file mode 100644 index e948da9..0000000 --- a/src/offscreen_manager.h +++ /dev/null @@ -1,25 +0,0 @@ -/* ********************************************************** - * Copyright (C) 1998-2002 VMware, Inc. - * All Rights Reserved - * **********************************************************/ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/vmware/offscreen_manager.h,v 1.2 2002/12/11 17:07:58 dawes Exp $ */ - -#ifndef OFFSCREEN_MANAGER_H -#define OFFSCREEN_MANAGER_H - -struct _Heap; -typedef struct _Heap Heap; - -extern Heap* vmwareHeap_Create(CARD8* ptr, CARD32 size, CARD32 maxSlots, - CARD32 startOffset, CARD32 sWidth, CARD32 sHeight, - CARD32 sBPP, CARD32 sPitch, CARD32 sFbOffset); -extern void vmwareHeap_Destroy(Heap* heap); - -extern void vmwareHeap_Clear(Heap* heap); - -extern SVGASurface* vmwareHeap_GetFrontBuffer(Heap* heap); - -extern SVGASurface* vmwareHeap_AllocSurface(Heap* heap, CARD32 width, CARD32 height, - CARD32 pitch, CARD32 bpp); - -#endif diff --git a/src/vmware.c b/src/vmware.c index 9075326..576530c 100644 --- a/src/vmware.c +++ b/src/vmware.c @@ -164,14 +164,12 @@ static XF86ModuleVersionInfo vmwareVersRec = { typedef enum { OPTION_HW_CURSOR, - OPTION_NOACCEL, OPTION_XINERAMA, OPTION_STATIC_XINERAMA } VMWAREOpts; static const OptionInfoRec VMWAREOptions[] = { { OPTION_HW_CURSOR, "HWcursor", OPTV_BOOLEAN, {0}, FALSE }, - { OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_XINERAMA, "Xinerama", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_STATIC_XINERAMA, "StaticXinerama", OPTV_STRING, {0}, FALSE }, { -1, NULL, OPTV_NONE, {0}, FALSE } @@ -846,12 +844,6 @@ VMWAREPreInit(ScrnInfoPtr pScrn, int flags) } xf86DrvMsg(pScrn->scrnIndex, from, "Using %s cursor\n", pVMWARE->hwCursor ? "HW" : "SW"); - if (xf86IsOptionSet(options, OPTION_NOACCEL)) { - pVMWARE->noAccel = TRUE; - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Acceleration disabled\n"); - } else { - pVMWARE->noAccel = FALSE; - } pScrn->videoRam = pVMWARE->videoRam / 1024; pScrn->memPhysBase = pVMWARE->memPhysBase; @@ -943,14 +935,6 @@ VMWAREPreInit(ScrnInfoPtr pScrn, int flags) xf86LoaderReqSymLists(ramdacSymbols, NULL); } - if (!pVMWARE->noAccel) { - if (!xf86LoadSubModule(pScrn, "xaa")) { - VMWAREFreeRec(pScrn); - return FALSE; - } - xf86LoaderReqSymLists(vmwareXaaSymbols, NULL); - } - /* Initialise VMWARE_CTRL extension. */ VMwareCtrl_ExtInit(pScrn); @@ -1145,15 +1129,6 @@ VMWAREModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode, Bool rebuildPixmap) */ /* - * Let XAA know about the mode change. - */ - if (!pVMWARE->noAccel) { - if (!vmwareXAAModeInit(pScrn, mode)) { - return FALSE; - } - } - - /* * Update Xinerama info appropriately. */ if (pVMWARE->xinerama && !pVMWARE->xineramaStatic) { @@ -1242,10 +1217,6 @@ VMWARECloseScreen(int scrnIndex, ScreenPtr pScreen) vmwareCursorCloseScreen(pScreen); } - if (pVMWARE->xaaInfo) { - vmwareXAACloseScreen(pScreen); - } - VMWARERestore(pScrn); VMWAREUnmapMem(pScrn); @@ -1550,17 +1521,6 @@ VMWAREScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) } /* - * Initialize acceleration. - */ - if (!pVMWARE->noAccel) { - if (!vmwareXAAScreenInit(pScreen)) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "XAA initialization failed -- running unaccelerated!\n"); - pVMWARE->noAccel = TRUE; - } - } - - /* * If backing store is to be supported (as is usually the case), * initialise it. */ @@ -1756,7 +1716,7 @@ vmwareSetup(pointer module, pointer opts, int *errmaj, int *errmin) xf86AddDriver(&VMWARE, module, VMWARE_DRIVER_FUNC); LoaderRefSymLists(vgahwSymbols, fbSymbols, ramdacSymbols, - shadowfbSymbols, vmwareXaaSymbols, NULL); + shadowfbSymbols, NULL); return (pointer)1; } diff --git a/src/vmware.h b/src/vmware.h index 159e374..960ce13 100644 --- a/src/vmware.h +++ b/src/vmware.h @@ -25,7 +25,6 @@ #include "vgaHW.h" /* VGA hardware */ #include "fb.h" -#include "xaa.h" #include "xf86cmap.h" /* xf86HandleColormaps */ @@ -33,8 +32,6 @@ #include "svga_reg.h" #include "svga_struct.h" -#include "offscreen_manager.h" - /* Arbitrarily choose max cursor dimensions. The emulation doesn't care. */ #define MAX_CURS 32 @@ -124,23 +121,6 @@ typedef struct { ScreenRec ScrnFuncs; /* - * XAA info rec and misc storage - */ - XAAInfoRecPtr xaaInfo; - int xaaFGColor; - int xaaBGColor; - int xaaRop; - - unsigned char* xaaColorExpScanLine[1]; - unsigned int xaaColorExpSize; /* size of current scan line in DWords */ - - Heap* heap; - SVGASurface* frontBuffer; - - SVGASurface* curPict; - int op; - - /* * Xinerama state */ Bool xinerama; @@ -189,8 +169,6 @@ static __inline ScrnInfoPtr infoFromScreen(ScreenPtr s) { #define MOUSE_ID 1 -extern const char *vmwareXaaSymbols[]; - /*#define DEBUG_LOGGING*/ #ifdef DEBUG_LOGGING # define VmwareLog(args) ErrorF args @@ -255,19 +233,6 @@ void vmwareCursorHookWrappers( ); -/* vmwarexaa.c */ -Bool vmwareXAAScreenInit( - ScreenPtr pScreen - ); - -Bool vmwareXAAModeInit( - ScrnInfoPtr pScrn, DisplayModePtr mode - ); - -void vmwareXAACloseScreen( - ScreenPtr pScreen - ); - /* vmwarectrl.c */ void VMwareCtrl_ExtInit(ScrnInfoPtr pScrn); diff --git a/src/vmwarexaa.c b/src/vmwarexaa.c deleted file mode 100644 index b0882c5..0000000 --- a/src/vmwarexaa.c +++ /dev/null @@ -1,589 +0,0 @@ -/* ********************************************************** - * Copyright (C) 1998-2001 VMware, Inc. - * All Rights Reserved - * **********************************************************/ -#ifdef VMX86_DEVEL -char rcsId_vmwarexaa[] = - "Id: $"; -#endif -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/vmware/vmwarexaa.c,v 1.5 2003/02/04 01:39:53 dawes Exp $ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "vmware.h" - -#define OFFSCREEN_SCRATCH_SIZE 1*1024*1024 -/* We'll assume we average about 32x32 alpha surfaces (4096 bytes) or larger */ -#define OFFSCREEN_SCRATCH_MAX_SLOTS OFFSCREEN_SCRATCH_SIZE / 4096 - -const char *vmwareXaaSymbols[] = { - "XAACreateInfoRec", - "XAADestroyInfoRec", - "XAAInit", - NULL -}; - -static void vmwareXAASync(ScrnInfoPtr pScrn); - -static void vmwareSetupForSolidFill(ScrnInfoPtr pScrn, int color, int rop, - unsigned int planemask); -static void vmwareSubsequentSolidFillRect(ScrnInfoPtr pScrn, - int x, int y, int w, int h); - -static void vmwareSetupForScreenToScreenCopy(ScrnInfoPtr pScrn, - int xdir, int ydir, int rop, - unsigned int planemask, - int trans_color); -static void vmwareSubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, - int x1, int y1, - int x2, int y2, - int width, int height); - -static void vmwareSetupForScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, - int fg, int bg, - int rop, - unsigned int planemask); -static void vmwareSubsequentScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, - int x, int y, - 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, - int alphaPitch, - int width, int height, - int flags); - -static Bool vmwareSetupForCPUToScreenTexture(ScrnInfoPtr pScrn, int op, - int texType, 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}; - -#endif - -#define SCRATCH_SIZE_BYTES(pvmware) \ - (((OFFSCREEN_SCRATCH_SIZE + (pvmware)->fbPitch - 1) / \ - (pvmware)->fbPitch) * (pvmware)->fbPitch) - -static void vmwareXAACreateHeap(ScreenPtr pScreen, ScrnInfoPtr pScrn, - VMWAREPtr pVMWARE) { - int scratchSizeBytes = SCRATCH_SIZE_BYTES(pVMWARE); - CARD8* osPtr = pVMWARE->FbBase + pVMWARE->videoRam - scratchSizeBytes; - - pVMWARE->heap = vmwareHeap_Create(osPtr, - scratchSizeBytes, - OFFSCREEN_SCRATCH_MAX_SLOTS, - pVMWARE->videoRam - scratchSizeBytes, - pScrn->virtualX, - pScrn->virtualY, - pVMWARE->bitsPerPixel, - pVMWARE->fbPitch, - pVMWARE->fbOffset); - pVMWARE->frontBuffer = vmwareHeap_GetFrontBuffer(pVMWARE->heap); -} - -#define DESTROY_XAA_INFO(pVMWARE) \ - if (pVMWARE->xaaInfo) { XAADestroyInfoRec(pVMWARE->xaaInfo); \ - 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; - - if (pVMWARE->vmwareCapability & SVGA_CAP_RECT_FILL) { - xaaInfo->SetupForSolidFill = vmwareSetupForSolidFill; - xaaInfo->SubsequentSolidFillRect = vmwareSubsequentSolidFillRect; - - xaaInfo->SolidFillFlags = NO_PLANEMASK | - (pVMWARE->vmwareCapability & SVGA_CAP_RASTER_OP ? 0 : GXCOPY_ONLY); - } - - if (pVMWARE->vmwareCapability & SVGA_CAP_RECT_COPY) { - xaaInfo->SetupForScreenToScreenCopy = vmwareSetupForScreenToScreenCopy; - xaaInfo->SubsequentScreenToScreenCopy = - vmwareSubsequentScreenToScreenCopy; - - xaaInfo->ScreenToScreenCopyFlags = NO_TRANSPARENCY | NO_PLANEMASK | - (pVMWARE->vmwareCapability & SVGA_CAP_RASTER_OP ? 0 : GXCOPY_ONLY); - } - - /* - * We don't support SVGA_CAP_GLYPH without clipping, since we use clipping - * for normal glyphs. - */ - if (pVMWARE->vmwareCapability & SVGA_CAP_GLYPH_CLIPPING) { - xaaInfo->SetupForScanlineCPUToScreenColorExpandFill = - vmwareSetupForScanlineCPUToScreenColorExpandFill; - xaaInfo->SubsequentScanlineCPUToScreenColorExpandFill = - vmwareSubsequentScanlineCPUToScreenColorExpandFill; - xaaInfo->SubsequentColorExpandScanline = - vmwareSubsequentColorExpandScanline; - - xaaInfo->NumScanlineColorExpandBuffers = 1; - xaaInfo->ScanlineColorExpandBuffers = pVMWARE->xaaColorExpScanLine; - - xaaInfo->ScanlineCPUToScreenColorExpandFillFlags = GXCOPY_ONLY | - NO_PLANEMASK | BIT_ORDER_IN_BYTE_MSBFIRST | LEFT_EDGE_CLIPPING; - } - - if (pVMWARE->vmwareCapability & SVGA_CAP_OFFSCREEN_1) { - int scratchSizeBytes = SCRATCH_SIZE_BYTES(pVMWARE); - BoxRec box; - RegionRec region; - - 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) { - 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 = - vmwareSetupForCPUToScreenAlphaTexture; - xaaInfo->SubsequentCPUToScreenAlphaTexture = - vmwareSubsequentCPUToScreenTexture; - xaaInfo->CPUToScreenAlphaTextureFlags = XAA_RENDER_NO_TILE | - XAA_RENDER_NO_SRC_ALPHA; - xaaInfo->CPUToScreenAlphaTextureFormats = vmwareAlphaTextureFormats; - - xaaInfo->SetupForCPUToScreenTexture = - vmwareSetupForCPUToScreenTexture; - xaaInfo->SubsequentCPUToScreenTexture = - vmwareSubsequentCPUToScreenTexture; - xaaInfo->CPUToScreenTextureFlags = XAA_RENDER_NO_TILE; - xaaInfo->CPUToScreenTextureFormats = vmwareTextureFormats; - } else { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Allocation of offscreen " - "scratch area for alpha blending failed\n"); - } - } -#endif - - if (box.y2 > box.y1) { - REGION_INIT(pScreen, ®ion, &box, 1); - - if (REGION_NOTEMPTY(pScreen, ®ion) && - xf86InitFBManagerRegion(pScreen, ®ion)) { - VmwareLog(("Offscreen memory initialized: (%d, %d) - (%d, %d)\n", - box.x1, box.y1, box.x2, box.y2)); - - xaaInfo->Flags = - LINEAR_FRAMEBUFFER | PIXMAP_CACHE | OFFSCREEN_PIXMAPS; - } else { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Offscreen memory manager " - "initialization failed.\n"); - } - - REGION_UNINIT(pScreen, ®ion); - } - } - - if (!XAAInit(pScreen, xaaInfo)) { - DESTROY_XAA_INFO(pVMWARE); - return FALSE; - } - -#ifdef RENDER - if (pVMWARE->heap) { - pVMWARE->EnableDisableFBAccess = pScrn->EnableDisableFBAccess; - pScrn->EnableDisableFBAccess = vmwareXAAEnableDisableFBAccess; - } -#endif - - return TRUE; -} - -Bool -vmwareXAAModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) -{ - VMWAREPtr pVMWARE = VMWAREPTR(pScrn); - - /* - * Alloc a sufficiently large buffer for XAA to render scanlines - * for a color expand into. - */ - if (pVMWARE->vmwareCapability & SVGA_CAP_GLYPH) { - /* - * This formula came straight from the XAA.HOWTO doc. The +62 is - * there because we potentially have 31 extra bits off to the left, - * since we claim LEFT_EDGE_CLIPPING support. - */ - int scanLineSize = ((pScrn->virtualX + 62)/32) * 4; - if (pVMWARE->xaaColorExpScanLine[0]) { - xfree(pVMWARE->xaaColorExpScanLine[0]); - } - pVMWARE->xaaColorExpScanLine[0] = xalloc(scanLineSize); - return pVMWARE->xaaColorExpScanLine[0] != NULL; - } - - return TRUE; -} - -void -vmwareXAACloseScreen(ScreenPtr pScreen) -{ - VMWAREPtr pVMWARE = VMWAREPTR(xf86Screens[pScreen->myNum]); - - if (pVMWARE->xaaColorExpScanLine[0]) { - xfree(pVMWARE->xaaColorExpScanLine[0]); - pVMWARE->xaaColorExpScanLine[0] = NULL; - } - - DESTROY_XAA_INFO(pVMWARE); - -#ifdef RENDER - if (pVMWARE->heap) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - pScrn->EnableDisableFBAccess = pVMWARE->EnableDisableFBAccess; - vmwareHeap_Destroy(pVMWARE->heap); - pVMWARE->heap = NULL; - } -#endif -} - -static void -vmwareXAASync(ScrnInfoPtr pScrn) -{ - VMWAREPtr pVMWARE = VMWAREPTR(pScrn); - - VmwareLog(("Sync\n")); - - vmwareWaitForFB(pVMWARE); - -#ifdef RENDER - if (pVMWARE->heap) { - vmwareHeap_Clear(pVMWARE->heap); - } -#endif -} - -static void -vmwareSetupForSolidFill(ScrnInfoPtr pScrn, - int color, int rop, unsigned int planemask) -{ - VMWAREPtr pVMWARE = VMWAREPTR(pScrn); - pVMWARE->xaaFGColor = color; - pVMWARE->xaaRop = rop; - - VmwareLog(("Setup Solid Fill (color = %d, rop = %d)\n", color, rop)); -} - -static void -vmwareSubsequentSolidFillRect(ScrnInfoPtr pScrn, int x, int y, int w, int h) -{ - VMWAREPtr pVMWARE = VMWAREPTR(pScrn); - - VmwareLog((" Do Solid Fill (x = %d, y = %d, w = %d, h = %d)\n", x, y, w, h)); - - if (pVMWARE->xaaRop != GXcopy) { - /* - * We'll never get here if SVGA_CAP_RASTER_OP isn't set, since - * we tell XAA we are GXCOPY_ONLY. - */ - vmwareWriteWordToFIFO(pVMWARE, SVGA_CMD_RECT_ROP_FILL); - vmwareWriteWordToFIFO(pVMWARE, pVMWARE->xaaFGColor); - vmwareWriteWordToFIFO(pVMWARE, x); - vmwareWriteWordToFIFO(pVMWARE, y); - vmwareWriteWordToFIFO(pVMWARE, w); - vmwareWriteWordToFIFO(pVMWARE, h); - vmwareWriteWordToFIFO(pVMWARE, pVMWARE->xaaRop); - } else { - vmwareWriteWordToFIFO(pVMWARE, SVGA_CMD_RECT_FILL); - vmwareWriteWordToFIFO(pVMWARE, pVMWARE->xaaFGColor); - vmwareWriteWordToFIFO(pVMWARE, x); - vmwareWriteWordToFIFO(pVMWARE, y); - vmwareWriteWordToFIFO(pVMWARE, w); - vmwareWriteWordToFIFO(pVMWARE, h); - } -} - -static void -vmwareSetupForScreenToScreenCopy(ScrnInfoPtr pScrn, - int xdir, int ydir, int rop, - unsigned int planemask, - int trans_color) -{ - /* - * We can safely ignore xdir and ydir since our "hardware" is smart - * enough to figure out the direction from the srcx/y, dstx/y, w and h. - */ - VMWAREPtr pVMWARE = VMWAREPTR(pScrn); - pVMWARE->xaaRop = rop; - - VmwareLog(("Setup Screen2Screen copy (rop = %d)\n", rop)); -} - -static void -vmwareSubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, - int x1, int y1, - int x2, int y2, - int width, int height) -{ - VMWAREPtr pVMWARE = VMWAREPTR(pScrn); - - VmwareLog((" Do Screen2Screen copy (x1 = %d, y1 = %d, x2 = %d, y2 = %d," - " w = %d, h = %d)\n", x1, y1, x2, y2, width, height)); - - if (pVMWARE->xaaRop != GXcopy) { - /* - * We'll never get here if SVGA_CAP_RASTER_OP isn't set, since - * we tell XAA we are GXCOPY_ONLY. - */ - vmwareWriteWordToFIFO(pVMWARE, SVGA_CMD_RECT_ROP_COPY); - vmwareWriteWordToFIFO(pVMWARE, x1); - vmwareWriteWordToFIFO(pVMWARE, y1); - vmwareWriteWordToFIFO(pVMWARE, x2); - vmwareWriteWordToFIFO(pVMWARE, y2); - vmwareWriteWordToFIFO(pVMWARE, width); - vmwareWriteWordToFIFO(pVMWARE, height); - vmwareWriteWordToFIFO(pVMWARE, pVMWARE->xaaRop); - } else { - vmwareWriteWordToFIFO(pVMWARE, SVGA_CMD_RECT_COPY); - vmwareWriteWordToFIFO(pVMWARE, x1); - vmwareWriteWordToFIFO(pVMWARE, y1); - vmwareWriteWordToFIFO(pVMWARE, x2); - vmwareWriteWordToFIFO(pVMWARE, y2); - vmwareWriteWordToFIFO(pVMWARE, width); - vmwareWriteWordToFIFO(pVMWARE, height); - } -} - -static void -vmwareSetupForScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, - int fg, int bg, - int rop, - unsigned int planemask) -{ - VMWAREPtr pVMWARE = VMWAREPTR(pScrn); - - pVMWARE->xaaFGColor = fg; - pVMWARE->xaaBGColor = bg; - VmwareLog(("Setup color expand (fg = %d, bg = %d, rop = %d)\n", - fg, bg, rop)); -} - -static void -vmwareSubsequentScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, - int x, int y, - int w, int h, - int skipleft ) -{ - /* - * XXX TODO: if xaaColorExpSize will fit entirely into the FIFO, - * temporarily switch to direct mode, and have XAA write bits - * directly into the fifo. See ATI driver for an example. - */ - VMWAREPtr pVMWARE = VMWAREPTR(pScrn); - - pVMWARE->xaaColorExpSize = SVGA_GLYPH_SCANLINE_SIZE_DWORDS(w); - - VmwareLog((" Do color expand (x = %d, y = %d, w = %d, h = %d," - " skipleft = %d, sizedw = %d)\n", - x, y, w, h, skipleft, pVMWARE->xaaColorExpSize)); - - vmwareWriteWordToFIFO(pVMWARE, SVGA_CMD_DRAW_GLYPH_CLIPPED); - vmwareWriteWordToFIFO(pVMWARE, x); - vmwareWriteWordToFIFO(pVMWARE, y); - vmwareWriteWordToFIFO(pVMWARE, pVMWARE->xaaColorExpSize * 32U); - vmwareWriteWordToFIFO(pVMWARE, h); - vmwareWriteWordToFIFO(pVMWARE, pVMWARE->xaaFGColor); - vmwareWriteWordToFIFO(pVMWARE, pVMWARE->xaaBGColor); - vmwareWriteWordToFIFO(pVMWARE, x + skipleft); - vmwareWriteWordToFIFO(pVMWARE, y); - vmwareWriteWordToFIFO(pVMWARE, w - skipleft); - vmwareWriteWordToFIFO(pVMWARE, h); -} - -static void -vmwareSubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno) -{ - VMWAREPtr pVMWARE = VMWAREPTR(pScrn); - CARD32* scanLine = (CARD32*)pVMWARE->xaaColorExpScanLine[0]; - unsigned int dwords = pVMWARE->xaaColorExpSize; - - while (dwords--) { - vmwareWriteWordToFIFO(pVMWARE, *scanLine++); - } -} - -#ifdef RENDER - -static void -RGBPlusAlphaChannelToPremultipliedRGBA( - CARD8 red, CARD8 green, CARD8 blue, - CARD8 *alphaPtr, /* in bytes */ - int alphaPitch, - CARD32 *dstPtr, - int dstPitch, /* in dwords */ - int width, int height) -{ - int x; - - while (height--) { - for (x = 0; x < width; x++) { - CARD8 alpha = alphaPtr[x]; - dstPtr[x] = (alpha << 24) | - ((red * alpha / 255) << 16) | - ((green * alpha / 255) << 8) | - (blue * alpha / 255); - } - dstPtr += dstPitch; - 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) -{ - 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)); - - if (op > PictOpSaturate) { - return FALSE; - } - - surf = vmwareHeap_AllocSurface(pVMWARE->heap, width, height, width * 4, 32); - - if (!surf) { - return FALSE; - } - - RGBPlusAlphaChannelToPremultipliedRGBA( - red >> 8, green >> 8, blue >> 8, - alphaPtr, alphaPitch, - (CARD32*)(pVMWARE->FbBase + surf->dataOffset), - width, width, height); - - 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) -{ - 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)); - - if (op > PictOpSaturate) { - return FALSE; - } - - surf = vmwareHeap_AllocSurface(pVMWARE->heap, width, height, texPitch, 32); - - if (!surf) { - return FALSE; - } - - memcpy(pVMWARE->FbBase + surf->dataOffset, texPtr, texPitch * height); - - pVMWARE->curPict = surf; - pVMWARE->op = op; - - return TRUE; -} - -void -vmwareSubsequentCPUToScreenTexture(ScrnInfoPtr pScrn, - int dstx, int dsty, - int srcx, int srcy, - int width, int height) -{ - VMWAREPtr pVMWARE = VMWAREPTR(pScrn); - - VmwareLog((" Do texture (dstx = %d, dsty = %d, srcx = %d, srcy = %d" - " w = %d, h = %d)\n", dstx, dsty, srcx, srcy, width, height)); - - pVMWARE->curPict->numQueued++; - pVMWARE->frontBuffer->numQueued++; - - vmwareWriteWordToFIFO(pVMWARE, SVGA_CMD_SURFACE_ALPHA_BLEND); - vmwareWriteWordToFIFO(pVMWARE, (CARD8*)pVMWARE->curPict - pVMWARE->FbBase); - vmwareWriteWordToFIFO(pVMWARE, (CARD8*)pVMWARE->frontBuffer - pVMWARE->FbBase); - vmwareWriteWordToFIFO(pVMWARE, srcx); - vmwareWriteWordToFIFO(pVMWARE, srcy); - vmwareWriteWordToFIFO(pVMWARE, dstx); - vmwareWriteWordToFIFO(pVMWARE, dsty); - vmwareWriteWordToFIFO(pVMWARE, width); - vmwareWriteWordToFIFO(pVMWARE, height); - vmwareWriteWordToFIFO(pVMWARE, pVMWARE->op); - vmwareWriteWordToFIFO(pVMWARE, 0); /* flags */ - vmwareWriteWordToFIFO(pVMWARE, 0); /* param1 */ - vmwareWriteWordToFIFO(pVMWARE, 0); /* param2 */ -} - -void -vmwareXAAEnableDisableFBAccess(int index, Bool enable) -{ - ScrnInfoPtr pScrn = xf86Screens[index]; - ScreenPtr pScreen = pScrn->pScreen; - VMWAREPtr pVMWARE = VMWAREPTR(pScrn); - - if (enable && pVMWARE->heap) { - vmwareHeap_Destroy(pVMWARE->heap); - vmwareXAACreateHeap(pScreen, pScrn, pVMWARE); - } - - (*pVMWARE->EnableDisableFBAccess)(index, enable); -} - -#endif |