diff options
author | Eric Anholt <eric@anholt.net> | 2007-01-31 14:01:41 -0800 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2007-01-31 14:01:41 -0800 |
commit | 5238ff9c80718f9f8baa06123aa1bb6e3193fce6 (patch) | |
tree | d85791910a3ddd3fae9d1cff9b7d25d528aef0b7 /src/i830_render.c | |
parent | c47210d94ed17ad9e8e489a1e1886732e6dc7220 (diff) |
Naming and formatting cleanup in Render acceleration code.
Diffstat (limited to 'src/i830_render.c')
-rw-r--r-- | src/i830_render.c | 210 |
1 files changed, 111 insertions, 99 deletions
diff --git a/src/i830_render.c b/src/i830_render.c index c335f6d0..99338439 100644 --- a/src/i830_render.c +++ b/src/i830_render.c @@ -48,7 +48,7 @@ do { \ #define I830FALLBACK(s, arg...) \ do { \ return FALSE; \ -} while(0) +} while(0) #endif struct blendinfo { @@ -112,7 +112,7 @@ struct formatinfo { #define TB0A_ARG1_SEL_TEXEL2 (8 << 6) #define TB0A_ARG1_SEL_TEXEL3 (9 << 6) -static struct blendinfo I830BlendOp[] = { +static struct blendinfo i830_blend_op[] = { /* Clear */ {0, 0, BLENDFACTOR_ZERO, BLENDFACTOR_ZERO}, /* Src */ @@ -141,21 +141,20 @@ static struct blendinfo I830BlendOp[] = { {0, 0, BLENDFACTOR_ONE, BLENDFACTOR_ONE}, }; - -static struct formatinfo I830TexFormats[] = { - {PICT_a8r8g8b8, MT_32BIT_ARGB8888 }, - {PICT_x8r8g8b8, MT_32BIT_ARGB8888 }, - {PICT_a8b8g8r8, MT_32BIT_ABGR8888 }, - {PICT_x8b8g8r8, MT_32BIT_ABGR8888 }, - {PICT_r5g6b5, MT_16BIT_RGB565 }, - {PICT_a1r5g5b5, MT_16BIT_ARGB1555 }, - {PICT_x1r5g5b5, MT_16BIT_ARGB1555 }, - {PICT_a8, MT_8BIT_I8 }, +static struct formatinfo i830_tex_formats[] = { + {PICT_a8r8g8b8, MT_32BIT_ARGB8888 }, + {PICT_x8r8g8b8, MT_32BIT_ARGB8888 }, + {PICT_a8b8g8r8, MT_32BIT_ABGR8888 }, + {PICT_x8b8g8r8, MT_32BIT_ABGR8888 }, + {PICT_r5g6b5, MT_16BIT_RGB565 }, + {PICT_a1r5g5b5, MT_16BIT_ARGB1555 }, + {PICT_x1r5g5b5, MT_16BIT_ARGB1555 }, + {PICT_a8, MT_8BIT_I8 }, }; -static Bool I830GetDestFormat(PicturePtr pDstPicture, CARD32 *dst_format) +static Bool i830_get_dest_format(PicturePtr pDstPicture, CARD32 *dst_format) { - /* XXX: color buffer format for i830 */ + /* XXX: color buffer format for i830 */ switch (pDstPicture->format) { case PICT_a8r8g8b8: case PICT_x8r8g8b8: @@ -177,35 +176,35 @@ static Bool I830GetDestFormat(PicturePtr pDstPicture, CARD32 *dst_format) break; default: I830FALLBACK("Unsupported dest format 0x%x\n", - (int)pDstPicture->format); + (int)pDstPicture->format); } return TRUE; } -static CARD32 I830GetBlendCntl(int op, PicturePtr pMask, CARD32 dst_format) +static CARD32 i830_get_blend_cntl(int op, PicturePtr pMask, CARD32 dst_format) { CARD32 sblend, dblend; - sblend = I830BlendOp[op].src_blend; - dblend = I830BlendOp[op].dst_blend; + sblend = i830_blend_op[op].src_blend; + dblend = i830_blend_op[op].dst_blend; /* If there's no dst alpha channel, adjust the blend op so that we'll treat * it as always 1. */ - if (PICT_FORMAT_A(dst_format) == 0 && I830BlendOp[op].dst_alpha) { + if (PICT_FORMAT_A(dst_format) == 0 && i830_blend_op[op].dst_alpha) { if (sblend == BLENDFACTOR_DST_ALPHA) sblend = BLENDFACTOR_ONE; else if (sblend == BLENDFACTOR_INV_DST_ALPHA) sblend = BLENDFACTOR_ZERO; } - /* If the source alpha is being used, then we should only be in a case where - * the source blend factor is 0, and the source blend value is the mask - * channels multiplied by the source picture's alpha. + /* If the source alpha is being used, then we should only be in a case + * where the source blend factor is 0, and the source blend value is the + * mask channels multiplied by the source picture's alpha. */ - if (pMask && pMask->componentAlpha && I830BlendOp[op].src_alpha) { + if (pMask && pMask->componentAlpha && i830_blend_op[op].src_alpha) { if (dblend == BLENDFACTOR_SRC_ALPHA) { dblend = BLENDFACTOR_SRC_COLR; } else if (dblend == BLENDFACTOR_INV_SRC_ALPHA) { @@ -213,27 +212,28 @@ static CARD32 I830GetBlendCntl(int op, PicturePtr pMask, CARD32 dst_format) } } - return (sblend << S8_SRC_BLEND_FACTOR_SHIFT) | - (dblend << S8_DST_BLEND_FACTOR_SHIFT); + return (sblend << S8_SRC_BLEND_FACTOR_SHIFT) | + (dblend << S8_DST_BLEND_FACTOR_SHIFT); } -static Bool I830CheckCompositeTexture(PicturePtr pPict, int unit) +static Bool i830_check_composite_texture(PicturePtr pPict, int unit) { int w = pPict->pDrawable->width; int h = pPict->pDrawable->height; int i; - + if ((w > 0x7ff) || (h > 0x7ff)) I830FALLBACK("Picture w/h too large (%dx%d)\n", w, h); - for (i = 0; i < sizeof(I830TexFormats) / sizeof(I830TexFormats[0]); i++) + for (i = 0; i < sizeof(i830_tex_formats) / sizeof(i830_tex_formats[0]); + i++) { - if (I830TexFormats[i].fmt == pPict->format) + if (i830_tex_formats[i].fmt == pPict->format) break; } - if (i == sizeof(I830TexFormats) / sizeof(I830TexFormats[0])) + if (i == sizeof(i830_tex_formats) / sizeof(i830_tex_formats[0])) I830FALLBACK("Unsupported picture format 0x%x\n", - (int)pPict->format); + (int)pPict->format); /* FIXME: fix repeat support */ if (pPict->repeat) @@ -241,20 +241,22 @@ static Bool I830CheckCompositeTexture(PicturePtr pPict, int unit) if (pPict->filter != PictFilterNearest && pPict->filter != PictFilterBilinear) + { I830FALLBACK("Unsupported filter 0x%x\n", pPict->filter); + } return TRUE; } static Bool -I830TextureSetup(PicturePtr pPict, PixmapPtr pPix, int unit) +i830_texture_setup(PicturePtr pPict, PixmapPtr pPix, int unit) { ScrnInfoPtr pScrn = xf86Screens[pPict->pDrawable->pScreen->myNum]; I830Ptr pI830 = I830PTR(pScrn); CARD32 format, offset, pitch, filter; int w, h, i; - CARD32 wrap_mode = TEXCOORDMODE_CLAMP; + CARD32 wrap_mode = TEXCOORDMODE_CLAMP; offset = intel_get_pixmap_offset(pPix); pitch = intel_get_pixmap_pitch(pPix); @@ -263,25 +265,27 @@ I830TextureSetup(PicturePtr pPict, PixmapPtr pPix, int unit) pI830->scale_units[unit][0] = pPix->drawable.width; pI830->scale_units[unit][1] = pPix->drawable.height; - for (i = 0; i < sizeof(I830TexFormats) / sizeof(I830TexFormats[0]); i++) { - if (I830TexFormats[i].fmt == pPict->format) + for (i = 0; i < sizeof(i830_tex_formats) / sizeof(i830_tex_formats[0]); + i++) + { + if (i830_tex_formats[i].fmt == pPict->format) break; } - if ( i == sizeof(I830TexFormats)/ sizeof(I830TexFormats[0]) ) + if (i == sizeof(i830_tex_formats)/ sizeof(i830_tex_formats[0])) I830FALLBACK("unknown texture format\n"); - format = I830TexFormats[i].card_fmt; + format = i830_tex_formats[i].card_fmt; - if (pPict->repeat) + if (pPict->repeat) wrap_mode = TEXCOORDMODE_WRAP; /* XXX: correct ? */ - + switch (pPict->filter) { case PictFilterNearest: - filter = ((FILTER_NEAREST<<TM0S3_MAG_FILTER_SHIFT) | - (FILTER_NEAREST<<TM0S3_MIN_FILTER_SHIFT)); + filter = ((FILTER_NEAREST<<TM0S3_MAG_FILTER_SHIFT) | + (FILTER_NEAREST<<TM0S3_MIN_FILTER_SHIFT)); break; case PictFilterBilinear: - filter = ((FILTER_LINEAR<<TM0S3_MAG_FILTER_SHIFT) | - (FILTER_LINEAR<<TM0S3_MIN_FILTER_SHIFT)); + filter = ((FILTER_LINEAR<<TM0S3_MAG_FILTER_SHIFT) | + (FILTER_LINEAR<<TM0S3_MIN_FILTER_SHIFT)); break; default: filter = 0; @@ -300,7 +304,7 @@ I830TextureSetup(PicturePtr pPict, PixmapPtr pPix, int unit) OUT_RING(_3DSTATE_MAP_INFO_CMD); OUT_RING(format | TEXMAP_INDEX(unit) | MAP_FORMAT_2D); OUT_RING(((pPix->drawable.height - 1) << 16) | - (pPix->drawable.width - 1)); /* height, width */ + (pPix->drawable.width - 1)); /* height, width */ OUT_RING(offset); /* map address */ OUT_RING(((pitch / 4) - 1) << 2); /* map pitch */ OUT_RING(0); @@ -310,16 +314,19 @@ I830TextureSetup(PicturePtr pPict, PixmapPtr pPix, int unit) { BEGIN_LP_RING(2); /* coord sets */ - OUT_RING(_3DSTATE_MAP_COORD_SET_CMD | TEXCOORD_SET(unit) | - ENABLE_TEXCOORD_PARAMS | TEXCOORDS_ARE_NORMAL | - TEXCOORDTYPE_CARTESIAN | ENABLE_ADDR_V_CNTL | - TEXCOORD_ADDR_V_MODE(wrap_mode) | - ENABLE_ADDR_U_CNTL | TEXCOORD_ADDR_U_MODE(wrap_mode)); + OUT_RING(_3DSTATE_MAP_COORD_SET_CMD | TEXCOORD_SET(unit) | + ENABLE_TEXCOORD_PARAMS | TEXCOORDS_ARE_NORMAL | + TEXCOORDTYPE_CARTESIAN | ENABLE_ADDR_V_CNTL | + TEXCOORD_ADDR_V_MODE(wrap_mode) | + ENABLE_ADDR_U_CNTL | TEXCOORD_ADDR_U_MODE(wrap_mode)); OUT_RING(MI_NOOP); /* XXX: filter seems hang engine...*/ #if 0 - OUT_RING(I830_STATE3D_MAP_FILTER | FILTER_MAP_INDEX(unit) | ENABLE_KEYS| DISABLE_COLOR_KEY | DISABLE_CHROMA_KEY | DISABLE_KILL_PIXEL |ENABLE_MIP_MODE_FILTER | MIPFILTER_NONE | filter); + OUT_RING(I830_STATE3D_MAP_FILTER | FILTER_MAP_INDEX(unit) | + ENABLE_KEYS| DISABLE_COLOR_KEY | DISABLE_CHROMA_KEY | + DISABLE_KILL_PIXEL |ENABLE_MIP_MODE_FILTER | + MIPFILTER_NONE | filter); OUT_RING(0); #endif @@ -334,63 +341,63 @@ I830TextureSetup(PicturePtr pPict, PixmapPtr pPix, int unit) ErrorF("try to sync to show any errors..."); I830Sync(pScrn); #endif - + return TRUE; } Bool -I830EXACheckComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture, - PicturePtr pDstPicture) +i830_check_composite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture, + PicturePtr pDstPicture) { CARD32 tmp1; - + /* Check for unsupported compositing operations. */ - if (op >= sizeof(I830BlendOp) / sizeof(I830BlendOp[0])) + if (op >= sizeof(i830_blend_op) / sizeof(i830_blend_op[0])) I830FALLBACK("Unsupported Composite op 0x%x\n", op); - + if (pMaskPicture != NULL && pMaskPicture->componentAlpha) { /* Check if it's component alpha that relies on a source alpha and on * the source value. We can only get one of those into the single * source value that we get to blend with. */ - if (I830BlendOp[op].src_alpha && - (I830BlendOp[op].src_blend != BLENDFACTOR_ZERO)) + if (i830_blend_op[op].src_alpha && + (i830_blend_op[op].src_blend != BLENDFACTOR_ZERO)) I830FALLBACK("Component alpha not supported with source " - "alpha and source value blending.\n"); + "alpha and source value blending.\n"); } - if (!I830CheckCompositeTexture(pSrcPicture, 0)) + if (!i830_check_composite_texture(pSrcPicture, 0)) I830FALLBACK("Check Src picture texture\n"); - if (pMaskPicture != NULL && !I830CheckCompositeTexture(pMaskPicture, 1)) + if (pMaskPicture != NULL && !i830_check_composite_texture(pMaskPicture, 1)) I830FALLBACK("Check Mask picture texture\n"); - if (!I830GetDestFormat(pDstPicture, &tmp1)) + if (!i830_get_dest_format(pDstPicture, &tmp1)) I830FALLBACK("Get Color buffer format\n"); return TRUE; } Bool -I830EXAPrepareComposite(int op, PicturePtr pSrcPicture, - PicturePtr pMaskPicture, PicturePtr pDstPicture, - PixmapPtr pSrc, PixmapPtr pMask, PixmapPtr pDst) +i830_prepare_composite(int op, PicturePtr pSrcPicture, + PicturePtr pMaskPicture, PicturePtr pDstPicture, + PixmapPtr pSrc, PixmapPtr pMask, PixmapPtr pDst) { -/* XXX: setup texture map from pixmap, vertex format, blend cntl */ + /* XXX: setup texture map from pixmap, vertex format, blend cntl */ ScrnInfoPtr pScrn = xf86Screens[pSrcPicture->pDrawable->pScreen->myNum]; I830Ptr pI830 = I830PTR(pScrn); CARD32 dst_format, dst_offset, dst_pitch; - I830GetDestFormat(pDstPicture, &dst_format); + i830_get_dest_format(pDstPicture, &dst_format); dst_offset = intel_get_pixmap_offset(pDst); dst_pitch = intel_get_pixmap_pitch(pDst); pI830->last_3d = LAST_3D_RENDER; - if (!I830TextureSetup(pSrcPicture, pSrc, 0)) + if (!i830_texture_setup(pSrcPicture, pSrc, 0)) I830FALLBACK("fail to setup src texture\n"); if (pMask != NULL) { - if (!I830TextureSetup(pMaskPicture, pMask, 1)) - I830FALLBACK("fail to setup mask texture\n"); + if (!i830_texture_setup(pMaskPicture, pMask, 1)) + I830FALLBACK("fail to setup mask texture\n"); } else { pI830->transform[1] = NULL; pI830->scale_units[1][0] = -1; @@ -398,17 +405,16 @@ I830EXAPrepareComposite(int op, PicturePtr pSrcPicture, } { - CARD32 cblend, ablend, blendctl, vf2; BEGIN_LP_RING(22+6); - - /*color buffer*/ + + /* color buffer */ OUT_RING(_3DSTATE_BUF_INFO_CMD); OUT_RING(BUF_3D_ID_COLOR_BACK| BUF_3D_PITCH(dst_pitch)); OUT_RING(BUF_3D_ADDR(dst_offset)); OUT_RING(MI_NOOP); - + OUT_RING(_3DSTATE_DST_BUF_VARS_CMD); OUT_RING(dst_format); @@ -423,10 +429,10 @@ I830EXAPrepareComposite(int op, PicturePtr pSrcPicture, OUT_RING(_3DSTATE_DFLT_SPEC_CMD); OUT_RING(0); - + OUT_RING(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | I1_LOAD_S(3) | 0); - OUT_RING((1 << S3_POINT_WIDTH_SHIFT) | (2 << S3_LINE_WIDTH_SHIFT) | - S3_CULLMODE_NONE | S3_VERTEXHAS_XY); + OUT_RING((1 << S3_POINT_WIDTH_SHIFT) | (2 << S3_LINE_WIDTH_SHIFT) | + S3_CULLMODE_NONE | S3_VERTEXHAS_XY); OUT_RING(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | I1_LOAD_S(2) | 0); if (pMask) vf2 = 2 << 12; /* 2 texture coord sets */ @@ -437,7 +443,7 @@ I830EXAPrepareComposite(int op, PicturePtr pSrcPicture, vf2 |= (TEXCOORDFMT_2D << 18); else vf2 |= (TEXCOORDFMT_1D << 18); - + vf2 |= (TEXCOORDFMT_1D << 20); vf2 |= (TEXCOORDFMT_1D << 22); vf2 |= (TEXCOORDFMT_1D << 24); @@ -452,10 +458,10 @@ I830EXAPrepareComposite(int op, PicturePtr pSrcPicture, /* IN operator: Multiply src by mask components or mask alpha.*/ /* TEXBLENDOP_MODULE: arg1*arg2 */ cblend = TB0C_LAST_STAGE | TB0C_RESULT_SCALE_1X | TB0C_OP_MODULE | - TB0C_OUTPUT_WRITE_CURRENT; - ablend = TB0A_RESULT_SCALE_1X | TB0A_OP_MODULE | + TB0C_OUTPUT_WRITE_CURRENT; + ablend = TB0A_RESULT_SCALE_1X | TB0A_OP_MODULE | TB0A_OUTPUT_WRITE_CURRENT; - + cblend |= TB0C_ARG1_SEL_TEXEL0; ablend |= TB0A_ARG1_SEL_TEXEL0; if (pMask) { @@ -465,11 +471,12 @@ I830EXAPrepareComposite(int op, PicturePtr pSrcPicture, cblend |= (TB0C_ARG2_SEL_TEXEL1 | TB0C_ARG2_REPLICATE_ALPHA); ablend |= TB0A_ARG2_SEL_TEXEL1; } else { - cblend |= TB0C_ARG2_SEL_ONE; - ablend |= TB0A_ARG2_SEL_ONE; + cblend |= TB0C_ARG2_SEL_ONE; + ablend |= TB0A_ARG2_SEL_ONE; } - - OUT_RING(_3DSTATE_LOAD_STATE_IMMEDIATE_2 | LOAD_TEXTURE_BLEND_STAGE(0)|1); + + OUT_RING(_3DSTATE_LOAD_STATE_IMMEDIATE_2 | + LOAD_TEXTURE_BLEND_STAGE(0)|1); OUT_RING(cblend); OUT_RING(ablend); OUT_RING(0); @@ -477,16 +484,16 @@ I830EXAPrepareComposite(int op, PicturePtr pSrcPicture, OUT_RING(MI_FLUSH | MI_WRITE_DIRTY_STATE | MI_INVALIDATE_MAP_CACHE); OUT_RING(MI_NOOP); /* pad to quadword */ - blendctl = I830GetBlendCntl(op, pMaskPicture, pDstPicture->format); + blendctl = i830_get_blend_cntl(op, pMaskPicture, pDstPicture->format); OUT_RING(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | I1_LOAD_S(8) | 0); OUT_RING(S8_ENABLE_COLOR_BLEND | S8_BLENDFUNC_ADD |(blendctl<<4) | - S8_ENABLE_COLOR_BUFFER_WRITE); + S8_ENABLE_COLOR_BUFFER_WRITE); ADVANCE_LP_RING(); } #ifdef I830DEBUG - Error("try to sync to show any errors..."); - I830Sync(pScrn); + Error("try to sync to show any errors..."); + I830Sync(pScrn); #endif return TRUE; @@ -499,8 +506,8 @@ I830EXAPrepareComposite(int op, PicturePtr pSrcPicture, * This function is shared between i830 and i915 generation code. */ void -IntelEXAComposite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY, - int dstX, int dstY, int w, int h) +i830_composite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY, + int dstX, int dstY, int w, int h) { ScrnInfoPtr pScrn = xf86Screens[pDst->drawable.pScreen->myNum]; I830Ptr pI830 = I830PTR(pScrn); @@ -533,7 +540,7 @@ IntelEXAComposite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY, } { - int vertex_count; + int vertex_count; if (has_mask) vertex_count = 3*6; @@ -555,8 +562,8 @@ IntelEXAComposite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY, OUT_RING_F(src_x[0] / pI830->scale_units[0][0]); OUT_RING_F(src_y[0] / pI830->scale_units[0][1]); if (has_mask) { - OUT_RING_F(mask_x[0] / pI830->scale_units[1][0]); - OUT_RING_F(mask_y[0] / pI830->scale_units[1][1]); + OUT_RING_F(mask_x[0] / pI830->scale_units[1][0]); + OUT_RING_F(mask_y[0] / pI830->scale_units[1][1]); } OUT_RING_F(dstX); @@ -564,8 +571,8 @@ IntelEXAComposite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY, OUT_RING_F(src_x[1] / pI830->scale_units[0][0]); OUT_RING_F(src_y[1] / pI830->scale_units[0][1]); if (has_mask) { - OUT_RING_F(mask_x[1] / pI830->scale_units[1][0]); - OUT_RING_F(mask_y[1] / pI830->scale_units[1][1]); + OUT_RING_F(mask_x[1] / pI830->scale_units[1][0]); + OUT_RING_F(mask_y[1] / pI830->scale_units[1][1]); } OUT_RING_F(dstX + w); @@ -573,15 +580,20 @@ IntelEXAComposite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY, OUT_RING_F(src_x[2] / pI830->scale_units[0][0]); OUT_RING_F(src_y[2] / pI830->scale_units[0][1]); if (has_mask) { - OUT_RING_F(mask_x[2] / pI830->scale_units[1][0]); - OUT_RING_F(mask_y[2] / pI830->scale_units[1][1]); + OUT_RING_F(mask_x[2] / pI830->scale_units[1][0]); + OUT_RING_F(mask_y[2] / pI830->scale_units[1][1]); } ADVANCE_LP_RING(); } } +/** + * Do any cleanup from the Composite operation. + * + * This is shared between i830 through i965. + */ void -IntelEXADoneComposite(PixmapPtr pDst) +i830_done_composite(PixmapPtr pDst) { #if ALWAYS_SYNC ScrnInfoPtr pScrn = xf86Screens[pDst->drawable.pScreen->myNum]; |