diff --git a/src/aticonfig.c b/src/aticonfig.c index 2132910..b3df202 100644 --- a/src/aticonfig.c +++ b/src/aticonfig.c @@ -93,7 +93,8 @@ #endif /* TV_OUT */ ATI_OPTION_REFERENCE_CLOCK, ATI_OPTION_SHADOW_FB, ATI_OPTION_SWCURSOR, - ATI_OPTION_ACCELMETHOD + ATI_OPTION_ACCELMETHOD, + ATI_OPTION_RENDER_ACCEL } ATIPublicOptionType; @@ -123,6 +124,7 @@ #endif /* TV_OUT */ { ATI_OPTION_SHADOW_FB, "shadow_fb", OPTV_BOOLEAN, {0, }, FALSE }, { ATI_OPTION_SWCURSOR, "sw_cursor", OPTV_BOOLEAN, {0, }, FALSE }, { ATI_OPTION_ACCELMETHOD, "AccelMethod", OPTV_STRING, {0, }, FALSE }, + { ATI_OPTION_RENDER_ACCEL, "RenderAccel", OPTV_BOOLEAN, {0 }, FALSE }, { -1, NULL, OPTV_NONE, {0, }, FALSE } }; @@ -214,6 +216,7 @@ # define ProbeClocks PublicOption[AT # define ShadowFB PublicOption[ATI_OPTION_SHADOW_FB].value.bool # define SWCursor PublicOption[ATI_OPTION_SWCURSOR].value.bool # define AccelMethod PublicOption[ATI_OPTION_ACCELMETHOD].value.str +# define RenderAccel PublicOption[ATI_OPTION_RENDER_ACCEL].value.bool # define LCDSync PrivateOption[ATI_OPTION_LCDSYNC].value.bool # define ReferenceClock \ @@ -375,6 +378,12 @@ #endif /* USE_EXA */ xf86DrvMsg(pScreenInfo->scrnIndex, from, "Using %s acceleration architecture\n", pATI->useEXA ? "EXA" : "XAA"); + +#if defined(USE_EXA) + pATI->RenderAccelEnabled = FALSE; + if (pATI->useEXA && RenderAccel) + pATI->RenderAccelEnabled = TRUE; +#endif } xfree(PublicOption); diff --git a/src/atimach64.c b/src/atimach64.c index f8144a6..76dcda6 100644 --- a/src/atimach64.c +++ b/src/atimach64.c @@ -466,6 +466,15 @@ ( pATIHW->src_height2 = inm(SRC_HEIGHT2); pATIHW->src_cntl = inm(SRC_CNTL); + if (pATI->Chip >= ATI_CHIP_264GTPRO) + { + CARD32 offset = TEX_LEVEL(inm(TEX_SIZE_PITCH)); + + /* Save 3D control & texture registers */ + pATIHW->tex_offset = inm(TEX_0_OFF + offset); + pATIHW->scale_3d_cntl = inm(SCALE_3D_CNTL); + } + /* Save host data register */ pATIHW->host_cntl = inm(HOST_CNTL); @@ -496,6 +505,13 @@ ( /* Save context */ pATIHW->context_mask = inm(CONTEXT_MASK); + + if (pATI->Chip >= ATI_CHIP_264GTPRO) + { + /* Save texture setup registers */ + pATIHW->tex_size_pitch = inm(TEX_SIZE_PITCH); + pATIHW->tex_cntl = inm(TEX_CNTL); + } if (pATI->Block1Base) { @@ -822,6 +838,14 @@ #endif /* AVOID_CPIO */ outf(DST_BRES_DEC, pATIHW->dst_bres_dec); outf(DST_CNTL, pATIHW->dst_cntl); + if (pATI->Chip >= ATI_CHIP_264GTPRO) + { + /* Load ROP unit registers */ + ATIMach64WaitForFIFO(pATI, 2); + outf(Z_CNTL, 0); + outf(ALPHA_TST_CNTL, 0); + } + /* Load source registers */ ATIMach64WaitForFIFO(pATI, 6); outf(SRC_OFF_PITCH, pATIHW->src_off_pitch); @@ -833,6 +857,16 @@ #endif /* AVOID_CPIO */ outf(SRC_HEIGHT2_WIDTH2, SetWord(pATIHW->src_width2, 1) | SetWord(pATIHW->src_height2, 0)); outf(SRC_CNTL, pATIHW->src_cntl); + + if (pATI->Chip >= ATI_CHIP_264GTPRO) + { + CARD32 offset = TEX_LEVEL(pATIHW->tex_size_pitch); + + /* Load 3D control & texture registers */ + ATIMach64WaitForFIFO(pATI, 2); + outf(TEX_0_OFF + offset, pATIHW->tex_offset); + outf(SCALE_3D_CNTL, pATIHW->scale_3d_cntl); + } /* Load host data register */ ATIMach64WaitForFIFO(pATI, 1); @@ -880,6 +914,14 @@ #endif /* AVOID_CPIO */ /* Load context mask */ ATIMach64WaitForFIFO(pATI, 1); outf(CONTEXT_MASK, pATIHW->context_mask); + + if (pATI->Chip >= ATI_CHIP_264GTPRO) + { + /* Load texture setup registers */ + ATIMach64WaitForFIFO(pATI, 2); + outf(TEX_SIZE_PITCH, pATIHW->tex_size_pitch); + outf(TEX_CNTL, pATIHW->tex_cntl); + } if (pATI->Block1Base) { @@ -951,6 +993,11 @@ #endif /* AVOID_CPIO */ CacheRegister(SRC_CNTL); + if (pATI->Chip >= ATI_CHIP_264GTPRO) + { + CacheRegister(SCALE_3D_CNTL); + } + CacheRegister(HOST_CNTL); CacheRegister(PAT_REG0); @@ -962,12 +1009,20 @@ #endif /* AVOID_CPIO */ CacheRegister(DP_BKGD_CLR); CacheRegister(DP_FRGD_CLR); +#if 0 CacheRegister(DP_WRITE_MASK); +#endif + CacheRegister(DP_PIX_WIDTH); CacheRegister(DP_MIX); CacheRegister(CLR_CMP_CLR); CacheRegister(CLR_CMP_MSK); CacheRegister(CLR_CMP_CNTL); + + if (pATI->Chip >= ATI_CHIP_264GTPRO) + { + CacheRegister(TEX_SIZE_PITCH); + } if (pATI->Block1Base) { diff --git a/src/atimach64accel.c b/src/atimach64accel.c index bc4ff4c..4ecf3f6 100644 --- a/src/atimach64accel.c +++ b/src/atimach64accel.c @@ -137,6 +137,11 @@ TestRegisterCachingDP(ScrnInfoPtr pScree TestRegisterCaching(SRC_CNTL); + if (pATI->Chip >= ATI_CHIP_264GTPRO) + { + TestRegisterCaching(SCALE_3D_CNTL); + } + TestRegisterCaching(HOST_CNTL); TestRegisterCaching(PAT_REG0); @@ -163,13 +168,20 @@ TestRegisterCachingDP(ScrnInfoPtr pScree TestRegisterCaching(DP_BKGD_CLR); TestRegisterCaching(DP_FRGD_CLR); +#if 0 TestRegisterCaching(DP_WRITE_MASK); +#endif TestRegisterCaching(DP_PIX_WIDTH); TestRegisterCaching(DP_MIX); TestRegisterCaching(CLR_CMP_CLR); TestRegisterCaching(CLR_CMP_MSK); TestRegisterCaching(CLR_CMP_CNTL); + + if (pATI->Chip >= ATI_CHIP_264GTPRO) + { + TestRegisterCaching(TEX_SIZE_PITCH); + } } static __inline__ void @@ -246,20 +258,25 @@ #ifdef XF86DRI_DEVEL if ( pATI->directRenderingEnabled && pATI->NeedDRISync ) { ATIHWPtr pATIHW = &pATI->NewHW; + CARD32 offset; if (pATI->OptionMMIOCache) { /* "Invalidate" the MMIO cache so the cache slots get updated */ UncacheRegister(SRC_CNTL); + UncacheRegister(SCALE_3D_CNTL); UncacheRegister(HOST_CNTL); UncacheRegister(PAT_CNTL); UncacheRegister(SC_LEFT_RIGHT); UncacheRegister(SC_TOP_BOTTOM); UncacheRegister(DP_BKGD_CLR); UncacheRegister(DP_FRGD_CLR); +#if 0 UncacheRegister(DP_WRITE_MASK); +#endif UncacheRegister(DP_PIX_WIDTH); UncacheRegister(DP_MIX); UncacheRegister(CLR_CMP_CNTL); + UncacheRegister(TEX_SIZE_PITCH); } ATIDRIWaitForIdle(pATI); @@ -280,12 +297,19 @@ #ifdef XF86DRI_DEVEL outf( DP_MIX, pATIHW->dp_mix ); outf( DP_FRGD_CLR, pATIHW->dp_frgd_clr ); outf( DP_WRITE_MASK, pATIHW->dp_write_mask ); - outf( DP_PIX_WIDTH, pATIHW->dp_pix_width ); + outf( CLR_CMP_CNTL, pATIHW->clr_cmp_cntl ); + + offset = TEX_LEVEL(pATIHW->tex_size_pitch); + + ATIMach64WaitForFIFO(pATI, 6); outf( ALPHA_TST_CNTL, 0 ); outf( Z_CNTL, 0 ); - outf( SCALE_3D_CNTL, 0 ); + outf( SCALE_3D_CNTL, pATIHW->scale_3d_cntl ); + outf( TEX_0_OFF + offset, pATIHW->tex_offset ); + outf( TEX_SIZE_PITCH, pATIHW->tex_size_pitch ); + outf( TEX_CNTL, pATIHW->tex_cntl ); ATIMach64WaitForFIFO(pATI, 2); outf( SC_LEFT_RIGHT, @@ -296,16 +320,23 @@ #ifdef XF86DRI_DEVEL if (pATI->OptionMMIOCache) { /* Now that the cache slots reflect the register state, re-enable MMIO cache */ CacheRegister(SRC_CNTL); + CacheRegister(SCALE_3D_CNTL); CacheRegister(HOST_CNTL); CacheRegister(PAT_CNTL); CacheRegister(SC_LEFT_RIGHT); CacheRegister(SC_TOP_BOTTOM); CacheRegister(DP_BKGD_CLR); CacheRegister(DP_FRGD_CLR); +#if 0 + /* FIXME: + * If I enable this, I get artifacts with evas_xrender_x11_test. + */ CacheRegister(DP_WRITE_MASK); +#endif CacheRegister(DP_PIX_WIDTH); CacheRegister(DP_MIX); CacheRegister(CLR_CMP_CNTL); + CacheRegister(TEX_SIZE_PITCH); } ATIMach64WaitForIdle(pATI); diff --git a/src/atimach64exa.c b/src/atimach64exa.c index 2adf2ca..fd98436 100644 --- a/src/atimach64exa.c +++ b/src/atimach64exa.c @@ -441,6 +441,8 @@ Mach64DownloadFromScreen(PixmapPtr pSrc, return TRUE; } +#include "atimach64render.c" + /* Compute log base 2 of val. */ static __inline__ int Mach64Log2(int val) { @@ -679,6 +681,26 @@ Bool ATIMach64ExaInit(ScreenPtr pScreen) */ 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); diff --git a/src/atimach64render.c b/src/atimach64render.c new file mode 100644 index 0000000..01a0262 --- /dev/null +++ b/src/atimach64render.c @@ -0,0 +1,839 @@ + +/* + * Based on: + * the mach64 DRI and DRM drivers (Gareth Hughes, Leif Delgass) + * the ati/r128 kdrive driver (Eric Anholt, Anders Carlsson) + * the via xfree86 driver (Thomas Hellstrom) + * + * Author: + * George Fufutos + */ + +/* + * Interesting cases for RENDER acceleration: + * + * cursor : ARGB8888 (24x24) Over + * RGB565 + * + * glyph : A8 (9x10) Add + * A8 (420x13) + * glyph set : ARGB8888 (1x1 R) In + * A8 (420x13) Over + * RGB565 + * + * shadow : ARGB8888 (1x1 R) In + * A8 (670x362) Over + * RGB565 + * translucent : RGB565 (652x344) In + * A8 (1x1 R) Over + * RGB565 + * + * In all interesting cases one of src/mask is "1x1 R". + * + * According to atiregs.h, SCALE_3D_CNTL (and TEX_0_OFF) appear in GT, thus + * chips as old as GT (but not VT, VTB) should be capable of RENDER accelera- + * tion, using the S_?_INC, T_?_INC registers for texture mapping. Those cards + * do not have enough memory (i.e. 8MB) to support RENDER, though. + * + * GTPRO added a triangle setup engine and multitexturing. However, it seems + * that none of the 8bpp mach64 formats expands the 8bit value to the alpha + * channel in texture mapping, RGB8 appears to expand to (I,I,I,0). This makes + * GTPRO multitexturing unsuitable for emulating the IN operation. Moreover, + * it seems that GT/GTPRO has a muxltiplexer instead of a blender for computing + * the final alpha channel which forbids destinations with an alpha channel and + * makes it impossible to convert "ARGB8888 IN A8" to "A8 IN_REV ARGB8888" for + * generic two-pass compositing. + * + * A texture unit combines the fragment color (VERTEX_?_ARGB) coming in from + * triangle rasterization with the texel from the texture according to the + * texture environment (TEX_LIGHT_FCN_). "1x1 R" textures may come in as frag- + * ment colors, eliminating the need for multitexturing in all interesting + * cases (via also uses this optimization). + * + * Texture registers are saved/restored and cached (see atimach64.c). TEX_CNTL + * cannot be cached because it flushes the texture cache. TEX_?_OFF are also + * not cached because I am not sure whether writing at some offset register + * affects the value at another offset. + * + * Vertex registers are not saved/restored. This shouldn't be a problem though + * either for DRI or VT switch because vertex registers are set and used within + * a signle acceleration hook: synchronization between the DDX and DRI is based + * on calling ATIDRISync() at the beginning of each DDX acceleration hook, + * which suggests the assumption that individual acceleration hooks are not + * interrupted. + */ + +#include +#include + +/* + * Helper functions copied from exa and via. + */ + +static void +Mach64ExaCompositePictDesc(PicturePtr pict, char *string, int n) +{ + char format[20]; + char size[20]; + + if (!pict) { + snprintf(string, n, "None"); + return; + } + + switch (pict->format) { + case PICT_x8r8g8b8: + snprintf(format, 20, "RGB8888 "); + break; + case PICT_x8b8g8r8: + snprintf(format, 20, "BGR8888 "); + break; + case PICT_a8r8g8b8: + snprintf(format, 20, "ARGB8888"); + break; + case PICT_a8b8g8r8: + snprintf(format, 20, "ABGR8888"); + break; + case PICT_r5g6b5: + snprintf(format, 20, "RGB565 "); + break; + case PICT_x1r5g5b5: + snprintf(format, 20, "RGB555 "); + break; + case PICT_a8: + snprintf(format, 20, "A8 "); + break; + case PICT_a1: + snprintf(format, 20, "A1 "); + break; + default: + snprintf(format, 20, "0x%x", (int)pict->format); + break; + } + + snprintf(size, 20, "%dx%d%s%s", + pict->pDrawable->width, + pict->pDrawable->height, + pict->repeat ? " R" : "", + pict->componentAlpha ? " C" : "" + ); + + snprintf(string, n, "%-10p: fmt %s (%s)", (void *)pict->pDrawable, format, size); +} + +static void +Mach64ExaPrintComposite(CARD8 op, + PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst, char *string) +{ + char sop[20]; + char srcdesc[40], maskdesc[40], dstdesc[40]; + + switch (op) { + case PictOpSrc: + sprintf(sop, "Src"); + break; + case PictOpOver: + sprintf(sop, "Over"); + break; + case PictOpInReverse: + sprintf(sop, "InR"); + break; + case PictOpOutReverse: + sprintf(sop, "OutR"); + break; + case PictOpAdd: + sprintf(sop, "Add"); + break; + default: + sprintf(sop, "0x%x", (int)op); + break; + } + + Mach64ExaCompositePictDesc(pSrc, srcdesc, 40); + Mach64ExaCompositePictDesc(pMask, maskdesc, 40); + Mach64ExaCompositePictDesc(pDst, dstdesc, 40); + + sprintf(string, "op %s, \n" + " src %s\n" + " mask %s\n" + " dst %s\n", sop, srcdesc, maskdesc, dstdesc); +} + +static __inline__ CARD32 +viaBitExpandHelper(CARD32 component, CARD32 bits) +{ + CARD32 tmp, mask; + + mask = (1 << (8 - bits)) - 1; + tmp = component << (8 - bits); + return ((component & 1) ? tmp | mask : tmp); +} + +static __inline__ void +Mach64PixelARGB(PixmapPtr pPixmap, CARD32 format, CARD32 *argb) +{ + CARD32 pixel; + CARD8 comp; + int bits, shift; + + /* Ensure that texture drawing has completed. */ + exaWaitSync(pPixmap->drawable.pScreen); + + /* exaGetPixmapFirstPixel() */ + + switch (pPixmap->drawable.bitsPerPixel) { + case 32: + pixel = *(CARD32 *)(pPixmap->devPrivate.ptr); + break; + case 16: + pixel = *(CARD16 *)(pPixmap->devPrivate.ptr); + break; + default: + pixel = *(CARD8 *)(pPixmap->devPrivate.ptr); + break; + } + + /* exaGetRGBAFromPixel()/viaPixelARGB8888() */ + + switch (PICT_FORMAT_TYPE(format)) { + case PICT_TYPE_A: + shift = 0; + bits = PICT_FORMAT_A(format); + comp = (pixel >> shift) & ((1 << bits) - 1); + comp = viaBitExpandHelper(comp, bits); + *argb = comp << 24; + break; + case PICT_TYPE_ARGB: + shift = 0; + bits = PICT_FORMAT_B(format); + comp = (pixel >> shift) & ((1 << bits) - 1); + comp = viaBitExpandHelper(comp, bits); + *argb = comp; + + shift += bits; + bits = PICT_FORMAT_G(format); + comp = (pixel >> shift) & ((1 << bits) - 1); + comp = viaBitExpandHelper(comp, bits); + *argb |= comp << 8; + + shift += bits; + bits = PICT_FORMAT_R(format); + comp = (pixel >> shift) & ((1 << bits) - 1); + comp = viaBitExpandHelper(comp, bits); + *argb |= comp << 16; + + shift += bits; + bits = PICT_FORMAT_A(format); + if (bits) { + comp = (pixel >> shift) & ((1 << bits) - 1); + comp = viaBitExpandHelper(comp, bits); + } else { + comp = 0xff; + } + *argb |= comp << 24; + break; + case PICT_TYPE_ABGR: + break; + default: + break; + } +} + +/* + * RENDER acceleration for mach64 + */ +typedef struct { + Bool supported; + CARD32 scale_3d_cntl; +} Mach64BlendOp; + +static Mach64BlendOp Mach64BlendOps[] = { + /* Clear */ + {1, MACH64_ALPHA_BLEND_SRC_ZERO | MACH64_ALPHA_BLEND_DST_ZERO}, + /* Src */ + {1, MACH64_ALPHA_BLEND_SRC_ONE | MACH64_ALPHA_BLEND_DST_ZERO}, + /* Dst */ + {1, MACH64_ALPHA_BLEND_SRC_ZERO | MACH64_ALPHA_BLEND_DST_ONE}, + /* Over */ + {1, MACH64_ALPHA_BLEND_SRC_ONE | MACH64_ALPHA_BLEND_DST_INVSRCALPHA}, + /* OverReverse */ + {1, MACH64_ALPHA_BLEND_SRC_INVDSTALPHA | MACH64_ALPHA_BLEND_DST_ONE}, + /* In */ + {1, MACH64_ALPHA_BLEND_SRC_DSTALPHA | MACH64_ALPHA_BLEND_DST_ZERO}, + /* InReverse */ + {1, MACH64_ALPHA_BLEND_SRC_ZERO | MACH64_ALPHA_BLEND_DST_SRCALPHA}, + /* Out */ + {1, MACH64_ALPHA_BLEND_SRC_INVDSTALPHA | MACH64_ALPHA_BLEND_DST_ZERO}, + /* OutReverse */ + {1, MACH64_ALPHA_BLEND_SRC_ZERO | MACH64_ALPHA_BLEND_DST_INVSRCALPHA}, + /* Atop */ + {0, MACH64_ALPHA_BLEND_SRC_DSTALPHA | MACH64_ALPHA_BLEND_DST_INVSRCALPHA}, + /* AtopReverse */ + {0, MACH64_ALPHA_BLEND_SRC_INVDSTALPHA | MACH64_ALPHA_BLEND_DST_SRCALPHA}, + /* Xor */ + {1, MACH64_ALPHA_BLEND_SRC_INVDSTALPHA | MACH64_ALPHA_BLEND_DST_INVSRCALPHA}, + /* Add */ + {1, MACH64_ALPHA_BLEND_SRC_ONE | MACH64_ALPHA_BLEND_DST_ONE} +}; + +#define MACH64_NR_BLEND_OPS \ + (sizeof(Mach64BlendOps) / sizeof(Mach64BlendOps[0])) + +typedef struct { + CARD32 pictFormat; + CARD32 dstFormat; + CARD32 texFormat; +} Mach64TexFormat; + +static Mach64TexFormat Mach64TexFormats[] = { + {PICT_a8r8g8b8, 0, MACH64_DATATYPE_ARGB8888}, + {PICT_x8r8g8b8, MACH64_DATATYPE_ARGB8888, MACH64_DATATYPE_ARGB8888}, + {PICT_a1r5g5b5, 0, MACH64_DATATYPE_ARGB1555}, + {PICT_x1r5g5b5, MACH64_DATATYPE_ARGB1555, MACH64_DATATYPE_ARGB1555}, + {PICT_r5g6b5, MACH64_DATATYPE_RGB565, MACH64_DATATYPE_RGB565 }, + {PICT_a8, MACH64_DATATYPE_RGB8, MACH64_DATATYPE_RGB8 } +}; + +#define MACH64_NR_TEX_FORMATS \ + (sizeof(Mach64TexFormats) / sizeof(Mach64TexFormats[0])) + +static Bool +Mach64GetOrder(int val, int *shift) +{ + *shift = 0; + + while (val > (1 << *shift)) + (*shift)++; + + return (val == (1 << *shift)); +} + +static Bool +Mach64CheckTexture(PicturePtr pPict) +{ + int w = pPict->pDrawable->width; + int h = pPict->pDrawable->height; + int l2w, l2h, level, i; + + for (i = 0; i < MACH64_NR_TEX_FORMATS; i++) { + if (Mach64TexFormats[i].pictFormat == pPict->format) + break; + } + + if (i == MACH64_NR_TEX_FORMATS) + MACH64_FALLBACK(("Unsupported picture format 0x%x\n", + (int)pPict->format)); + + /* l2w equals l2p (pitch) for all interesting cases (w >= 64) */ + Mach64GetOrder(w, &l2w); + Mach64GetOrder(h, &l2h); + + level = (l2w > l2h) ? l2w : l2h; + + if (level > 10) + MACH64_FALLBACK(("Picture w/h too large (%dx%d)\n", w, h)); + + return TRUE; +} + +Bool +Mach64CheckComposite +( + int op, + PicturePtr pSrcPicture, + PicturePtr pMaskPicture, + PicturePtr pDstPicture +) +{ + Bool src_solid, mask_solid, mask_comp, op_comp; + +#if 0 + char compdesc[240]; + int w = pSrcPicture->pDrawable->width; + int h = pSrcPicture->pDrawable->height; + + if (w != 24 && h != 24) { /* cursor */ + Mach64ExaPrintComposite(op, pSrcPicture, pMaskPicture, pDstPicture, compdesc); + ErrorF("Check: %s", compdesc); + } +#endif + + if (op >= MACH64_NR_BLEND_OPS || !Mach64BlendOps[op].supported) + return FALSE; + + if (!Mach64CheckTexture(pSrcPicture)) + return FALSE; + + if (pMaskPicture && !Mach64CheckTexture(pMaskPicture)) + return FALSE; + + if (!Mach64CheckTexture(pDstPicture)) + return FALSE; + + /* Check combinations of src/dst formats. */ + + if (pDstPicture->format == PICT_a8) { + if (pMaskPicture || pSrcPicture->format != PICT_a8 || op != PictOpAdd) + MACH64_FALLBACK(("A8 dst with mask or non-A8 src.\n")); + } + + if (pDstPicture->format != PICT_a8) { + if (pSrcPicture->format == PICT_a8) + MACH64_FALLBACK(("A8 src with non-A8 dst.\n")); + + if (PICT_FORMAT_A(pDstPicture->format)) + MACH64_FALLBACK(("Destination with alpha channel.\n")); + } + + /* Check that one of src/mask can come in as the fragment color. */ + + src_solid = pSrcPicture && + pSrcPicture->pDrawable->width == 1 && + pSrcPicture->pDrawable->height == 1 && + pSrcPicture->repeat; + + mask_solid = pMaskPicture && + pMaskPicture->pDrawable->width == 1 && + pMaskPicture->pDrawable->height == 1 && + pMaskPicture->repeat; + + mask_comp = pMaskPicture && + pMaskPicture->componentAlpha; + + op_comp = op == PictOpAdd || + op == PictOpInReverse || + op == PictOpOutReverse; + + if (mask_solid && src_solid) + MACH64_FALLBACK(("Bad one-pixel IN composite operation.\n")); + + if (pMaskPicture) { + if (!mask_solid && !src_solid) + MACH64_FALLBACK(("Multitexturing required.\n")); + + if (!mask_solid && !op_comp) + MACH64_FALLBACK(("Non-solid mask.\n")); + + if (mask_comp && !src_solid) + MACH64_FALLBACK(("Component-alpha mask.\n")); + + if (!mask_comp && pMaskPicture->format != PICT_a8) + MACH64_FALLBACK(("Non-A8 mask.\n")); + + if (mask_comp && pMaskPicture->format != PICT_a8r8g8b8) + MACH64_FALLBACK(("Non-ARGB mask.\n")); + } + + /* Transforms */ + + if (pSrcPicture->transform) + MACH64_FALLBACK(("transform\n")); + + if (pMaskPicture && pMaskPicture->transform) + MACH64_FALLBACK(("transform\n")); + + return TRUE; +} + +static Bool +Mach64PrepareMask +( + Mach64ContextRegs3D *m3d, + int op, + PicturePtr pSrcPicture, + PicturePtr pMaskPicture, + PixmapPtr pSrc, + PixmapPtr pMask +) +{ + Bool mask_solid, src_solid; + CARD32 argb = 0; + + m3d->frag_src = FALSE; + m3d->frag_mask = FALSE; + m3d->frag_color = 0xffffffff; + + m3d->color_alpha = FALSE; + + if (!pMaskPicture) + return TRUE; + + mask_solid = pMaskPicture && + pMaskPicture->pDrawable->width == 1 && + pMaskPicture->pDrawable->height == 1 && + pMaskPicture->repeat; + + src_solid = pSrcPicture && + pSrcPicture->pDrawable->width == 1 && + pSrcPicture->pDrawable->height == 1 && + pSrcPicture->repeat; + + if (mask_solid) { + Mach64PixelARGB(pMask, pMaskPicture->format, &argb); + argb >>= 24; + argb &= 0xff; + + m3d->frag_mask = TRUE; + m3d->frag_color = (argb << 24) | (argb << 16) | (argb << 8) | argb; + return TRUE; + } + + if (src_solid) { + /* We can only handle cases where either the src color (e.g. ADD) or + * the src alpha (e.g. IN_REV, OUT_REV) is used but not both. + * + * (ARGB8888 IN A8) OVER RGB565 is implemented as: + * (ARGB8888 IN A8) ADD ((ARGB8888 IN A8) OUT_REV RGB565). + */ + if (op == PictOpInReverse || op == PictOpOutReverse) { + Mach64PixelARGB(pSrc, pSrcPicture->format, &argb); + argb >>= 24; + argb &= 0xff; + + m3d->frag_src = TRUE; + m3d->frag_color = (argb << 24) | (argb << 16) | (argb << 8) | argb; + m3d->color_alpha = TRUE; + return TRUE; + } + + if (op == PictOpAdd) { + Mach64PixelARGB(pSrc, pSrcPicture->format, &argb); + + m3d->frag_src = TRUE; + m3d->frag_color = argb; + return TRUE; + } + } + + return FALSE; +} + +static void __inline__ Mach64BlendCntl(Mach64ContextRegs3D *m3d, int op) +{ + m3d->scale_3d_cntl |= MACH64_SCALE_PIX_EXPAND_DYNAMIC_RANGE | + MACH64_SCALE_DITHER_2D_TABLE | + MACH64_DITHER_INIT_RESET; + + m3d->scale_3d_cntl |= Mach64BlendOps[op].scale_3d_cntl; + + if (m3d->color_alpha) { + /* A8 uses RGB8 which expands to (I,I,I,0). Thus, we use the color + * channels instead of the alpha channel as the alpha factor. We also + * use the color channels for ARGB8888 masks with component-alpha. + */ + CARD32 Ad = m3d->scale_3d_cntl & MACH64_ALPHA_BLEND_DST_MASK; + + /* InReverse */ + if (Ad == MACH64_ALPHA_BLEND_DST_SRCALPHA) { + m3d->scale_3d_cntl &= ~MACH64_ALPHA_BLEND_DST_MASK; + m3d->scale_3d_cntl |= MACH64_ALPHA_BLEND_DST_SRCCOLOR; + } + + /* OutReverse */ + if (Ad == MACH64_ALPHA_BLEND_DST_INVSRCALPHA) { + m3d->scale_3d_cntl &= ~MACH64_ALPHA_BLEND_DST_MASK; + m3d->scale_3d_cntl |= MACH64_ALPHA_BLEND_DST_INVSRCCOLOR; + } + } + + /* Can't color mask and blend at the same time */ + m3d->dp_write_mask = 0xffffffff; + + /* Can't fog and blend at the same time */ + m3d->scale_3d_cntl |= MACH64_ALPHA_FOG_EN_ALPHA; + + /* Enable texture mapping mode */ + m3d->scale_3d_cntl |= MACH64_SCALE_3D_FCN_TEXTURE; + m3d->scale_3d_cntl |= MACH64_MIP_MAP_DISABLE; + + /* Setup the texture environment */ + m3d->scale_3d_cntl |= MACH64_TEX_LIGHT_FCN_MODULATE; + + /* Initialize texture unit */ + m3d->tex_cntl |= MACH64_TEX_ST_DIRECT | + MACH64_TEX_SRC_LOCAL | + MACH64_TEX_UNCOMPRESSED | + MACH64_TEX_CACHE_FLUSH | + MACH64_TEX_CACHE_SIZE_4K; +} + +static Bool +Mach64PrepareTexture(PicturePtr pPict, PixmapPtr pPix) +{ + ScrnInfoPtr pScreenInfo = xf86Screens[pPix->drawable.pScreen->myNum]; + ATIPtr pATI = ATIPTR(pScreenInfo); + Mach64ContextRegs3D *m3d = &pATI->m3d; + + CARD32 texFormat; + + int w = pPict->pDrawable->width; + int h = pPict->pDrawable->height; + int l2w, l2h, l2p, level, pitch, pitchAlign, cpp, i; + + /* Prepare picture format */ + for (i = 0; i < MACH64_NR_TEX_FORMATS; i++) { + if (Mach64TexFormats[i].pictFormat == pPict->format) + break; + } + texFormat = Mach64TexFormats[i].texFormat; + + /* Prepare picture size */ + cpp = PICT_FORMAT_BPP(pPict->format) / 8; + pitch = exaGetPixmapPitch(pPix) / cpp; + pitchAlign = pATI->pExa->pixmapPitchAlign; + + Mach64GetOrder(w, &l2w); + Mach64GetOrder(h, &l2h); + Mach64GetOrder(pitch, &l2p); + + if ((pitch & (pitch - 1)) != 0) + MACH64_FALLBACK(("Error: NPOT pitch 0x%x unsupported\n", pitch)); + + if (w >= pitchAlign && l2w != l2p) + MACH64_FALLBACK(("Error: width 0x%x != pitch 0x%x\n", w, pitch)); + + if (pPict->repeat && w == 1 && h == 1) + l2p = 0; + else if (pPict->repeat) + MACH64_FALLBACK(("Repeat not supported for w,h != 1,1\n")); + + l2w = l2p; + + level = (l2w > l2h) ? l2w : l2h; + + m3d->tex_width = (1 << l2w); + m3d->tex_height = (1 << l2h); + + /* Update hw state */ + m3d->dp_pix_width |= SetBits(texFormat, DP_SCALE_PIX_WIDTH); + + m3d->tex_size_pitch = (l2w << 0) | + (level << 4) | + (l2h << 8); + + m3d->tex_offset = exaGetPixmapOffset(pPix); + + if (PICT_FORMAT_A(pPict->format)) + m3d->scale_3d_cntl |= MACH64_TEX_MAP_AEN; + + switch (pPict->filter) { + case PictFilterNearest: + m3d->scale_3d_cntl |= MACH64_TEX_BLEND_FCN_NEAREST; + break; + case PictFilterBilinear: + m3d->scale_3d_cntl |= MACH64_TEX_BLEND_FCN_LINEAR; + m3d->scale_3d_cntl |= MACH64_BILINEAR_TEX_EN; + break; + default: + MACH64_FALLBACK(("Bad filter 0x%x\n", pPict->filter)); + } + + return TRUE; +} + +Bool +Mach64PrepareComposite +( + int op, + PicturePtr pSrcPicture, + PicturePtr pMaskPicture, + PicturePtr pDstPicture, + PixmapPtr pSrc, + PixmapPtr pMask, + PixmapPtr pDst +) +{ + ScrnInfoPtr pScreenInfo = xf86Screens[pDst->drawable.pScreen->myNum]; + ATIPtr pATI = ATIPTR(pScreenInfo); + Mach64ContextRegs3D *m3d = &pATI->m3d; + + CARD32 dstFormat; + int offset, i; + +#if 0 + char compdesc[240]; + int w = pSrcPicture->pDrawable->width; + int h = pSrcPicture->pDrawable->height; +#endif + + ATIDRISync(pScreenInfo); + + m3d->dp_mix = SetBits(MIX_SRC, DP_BKGD_MIX) | + SetBits(MIX_SRC, DP_FRGD_MIX); + + m3d->dp_src = SetBits(SRC_SCALER_3D, DP_BKGD_SRC) | + SetBits(SRC_SCALER_3D, DP_FRGD_SRC) | + DP_MONO_SRC_ALLONES; + + Mach64GetPixmapOffsetPitch(pDst, &m3d->dst_pitch_offset); + + m3d->scale_3d_cntl = 0; + m3d->tex_cntl = 0; + + if (!Mach64PrepareMask(m3d, op, pSrcPicture, pMaskPicture, pSrc, pMask)) + return FALSE; + +#if 0 + /* BUGZILLA: EXA/smart with unaccelerated composite for glyphs. + * + * Returning FALSE in Prepare (later) instead of Check (earlier) results + * in uploads of glyph pixmaps only and performance similar to exa/greedy. + * Otherwise, it moves the firefox pixmap in and out of offscreen memory. + */ + if (pMaskPicture && !m3d->frag_mask) + return FALSE; +#endif + + Mach64BlendCntl(m3d, op); + + for (i = 0; i < MACH64_NR_TEX_FORMATS; i++) { + if (Mach64TexFormats[i].pictFormat == pDstPicture->format) + break; + } + dstFormat = Mach64TexFormats[i].dstFormat; + + m3d->dp_pix_width = SetBits(dstFormat, DP_DST_PIX_WIDTH) | + SetBits(dstFormat, DP_SRC_PIX_WIDTH) | + SetBits(dstFormat, DP_HOST_PIX_WIDTH); + + if (!m3d->frag_src) { + if (!Mach64PrepareTexture(pSrcPicture, pSrc)) + return FALSE; + } + + if (pMaskPicture && !m3d->frag_mask) { + if (!Mach64PrepareTexture(pMaskPicture, pMask)) + return FALSE; + } + + offset = TEX_LEVEL(m3d->tex_size_pitch); + + /* Emit hw state */ + ATIMach64WaitForFIFO(pATI, 12); + outf(DP_SRC, m3d->dp_src); + outf(DP_MIX, m3d->dp_mix); + + outf(CLR_CMP_CNTL, CLR_CMP_FN_FALSE); + outf(DST_CNTL, DST_X_DIR | DST_Y_DIR); + outf(DST_OFF_PITCH, m3d->dst_pitch_offset); + + outf(SCALE_3D_CNTL, m3d->scale_3d_cntl); + outf(DP_WRITE_MASK, m3d->dp_write_mask); + outf(DP_PIX_WIDTH, m3d->dp_pix_width); + + outf(SETUP_CNTL, 0); + + outf(TEX_SIZE_PITCH, m3d->tex_size_pitch); + outf(TEX_CNTL, m3d->tex_cntl); + outf(TEX_0_OFF + offset, m3d->tex_offset); + +#if 0 + if (w != 24 && h != 24) { /* cursor */ + Mach64ExaPrintComposite(op, pSrcPicture, pMaskPicture, pDstPicture, compdesc); + ErrorF("Prep : %s", compdesc); + } +#endif + + return TRUE; +} + +typedef struct { + float s0; /* normalized texture coords */ + float t0; + float x; /* quarter-pixels */ + float y; + CARD32 argb; /* fragment color */ +} Mach64Vertex; + +#define VTX_SET(_v, _col, _dstX, _dstY, _srcX, _srcY) \ +do { \ + _v.s0 = ((float)(_srcX) + 0.0) / m3d->tex_width; \ + _v.t0 = ((float)(_srcY) + 0.0) / m3d->tex_height; \ + _v.x = ((float)(_dstX) * 4.0 + 0.0); \ + _v.y = ((float)(_dstY) * 4.0 + 0.0); \ + _v.argb = _col; \ +} while (0) + +#define FVAL(_fval) (*(CARD32 *)&(_fval)) + +#define VTX_OUT(_v, n) \ +do { \ + float w = 1.0; \ + CARD32 z = 0xffff << 15; \ + CARD32 x_y = ((CARD16)_v.x << 16) | \ + ((CARD16)_v.y & 0xffff); \ + \ + ATIMach64WaitForFIFO(pATI, 6); \ + outf(VERTEX_##n##_S, FVAL(_v.s0)); \ + outf(VERTEX_##n##_T, FVAL(_v.t0)); \ + outf(VERTEX_##n##_W, FVAL(w)); \ + \ + outf(VERTEX_##n##_Z, z); \ + outf(VERTEX_##n##_ARGB, _v.argb); \ + outf(VERTEX_##n##_X_Y, x_y); \ +} while (0) + +void +Mach64Composite +( + PixmapPtr pDst, + int srcX, + int srcY, + int maskX, + int maskY, + int dstX, + int dstY, + int w, + int h +) +{ + ScrnInfoPtr pScreenInfo = xf86Screens[pDst->drawable.pScreen->myNum]; + ATIPtr pATI = ATIPTR(pScreenInfo); + Mach64ContextRegs3D *m3d = &pATI->m3d; + + Mach64Vertex v0, v1, v2, v3; + float ooa; + CARD32 col; + + ATIDRISync(pScreenInfo); + + /* Disable clipping if it gets in the way */ + ATIMach64ValidateClip(pATI, dstX, dstX + w - 1, dstY, dstY + h - 1); + + /* Handle solid textures which come in as fragment color */ + col = m3d->frag_color; + if (m3d->frag_src) { + srcX = maskX; + srcY = maskY; + } + + /* Create vertices in clock-wise order */ + VTX_SET(v0, col, dstX, dstY, srcX, srcY); + VTX_SET(v1, col, dstX + w, dstY, srcX + w, srcY); + VTX_SET(v2, col, dstX + w, dstY + h, srcX + w, srcY + h); + VTX_SET(v3, col, dstX, dstY + h, srcX, srcY + h); + + /* Setup upper triangle (v0, v1, v3) */ + VTX_OUT(v0, 1); + VTX_OUT(v1, 2); + VTX_OUT(v3, 3); + + ooa = 1.0 / (w * h); + outf(ONE_OVER_AREA, FVAL(ooa)); + + /* Setup lower triangle (v2, v1, v3) */ + VTX_OUT(v2, 1); + + ooa = -ooa; + outf(ONE_OVER_AREA, FVAL(ooa)); +} + +void +Mach64DoneComposite(PixmapPtr pDst) +{ + ScrnInfoPtr pScreenInfo = xf86Screens[pDst->drawable.pScreen->myNum]; + ATIPtr pATI = ATIPTR(pScreenInfo); + + ATIDRISync(pScreenInfo); + outf(SCALE_3D_CNTL, 0); +} diff --git a/src/atiregs.h b/src/atiregs.h index 102347b..8ab8340 100644 --- a/src/atiregs.h +++ b/src/atiregs.h @@ -2751,4 +2751,132 @@ #define OVERLAY_MIX_EQUAL 0x05u /* ? 0x06u */ /* ? 0x07u */ +/* 3D Engine for render acceleration (from Mach64 DRI driver) */ + +/* SCALE_3D_CNTL */ +#define MACH64_SCALE_PIX_EXPAND_ZERO_EXTEND (0 << 0) +#define MACH64_SCALE_PIX_EXPAND_DYNAMIC_RANGE (1 << 0) +#define MACH64_SCALE_DITHER_ERROR_DIFFUSE (0 << 1) +#define MACH64_SCALE_DITHER_2D_TABLE (1 << 1) +#define MACH64_DITHER_EN (1 << 2) +#define MACH64_DITHER_INIT_CURRENT (O << 3) +#define MACH64_DITHER_INIT_RESET (1 << 3) +#define MACH64_ROUND_EN (1 << 4) + +#define MACH64_TEX_CACHE_DIS (1 << 5) + +#define MACH64_SCALE_3D_FCN_MASK (3 << 6) +#define MACH64_SCALE_3D_FCN_NOP (0 << 6) +#define MACH64_SCALE_3D_FCN_SCALE (1 << 6) +#define MACH64_SCALE_3D_FCN_TEXTURE (2 << 6) +#define MACH64_SCALE_3D_FCN_SHADE (3 << 6) +#define MACH64_TEXTURE_DISABLE (1 << 6) + +#define MACH64_EDGE_ANTI_ALIAS (1 << 8) +#define MACH64_TEX_CACHE_SPLIT (1 << 9) +#define MACH64_APPLE_YUV_MODE (1 << 10) + +#define MACH64_ALPHA_FOG_EN_MASK (3 << 11) +#define MACH64_ALPHA_FOG_DIS (0 << 11) +#define MACH64_ALPHA_FOG_EN_ALPHA (1 << 11) +#define MACH64_ALPHA_FOG_EN_FOG (2 << 11) + +#define MACH64_ALPHA_BLEND_SAT (1 << 13) +#define MACH64_RED_DITHER_MAX (1 << 14) +#define MACH64_SIGNED_DST_CLAMP (1 << 15) + +#define MACH64_ALPHA_BLEND_SRC_MASK (7 << 16) +#define MACH64_ALPHA_BLEND_SRC_ZERO (0 << 16) +#define MACH64_ALPHA_BLEND_SRC_ONE (1 << 16) +#define MACH64_ALPHA_BLEND_SRC_DSTCOLOR (2 << 16) +#define MACH64_ALPHA_BLEND_SRC_INVDSTCOLOR (3 << 16) +#define MACH64_ALPHA_BLEND_SRC_SRCALPHA (4 << 16) +#define MACH64_ALPHA_BLEND_SRC_INVSRCALPHA (5 << 16) +#define MACH64_ALPHA_BLEND_SRC_DSTALPHA (6 << 16) +#define MACH64_ALPHA_BLEND_SRC_INVDSTALPHA (7 << 16) +#define MACH64_ALPHA_BLEND_DST_MASK (7 << 19) +#define MACH64_ALPHA_BLEND_DST_ZERO (0 << 19) +#define MACH64_ALPHA_BLEND_DST_ONE (1 << 19) +#define MACH64_ALPHA_BLEND_DST_SRCCOLOR (2 << 19) +#define MACH64_ALPHA_BLEND_DST_INVSRCCOLOR (3 << 19) +#define MACH64_ALPHA_BLEND_DST_SRCALPHA (4 << 19) +#define MACH64_ALPHA_BLEND_DST_INVSRCALPHA (5 << 19) +#define MACH64_ALPHA_BLEND_DST_DSTALPHA (6 << 19) +#define MACH64_ALPHA_BLEND_DST_INVDSTALPHA (7 << 19) + +#define MACH64_TEX_LIGHT_FCN_MASK (3 << 22) +#define MACH64_TEX_LIGHT_FCN_REPLACE (0 << 22) +#define MACH64_TEX_LIGHT_FCN_MODULATE (1 << 22) +#define MACH64_TEX_LIGHT_FCN_ALPHA_DECAL (2 << 22) + +#define MACH64_MIP_MAP_DISABLE (1 << 24) + +#define MACH64_BILINEAR_TEX_EN (1 << 25) +#define MACH64_TEX_BLEND_FCN_MASK (3 << 26) +#define MACH64_TEX_BLEND_FCN_NEAREST (0 << 26) +#define MACH64_TEX_BLEND_FCN_LINEAR (2 << 26) +#define MACH64_TEX_BLEND_FCN_TRILINEAR (3 << 26) + +#define MACH64_TEX_AMASK_AEN (1 << 28) +#define MACH64_TEX_AMASK_BLEND_EDGE (1 << 29) +#define MACH64_TEX_MAP_AEN (1 << 30) +#define MACH64_SRC_3D_HOST_FIFO (1 << 31) + +/* TEX_CNTL */ +#define MACH64_LOD_BIAS_SHIFT 0 +#define MACH64_LOD_BIAS_MASK (0xf << 0) +#define MACH64_COMP_FACTOR_SHIFT 4 +#define MACH64_COMP_FACTOR_MASK (0xf << 4) + +#define MACH64_TEXTURE_COMPOSITE (1 << 8) + +#define MACH64_COMP_COMBINE_BLEND (0 << 9) +#define MACH64_COMP_COMBINE_MODULATE (1 << 9) +#define MACH64_COMP_BLEND_NEAREST (0 << 11) +#define MACH64_COMP_BLEND_BILINEAR (1 << 11) +#define MACH64_COMP_FILTER_NEAREST (0 << 12) +#define MACH64_COMP_FILTER_BILINEAR (1 << 12) +#define MACH64_COMP_ALPHA (1 << 13) + +#define MACH64_TEXTURE_TILING (1 << 14) +#define MACH64_COMPOSITE_TEX_TILING (1 << 15) +#define MACH64_TEX_COLLISION_DISABLE (1 << 16) + +#define MACH64_TEXTURE_CLAMP_S (1 << 17) +#define MACH64_TEXTURE_CLAMP_T (1 << 18) +#define MACH64_TEX_ST_MULT_W (0 << 19) +#define MACH64_TEX_ST_DIRECT (1 << 19) +#define MACH64_TEX_SRC_LOCAL (0 << 20) +#define MACH64_TEX_SRC_AGP (1 << 20) +#define MACH64_TEX_UNCOMPRESSED (0 << 21) +#define MACH64_TEX_VQ_COMPRESSED (1 << 21) +#define MACH64_COMP_TEX_UNCOMPRESSED (0 << 22) +#define MACH64_COMP_TEX_VQ_COMPRESSED (1 << 22) +#define MACH64_TEX_CACHE_FLUSH (1 << 23) +#define MACH64_SEC_TEX_CLAMP_S (1 << 24) +#define MACH64_SEC_TEX_CLAMP_T (1 << 25) +#define MACH64_TEX_WRAP_S (1 << 28) +#define MACH64_TEX_WRAP_T (1 << 29) +#define MACH64_TEX_CACHE_SIZE_4K (1 << 30) +#define MACH64_TEX_CACHE_SIZE_2K (1 << 30) +#define MACH64_SECONDARY_STW (1 << 31) + +/* DP_PIX_WIDTH (superset of PIX_WIDTH_?BPP) */ +#define MACH64_DATATYPE_CI8 2 +#define MACH64_DATATYPE_ARGB1555 3 +#define MACH64_DATATYPE_RGB565 4 +#define MACH64_DATATYPE_ARGB8888 6 +#define MACH64_DATATYPE_RGB332 7 +#define MACH64_DATATYPE_Y8 8 +#define MACH64_DATATYPE_RGB8 9 +#define MACH64_DATATYPE_VYUY422 11 +#define MACH64_DATATYPE_YVYU422 12 +#define MACH64_DATATYPE_AYUV444 14 +#define MACH64_DATATYPE_ARGB4444 15 + +/* Extract texture level from TEX_SIZE_PITCH and shift appropriately for + * addition to TEX_0_OFF. + */ +#define TEX_LEVEL(_tex_size_pitch) (((_tex_size_pitch) & 0xf0) >> 2) + #endif /* ___ATIREGS_H___ */ diff --git a/src/atistruct.h b/src/atistruct.h index 7ea0d8d..8c4c328 100644 --- a/src/atistruct.h +++ b/src/atistruct.h @@ -158,6 +158,7 @@ #endif /* AVOID_CPIO */ scaler_h_coeff2, scaler_h_coeff3, scaler_h_coeff4, gui_cntl, scaler_buf0_offset_u, scaler_buf0_offset_v, scaler_buf1_offset_u, scaler_buf1_offset_v; + CARD32 scale_3d_cntl, tex_size_pitch, tex_cntl, tex_offset; /* Clock map pointers */ const CARD8 *ClockMap, *ClockUnmap; @@ -176,6 +177,36 @@ #endif /* AVOID_CPIO */ } ATIHWRec; +#ifdef USE_EXA +/* + * Card engine state for communication across RENDER acceleration hooks. + */ +typedef struct _Mach64ContextRegs3D +{ + CARD32 dp_mix; + CARD32 dp_src; + CARD32 dp_write_mask; + CARD32 dp_pix_width; + CARD32 dst_pitch_offset; + + CARD32 scale_3d_cntl; + + CARD32 tex_cntl; + CARD32 tex_size_pitch; + CARD32 tex_offset; + + int tex_width; /* src/mask texture width (pixels) */ + int tex_height; /* src/mask texture height (pixels) */ + + Bool frag_src; /* solid src uses fragment color */ + Bool frag_mask; /* solid mask uses fragment color */ + CARD32 frag_color; /* solid src/mask color */ + + Bool color_alpha; /* the alpha value is contained in the color + channels instead of the alpha channel */ +} Mach64ContextRegs3D; +#endif /* USE_EXA */ + /* * This structure defines the driver's private area. */ @@ -291,6 +322,10 @@ #endif #ifdef USE_XAA CARD32 *ExpansionBitmapScanlinePtr[2]; int ExpansionBitmapWidth; +#endif +#ifdef USE_EXA + Bool RenderAccelEnabled; + Mach64ContextRegs3D m3d; #endif /*