Index: Imakefile =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/mga/Imakefile,v retrieving revision 1.8 diff -u -r1.8 Imakefile --- Imakefile 23 Aug 2005 04:03:53 -0000 1.8 +++ Imakefile 10 Oct 2005 07:58:41 -0000 @@ -58,11 +58,11 @@ MGASRCS = mga_driver.c mga_hwcurs.c /* mga_cmap.c */ mga_dac3026.c mga_dacG.c \ mga_storm8.c mga_storm16.c mga_storm24.c mga_storm32.c mga_arc.c \ mga_dga.c mga_shadow.c mga_video.c mga_g450pll.c mga_dh.c mga_esc.c \ - mga_merge.c mga_bios.c $(DRISRCS) + mga_merge.c mga_bios.c mga_render.c $(DRISRCS) MGAOBJS = mga_driver.o mga_hwcurs.o /* mga_cmap.o */ mga_dac3026.o mga_dacG.o \ mga_storm8.o mga_storm16.o mga_storm24.o mga_storm32.o mga_arc.o \ mga_dga.o mga_shadow.o mga_video.o mga_g450pll.o mga_dh.o mga_esc.o \ - mga_merge.o mga_bios.o $(DRIOBJS) + mga_merge.o mga_bios.o mga_render.o $(DRIOBJS) SRCS = $(MGASRCS) $(MGAHALSRCS) OBJS = $(MGAOBJS) $(MGAHALOBJS) @@ -128,6 +128,8 @@ InstallDriverSDKNonExecFile(mga_macros.h,$(DRIVERSDKDIR)/drivers/mga) InstallDriverSDKNonExecFile(mga_map.h,$(DRIVERSDKDIR)/drivers/mga) InstallDriverSDKNonExecFile(mga_reg.h,$(DRIVERSDKDIR)/drivers/mga) +InstallDriverSDKNonExecFile(mga_render.c,$(DRIVERSDKDIR)/drivers/mga) +InstallDriverSDKNonExecFile(mga_render.h,$(DRIVERSDKDIR)/drivers/mga) InstallDriverSDKNonExecFile(mga_shadow.c,$(DRIVERSDKDIR)/drivers/mga) InstallDriverSDKNonExecFile(mga_storm.c,$(DRIVERSDKDIR)/drivers/mga) InstallDriverSDKNonExecFile(mga_video.c,$(DRIVERSDKDIR)/drivers/mga) Index: mga.h =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/mga/mga.h,v retrieving revision 1.10 diff -u -r1.10 mga.h --- mga.h 15 Aug 2005 07:30:05 -0000 1.10 +++ mga.h 10 Oct 2005 07:58:42 -0000 @@ -87,7 +87,8 @@ OPTION_MONITOR2POS, OPTION_METAMODES, OPTION_OLDDMA, - OPTION_PCIDMA + OPTION_PCIDMA, + OPTION_RENDER_ACCEL } MGAOpts; Index: mga.man =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/mga/mga.man,v retrieving revision 1.4 diff -u -r1.4 mga.man --- mga.man 26 Aug 2005 07:10:29 -0000 1.4 +++ mga.man 10 Oct 2005 07:58:43 -0000 @@ -125,6 +125,13 @@ .BI "Option \*qPciRetry\*q \*q" boolean \*q Enable or disable PCI retries. Default: off. .TP +.BI "Option \*qRenderAccel\*q \*q" boolean \*q +Enables or disables hardware Render acceleration. This driver does not +support component alpha (subpixel) rendering. It is only supported on +the G200 through G550. The default is to +.B enable +Render acceleration. +.TP .BI "Option \*qRotate\*q \*qCW\*q" .TP .BI "Option \*qRotate\*q \*qCCW\*q" Index: mga_driver.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c,v retrieving revision 1.18 diff -u -r1.18 mga_driver.c --- mga_driver.c 9 Sep 2005 23:15:45 -0000 1.18 +++ mga_driver.c 10 Oct 2005 07:58:47 -0000 @@ -225,6 +225,9 @@ { OPTION_METAMODES, "MetaModes", OPTV_ANYSTR, {0}, FALSE }, { OPTION_OLDDMA, "OldDmaInit", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_PCIDMA, "ForcePciDma", OPTV_BOOLEAN, {0}, FALSE }, +#ifdef RENDER + { OPTION_RENDER_ACCEL, "RenderAccel", OPTV_BOOLEAN, {0}, FALSE }, +#endif { -1, NULL, OPTV_NONE, {0}, FALSE } }; Index: mga_reg.h =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_reg.h,v retrieving revision 1.2 diff -u -r1.2 mga_reg.h --- mga_reg.h 23 Apr 2004 19:37:16 -0000 1.2 +++ mga_reg.h 10 Oct 2005 07:58:48 -0000 @@ -143,7 +143,7 @@ /* Trapezoids */ #define MGADWG_TRAP 0x04 -#define MGADWG_TEXTURE_TRAP 0x05 +#define MGADWG_TEXTURE_TRAP 0x06 /* BitBlts */ @@ -465,14 +465,170 @@ #define MGAREG_TEXWIDTH 0x2c28 #define MGAREG_TEXHEIGHT 0x2c2c #define MGAREG_TEXCTL 0x2c30 +# define TMC_tformat_MASK 0xfffffff0 /* bits 0-3 */ +# define TMC_tformat_tw4 0x0 /* val 0, shift 0 */ +# define TMC_tformat_tw8 0x1 /* val 1, shift 0 */ +# define TMC_tformat_tw15 0x2 /* val 2, shift 0 */ +# define TMC_tformat_tw16 0x3 /* val 3, shift 0 */ +# define TMC_tformat_tw12 0x4 /* val 4, shift 0 */ +# define TMC_tformat_tw32 0x6 /* val 6, shift 0 */ +# define TMC_tformat_tw8a 0x7 /* val 7, shift 0 */ +# define TMC_tformat_tw8al 0x8 /* val 8, shift 0 */ +# define TMC_tformat_tw422 0xa /* val 10, shift 0 */ +# define TMC_tformat_tw422uyvy 0xb /* val 11, shift 0 */ +# define TMC_tpitchlin_MASK 0xfffffeff /* bit 8 */ +# define TMC_tpitchlin_disable 0x0 +# define TMC_tpitchlin_enable 0x100 +# define TMC_tpitchext_MASK 0xfff001ff /* bits 9-19 */ +# define TMC_tpitchext_SHIFT 9 +# define TMC_tpitch_MASK 0xfff8ffff /* bits 16-18 */ +# define TMC_tpitch_SHIFT 16 +# define TMC_owalpha_MASK 0xffbfffff /* bit 22 */ +# define TMC_owalpha_disable 0x0 +# define TMC_owalpha_enable 0x00400000 +# define TMC_azeroextend_MASK 0xff7fffff /* bit 23 */ +# define TMC_azeroextend_disable 0x0 +# define TMC_azeroextend_enable 0x00800000 +# define TMC_decalckey_MASK 0xfeffffff /* bit 24 */ +# define TMC_decalckey_disable 0x0 +# define TMC_decalckey_enable 0x01000000 +# define TMC_takey_MASK 0xfdffffff /* bit 25 */ +# define TMC_takey_0 0x0 +# define TMC_takey_1 0x02000000 +# define TMC_tamask_MASK 0xfbffffff /* bit 26 */ +# define TMC_tamask_0 0x0 +# define TMC_tamask_1 0x04000000 +# define TMC_clampv_MASK 0xf7ffffff /* bit 27 */ +# define TMC_clampv_disable 0x0 +# define TMC_clampv_enable 0x08000000 +# define TMC_clampu_MASK 0xefffffff /* bit 28 */ +# define TMC_clampu_disable 0x0 +# define TMC_clampu_enable 0x10000000 +# define TMC_tmodulate_MASK 0xdfffffff /* bit 29 */ +# define TMC_tmodulate_disable 0x0 +# define TMC_tmodulate_enable 0x20000000 +# define TMC_strans_MASK 0xbfffffff /* bit 30 */ +# define TMC_strans_disable 0x0 +# define TMC_strans_enable 0x40000000 +# define TMC_itrans_MASK 0x7fffffff /* bit 31 */ +# define TMC_itrans_disable 0x0 +# define TMC_itrans_enable 0x80000000 + #define MGAREG_TEXCTL2 0x2c3c +# define TMC_decalblend_MASK 0xfffffffe /* bit 0 */ +# define TMC_decalblend_disable 0x0 +# define TMC_decalblend_enable 0x1 +# define TMC_idecal_MASK 0xfffffffd /* bit 1 */ +# define TMC_idecal_disable 0x0 +# define TMC_idecal_enable 0x2 +# define TMC_decaldis_MASK 0xfffffffb /* bit 2 */ +# define TMC_decaldis_disable 0x0 +# define TMC_decaldis_enable 0x4 +# define TMC_ckstransdis_MASK 0xffffffef /* bit 4 */ +# define TMC_ckstransdis_disable 0x0 +# define TMC_ckstransdis_enable 0x10 +# define TMC_borderen_MASK 0xffffffdf /* bit 5 */ +# define TMC_borderen_disable 0x0 +# define TMC_borderen_enable 0x20 +# define TMC_specen_MASK 0xffffffbf /* bit 6 */ +# define TMC_specen_disable 0x0 +# define TMC_specen_enable 0x40 +# define TMC_dualtex_MASK 0xffffff7f /* bit 7 */ +# define TMC_dualtex_disable 0x0 +# define TMC_dualtex_enable 0x80 +# define TMC_tablefog_MASK 0xfffffeff /* bit 8 */ +# define TMC_tablefog_disable 0x0 +# define TMC_tablefog_enable 0x100 +# define TMC_bumpmap_MASK 0xfffffdff /* bit 9 */ +# define TMC_bumpmap_disable 0x0 +# define TMC_bumpmap_enable 0x200 +# define TMC_map1_MASK 0x7fffffff /* bit 31 */ +# define TMC_map1_disable 0x0 +# define TMC_map1_enable 0x80000000 + #define MGAREG_TEXTRANS 0x2c34 #define MGAREG_TEXTRANSHIGH 0x2c38 #define MGAREG_TEXFILTER 0x2c58 +# define TF_minfilter_MASK 0xfffffff0 /* bits 0-3 */ +# define TF_minfilter_nrst 0x0 /* val 0, shift 0 */ +# define TF_minfilter_bilin 0x2 /* val 2, shift 0 */ +# define TF_minfilter_cnst 0x3 /* val 3, shift 0 */ +# define TF_minfilter_mm1s 0x8 /* val 8, shift 0 */ +# define TF_minfilter_mm2s 0x9 /* val 9, shift 0 */ +# define TF_minfilter_mm4s 0xa /* val 10, shift 0 */ +# define TF_minfilter_mm8s 0xc /* val 12, shift 0 */ +# define TF_magfilter_MASK 0xffffff0f /* bits 4-7 */ +# define TF_magfilter_nrst 0x0 /* val 0, shift 4 */ +# define TF_magfilter_bilin 0x20 /* val 2, shift 4 */ +# define TF_magfilter_cnst 0x30 /* val 3, shift 4 */ +# define TF_uvoffset_SHIFT 17 +# define TF_uvoffset_OGL (0U << TF_uvoffset_SHIFT) +# define TF_uvoffset_D3D (1U << TF_uvoffset_SHIFT) +# define TF_uvoffset_MASK (~(1U << TF_uvoffset_SHIFT)) +# define TF_reserved_MASK (~0x1ff00) /* bits 8-16 */ +# define TF_mapnbhigh_SHIFT 18 +# define TF_mapnbhigh_MASK (~(1U << TF_mapnbhigh_SHIFT)) +# define TF_avgstride_MASK 0xfff7ffff /* bit 19 */ +# define TF_avgstride_disable 0x0 +# define TF_avgstride_enable 0x80000 +# define TF_filteralpha_MASK 0xffefffff /* bit 20 */ +# define TF_filteralpha_disable 0x0 +# define TF_filteralpha_enable 0x100000 +# define TF_fthres_MASK 0xe01fffff /* bits 21-28 */ +# define TF_fthres_SHIFT 21 +# define TF_mapnb_MASK 0x1fffffff /* bits 29-31 */ +# define TF_mapnb_SHIFT 29 + #define MGAREG_ALPHASTART 0x2c70 #define MGAREG_ALPHAXINC 0x2c74 #define MGAREG_ALPHAYINC 0x2c78 #define MGAREG_ALPHACTRL 0x2c7c +# define AC_src_MASK 0xfffffff0 /* bits 0-3 */ +# define AC_src_zero 0x0 /* val 0, shift 0 */ +# define AC_src_one 0x1 /* val 1, shift 0 */ +# define AC_src_dst_color 0x2 /* val 2, shift 0 */ +# define AC_src_om_dst_color 0x3 /* val 3, shift 0 */ +# define AC_src_src_alpha 0x4 /* val 4, shift 0 */ +# define AC_src_om_src_alpha 0x5 /* val 5, shift 0 */ +# define AC_src_dst_alpha 0x6 /* val 6, shift 0 */ +# define AC_src_om_dst_alpha 0x7 /* val 7, shift 0 */ +# define AC_src_src_alpha_sat 0x8 /* val 8, shift 0 */ +# define AC_dst_MASK 0xffffff0f /* bits 4-7 */ +# define AC_dst_zero 0x0 /* val 0, shift 4 */ +# define AC_dst_one 0x10 /* val 1, shift 4 */ +# define AC_dst_src_color 0x20 /* val 2, shift 4 */ +# define AC_dst_om_src_color 0x30 /* val 3, shift 4 */ +# define AC_dst_src_alpha 0x40 /* val 4, shift 4 */ +# define AC_dst_om_src_alpha 0x50 /* val 5, shift 4 */ +# define AC_dst_dst_alpha 0x60 /* val 6, shift 4 */ +# define AC_dst_om_dst_alpha 0x70 /* val 7, shift 4 */ +# define AC_amode_MASK 0xfffffcff /* bits 8-9 */ +# define AC_amode_FCOL 0x0 /* val 0, shift 8 */ +# define AC_amode_alpha_channel 0x100 /* val 1, shift 8 */ +# define AC_amode_video_alpha 0x200 /* val 2, shift 8 */ +# define AC_amode_RSVD 0x300 /* val 3, shift 8 */ +# define AC_astipple_MASK 0xfffff7ff /* bit 11 */ +# define AC_astipple_disable 0x0 +# define AC_astipple_enable 0x800 +# define AC_aten_MASK 0xffffefff /* bit 12 */ +# define AC_aten_disable 0x0 +# define AC_aten_enable 0x1000 +# define AC_atmode_MASK 0xffff1fff /* bits 13-15 */ +# define AC_atmode_noacmp 0x0 /* val 0, shift 13 */ +# define AC_atmode_ae 0x4000 /* val 2, shift 13 */ +# define AC_atmode_ane 0x6000 /* val 3, shift 13 */ +# define AC_atmode_alt 0x8000 /* val 4, shift 13 */ +# define AC_atmode_alte 0xa000 /* val 5, shift 13 */ +# define AC_atmode_agt 0xc000 /* val 6, shift 13 */ +# define AC_atmode_agte 0xe000 /* val 7, shift 13 */ +# define AC_atref_MASK 0xff00ffff /* bits 16-23 */ +# define AC_atref_SHIFT 16 +# define AC_alphasel_MASK 0xfcffffff /* bits 24-25 */ +# define AC_alphasel_fromtex 0x0 /* val 0, shift 24 */ +# define AC_alphasel_diffused 0x1000000 /* val 1, shift 24 */ +# define AC_alphasel_modulated 0x2000000 /* val 2, shift 24 */ +# define AC_alphasel_trans 0x3000000 /* val 3, shift 24 */ + #define MGAREG_DWGSYNC 0x2c4c #define MGAREG_AGP_PLL 0x1e4c Index: mga_storm.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_storm.c,v retrieving revision 1.8 diff -u -r1.8 mga_storm.c --- mga_storm.c 11 Jul 2005 02:29:51 -0000 1.8 +++ mga_storm.c 10 Oct 2005 07:58:50 -0000 @@ -35,6 +35,10 @@ #include "mga_map.h" #include "mga_macros.h" +#ifdef RENDER +#include "mga_render.h" +#endif /* RENDER */ + #ifdef XF86DRI #include "mga_dri.h" #endif @@ -144,432 +148,6 @@ extern void MGAFillCacheBltRects(ScrnInfoPtr, int, unsigned int, int, BoxPtr, int, int, XAACacheInfoPtr); -#ifdef RENDER - -extern Bool -MGASetupForCPUToScreenAlphaTexture ( - ScrnInfoPtr pScrn, - int op, - CARD16 red, - CARD16 green, - CARD16 blue, - CARD16 alpha, - int alphaType, - CARD8 *alphaPtr, - int alphaPitch, - int width, - int height, - int flags -); - -extern Bool -MGASetupForCPUToScreenAlphaTextureFaked ( - ScrnInfoPtr pScrn, - int op, - CARD16 red, - CARD16 green, - CARD16 blue, - CARD16 alpha, - int alphaType, - CARD8 *alphaPtr, - int alphaPitch, - int width, - int height, - int flags -); - - -extern Bool -MGASetupForCPUToScreenTexture ( - ScrnInfoPtr pScrn, - int op, - int texType, - CARD8 *texPtr, - int texPitch, - int width, - int height, - int flags -); - -extern void -MGASubsequentCPUToScreenTexture ( - ScrnInfoPtr pScrn, - int dstx, - int dsty, - int srcx, - int srcy, - int width, - int height -); - -extern CARD32 MGAAlphaTextureFormats[2]; -extern CARD32 MGATextureFormats[2]; - -#if PSZ == 8 -#include "mipict.h" -#include "dixstruct.h" - -CARD32 MGAAlphaTextureFormats[2] = {PICT_a8, 0}; -CARD32 MGATextureFormats[2] = {PICT_a8r8g8b8, 0}; - -static void -RemoveLinear (FBLinearPtr linear) -{ - MGAPtr pMga = (MGAPtr)(linear->devPrivate.ptr); - - pMga->LinearScratch = NULL; /* just lost our scratch */ -} - -static void -RenderCallback (ScrnInfoPtr pScrn) -{ - MGAPtr pMga = MGAPTR(pScrn); - - if((currentTime.milliseconds > pMga->RenderTime) && pMga->LinearScratch) { - xf86FreeOffscreenLinear(pMga->LinearScratch); - pMga->LinearScratch = NULL; - } - - if(!pMga->LinearScratch) - pMga->RenderCallback = NULL; -} - -#define RENDER_DELAY 15000 - -static Bool -AllocateLinear ( - ScrnInfoPtr pScrn, - int sizeNeeded -){ - MGAPtr pMga = MGAPTR(pScrn); - - pMga->RenderTime = currentTime.milliseconds + RENDER_DELAY; - pMga->RenderCallback = RenderCallback; - - if(pMga->LinearScratch) { - if(pMga->LinearScratch->size >= sizeNeeded) - return TRUE; - else { - if(xf86ResizeOffscreenLinear(pMga->LinearScratch, sizeNeeded)) - return TRUE; - - xf86FreeOffscreenLinear(pMga->LinearScratch); - pMga->LinearScratch = NULL; - } - } - - pMga->LinearScratch = xf86AllocateOffscreenLinear( - pScrn->pScreen, sizeNeeded, 32, - NULL, RemoveLinear, pMga); - - return (pMga->LinearScratch != NULL); -} - -static int -GetPowerOfTwo(int w) -{ - int Pof2 = 0; - int i = 12; - - while(--i) { - if(w & (1 << i)) { - Pof2 = i; - if(w & ((1 << i) - 1)) - Pof2++; - break; - } - } - return Pof2; -} - - -static int tex_padw, tex_padh; - -Bool -MGASetupForCPUToScreenAlphaTextureFaked ( - ScrnInfoPtr pScrn, - int op, - CARD16 red, - CARD16 green, - CARD16 blue, - CARD16 alpha, - int alphaType, - CARD8 *alphaPtr, - int alphaPitch, - int width, - int height, - int flags -){ - int log2w, log2h, i, pitch, sizeNeeded, offset; - MGAPtr pMga = MGAPTR(pScrn); - - if(op != PictOpOver) /* only one tested */ - return FALSE; - - if((width > 2048) || (height > 2048)) - return FALSE; - - log2w = GetPowerOfTwo(width); - log2h = GetPowerOfTwo(height); - - CHECK_DMA_QUIESCENT(pMga, pScrn); - - if(pMga->Overlay8Plus24) { - i = 0x00ffffff; - WAITFIFO(1); - SET_PLANEMASK(i); - } - - pitch = (width + 15) & ~15; - sizeNeeded = pitch * height; - if(pScrn->bitsPerPixel == 16) - sizeNeeded <<= 1; - - if(!AllocateLinear(pScrn, sizeNeeded)) - return FALSE; - - offset = pMga->LinearScratch->offset << 1; - if(pScrn->bitsPerPixel == 32) - offset <<= 1; - - if(pMga->AccelInfoRec->NeedToSync) - MGAStormSync(pScrn); - - XAA_888_plus_PICT_a8_to_8888( - (blue >> 8) | (green & 0xff00) | ((red & 0xff00) << 8), - alphaPtr, alphaPitch, (CARD32*)(pMga->FbStart + offset), - pitch, width, height); - - tex_padw = 1 << log2w; - tex_padh = 1 << log2h; - - WAITFIFO(15); - OUTREG(MGAREG_TMR0, (1 << 20) / tex_padw); /* sx inc */ - OUTREG(MGAREG_TMR1, 0); /* sy inc */ - OUTREG(MGAREG_TMR2, 0); /* tx inc */ - OUTREG(MGAREG_TMR3, (1 << 20) / tex_padh); /* ty inc */ - OUTREG(MGAREG_TMR4, 0x00000000); - OUTREG(MGAREG_TMR5, 0x00000000); - OUTREG(MGAREG_TMR8, 0x00010000); - OUTREG(MGAREG_TEXORG, offset); - OUTREG(MGAREG_TEXWIDTH, log2w | (((8 - log2w) & 63) << 9) | - ((width - 1) << 18)); - OUTREG(MGAREG_TEXHEIGHT, log2h | (((8 - log2h) & 63) << 9) | - ((height - 1) << 18)); - OUTREG(MGAREG_TEXCTL, 0x1A000106 | ((pitch & 0x07FF) << 9)); - OUTREG(MGAREG_TEXCTL2, 0x00000014); - OUTREG(MGAREG_DWGCTL, 0x000c7076); - OUTREG(MGAREG_TEXFILTER, 0x01e00020); - OUTREG(MGAREG_ALPHACTRL, 0x00000154); - - return TRUE; -} - -Bool -MGASetupForCPUToScreenAlphaTexture ( - ScrnInfoPtr pScrn, - int op, - CARD16 red, - CARD16 green, - CARD16 blue, - CARD16 alpha, - int alphaType, - CARD8 *alphaPtr, - int alphaPitch, - int width, - int height, - int flags -){ - int log2w, log2h, i, pitch, sizeNeeded, offset; - CARD8 *dst; - MGAPtr pMga = MGAPTR(pScrn); - - if(op != PictOpOver) /* only one tested */ - return FALSE; - - if((width > 2048) || (height > 2048)) - return FALSE; - - log2w = GetPowerOfTwo(width); - log2h = GetPowerOfTwo(height); - - CHECK_DMA_QUIESCENT(pMga, pScrn); - - if(pMga->Overlay8Plus24) { - i = 0x00ffffff; - WAITFIFO(1); - SET_PLANEMASK(i); - } - - pitch = (width + 15) & ~15; - sizeNeeded = (pitch * height) >> 1; - if(pScrn->bitsPerPixel == 32) - sizeNeeded >>= 1; - - if(!AllocateLinear(pScrn, sizeNeeded)) - return FALSE; - - offset = pMga->LinearScratch->offset << 1; - if(pScrn->bitsPerPixel == 32) - offset <<= 1; - - if(pMga->AccelInfoRec->NeedToSync) - MGAStormSync(pScrn); - - i = height; - dst = pMga->FbStart + offset; - while(i--) { - memcpy(dst, alphaPtr, width); - dst += pitch; - alphaPtr += alphaPitch; - } - - tex_padw = 1 << log2w; - tex_padh = 1 << log2h; - - - WAITFIFO(12); - OUTREG(MGAREG_DR4, red << 7); /* red start */ - OUTREG(MGAREG_DR6, 0); - OUTREG(MGAREG_DR7, 0); - OUTREG(MGAREG_DR8, green << 7); /* green start */ - OUTREG(MGAREG_DR10, 0); - OUTREG(MGAREG_DR11, 0); - OUTREG(MGAREG_DR12, blue << 7); /* blue start */ - OUTREG(MGAREG_DR14, 0); - OUTREG(MGAREG_DR15, 0); - OUTREG(MGAREG_ALPHASTART, alpha << 7); /* alpha start */ - OUTREG(MGAREG_ALPHAXINC, 0); - OUTREG(MGAREG_ALPHAYINC, 0); - - WAITFIFO(15); - OUTREG(MGAREG_TMR0, (1 << 20) / tex_padw); /* sx inc */ - OUTREG(MGAREG_TMR1, 0); /* sy inc */ - OUTREG(MGAREG_TMR2, 0); /* tx inc */ - OUTREG(MGAREG_TMR3, (1 << 20) / tex_padh); /* ty inc */ - OUTREG(MGAREG_TMR4, 0x00000000); - OUTREG(MGAREG_TMR5, 0x00000000); - OUTREG(MGAREG_TMR8, 0x00010000); - OUTREG(MGAREG_TEXORG, offset); - OUTREG(MGAREG_TEXWIDTH, log2w | (((8 - log2w) & 63) << 9) | - ((width - 1) << 18)); - OUTREG(MGAREG_TEXHEIGHT, log2h | (((8 - log2h) & 63) << 9) | - ((height - 1) << 18)); - OUTREG(MGAREG_TEXCTL, 0x3A000107 | ((pitch & 0x07FF) << 9)); - OUTREG(MGAREG_TEXCTL2, 0x00000014); - OUTREG(MGAREG_DWGCTL, 0x000c7076); - OUTREG(MGAREG_TEXFILTER, 0x01e00020); - OUTREG(MGAREG_ALPHACTRL, 0x02000151); - - return TRUE; -} - - -Bool -MGASetupForCPUToScreenTexture ( - ScrnInfoPtr pScrn, - int op, - int texType, - CARD8 *texPtr, - int texPitch, - int width, - int height, - int flags -){ - int log2w, log2h, i, pitch, sizeNeeded, offset; - MGAPtr pMga = MGAPTR(pScrn); - - if(op != PictOpOver) /* only one tested */ - return FALSE; - - if((width > 2048) || (height > 2048)) - return FALSE; - - log2w = GetPowerOfTwo(width); - log2h = GetPowerOfTwo(height); - - CHECK_DMA_QUIESCENT(pMga, pScrn); - - if(pMga->Overlay8Plus24) { - i = 0x00ffffff; - WAITFIFO(1); - SET_PLANEMASK(i); - } - - pitch = (width + 15) & ~15; - sizeNeeded = pitch * height; - if(pScrn->bitsPerPixel == 16) - sizeNeeded <<= 1; - - if(!AllocateLinear(pScrn, sizeNeeded)) - return FALSE; - - offset = pMga->LinearScratch->offset << 1; - if(pScrn->bitsPerPixel == 32) - offset <<= 1; - - if(pMga->AccelInfoRec->NeedToSync) - MGAStormSync(pScrn); - - { - CARD8 *dst = (CARD8*)(pMga->FbStart + offset); - i = height; - while(i--) { - memcpy(dst, texPtr, width << 2); - texPtr += texPitch; - dst += pitch << 2; - } - } - - tex_padw = 1 << log2w; - tex_padh = 1 << log2h; - - WAITFIFO(15); - OUTREG(MGAREG_TMR0, (1 << 20) / tex_padw); /* sx inc */ - OUTREG(MGAREG_TMR1, 0); /* sy inc */ - OUTREG(MGAREG_TMR2, 0); /* tx inc */ - OUTREG(MGAREG_TMR3, (1 << 20) / tex_padh); /* ty inc */ - OUTREG(MGAREG_TMR4, 0x00000000); - OUTREG(MGAREG_TMR5, 0x00000000); - OUTREG(MGAREG_TMR8, 0x00010000); - OUTREG(MGAREG_TEXORG, offset); - OUTREG(MGAREG_TEXWIDTH, log2w | (((8 - log2w) & 63) << 9) | - ((width - 1) << 18)); - OUTREG(MGAREG_TEXHEIGHT, log2h | (((8 - log2h) & 63) << 9) | - ((height - 1) << 18)); - OUTREG(MGAREG_TEXCTL, 0x1A000106 | ((pitch & 0x07FF) << 9)); - OUTREG(MGAREG_TEXCTL2, 0x00000014); - OUTREG(MGAREG_DWGCTL, 0x000c7076); - OUTREG(MGAREG_TEXFILTER, 0x01e00020); - OUTREG(MGAREG_ALPHACTRL, 0x00000151); - - return TRUE; -} -void -MGASubsequentCPUToScreenTexture ( - ScrnInfoPtr pScrn, - int dstx, - int dsty, - int srcx, - int srcy, - int width, - int height -){ - MGAPtr pMga = MGAPTR(pScrn); - - WAITFIFO(4); - OUTREG(MGAREG_TMR6, (srcx << 20) / tex_padw); - OUTREG(MGAREG_TMR7, (srcy << 20) / tex_padh); - OUTREG(MGAREG_FXBNDRY, ((dstx + width) << 16) | (dstx & 0xffff)); - OUTREG(MGAREG_YDSTLEN + MGAREG_EXEC, (dsty << 16) | height); - - pMga->AccelInfoRec->NeedToSync = TRUE; -} - - -#endif -#endif - Bool MGANAME(AccelInit)(ScreenPtr pScreen) { @@ -611,7 +189,8 @@ /* fallthrough */ case PCI_CHIP_MGAG200: case PCI_CHIP_MGAG200_PCI: - doRender = FALSE; + if (pMga->SecondCrtc == FALSE) + doRender = TRUE; pMga->AccelFlags = TRANSC_SOLID_FILL | TWO_PASS_COLOR_EXPAND; @@ -955,26 +534,48 @@ } #ifdef RENDER + if (!xf86ReturnOptValBool(pMga->Options, OPTION_RENDER_ACCEL, TRUE)) + doRender = FALSE; + if(doRender && ((pScrn->bitsPerPixel == 32) || (pScrn->bitsPerPixel == 16))) { if(pMga->Chipset == PCI_CHIP_MGAG400 || pMga->Chipset == PCI_CHIP_MGAG550) { infoPtr->CPUToScreenAlphaTextureFlags = XAA_RENDER_NO_TILE; - infoPtr->SetupForCPUToScreenAlphaTexture = + infoPtr->SetupForCPUToScreenAlphaTexture2 = MGASetupForCPUToScreenAlphaTexture; } else { infoPtr->CPUToScreenAlphaTextureFlags = XAA_RENDER_NO_TILE | XAA_RENDER_NO_SRC_ALPHA; - infoPtr->SetupForCPUToScreenAlphaTexture = + infoPtr->SetupForCPUToScreenAlphaTexture2 = MGASetupForCPUToScreenAlphaTextureFaked; } infoPtr->SubsequentCPUToScreenAlphaTexture = MGASubsequentCPUToScreenTexture; infoPtr->CPUToScreenAlphaTextureFormats = MGAAlphaTextureFormats; - infoPtr->SetupForCPUToScreenTexture = MGASetupForCPUToScreenTexture; + infoPtr->SetupForCPUToScreenTexture2 = MGASetupForCPUToScreenTexture; infoPtr->SubsequentCPUToScreenTexture = MGASubsequentCPUToScreenTexture; infoPtr->CPUToScreenTextureFlags = XAA_RENDER_NO_TILE; infoPtr->CPUToScreenTextureFormats = MGATextureFormats; + switch (pScrn->depth) { + case 15: + infoPtr->CPUToScreenAlphaTextureDstFormats = MGADstTextureFormats15; + infoPtr->CPUToScreenTextureDstFormats = MGADstTextureFormats15; + break; + case 16: + infoPtr->CPUToScreenAlphaTextureDstFormats = MGADstTextureFormats16; + infoPtr->CPUToScreenTextureDstFormats = MGADstTextureFormats16; + break; + case 24: + infoPtr->CPUToScreenAlphaTextureDstFormats = MGADstTextureFormats32; + infoPtr->CPUToScreenTextureDstFormats = MGADstTextureFormats32; + break; + } + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Render acceleration enabled\n"); + } else { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Render acceleration disabled\n"); + } + } } #endif --- /dev/null 2005-10-10 09:12:26.436265750 +0200 +++ mga_render.c 2005-10-09 18:11:04.000000000 +0200 @@ -0,0 +1,504 @@ +/************************************************************************** + +Copyright 2004 Eric Anholt +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 +on 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 +ERIC ANHOLT 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: + * Eric Anholt + */ + +#ifdef RENDER + +#include "mipict.h" +#include "dixstruct.h" + +#include "xaa.h" +#include "xaalocal.h" + +#include "mga.h" +#include "mga_reg.h" +#include "mga_macros.h" +#include "mga_render.h" + +struct blendinfo { + Bool dst_alpha; + Bool src_alpha; + CARD32 blend_cntl; +}; + +/* The first part of blend_cntl corresponds to Fa from the render "protocol" + * document, and the second part to Fb. + */ +static const struct blendinfo MgaBlendOp[] = { + + {0, 0, AC_src_zero | AC_dst_zero}, /* Clear */ + {0, 0, AC_src_one | AC_dst_zero}, /* Src */ + {0, 0, AC_src_zero | AC_dst_one}, /* Dst */ + {0, 1, AC_src_one | AC_dst_om_src_alpha}, /* Over */ + {1, 0, AC_src_om_dst_alpha | AC_dst_one}, /* OverReverse */ + {1, 0, AC_src_dst_alpha | AC_dst_zero}, /* In */ + {0, 1, AC_src_zero | AC_dst_src_alpha}, /* InReverse */ + {1, 0, AC_src_om_dst_alpha | AC_dst_zero}, /* Out */ + {0, 1, AC_src_zero | AC_dst_om_src_alpha}, /* OutReverse */ + {1, 1, AC_src_dst_alpha | AC_dst_om_src_alpha}, /* Atop */ + {1, 1, AC_src_om_dst_alpha | AC_dst_src_alpha}, /* AtopReverse */ + {1, 1, AC_src_om_dst_alpha | AC_dst_om_src_alpha}, /* Xor */ + {0, 0, AC_src_one | AC_dst_one}, /* Add */ + {1, 1, AC_src_src_alpha_sat | AC_dst_one}, /* Saturate */ + {0, 0, 0}, + {0, 0, 0}, + {0, 0, AC_src_zero | AC_dst_zero}, /* DisjointClear */ + {0, 0, AC_src_one | AC_dst_zero}, /* DisjointSrc */ + {0, 0, AC_src_zero | AC_dst_one}, /* DisjointDst */ + {0, 0, 0}, /* DisjointOver */ + {1, 1, AC_src_src_alpha_sat | AC_dst_one}, /* DisjointOverReverse */ + {0, 0, 0}, /* DisjointIn */ + {0, 0, 0}, /* DisjointInReverse */ + {1, 1, AC_src_src_alpha_sat | AC_dst_zero}, /* DisjointOut */ + {0, 0, 0}, /* DisjointOutReverse */ + {0, 0, 0}, /* DisjointAtop */ + {0, 0, 0}, /* DisjointAtopReverse */ + {0, 0, 0}, /* DisjointXor */ + {0, 0, 0}, + {0, 0, 0}, + {0, 0, 0}, + {0, 0, 0}, + {0, 0, AC_src_zero | AC_dst_zero}, /* ConjointClear */ + {0, 0, AC_src_one | AC_dst_zero}, /* ConjointSrc */ + {0, 0, AC_src_zero | AC_dst_one}, /* ConjointDst */ +}; +#define MgaOpMax (sizeof(MgaBlendOp) / sizeof(MgaBlendOp[0])) + +/* Returns an MGAREG_ALPHACTRL value, or 0 if the operation is not + * supported + */ +static CARD32 +MgaGetBlendCntl(CARD8 op, CARD32 dstFormat) +{ + CARD32 blend_cntl; + + if (op >= MgaOpMax || MgaBlendOp[op].blend_cntl == 0) + return 0; + + blend_cntl = MgaBlendOp[op].blend_cntl | AC_amode_alpha_channel; + + if (!PICT_FORMAT_A(dstFormat) && MgaBlendOp[op].dst_alpha) { + CARD32 srcblend = blend_cntl & ~AC_src_MASK; + + /* If there's no destination alpha channel, we need to wire the blending + * to treat the alpha channel as always 1. + */ + if (srcblend == AC_src_om_dst_alpha || srcblend == AC_src_src_alpha_sat) + blend_cntl = (blend_cntl & AC_src_MASK) | AC_src_zero; + else if (srcblend == AC_src_dst_alpha) + blend_cntl = (blend_cntl & AC_src_MASK) | AC_src_one; + } + + return blend_cntl; +} + +CARD32 MGAAlphaTextureFormats[] = {PICT_a8, 0}; +CARD32 MGATextureFormats[] = {PICT_a8r8g8b8, 0}; +CARD32 MGADstTextureFormats15[] = {PICT_x1r5g5b5, PICT_a1r5g5b5, 0}; +CARD32 MGADstTextureFormats16[] = {PICT_r5g6b5, 0}; +CARD32 MGADstTextureFormats32[] = {PICT_x8r8g8b8, PICT_a8r8g8b8, 0}; + +static void +RemoveLinear (FBLinearPtr linear) +{ + MGAPtr pMga = (MGAPtr)(linear->devPrivate.ptr); + + pMga->LinearScratch = NULL; /* just lost our scratch */ +} + +static void +RenderCallback (ScrnInfoPtr pScrn) +{ + MGAPtr pMga = MGAPTR(pScrn); + + if((currentTime.milliseconds > pMga->RenderTime) && pMga->LinearScratch) { + xf86FreeOffscreenLinear(pMga->LinearScratch); + pMga->LinearScratch = NULL; + } + + if(!pMga->LinearScratch) + pMga->RenderCallback = NULL; +} + +#define RENDER_DELAY 15000 + +static Bool +AllocateLinear ( + ScrnInfoPtr pScrn, + int sizeNeeded +){ + MGAPtr pMga = MGAPTR(pScrn); + + pMga->RenderTime = currentTime.milliseconds + RENDER_DELAY; + pMga->RenderCallback = RenderCallback; + + if(pMga->LinearScratch) { + if(pMga->LinearScratch->size >= sizeNeeded) + return TRUE; + else { + if(xf86ResizeOffscreenLinear(pMga->LinearScratch, sizeNeeded)) + return TRUE; + + xf86FreeOffscreenLinear(pMga->LinearScratch); + pMga->LinearScratch = NULL; + } + } + + pMga->LinearScratch = xf86AllocateOffscreenLinear( + pScrn->pScreen, sizeNeeded, 32, + NULL, RemoveLinear, pMga); + + return (pMga->LinearScratch != NULL); +} + +static int +GetPowerOfTwo(int w) +{ + int Pof2 = 0; + int i = 12; + + while(--i) { + if(w & (1 << i)) { + Pof2 = i; + if(w & ((1 << i) - 1)) + Pof2++; + break; + } + } + return Pof2; +} + +static int tex_padw, tex_padh; + +Bool +MGASetupForCPUToScreenAlphaTextureFaked ( + ScrnInfoPtr pScrn, + int op, + CARD16 red, + CARD16 green, + CARD16 blue, + CARD16 alpha, + CARD32 maskFormat, + CARD32 dstFormat, + CARD8 *alphaPtr, + int alphaPitch, + int width, + int height, + int flags +){ + int log2w, log2h, i, pitch, sizeNeeded, offset; + MGAPtr pMga = MGAPTR(pScrn); + CARD32 alphactrl; + + /* In the faked version, we're using the XAA combiner which doesn't do + * premultiplication, which the big table at the top requires. So, just + * support Over with a hardcoded alphactrl. + */ + if (op != PictOpOver) + return FALSE; + alphactrl = AC_amode_alpha_channel | AC_src_src_alpha | AC_dst_om_src_alpha; + + if((width > 2048) || (height > 2048)) + return FALSE; + + log2w = GetPowerOfTwo(width); + log2h = GetPowerOfTwo(height); + + CHECK_DMA_QUIESCENT(pMga, pScrn); + + if(pMga->Overlay8Plus24) { + i = 0x00ffffff; + WAITFIFO(1); + SET_PLANEMASK(i); + } + + pitch = (width + 15) & ~15; + sizeNeeded = pitch * height; + if(pScrn->bitsPerPixel == 16) + sizeNeeded <<= 1; + + if(!AllocateLinear(pScrn, sizeNeeded)) + return FALSE; + + offset = pMga->LinearScratch->offset << 1; + if(pScrn->bitsPerPixel == 32) + offset <<= 1; + + if(pMga->AccelInfoRec->NeedToSync) + MGAStormSync(pScrn); + + XAA_888_plus_PICT_a8_to_8888( + (blue >> 8) | (green & 0xff00) | ((red & 0xff00) << 8), + alphaPtr, alphaPitch, (CARD32*)(pMga->FbStart + offset), + pitch, width, height); + + tex_padw = 1 << log2w; + tex_padh = 1 << log2h; + + WAITFIFO(15); + OUTREG(MGAREG_TMR0, (1 << 20) / tex_padw); /* sx inc */ + OUTREG(MGAREG_TMR1, 0); /* sy inc */ + OUTREG(MGAREG_TMR2, 0); /* tx inc */ + OUTREG(MGAREG_TMR3, (1 << 20) / tex_padh); /* ty inc */ + OUTREG(MGAREG_TMR4, 0x00000000); + OUTREG(MGAREG_TMR5, 0x00000000); + OUTREG(MGAREG_TMR8, 0x00010000); + OUTREG(MGAREG_TEXORG, offset); + OUTREG(MGAREG_TEXWIDTH, log2w | (((8 - log2w) & 63) << 9) | + ((width - 1) << 18)); + OUTREG(MGAREG_TEXHEIGHT, log2h | (((8 - log2h) & 63) << 9) | + ((height - 1) << 18)); + OUTREG(MGAREG_TEXCTL, TMC_clampu_enable | TMC_clampv_enable | TMC_takey_1 | + ((pitch & 0x07FF) << 9)); + OUTREG(MGAREG_TEXCTL2, TMC_ckstransdis_enable | TMC_decaldis_enable); + OUTREG(MGAREG_DWGCTL, pMga->Atype[GXcopy] | MGADWG_SHIFTZERO | + MGADWG_SGNZERO | MGADWG_ARZERO | MGADWG_I | + MGADWG_TEXTURE_TRAP); + OUTREG(MGAREG_TEXFILTER, (0xf < TF_fthres_SHIFT) | TF_magfilter_bilin); + OUTREG(MGAREG_ALPHACTRL, 0x00000154); + + return TRUE; +} + +Bool +MGASetupForCPUToScreenAlphaTexture ( + ScrnInfoPtr pScrn, + int op, + CARD16 red, + CARD16 green, + CARD16 blue, + CARD16 alpha, + CARD32 maskFormat, + CARD32 dstFormat, + CARD8 *alphaPtr, + int alphaPitch, + int width, + int height, + int flags +){ + int log2w, log2h, i, pitch, sizeNeeded, offset; + CARD8 *dst; + MGAPtr pMga = MGAPTR(pScrn); + CARD32 alphactrl; + + alphactrl = MgaGetBlendCntl(op, dstFormat); + if (alphactrl == 0) + return FALSE; + + if((width > 2048) || (height > 2048)) + return FALSE; + + log2w = GetPowerOfTwo(width); + log2h = GetPowerOfTwo(height); + + CHECK_DMA_QUIESCENT(pMga, pScrn); + + if(pMga->Overlay8Plus24) { + i = 0x00ffffff; + WAITFIFO(1); + SET_PLANEMASK(i); + } + + pitch = (width + 15) & ~15; + sizeNeeded = (pitch * height) >> 1; + if(pScrn->bitsPerPixel == 32) + sizeNeeded >>= 1; + + if(!AllocateLinear(pScrn, sizeNeeded)) + return FALSE; + + offset = pMga->LinearScratch->offset << 1; + if(pScrn->bitsPerPixel == 32) + offset <<= 1; + + if(pMga->AccelInfoRec->NeedToSync) + MGAStormSync(pScrn); + + i = height; + dst = pMga->FbStart + offset; + while(i--) { + memcpy(dst, alphaPtr, width); + dst += pitch; + alphaPtr += alphaPitch; + } + + tex_padw = 1 << log2w; + tex_padh = 1 << log2h; + + + WAITFIFO(12); + OUTREG(MGAREG_DR4, red << 7); /* red start */ + OUTREG(MGAREG_DR6, 0); + OUTREG(MGAREG_DR7, 0); + OUTREG(MGAREG_DR8, green << 7); /* green start */ + OUTREG(MGAREG_DR10, 0); + OUTREG(MGAREG_DR11, 0); + OUTREG(MGAREG_DR12, blue << 7); /* blue start */ + OUTREG(MGAREG_DR14, 0); + OUTREG(MGAREG_DR15, 0); + OUTREG(MGAREG_ALPHASTART, alpha << 7); /* alpha start */ + OUTREG(MGAREG_ALPHAXINC, 0); + OUTREG(MGAREG_ALPHAYINC, 0); + + WAITFIFO(15); + OUTREG(MGAREG_TMR0, (1 << 20) / tex_padw); /* sx inc */ + OUTREG(MGAREG_TMR1, 0); /* sy inc */ + OUTREG(MGAREG_TMR2, 0); /* tx inc */ + OUTREG(MGAREG_TMR3, (1 << 20) / tex_padh); /* ty inc */ + OUTREG(MGAREG_TMR4, 0x00000000); + OUTREG(MGAREG_TMR5, 0x00000000); + OUTREG(MGAREG_TMR8, 0x00010000); + OUTREG(MGAREG_TEXORG, offset); + OUTREG(MGAREG_TEXWIDTH, log2w | (((8 - log2w) & 63) << 9) | + ((width - 1) << 18)); + OUTREG(MGAREG_TEXHEIGHT, log2h | (((8 - log2h) & 63) << 9) | + ((height - 1) << 18)); + OUTREG(MGAREG_TEXCTL, TMC_tmodulate_enable | TMC_clampu_enable | + TMC_clampv_enable | TMC_tpitchlin_enable | + TMC_tformat_tw8a | ((pitch & 0x07FF) << 9)); + OUTREG(MGAREG_TEXCTL2, TMC_ckstransdis_enable | TMC_decaldis_enable); + OUTREG(MGAREG_DWGCTL, pMga->Atype[GXcopy] | MGADWG_SHIFTZERO | + MGADWG_SGNZERO | MGADWG_ARZERO | MGADWG_I | + MGADWG_TEXTURE_TRAP); + OUTREG(MGAREG_TEXFILTER, (0xf < TF_fthres_SHIFT) | TF_magfilter_bilin); + OUTREG(MGAREG_ALPHACTRL, AC_alphasel_modulated | alphactrl); + + return TRUE; +} + + +Bool +MGASetupForCPUToScreenTexture ( + ScrnInfoPtr pScrn, + int op, + CARD32 srcFormat, + CARD32 dstFormat, + CARD8 *texPtr, + int texPitch, + int width, + int height, + int flags +){ + int log2w, log2h, i, pitch, sizeNeeded, offset; + MGAPtr pMga = MGAPTR(pScrn); + CARD32 alphactrl; + + alphactrl = MgaGetBlendCntl(op, dstFormat); + if (alphactrl == 0) + return FALSE; + + if((width > 2048) || (height > 2048)) + return FALSE; + + log2w = GetPowerOfTwo(width); + log2h = GetPowerOfTwo(height); + + CHECK_DMA_QUIESCENT(pMga, pScrn); + + if(pMga->Overlay8Plus24) { + i = 0x00ffffff; + WAITFIFO(1); + SET_PLANEMASK(i); + } + + pitch = (width + 15) & ~15; + sizeNeeded = pitch * height; + if(pScrn->bitsPerPixel == 16) + sizeNeeded <<= 1; + + if(!AllocateLinear(pScrn, sizeNeeded)) + return FALSE; + + offset = pMga->LinearScratch->offset << 1; + if(pScrn->bitsPerPixel == 32) + offset <<= 1; + + if(pMga->AccelInfoRec->NeedToSync) + MGAStormSync(pScrn); + + { + CARD8 *dst = (CARD8*)(pMga->FbStart + offset); + i = height; + while(i--) { + memcpy(dst, texPtr, width << 2); + texPtr += texPitch; + dst += pitch << 2; + } + } + + tex_padw = 1 << log2w; + tex_padh = 1 << log2h; + + WAITFIFO(15); + OUTREG(MGAREG_TMR0, (1 << 20) / tex_padw); /* sx inc */ + OUTREG(MGAREG_TMR1, 0); /* sy inc */ + OUTREG(MGAREG_TMR2, 0); /* tx inc */ + OUTREG(MGAREG_TMR3, (1 << 20) / tex_padh); /* ty inc */ + OUTREG(MGAREG_TMR4, 0x00000000); + OUTREG(MGAREG_TMR5, 0x00000000); + OUTREG(MGAREG_TMR8, 0x00010000); + OUTREG(MGAREG_TEXORG, offset); + OUTREG(MGAREG_TEXWIDTH, log2w | (((8 - log2w) & 63) << 9) | + ((width - 1) << 18)); + OUTREG(MGAREG_TEXHEIGHT, log2h | (((8 - log2h) & 63) << 9) | + ((height - 1) << 18)); + OUTREG(MGAREG_TEXCTL, TMC_clampu_enable | TMC_clampv_enable | + TMC_tpitchlin_enable | TMC_tformat_tw32 | + ((pitch & 0x07FF) << 9)); + OUTREG(MGAREG_TEXCTL2, TMC_ckstransdis_enable | TMC_decaldis_enable); + OUTREG(MGAREG_DWGCTL, pMga->Atype[GXcopy] | MGADWG_SHIFTZERO | + MGADWG_SGNZERO | MGADWG_ARZERO | MGADWG_I | + MGADWG_TEXTURE_TRAP); + OUTREG(MGAREG_TEXFILTER, (0xf < TF_fthres_SHIFT) | TF_magfilter_bilin); + OUTREG(MGAREG_ALPHACTRL, alphactrl); + + return TRUE; +} +void +MGASubsequentCPUToScreenTexture ( + ScrnInfoPtr pScrn, + int dstx, + int dsty, + int srcx, + int srcy, + int width, + int height +){ + MGAPtr pMga = MGAPTR(pScrn); + + WAITFIFO(4); + OUTREG(MGAREG_TMR6, (srcx << 20) / tex_padw); + OUTREG(MGAREG_TMR7, (srcy << 20) / tex_padh); + OUTREG(MGAREG_FXBNDRY, ((dstx + width) << 16) | (dstx & 0xffff)); + OUTREG(MGAREG_YDSTLEN + MGAREG_EXEC, (dsty << 16) | height); + + pMga->AccelInfoRec->NeedToSync = TRUE; +} + +#endif --- /dev/null 2005-10-10 09:12:26.436265750 +0200 +++ mga_render.h 2005-10-09 18:00:08.000000000 +0200 @@ -0,0 +1,94 @@ +/************************************************************************** + +Copyright 2004 Eric Anholt +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 +on 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 +ERIC ANHOLT 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: + * Eric Anholt + */ + +extern Bool +MGASetupForCPUToScreenAlphaTexture ( + ScrnInfoPtr pScrn, + int op, + CARD16 red, + CARD16 green, + CARD16 blue, + CARD16 alpha, + CARD32 maskFormat, + CARD32 dstFormat, + CARD8 *alphaPtr, + int alphaPitch, + int width, + int height, + int flags +); + +extern Bool +MGASetupForCPUToScreenAlphaTextureFaked ( + ScrnInfoPtr pScrn, + int op, + CARD16 red, + CARD16 green, + CARD16 blue, + CARD16 alpha, + CARD32 maskFormat, + CARD32 dstFormat, + CARD8 *alphaPtr, + int alphaPitch, + int width, + int height, + int flags +); + + +extern Bool +MGASetupForCPUToScreenTexture ( + ScrnInfoPtr pScrn, + int op, + CARD32 srcFormat, + CARD32 dstFormat, + CARD8 *texPtr, + int texPitch, + int width, + int height, + int flags +); + +extern void +MGASubsequentCPUToScreenTexture ( + ScrnInfoPtr pScrn, + int dstx, + int dsty, + int srcx, + int srcy, + int width, + int height +); + +extern CARD32 MGAAlphaTextureFormats[]; +extern CARD32 MGATextureFormats[]; +extern CARD32 MGADstTextureFormats15[]; +extern CARD32 MGADstTextureFormats16[]; +extern CARD32 MGADstTextureFormats32[];