📄 radeon_accelfuncs.c
字号:
FUNC_NAME(RADEONSetupForScanlineImageWrite)(ScrnInfoPtr pScrn, int rop, unsigned int planemask, int trans_color, int bpp, int depth){ RADEONInfoPtr info = RADEONPTR(pScrn); ACCEL_PREAMBLE(); info->scanline_bpp = bpp; /* Save for later clipping */ info->dp_gui_master_cntl_clip = (info->dp_gui_master_cntl | RADEON_GMC_DST_CLIPPING | RADEON_GMC_BRUSH_NONE | RADEON_GMC_SRC_DATATYPE_COLOR | RADEON_ROP[rop].rop | RADEON_GMC_BYTE_MSB_TO_LSB | RADEON_DP_SRC_SOURCE_HOST_DATA);#ifdef ACCEL_MMIO#if X_BYTE_ORDER == X_LITTLE_ENDIAN BEGIN_ACCEL(2);#else BEGIN_ACCEL(3); if (bpp == 16) OUT_ACCEL_REG(RADEON_RBBM_GUICNTL, RADEON_HOST_DATA_SWAP_16BIT); else if (bpp == 32) OUT_ACCEL_REG(RADEON_RBBM_GUICNTL, RADEON_HOST_DATA_SWAP_32BIT); else OUT_ACCEL_REG(RADEON_RBBM_GUICNTL, RADEON_HOST_DATA_SWAP_NONE);#endif OUT_ACCEL_REG(RADEON_DP_GUI_MASTER_CNTL, info->dp_gui_master_cntl_clip);#else /* ACCEL_CP */#if X_BYTE_ORDER == X_LITTLE_ENDIAN BEGIN_ACCEL(1);#else if (info->ChipFamily < CHIP_FAMILY_R300) { BEGIN_ACCEL(2); if (bpp == 16) OUT_ACCEL_REG(RADEON_RBBM_GUICNTL, RADEON_HOST_DATA_SWAP_HDW); else OUT_ACCEL_REG(RADEON_RBBM_GUICNTL, RADEON_HOST_DATA_SWAP_NONE); } else BEGIN_ACCEL(1);#endif#endif OUT_ACCEL_REG(RADEON_DP_WRITE_MASK, planemask); FINISH_ACCEL(); info->trans_color = trans_color; FUNC_NAME(RADEONSetTransparency)(pScrn, trans_color);}/* Subsequent XAA indirect image write. This is only called once for * each rectangle. */static voidFUNC_NAME(RADEONSubsequentScanlineImageWriteRect)(ScrnInfoPtr pScrn, int x, int y, int w, int h, int skipleft){ RADEONInfoPtr info = RADEONPTR(pScrn);#ifdef ACCEL_MMIO int shift = 0; /* 32bpp */ ACCEL_PREAMBLE(); if (pScrn->bitsPerPixel == 8) shift = 3; else if (pScrn->bitsPerPixel == 16) shift = 1; info->scanline_h = h; info->scanline_words = (w * info->scanline_bpp + 31) >> 5;#ifdef __alpha__ /* Always use indirect for Alpha */ if (0)#else if ((info->scanline_words * h) <= 9)#endif { /* Turn on direct for less than 9 dword colour expansion */ info->scratch_buffer[0] = (unsigned char *)(ADDRREG(RADEON_HOST_DATA_LAST) - (info->scanline_words - 1)); info->scanline_direct = 1; } else { /* Use indirect for anything else */ info->scratch_buffer[0] = info->scratch_save; info->scanline_direct = 0; } BEGIN_ACCEL(5 + (info->scanline_direct ? (info->scanline_words * h) : 0)); OUT_ACCEL_REG(RADEON_DST_PITCH_OFFSET, info->dst_pitch_offset | ((info->tilingEnabled && (y <= pScrn->virtualY)) ? RADEON_DST_TILE_MACRO : 0)); OUT_ACCEL_REG(RADEON_SC_TOP_LEFT, (y << 16) | ((x+skipleft) & 0xffff)); OUT_ACCEL_REG(RADEON_SC_BOTTOM_RIGHT, ((y+h) << 16) | ((x+w) & 0xffff)); OUT_ACCEL_REG(RADEON_DST_Y_X, (y << 16) | (x & 0xffff)); /* Have to pad the width here and use clipping engine */ OUT_ACCEL_REG(RADEON_DST_HEIGHT_WIDTH, (h << 16) | ((w + shift) & ~shift)); FINISH_ACCEL();#else /* ACCEL_CP */ int pad = 0; /* 32bpp */ if (pScrn->bitsPerPixel == 8) pad = 3; else if (pScrn->bitsPerPixel == 16) pad = 1; info->scanline_x = x; info->scanline_y = y; /* Have to pad the width here and use clipping engine */ info->scanline_w = (w + pad) & ~pad; info->scanline_h = h; info->scanline_x1clip = x + skipleft; info->scanline_x2clip = x + w; info->scanline_words = (w * info->scanline_bpp + 31) / 32; info->scanline_hpass = min(h,(CP_BUFSIZE/info->scanline_words)); RADEONCPScanlinePacket(pScrn, 0);#endif}/* Set up the clipping rectangle */static voidFUNC_NAME(RADEONSetClippingRectangle)(ScrnInfoPtr pScrn, int xa, int ya, int xb, int yb){ RADEONInfoPtr info = RADEONPTR(pScrn); unsigned long tmp1 = 0; unsigned long tmp2 = 0; ACCEL_PREAMBLE(); if (xa < 0) { tmp1 = (-xa) & 0x3fff; tmp1 |= RADEON_SC_SIGN_MASK_LO; } else { tmp1 = xa; } if (ya < 0) { tmp1 |= (((-ya) & 0x3fff) << 16); tmp1 |= RADEON_SC_SIGN_MASK_HI; } else { tmp1 |= (ya << 16); } xb++; yb++; if (xb < 0) { tmp2 = (-xb) & 0x3fff; tmp2 |= RADEON_SC_SIGN_MASK_LO; } else { tmp2 = xb; } if (yb < 0) { tmp2 |= (((-yb) & 0x3fff) << 16); tmp2 |= RADEON_SC_SIGN_MASK_HI; } else { tmp2 |= (yb << 16); } BEGIN_ACCEL(3); OUT_ACCEL_REG(RADEON_DP_GUI_MASTER_CNTL, (info->dp_gui_master_cntl_clip | RADEON_GMC_DST_CLIPPING)); OUT_ACCEL_REG(RADEON_SC_TOP_LEFT, tmp1); OUT_ACCEL_REG(RADEON_SC_BOTTOM_RIGHT, tmp2); FINISH_ACCEL(); FUNC_NAME(RADEONSetTransparency)(pScrn, info->trans_color);}/* Disable the clipping rectangle */static voidFUNC_NAME(RADEONDisableClipping)(ScrnInfoPtr pScrn){ RADEONInfoPtr info = RADEONPTR(pScrn); ACCEL_PREAMBLE(); BEGIN_ACCEL(3); OUT_ACCEL_REG(RADEON_DP_GUI_MASTER_CNTL, info->dp_gui_master_cntl_clip); OUT_ACCEL_REG(RADEON_SC_TOP_LEFT, 0); OUT_ACCEL_REG(RADEON_SC_BOTTOM_RIGHT, (RADEON_DEFAULT_SC_RIGHT_MAX | RADEON_DEFAULT_SC_BOTTOM_MAX)); FINISH_ACCEL(); FUNC_NAME(RADEONSetTransparency)(pScrn, info->trans_color);}voidFUNC_NAME(RADEONAccelInit)(ScreenPtr pScreen, XAAInfoRecPtr a){ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; RADEONInfoPtr info = RADEONPTR(pScrn); a->Flags = (PIXMAP_CACHE | OFFSCREEN_PIXMAPS | LINEAR_FRAMEBUFFER); /* Sync */ a->Sync = FUNC_NAME(RADEONWaitForIdle); /* Solid Filled Rectangle */ a->PolyFillRectSolidFlags = 0; a->SetupForSolidFill = FUNC_NAME(RADEONSetupForSolidFill); a->SubsequentSolidFillRect = FUNC_NAME(RADEONSubsequentSolidFillRect); /* Screen-to-screen Copy */ a->ScreenToScreenCopyFlags = 0; a->SetupForScreenToScreenCopy = FUNC_NAME(RADEONSetupForScreenToScreenCopy); a->SubsequentScreenToScreenCopy = FUNC_NAME(RADEONSubsequentScreenToScreenCopy); /* Mono 8x8 Pattern Fill (Color Expand) */ a->SetupForMono8x8PatternFill = FUNC_NAME(RADEONSetupForMono8x8PatternFill); a->SubsequentMono8x8PatternFillRect = FUNC_NAME(RADEONSubsequentMono8x8PatternFillRect); a->Mono8x8PatternFillFlags = (HARDWARE_PATTERN_PROGRAMMED_BITS | HARDWARE_PATTERN_PROGRAMMED_ORIGIN | HARDWARE_PATTERN_SCREEN_ORIGIN);#if X_BYTE_ORDER == X_LITTLE_ENDIAN if (info->ChipFamily >= CHIP_FAMILY_RV200) a->Mono8x8PatternFillFlags |= BIT_ORDER_IN_BYTE_MSBFIRST; else a->Mono8x8PatternFillFlags |= BIT_ORDER_IN_BYTE_LSBFIRST;#else a->Mono8x8PatternFillFlags |= BIT_ORDER_IN_BYTE_LSBFIRST;#endif /* Indirect CPU-To-Screen Color Expand */ /* RADEON gets upset, when using HOST provided data without a source rop. To show run 'xtest's drwarc. */ a->ScanlineCPUToScreenColorExpandFillFlags = (LEFT_EDGE_CLIPPING | ROP_NEEDS_SOURCE | LEFT_EDGE_CLIPPING_NEGATIVE_X); a->NumScanlineColorExpandBuffers = 1; a->ScanlineColorExpandBuffers = info->scratch_buffer; if (!info->scratch_save) info->scratch_save = xalloc(((pScrn->virtualX+31)/32*4) + (pScrn->virtualX * info->CurrentLayout.pixel_bytes)); info->scratch_buffer[0] = info->scratch_save; a->SetupForScanlineCPUToScreenColorExpandFill = FUNC_NAME(RADEONSetupForScanlineCPUToScreenColorExpandFill); a->SubsequentScanlineCPUToScreenColorExpandFill = FUNC_NAME(RADEONSubsequentScanlineCPUToScreenColorExpandFill); a->SubsequentColorExpandScanline = FUNC_NAME(RADEONSubsequentScanline); /* Solid Lines */ a->SetupForSolidLine = FUNC_NAME(RADEONSetupForSolidLine); a->SubsequentSolidHorVertLine = FUNC_NAME(RADEONSubsequentSolidHorVertLine);#ifdef XFree86LOADER if (info->xaaReq.minorversion >= 1) {#endif /* RADEON only supports 14 bits for lines and clipping and only * draws lines that are completely on-screen correctly. This will * cause display corruption problem in the cases when out-of-range * commands are issued, like when dimming screen during GNOME logout * in dual-head setup. Solid and dashed lines are therefore limited * to the virtual screen. */ a->SolidLineFlags = LINE_LIMIT_COORDS; a->SolidLineLimits.x1 = 0; a->SolidLineLimits.y1 = 0; a->SolidLineLimits.x2 = pScrn->virtualX-1; a->SolidLineLimits.y2 = pScrn->virtualY-1; /* Call miSetZeroLineBias() to have mi/mfb/fb routines match hardware accel two point lines */ miSetZeroLineBias(pScreen, (OCTANT5 | OCTANT6 | OCTANT7 | OCTANT8)); a->SubsequentSolidTwoPointLine = FUNC_NAME(RADEONSubsequentSolidTwoPointLine); /* Disabled on RV200 and newer because it does not pass XTest */ if (info->ChipFamily < CHIP_FAMILY_RV200) { a->SetupForDashedLine = FUNC_NAME(RADEONSetupForDashedLine); a->SubsequentDashedTwoPointLine = FUNC_NAME(RADEONSubsequentDashedTwoPointLine); a->DashPatternMaxLength = 32; /* ROP3 doesn't seem to work properly for dashedline with GXinvert */ a->DashedLineFlags = (LINE_PATTERN_LSBFIRST_LSBJUSTIFIED | LINE_PATTERN_POWER_OF_2_ONLY | LINE_LIMIT_COORDS | ROP_NEEDS_SOURCE); a->DashedLineLimits.x1 = 0; a->DashedLineLimits.y1 = 0; a->DashedLineLimits.x2 = pScrn->virtualX-1; a->DashedLineLimits.y2 = pScrn->virtualY-1; }#ifdef XFree86LOADER } else { xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "libxaa too old, can't accelerate TwoPoint lines\n"); }#endif /* Clipping, note that without this, all line accelerations will * not be called */ a->SetClippingRectangle = FUNC_NAME(RADEONSetClippingRectangle); a->DisableClipping = FUNC_NAME(RADEONDisableClipping); a->ClippingFlags = (HARDWARE_CLIP_SOLID_LINE | HARDWARE_CLIP_DASHED_LINE /* | HARDWARE_CLIP_SOLID_FILL -- seems very slow with this on */ | HARDWARE_CLIP_MONO_8x8_FILL | HARDWARE_CLIP_SCREEN_TO_SCREEN_COPY); if (xf86IsEntityShared(info->pEnt->index)) { /* If there are more than one devices sharing this entity, we * have to assign this call back, otherwise the XAA will be * disabled */ if (xf86GetNumEntityInstances(info->pEnt->index) > 1) a->RestoreAccelState = FUNC_NAME(RADEONRestoreAccelState); } /* ImageWrite */ a->NumScanlineImageWriteBuffers = 1; a->ScanlineImageWriteBuffers = info->scratch_buffer; a->SetupForScanlineImageWrite = FUNC_NAME(RADEONSetupForScanlineImageWrite); a->SubsequentScanlineImageWriteRect = FUNC_NAME(RADEONSubsequentScanlineImageWriteRect); a->SubsequentImageWriteScanline = FUNC_NAME(RADEONSubsequentScanline); a->ScanlineImageWriteFlags = (CPU_TRANSFER_PAD_DWORD#ifdef ACCEL_MMIO /* Performance tests show that we shouldn't use GXcopy * for uploads as a memcpy is faster */ | NO_GXCOPY#endif /* RADEON gets upset, when using HOST provided data * without a source rop. To show run 'xtest's ptimg */ | ROP_NEEDS_SOURCE | SCANLINE_PAD_DWORD | LEFT_EDGE_CLIPPING | LEFT_EDGE_CLIPPING_NEGATIVE_X);#if 0 /* Color 8x8 Pattern Fill */ a->SetupForColor8x8PatternFill = FUNC_NAME(RADEONSetupForColor8x8PatternFill); a->SubsequentColor8x8PatternFillRect = FUNC_NAME(RADEONSubsequentColor8x8PatternFillRect); a->Color8x8PatternFillFlags = (HARDWARE_PATTERN_PROGRAMMED_ORIGIN | HARDWARE_PATTERN_SCREEN_ORIGIN | BIT_ORDER_IN_BYTE_LSBFIRST);#endif#ifdef RENDER if (info->RenderAccel#ifdef XFree86LOADER && info->xaaReq.minorversion >= 2#endif ) { a->CPUToScreenAlphaTextureFlags = XAA_RENDER_POWER_OF_2_TILE_ONLY; a->CPUToScreenAlphaTextureFormats = RADEONTextureFormats; a->CPUToScreenAlphaTextureDstFormats = RADEONDstFormats; a->CPUToScreenTextureFlags = XAA_RENDER_POWER_OF_2_TILE_ONLY; a->CPUToScreenTextureFormats = RADEONTextureFormats; a->CPUToScreenTextureDstFormats = RADEONDstFormats; if (IS_R300_VARIANT) { xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Render acceleration " "unsupported on Radeon 9500/9700 and newer.\n"); } else if ((info->ChipFamily == CHIP_FAMILY_RV250) || (info->ChipFamily == CHIP_FAMILY_RV280) || (info->ChipFamily == CHIP_FAMILY_RS300) || (info->ChipFamily == CHIP_FAMILY_R200)) { a->SetupForCPUToScreenAlphaTexture2 = FUNC_NAME(R200SetupForCPUToScreenAlphaTexture); a->SubsequentCPUToScreenAlphaTexture = FUNC_NAME(R200SubsequentCPUToScreenTexture); a->SetupForCPUToScreenTexture2 = FUNC_NAME(R200SetupForCPUToScreenTexture); a->SubsequentCPUToScreenTexture = FUNC_NAME(R200SubsequentCPUToScreenTexture); } else { a->SetupForCPUToScreenAlphaTexture2 = FUNC_NAME(R100SetupForCPUToScreenAlphaTexture); a->SubsequentCPUToScreenAlphaTexture = FUNC_NAME(R100SubsequentCPUToScreenTexture); a->SetupForCPUToScreenTexture2 = FUNC_NAME(R100SetupForCPUToScreenTexture); a->SubsequentCPUToScreenTexture = FUNC_NAME(R100SubsequentCPUToScreenTexture); } } else if (info->RenderAccel) { xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Render acceleration currently " "requires XAA v1.2 or newer.\n"); } if (!a->SetupForCPUToScreenAlphaTexture2 && !a->SetupForCPUToScreenTexture2) info->RenderAccel = FALSE; xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Render acceleration %s\n", info->RenderAccel ? "enabled" : "disabled");#endif /* RENDER */}#endif /* USE_XAA */#undef FUNC_NAME
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -