⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 atimach64exa.c

📁 x.org上有关ati系列显卡最新驱动
💻 C
📖 第 1 页 / 共 2 页
字号:
    int       x1,     int       y1,     int       x2,     int       y2){    ScrnInfoPtr pScreenInfo = xf86Screens[pPixmap->drawable.pScreen->myNum];    ATIPtr pATI = ATIPTR(pScreenInfo);    int x = x1;    int y = y1;    int w = x2-x1;    int h = y2-y1;    ATIDRISync(pScreenInfo);    if (pATI->XModifier != 1)    {        x *= pATI->XModifier;        w *= pATI->XModifier;        outf(DST_CNTL, SetBits((x / 4) % 6, DST_24_ROT) |            (DST_X_DIR | DST_Y_DIR | DST_24_ROT_EN));    }    /* Disable clipping if it gets in the way */    ATIMach64ValidateClip(pATI, x, x + w - 1, y, y + h - 1);    ATIMach64WaitForFIFO(pATI, 2);    outf(DST_Y_X, SetWord(x, 1) | SetWord(y, 0));    outf(DST_HEIGHT_WIDTH, SetWord(w, 1) | SetWord(h, 0));}static void Mach64DoneSolid(PixmapPtr pPixmap) { }/* * Memcpy-based UTS. */static BoolMach64UploadToScreen(PixmapPtr pDst, int x, int y, int w, int h,    char *src, int src_pitch){    char  *dst        = pDst->devPrivate.ptr;    int    dst_pitch  = exaGetPixmapPitch(pDst);    int bpp    = pDst->drawable.bitsPerPixel;    int cpp    = (bpp + 7) / 8;    int wBytes = w * cpp;    exaWaitSync(pDst->drawable.pScreen);    dst += (x * cpp) + (y * dst_pitch);    while (h--) {        memcpy(dst, src, wBytes);        src += src_pitch;        dst += dst_pitch;    }    return TRUE;}/* * Memcpy-based DFS. */static BoolMach64DownloadFromScreen(PixmapPtr pSrc, int x, int y, int w, int h,    char *dst, int dst_pitch){    char  *src        = pSrc->devPrivate.ptr;    int    src_pitch  = exaGetPixmapPitch(pSrc);    int bpp    = pSrc->drawable.bitsPerPixel;    int cpp    = (bpp + 7) / 8;    int wBytes = w * cpp;    exaWaitSync(pSrc->drawable.pScreen);    src += (x * cpp) + (y * src_pitch);    while (h--) {        memcpy(dst, src, wBytes);        src += src_pitch;        dst += dst_pitch;    }    return TRUE;}#include "atimach64render.c"/* Compute log base 2 of val. */static __inline__ int Mach64Log2(int val){    int bits;    for (bits = 0; val != 0; val >>= 1, ++bits)        ;    return bits - 1;}/* * Memory layour for EXA with DRI (no local_textures): * | front  | back   | depth  | textures | pixmaps, xv | c | * * 1024x768@16bpp with 8 MB: * | 1.5 MB | 1.5 MB | 1.5 MB | 0        | ~3.5 MB     | c | * * 1024x768@32bpp with 8 MB: * | 3.0 MB | 3.0 MB | 1.5 MB | 0        | ~0.5 MB     | c | * * "c" is the hw cursor which occupies 1KB */static voidMach64SetupMemEXA(ScreenPtr pScreen){    ScrnInfoPtr pScreenInfo = xf86Screens[pScreen->myNum];    ATIPtr pATI = ATIPTR(pScreenInfo);    int cpp = (pScreenInfo->bitsPerPixel + 7) / 8;    /* front and back buffer */    int bufferSize = pScreenInfo->virtualY * pScreenInfo->displayWidth * cpp;    /* always 16-bit z-buffer */    int depthSize  = pScreenInfo->virtualY * pScreenInfo->displayWidth * 2;    ExaDriverPtr pExa = pATI->pExa;    pExa->memoryBase = pATI->pMemory;    pExa->memorySize = pScreenInfo->videoRam * 1024;    pExa->offScreenBase = bufferSize;#ifdef XF86DRI_DEVEL    if (pATI->directRenderingEnabled)    {	ATIDRIServerInfoPtr pATIDRIServer = pATI->pDRIServerInfo;	Bool is_pci = pATIDRIServer->IsPCI;	int textureSize = 0;	int pixmapCache = 0;	int next = 0;	/* front buffer */	pATIDRIServer->frontOffset = 0;	pATIDRIServer->frontPitch = pScreenInfo->displayWidth;	next += bufferSize;	/* back buffer */	pATIDRIServer->backOffset = next;	pATIDRIServer->backPitch = pScreenInfo->displayWidth;	next += bufferSize;	/* depth buffer */	pATIDRIServer->depthOffset = next;	pATIDRIServer->depthPitch = pScreenInfo->displayWidth;	next += depthSize;	/* ATIScreenInit does check for the this condition. */	if (next > pExa->memorySize)	{	    xf86DrvMsg(pScreen->myNum, X_WARNING,		"DRI static buffer allocation failed, disabling DRI --"		"need at least %d kB video memory\n", next / 1024 );	    ATIDRICloseScreen(pScreen);	    pATI->directRenderingEnabled = FALSE;	}	/* local textures */	/* Reserve approx. half of offscreen memory for local textures */	textureSize = (pExa->memorySize - next) / 2;	/* In case DRI requires more offscreen memory than available,	 * should not happen as ATIScreenInit would have not enabled DRI */	if (textureSize < 0)	    textureSize = 0;	/* Try for enough pixmap cache for a full viewport */	pixmapCache = (pExa->memorySize - next) - textureSize;	if (pixmapCache < bufferSize)	    textureSize = 0;	/* Don't allocate a local texture heap for AGP unless requested */	if ( !is_pci && !pATI->OptionLocalTextures )	    textureSize = 0;	if (textureSize > 0)	{	    int l = Mach64Log2(textureSize / MACH64_NR_TEX_REGIONS);	    if (l < MACH64_LOG_TEX_GRANULARITY)		l = MACH64_LOG_TEX_GRANULARITY;	    pATIDRIServer->logTextureGranularity = l;	    /* Round the texture size down to the nearest whole number of	     * texture regions.	     */	    textureSize = (textureSize >> l) << l;	}	/* Set a minimum usable local texture heap size.  This will fit	 * two 256x256 textures.  We check this after any rounding of	 * the texture area.	 */	if (textureSize < 256*256 * cpp * 2)	    textureSize = 0;	/* Disable DRI for PCI if cannot allocate a local texture heap */	if ( is_pci && textureSize == 0 )	{	    xf86DrvMsg(pScreen->myNum, X_WARNING,		"Not enough memory for local textures, disabling DRI\n");	    ATIDRICloseScreen(pScreen);	    pATI->directRenderingEnabled = FALSE;	}	pATIDRIServer->textureOffset = next;	pATIDRIServer->textureSize = textureSize;	next += textureSize;	if (pATI->directRenderingEnabled)	    pExa->offScreenBase = next;    }#endif /* XF86DRI_DEVEL */    xf86DrvMsg(pScreen->myNum, X_INFO,        "EXA memory management initialized\n"        "\t base     :  %10p\n"        "\t offscreen: +%10lx\n"        "\t size     : +%10lx\n"        "\t cursor   :  %10p\n",        pExa->memoryBase,        pExa->offScreenBase,        pExa->memorySize,        pATI->pCursorImage);    if (TRUE || xf86GetVerbosity() > 1)    {        int offscreen = pExa->memorySize - pExa->offScreenBase;        int viewport = bufferSize;        int dvdframe = 720*480*cpp; /* enough for single-buffered DVD */        xf86DrvMsg(pScreen->myNum, X_INFO,            "Will use %d kB of offscreen memory for EXA\n"            "\t\t or %5.2f viewports (composite)\n"            "\t\t or %5.2f dvdframes (xvideo)\n",            offscreen / 1024,            1.0 * offscreen / viewport,            1.0 * offscreen / dvdframe);    }#ifdef XF86DRI_DEVEL    if (pATI->directRenderingEnabled)    {        ATIDRIServerInfoPtr pATIDRIServer = pATI->pDRIServerInfo;        xf86DrvMsg(pScreen->myNum, X_INFO,                   "Will use back  buffer at offset 0x%x\n",                   pATIDRIServer->backOffset);        xf86DrvMsg(pScreen->myNum, X_INFO,                   "Will use depth buffer at offset 0x%x\n",                   pATIDRIServer->depthOffset);        if (pATIDRIServer->textureSize > 0)        {            xf86DrvMsg(pScreen->myNum, X_INFO,                   "Will use %d kB for local textures at offset 0x%x\n",                   pATIDRIServer->textureSize/1024,                   pATIDRIServer->textureOffset);        }    }#endif /* XF86DRI_DEVEL */    pExa->pixmapOffsetAlign = 64;    pExa->pixmapPitchAlign = 64;    pExa->flags = EXA_OFFSCREEN_PIXMAPS;    pExa->maxX = ATIMach64MaxX;    pExa->maxY = ATIMach64MaxY;}Bool ATIMach64ExaInit(ScreenPtr pScreen){    ScrnInfoPtr pScreenInfo = xf86Screens[pScreen->myNum];    ATIPtr pATI = ATIPTR(pScreenInfo);    ExaDriverPtr pExa;    /* FIXME: which chips support EXA ? */    if (pATI->Chip < ATI_CHIP_264CT)    {        xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR,            "EXA is not supported for ATI chips earlier than "            "the ATI Mach64.\n");        return FALSE;    }    pExa = exaDriverAlloc();    if (!pExa)        return FALSE;    pATI->pExa = pExa;    pExa->exa_major = 2;    pExa->exa_minor = 0;    Mach64SetupMemEXA(pScreen);    pExa->WaitMarker = Mach64WaitMarker;    pExa->PrepareSolid = Mach64PrepareSolid;    pExa->Solid = Mach64Solid;    pExa->DoneSolid = Mach64DoneSolid;    pExa->PrepareCopy = Mach64PrepareCopy;    pExa->Copy = Mach64Copy;    pExa->DoneCopy = Mach64DoneCopy;    /* EXA hits more optimized paths when it does not have to fallback because     * of missing UTS/DFS, hook memcpy-based UTS/DFS.     */    pExa->UploadToScreen = Mach64UploadToScreen;    pExa->DownloadFromScreen = Mach64DownloadFromScreen;    if (pATI->RenderAccelEnabled) {	if (pATI->Chip >= ATI_CHIP_264GTPRO) {	    /* 3D Rage Pro does not support NPOT textures. */	    pExa->flags |= EXA_OFFSCREEN_ALIGN_POT;	    pExa->CheckComposite = Mach64CheckComposite;	    pExa->PrepareComposite = Mach64PrepareComposite;	    pExa->Composite = Mach64Composite;	    pExa->DoneComposite = Mach64DoneComposite;	} else {	    xf86DrvMsg(pScreen->myNum, X_INFO,		       "Render acceleration is not supported for ATI chips "		       "earlier than the ATI 3D Rage Pro.\n");	    pATI->RenderAccelEnabled = FALSE;	}    }    xf86DrvMsg(pScreen->myNum, X_INFO, "Render acceleration %s\n",	       pATI->RenderAccelEnabled ? "enabled" : "disabled");    if (!exaDriverInit(pScreen, pATI->pExa)) {	xfree(pATI->pExa);	pATI->pExa = NULL;	return FALSE;    }    return TRUE;}#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -