📄 r128_accel.c
字号:
x11perf -line500 1024x768@76Hz 1024x768@76Hz 8bpp 32bpp not used: 39700.0/sec 34100.0/sec used: 47600.0/sec 36800.0/sec*/static void R128SubsequentSolidBresenhamLine(ScrnInfoPtr pScrn, int x, int y, int major, int minor, int err, int len, int octant){ R128InfoPtr info = R128PTR(pScrn); unsigned char *R128MMIO = info->MMIO; int flags = 0; if (octant & YMAJOR) flags |= R128_DST_Y_MAJOR; if (!(octant & XDECREASING)) flags |= R128_DST_X_DIR_LEFT_TO_RIGHT; if (!(octant & YDECREASING)) flags |= R128_DST_Y_DIR_TOP_TO_BOTTOM; R128WaitForFifo(pScrn, 6); OUTREG(R128_DP_CNTL_XDIR_YDIR_YMAJOR, flags); OUTREG(R128_DST_Y_X, (y << 16) | x); OUTREG(R128_DST_BRES_ERR, err); OUTREG(R128_DST_BRES_INC, minor); OUTREG(R128_DST_BRES_DEC, -major); OUTREG(R128_DST_BRES_LNTH, len);}/* Subsequent XAA solid horizontal and vertical lines 1024x768@76Hz 8bpp Without With x11perf -hseg500 87600.0/sec 798000.0/sec x11perf -vseg500 38100.0/sec 38000.0/sec*/static void R128SubsequentSolidHorVertLine(ScrnInfoPtr pScrn, int x, int y, int len, int dir ){ R128InfoPtr info = R128PTR(pScrn); unsigned char *R128MMIO = info->MMIO; R128WaitForFifo(pScrn, 1); OUTREG(R128_DP_CNTL, (R128_DST_X_LEFT_TO_RIGHT | R128_DST_Y_TOP_TO_BOTTOM)); if (dir == DEGREES_0) { R128SubsequentSolidFillRect(pScrn, x, y, len, 1); } else { R128SubsequentSolidFillRect(pScrn, x, y, 1, len); }}/* Setup for XAA dashed lines. Tests: xtest CH05/stdshs, XFree86/drwln NOTE: Since we can only accelerate lines with power-of-2 patterns of length <= 32, these x11perf numbers are not representative of the speed-up on appropriately-sized patterns. 1024x768@76Hz 8bpp Without With x11perf -dseg100 218000.0/sec 222000.0/sec x11perf -dline100 215000.0/sec 221000.0/sec x11perf -ddline100 178000.0/sec 180000.0/sec*/static void R128SetupForDashedLine(ScrnInfoPtr pScrn, int fg, int bg, int rop, unsigned int planemask, int length, unsigned char *pattern){ R128InfoPtr info = R128PTR(pScrn); unsigned char *R128MMIO = info->MMIO; CARD32 pat = *(CARD32 *)(pointer)pattern;#if X_BYTE_ORDER == X_LITTLE_ENDIAN# define PAT_SHIFT(pat,n) pat << n#else# define PAT_SHIFT(pat,n) pat >> n#endif switch (length) { case 2: pat |= PAT_SHIFT(pat,2); /* fall through */ case 4: pat |= PAT_SHIFT(pat,4); /* fall through */ case 8: pat |= PAT_SHIFT(pat,8); /* fall through */ case 16: pat |= PAT_SHIFT(pat,16); } R128WaitForFifo(pScrn, 5); OUTREG(R128_DP_GUI_MASTER_CNTL, (info->dp_gui_master_cntl | (bg == -1 ? R128_GMC_BRUSH_32x1_MONO_FG_LA : R128_GMC_BRUSH_32x1_MONO_FG_BG) | R128_ROP[rop].pattern | R128_GMC_BYTE_LSB_TO_MSB)); OUTREG(R128_DP_WRITE_MASK, planemask); OUTREG(R128_DP_BRUSH_FRGD_CLR, fg); OUTREG(R128_DP_BRUSH_BKGD_CLR, bg); OUTREG(R128_BRUSH_DATA0, pat);}/* Subsequent XAA dashed line. */static void R128SubsequentDashedBresenhamLine(ScrnInfoPtr pScrn, int x, int y, int major, int minor, int err, int len, int octant, int phase){ R128InfoPtr info = R128PTR(pScrn); unsigned char *R128MMIO = info->MMIO; int flags = 0; if (octant & YMAJOR) flags |= R128_DST_Y_MAJOR; if (!(octant & XDECREASING)) flags |= R128_DST_X_DIR_LEFT_TO_RIGHT; if (!(octant & YDECREASING)) flags |= R128_DST_Y_DIR_TOP_TO_BOTTOM; R128WaitForFifo(pScrn, 7); OUTREG(R128_DP_CNTL_XDIR_YDIR_YMAJOR, flags); OUTREG(R128_DST_Y_X, (y << 16) | x); OUTREG(R128_BRUSH_Y_X, (phase << 16) | phase); OUTREG(R128_DST_BRES_ERR, err); OUTREG(R128_DST_BRES_INC, minor); OUTREG(R128_DST_BRES_DEC, -major); OUTREG(R128_DST_BRES_LNTH, len);}#if R128_TRAPEZOIDS /* This doesn't work. Except in the lower-left quadrant, all of the pixel errors appear to be because eL and eR are not correct. Drawing from right to left doesn't help. Be aware that the non-_SUB registers set the sub-pixel values to 0.5 (0x08), which isn't what XAA wants. *//* Subsequent XAA SolidFillTrap. XAA always passes data that assumes we fill from top to bottom, so dyL and dyR are always non-negative. */static void R128SubsequentSolidFillTrap(ScrnInfoPtr pScrn, int y, int h, int left, int dxL, int dyL, int eL, int right, int dxR, int dyR, int eR){ R128InfoPtr info = R128PTR(pScrn); unsigned char *R128MMIO = info->MMIO; int flags = 0; int Lymajor = 0; int Rymajor = 0; int origdxL = dxL; int origdxR = dxR; R128TRACE(("Trap %d %d; L %d %d %d %d; R %d %d %d %d\n", y, h, left, dxL, dyL, eL, right, dxR, dyR, eR)); if (dxL < 0) dxL = -dxL; else flags |= (1 << 0) /* | (1 << 8) */; if (dxR < 0) dxR = -dxR; else flags |= (1 << 6); R128WaitForFifo(pScrn, 11);#if 1 OUTREG(R128_DP_CNTL, flags | (1 << 1) | (1 << 7)); OUTREG(R128_DST_Y_SUB, ((y) << 4) | 0x0 ); OUTREG(R128_DST_X_SUB, ((left) << 4)|0x0); OUTREG(R128_TRAIL_BRES_ERR, eR-dxR); OUTREG(R128_TRAIL_BRES_INC, dxR); OUTREG(R128_TRAIL_BRES_DEC, -dyR); OUTREG(R128_TRAIL_X_SUB, ((right) << 4) | 0x0); OUTREG(R128_LEAD_BRES_ERR, eL-dxL); OUTREG(R128_LEAD_BRES_INC, dxL); OUTREG(R128_LEAD_BRES_DEC, -dyL); OUTREG(R128_LEAD_BRES_LNTH_SUB, ((h) << 4) | 0x00);#else OUTREG(R128_DP_CNTL, flags | (1 << 1) ); OUTREG(R128_DST_Y_SUB, (y << 4)); OUTREG(R128_DST_X_SUB, (right << 4)); OUTREG(R128_TRAIL_BRES_ERR, eL); OUTREG(R128_TRAIL_BRES_INC, dxL); OUTREG(R128_TRAIL_BRES_DEC, -dyL); OUTREG(R128_TRAIL_X_SUB, (left << 4) | 0); OUTREG(R128_LEAD_BRES_ERR, eR); OUTREG(R128_LEAD_BRES_INC, dxR); OUTREG(R128_LEAD_BRES_DEC, -dyR); OUTREG(R128_LEAD_BRES_LNTH_SUB, h << 4);#endif}#endif/* Setup for XAA screen-to-screen copy. Tests: xtest CH06/fllrctngl (also tests transparency).*/static void R128SetupForScreenToScreenCopy(ScrnInfoPtr pScrn, int xdir, int ydir, int rop, unsigned int planemask, int trans_color){ R128InfoPtr info = R128PTR(pScrn); unsigned char *R128MMIO = info->MMIO; info->xdir = xdir; info->ydir = ydir; R128WaitForFifo(pScrn, 3); OUTREG(R128_DP_GUI_MASTER_CNTL, (info->dp_gui_master_cntl | R128_GMC_BRUSH_SOLID_COLOR | R128_GMC_SRC_DATATYPE_COLOR | R128_ROP[rop].rop | R128_DP_SRC_SOURCE_MEMORY)); OUTREG(R128_DP_WRITE_MASK, planemask); OUTREG(R128_DP_CNTL, ((xdir >= 0 ? R128_DST_X_LEFT_TO_RIGHT : 0) | (ydir >= 0 ? R128_DST_Y_TOP_TO_BOTTOM : 0))); if ((trans_color != -1) || (info->XAAForceTransBlit == TRUE)) { /* Set up for transparency */ R128WaitForFifo(pScrn, 3); OUTREG(R128_CLR_CMP_CLR_SRC, trans_color); OUTREG(R128_CLR_CMP_MASK, R128_CLR_CMP_MSK); OUTREG(R128_CLR_CMP_CNTL, (R128_SRC_CMP_NEQ_COLOR | R128_CLR_CMP_SRC_SOURCE)); }}/* Subsequent XAA screen-to-screen copy. */static void R128SubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, int xa, int ya, int xb, int yb, int w, int h){ R128InfoPtr info = R128PTR(pScrn); unsigned char *R128MMIO = info->MMIO; if (info->xdir < 0) xa += w - 1, xb += w - 1; if (info->ydir < 0) ya += h - 1, yb += h - 1; R128WaitForFifo(pScrn, 3); OUTREG(R128_SRC_Y_X, (ya << 16) | xa); OUTREG(R128_DST_Y_X, (yb << 16) | xb); OUTREG(R128_DST_HEIGHT_WIDTH, (h << 16) | w);}/* Setup for XAA mono 8x8 pattern color expansion. Patterns with transparency use `bg == -1'. This routine is only used if the XAA pixmap cache is turned on. Tests: xtest XFree86/fllrctngl (no other test will test this routine with both transparency and non-transparency) 1024x768@76Hz 8bpp Without With x11perf -srect100 38600.0/sec 85700.0/sec x11perf -osrect100 38600.0/sec 85700.0/sec*/static void R128SetupForMono8x8PatternFill(ScrnInfoPtr pScrn, int patternx, int patterny, int fg, int bg, int rop, unsigned int planemask){ R128InfoPtr info = R128PTR(pScrn); unsigned char *R128MMIO = info->MMIO; R128WaitForFifo(pScrn, 6); OUTREG(R128_DP_GUI_MASTER_CNTL, (info->dp_gui_master_cntl | (bg == -1 ? R128_GMC_BRUSH_8X8_MONO_FG_LA : R128_GMC_BRUSH_8X8_MONO_FG_BG) | R128_ROP[rop].pattern | R128_GMC_BYTE_LSB_TO_MSB)); OUTREG(R128_DP_WRITE_MASK, planemask); OUTREG(R128_DP_BRUSH_FRGD_CLR, fg); OUTREG(R128_DP_BRUSH_BKGD_CLR, bg); OUTREG(R128_BRUSH_DATA0, patternx); OUTREG(R128_BRUSH_DATA1, patterny);}/* Subsequent XAA 8x8 pattern color expansion. Because they are used in the setup function, `patternx' and `patterny' are not used here. */static void R128SubsequentMono8x8PatternFillRect(ScrnInfoPtr pScrn, int patternx, int patterny, int x, int y, int w, int h){ R128InfoPtr info = R128PTR(pScrn); unsigned char *R128MMIO = info->MMIO; R128WaitForFifo(pScrn, 3); OUTREG(R128_BRUSH_Y_X, (patterny << 8) | patternx); OUTREG(R128_DST_Y_X, (y << 16) | x); OUTREG(R128_DST_HEIGHT_WIDTH, (h << 16) | w);}#if 0/* Setup for XAA color 8x8 pattern fill. Tests: xtest XFree86/fllrctngl (with Mono8x8PatternFill off)*/static void R128SetupForColor8x8PatternFill(ScrnInfoPtr pScrn, int patx, int paty, int rop, unsigned int planemask, int trans_color){ R128InfoPtr info = R128PTR(pScrn); unsigned char *R128MMIO = info->MMIO; R128TRACE(("Color8x8 %d %d %d\n", trans_color, patx, paty)); R128WaitForFifo(pScrn, 2); OUTREG(R128_DP_GUI_MASTER_CNTL, (info->dp_gui_master_cntl | R128_GMC_BRUSH_8x8_COLOR | R128_GMC_SRC_DATATYPE_COLOR | R128_ROP[rop].rop | R128_DP_SRC_SOURCE_MEMORY)); OUTREG(R128_DP_WRITE_MASK, planemask); if (trans_color != -1) { /* Set up for transparency */ R128WaitForFifo(pScrn, 3); OUTREG(R128_CLR_CMP_CLR_SRC, trans_color); OUTREG(R128_CLR_CMP_MASK, R128_CLR_CMP_MSK); OUTREG(R128_CLR_CMP_CNTL, (R128_SRC_CMP_NEQ_COLOR | R128_CLR_CMP_SRC_SOURCE)); }}/* Subsequent XAA 8x8 pattern color expansion. */static void R128SubsequentColor8x8PatternFillRect( ScrnInfoPtr pScrn, int patx, int paty, int x, int y, int w, int h){ R128InfoPtr info = R128PTR(pScrn); unsigned char *R128MMIO = info->MMIO; R128TRACE(("Color8x8 %d,%d %d,%d %d %d\n", patx, paty, x, y, w, h)); R128WaitForFifo(pScrn, 3); OUTREG(R128_SRC_Y_X, (paty << 16) | patx); OUTREG(R128_DST_Y_X, (y << 16) | x); OUTREG(R128_DST_HEIGHT_WIDTH, (h << 16) | w);}#endif/* Setup for XAA indirect CPU-to-screen color expansion (indirect). Because of how the scratch buffer is initialized, this is really a mainstore-to-screen color expansion. Transparency is supported when `bg == -1'. x11perf -ftext (pure indirect): 1024x768@76Hz 1024x768@76Hz 8bpp 32bpp not used: 685000.0/sec 794000.0/sec used: 1070000.0/sec 1080000.0/sec We could improve this indirect routine by about 10% if the hardware could accept DWORD padded scanlines, or if XAA could provide bit-packed data. We might also be able to move to a direct routine if there were more HOST_DATA registers. Implementing the hybrid indirect/direct scheme improved performance in a few areas: 1024x768@76 8bpp Indirect Hybrid x11perf -oddsrect10 50100.0/sec 71700.0/sec x11perf -oddsrect100 4240.0/sec 6660.0/sec x11perf -bigsrect10 50300.0/sec 71100.0/sec x11perf -bigsrect100 4190.0/sec 6800.0/sec x11perf -polytext 584000.0/sec 714000.0/sec x11perf -polytext16 154000.0/sec 172000.0/sec x11perf -seg1 1780000.0/sec 1880000.0/sec x11perf -copyplane10 42900.0/sec 58300.0/sec x11perf -copyplane100 4400.0/sec 6710.0/sec x11perf -putimagexy10 5090.0/sec 6670.0/sec x11perf -putimagexy100 424.0/sec 575.0/sec 1024x768@76 -depth 24 -fbbpp 32 Indirect Hybrid x11perf -oddsrect100 4240.0/sec 6670.0/sec x11perf -bigsrect100 4190.0/sec 6800.0/sec x11perf -polytext 585000.0/sec 719000.0/sec
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -