Esempio n. 1
0
static inline void emit_cb_setup(struct r100_context *r100,
				 struct radeon_bo *bo,
				 intptr_t offset,
				 gl_format mesa_format,
				 unsigned pitch,
				 unsigned width,
				 unsigned height)
{
    uint32_t dst_pitch = pitch;
    uint32_t dst_format = 0;
    BATCH_LOCALS(&r100->radeon);

    /* XXX others?  BE/LE? */
    switch (mesa_format) {
    case MESA_FORMAT_ARGB8888:
    case MESA_FORMAT_XRGB8888:
	    dst_format = RADEON_COLOR_FORMAT_ARGB8888;
	    break;
    case MESA_FORMAT_RGB565:
	    dst_format = RADEON_COLOR_FORMAT_RGB565;
	    break;
    case MESA_FORMAT_ARGB4444:
	    dst_format = RADEON_COLOR_FORMAT_ARGB4444;
	    break;
    case MESA_FORMAT_ARGB1555:
	    dst_format = RADEON_COLOR_FORMAT_ARGB1555;
	    break;
    case MESA_FORMAT_A8:
    case MESA_FORMAT_L8:
    case MESA_FORMAT_I8:
	    dst_format = RADEON_COLOR_FORMAT_RGB8;
	    break;
    default:
	    break;
    }

    if (bo->flags & RADEON_BO_FLAGS_MACRO_TILE)
        dst_pitch |= RADEON_COLOR_TILE_ENABLE;

    if (bo->flags & RADEON_BO_FLAGS_MICRO_TILE)
        dst_pitch |= RADEON_COLOR_MICROTILE_ENABLE;

    BEGIN_BATCH_NO_AUTOSTATE(18);
    OUT_BATCH_REGVAL(RADEON_RE_TOP_LEFT, 0);
    OUT_BATCH_REGVAL(RADEON_RE_WIDTH_HEIGHT, (((width - 1) << RADEON_RE_WIDTH_SHIFT) |
					      ((height - 1) << RADEON_RE_HEIGHT_SHIFT)));
    OUT_BATCH_REGVAL(RADEON_RB3D_PLANEMASK, 0xffffffff);
    OUT_BATCH_REGVAL(RADEON_RB3D_BLENDCNTL, RADEON_SRC_BLEND_GL_ONE | RADEON_DST_BLEND_GL_ZERO);
    OUT_BATCH_REGVAL(RADEON_RB3D_CNTL, dst_format);

    OUT_BATCH_REGSEQ(RADEON_RB3D_COLOROFFSET, 1);
    OUT_BATCH_RELOC(offset, bo, offset, 0, RADEON_GEM_DOMAIN_GTT|RADEON_GEM_DOMAIN_VRAM, 0);
    OUT_BATCH_REGSEQ(RADEON_RB3D_COLORPITCH, 1);
    OUT_BATCH_RELOC(dst_pitch, bo, dst_pitch, 0, RADEON_GEM_DOMAIN_GTT|RADEON_GEM_DOMAIN_VRAM, 0);

    END_BATCH();
}
Esempio n. 2
0
void r300EmitCacheFlush(r300ContextPtr rmesa)
{
	BATCH_LOCALS(&rmesa->radeon);

	BEGIN_BATCH_NO_AUTOSTATE(4);
	OUT_BATCH_REGVAL(R300_RB3D_DSTCACHE_CTLSTAT,
		R300_RB3D_DSTCACHE_CTLSTAT_DC_FREE_FREE_3D_TAGS |
		R300_RB3D_DSTCACHE_CTLSTAT_DC_FLUSH_FLUSH_DIRTY_3D);
	OUT_BATCH_REGVAL(R300_ZB_ZCACHE_CTLSTAT,
		R300_ZB_ZCACHE_CTLSTAT_ZC_FLUSH_FLUSH_AND_FREE |
		R300_ZB_ZCACHE_CTLSTAT_ZC_FREE_FREE);
	END_BATCH();
	COMMIT_BATCH();
}
Esempio n. 3
0
static inline void emit_vtx_state(struct r100_context *r100)
{
    BATCH_LOCALS(&r100->radeon);

    BEGIN_BATCH(8);
    if (r100->radeon.radeonScreen->chip_flags & RADEON_CHIPSET_TCL) {
	    OUT_BATCH_REGVAL(RADEON_SE_CNTL_STATUS, 0);
    } else {
	    OUT_BATCH_REGVAL(RADEON_SE_CNTL_STATUS, RADEON_TCL_BYPASS);

    }
    OUT_BATCH_REGVAL(RADEON_SE_COORD_FMT, (RADEON_VTX_XY_PRE_MULT_1_OVER_W0 |
					   RADEON_TEX1_W_ROUTING_USE_W0));
    OUT_BATCH_REGVAL(RADEON_SE_VTX_FMT, RADEON_SE_VTX_FMT_XY | RADEON_SE_VTX_FMT_ST0);
    OUT_BATCH_REGVAL(RADEON_SE_CNTL, (RADEON_DIFFUSE_SHADE_GOURAUD |
				      RADEON_BFACE_SOLID |
				      RADEON_FFACE_SOLID |
				      RADEON_VTX_PIX_CENTER_OGL |
				      RADEON_ROUND_MODE_ROUND |
				      RADEON_ROUND_PREC_4TH_PIX));
    END_BATCH();
}
Esempio n. 4
0
static inline void emit_cb_setup(struct r200_context *r200,
				 struct radeon_bo *bo,
				 intptr_t offset,
				 gl_format mesa_format,
				 unsigned pitch,
				 unsigned width,
				 unsigned height)
{
    uint32_t dst_pitch = pitch;
    uint32_t dst_format = 0;
    BATCH_LOCALS(&r200->radeon);

    /* XXX others?  BE/LE? */
    switch (mesa_format) {
    case MESA_FORMAT_ARGB8888:
    case MESA_FORMAT_XRGB8888:
	    dst_format = RADEON_COLOR_FORMAT_ARGB8888;
	    break;
    case MESA_FORMAT_RGB565:
	    dst_format = RADEON_COLOR_FORMAT_RGB565;
	    break;
    case MESA_FORMAT_ARGB4444:
	    dst_format = RADEON_COLOR_FORMAT_ARGB4444;
	    break;
    case MESA_FORMAT_ARGB1555:
	    dst_format = RADEON_COLOR_FORMAT_ARGB1555;
	    break;
    case MESA_FORMAT_A8:
	    dst_format = RADEON_COLOR_FORMAT_RGB8;
	    break;
    default:
	    break;
    }

    BEGIN_BATCH_NO_AUTOSTATE(22);
    OUT_BATCH_REGVAL(R200_RE_AUX_SCISSOR_CNTL, 0);
    OUT_BATCH_REGVAL(R200_RE_CNTL, 0);
    OUT_BATCH_REGVAL(RADEON_RE_TOP_LEFT, 0);
    OUT_BATCH_REGVAL(RADEON_RE_WIDTH_HEIGHT, ((width << RADEON_RE_WIDTH_SHIFT) |
					      (height << RADEON_RE_HEIGHT_SHIFT)));
    OUT_BATCH_REGVAL(RADEON_RB3D_PLANEMASK, 0xffffffff);
    OUT_BATCH_REGVAL(RADEON_RB3D_BLENDCNTL, RADEON_SRC_BLEND_GL_ONE | RADEON_DST_BLEND_GL_ZERO);
    OUT_BATCH_REGVAL(RADEON_RB3D_CNTL, dst_format);

    OUT_BATCH_REGSEQ(RADEON_RB3D_COLOROFFSET, 1);
    OUT_BATCH_RELOC(0, bo, 0, 0, RADEON_GEM_DOMAIN_GTT|RADEON_GEM_DOMAIN_VRAM, 0);
    OUT_BATCH_REGSEQ(RADEON_RB3D_COLORPITCH, 1);
    OUT_BATCH_RELOC(dst_pitch, bo, dst_pitch, 0, RADEON_GEM_DOMAIN_GTT|RADEON_GEM_DOMAIN_VRAM, 0);

    END_BATCH();
}
Esempio n. 5
0
static inline void emit_vtx_state(struct r200_context *r200)
{
    BATCH_LOCALS(&r200->radeon);

    BEGIN_BATCH(14);
    if (r200->radeon.radeonScreen->chip_flags & RADEON_CHIPSET_TCL) {
	    OUT_BATCH_REGVAL(R200_SE_VAP_CNTL_STATUS, 0);
    } else {
	    OUT_BATCH_REGVAL(R200_SE_VAP_CNTL_STATUS, RADEON_TCL_BYPASS);
    }
    OUT_BATCH_REGVAL(R200_SE_VAP_CNTL, (R200_VAP_FORCE_W_TO_ONE |
					(9 << R200_VAP_VF_MAX_VTX_NUM__SHIFT)));
    OUT_BATCH_REGVAL(R200_SE_VTX_STATE_CNTL, 0);
    OUT_BATCH_REGVAL(R200_SE_VTE_CNTL, 0);
    OUT_BATCH_REGVAL(R200_SE_VTX_FMT_0, R200_VTX_XY);
    OUT_BATCH_REGVAL(R200_SE_VTX_FMT_1, (2 << R200_VTX_TEX0_COMP_CNT_SHIFT));
    OUT_BATCH_REGVAL(RADEON_SE_CNTL, (RADEON_DIFFUSE_SHADE_GOURAUD |
				      RADEON_BFACE_SOLID |
				      RADEON_FFACE_SOLID |
				      RADEON_VTX_PIX_CENTER_OGL |
				      RADEON_ROUND_MODE_ROUND |
				      RADEON_ROUND_PREC_4TH_PIX));
    END_BATCH();
}
Esempio n. 6
0
static void inline emit_tx_setup(struct r200_context *r200,
				 gl_format mesa_format,
				 struct radeon_bo *bo,
				 intptr_t offset,
				 unsigned width,
				 unsigned height,
				 unsigned pitch)
{
    uint32_t txformat = R200_TXFORMAT_NON_POWER2;
    BATCH_LOCALS(&r200->radeon);

    assert(width <= 2047);
    assert(height <= 2047);
    assert(offset % 32 == 0);

    /* XXX others?  BE/LE? */
    switch (mesa_format) {
    case MESA_FORMAT_ARGB8888:
	    txformat |= R200_TXFORMAT_ARGB8888 | R200_TXFORMAT_ALPHA_IN_MAP;
	    break;
    case MESA_FORMAT_XRGB8888:
	    txformat |= R200_TXFORMAT_ARGB8888;
	    break;
    case MESA_FORMAT_RGB565:
	    txformat |= R200_TXFORMAT_RGB565;
	    break;
    case MESA_FORMAT_ARGB4444:
	    txformat |= R200_TXFORMAT_ARGB4444 | R200_TXFORMAT_ALPHA_IN_MAP;
	    break;
    case MESA_FORMAT_ARGB1555:
	    txformat |= R200_TXFORMAT_ARGB1555 | R200_TXFORMAT_ALPHA_IN_MAP;
	    break;
    case MESA_FORMAT_A8:
	    txformat |= R200_TXFORMAT_I8 | R200_TXFORMAT_ALPHA_IN_MAP;
	    break;
    default:
	    break;
    }

    BEGIN_BATCH(28);
    OUT_BATCH_REGVAL(RADEON_PP_CNTL, RADEON_TEX_0_ENABLE | RADEON_TEX_BLEND_0_ENABLE);
    OUT_BATCH_REGVAL(R200_PP_CNTL_X, 0);
    OUT_BATCH_REGVAL(R200_PP_TXMULTI_CTL_0, 0);
    OUT_BATCH_REGVAL(R200_PP_TXCBLEND_0, (R200_TXC_ARG_A_ZERO |
					  R200_TXC_ARG_B_ZERO |
					  R200_TXC_ARG_C_R0_COLOR |
					  R200_TXC_OP_MADD));
    OUT_BATCH_REGVAL(R200_PP_TXCBLEND2_0, R200_TXC_CLAMP_0_1 | R200_TXC_OUTPUT_REG_R0);
    OUT_BATCH_REGVAL(R200_PP_TXABLEND_0, (R200_TXA_ARG_A_ZERO |
					  R200_TXA_ARG_B_ZERO |
					  R200_TXA_ARG_C_R0_ALPHA |
					  R200_TXA_OP_MADD));
    OUT_BATCH_REGVAL(R200_PP_TXABLEND2_0, R200_TXA_CLAMP_0_1 | R200_TXA_OUTPUT_REG_R0);
    OUT_BATCH_REGVAL(R200_PP_TXFILTER_0, (R200_CLAMP_S_CLAMP_LAST |
					  R200_CLAMP_T_CLAMP_LAST |
					  R200_MAG_FILTER_NEAREST |
					  R200_MIN_FILTER_NEAREST));
    OUT_BATCH_REGVAL(R200_PP_TXFORMAT_0, txformat);
    OUT_BATCH_REGVAL(R200_PP_TXFORMAT_X_0, 0);
    OUT_BATCH_REGVAL(R200_PP_TXSIZE_0, ((width - 1) |
					((height - 1) << RADEON_TEX_VSIZE_SHIFT)));
    OUT_BATCH_REGVAL(R200_PP_TXPITCH_0, pitch * _mesa_get_format_bytes(mesa_format) - 32);

    OUT_BATCH_REGSEQ(R200_PP_TXOFFSET_0, 1);
    OUT_BATCH_RELOC(0, bo, 0, RADEON_GEM_DOMAIN_GTT|RADEON_GEM_DOMAIN_VRAM, 0, 0);

    END_BATCH();
}
static void inline emit_tx_setup(struct r200_context *r200,
				 gl_format src_mesa_format,
				 gl_format dst_mesa_format,
				 struct radeon_bo *bo,
				 intptr_t offset,
				 unsigned width,
				 unsigned height,
				 unsigned pitch)
{
    uint32_t txformat = R200_TXFORMAT_NON_POWER2;
    BATCH_LOCALS(&r200->radeon);

    assert(width <= 2048);
    assert(height <= 2048);
    assert(offset % 32 == 0);

    /* XXX others?  BE/LE? */
    switch (src_mesa_format) {
    case MESA_FORMAT_ARGB8888:
	    txformat |= R200_TXFORMAT_ARGB8888 | R200_TXFORMAT_ALPHA_IN_MAP;
	    break;
    case MESA_FORMAT_RGBA8888:
	    txformat |= R200_TXFORMAT_RGBA8888 | R200_TXFORMAT_ALPHA_IN_MAP;
	    break;
    case MESA_FORMAT_RGBA8888_REV:
	    txformat |= R200_TXFORMAT_ABGR8888 | R200_TXFORMAT_ALPHA_IN_MAP;
	    break;
    case MESA_FORMAT_XRGB8888:
	    txformat |= R200_TXFORMAT_ARGB8888;
	    break;
    case MESA_FORMAT_RGB565:
	    txformat |= R200_TXFORMAT_RGB565;
	    break;
    case MESA_FORMAT_ARGB4444:
	    txformat |= R200_TXFORMAT_ARGB4444 | R200_TXFORMAT_ALPHA_IN_MAP;
	    break;
    case MESA_FORMAT_ARGB1555:
	    txformat |= R200_TXFORMAT_ARGB1555 | R200_TXFORMAT_ALPHA_IN_MAP;
	    break;
    case MESA_FORMAT_A8:
    case MESA_FORMAT_I8:
	    txformat |= R200_TXFORMAT_I8 | R200_TXFORMAT_ALPHA_IN_MAP;
	    break;
    case MESA_FORMAT_L8:
	    txformat |= R200_TXFORMAT_I8;
	    break;
    case MESA_FORMAT_AL88:
	    txformat |= R200_TXFORMAT_AI88 | R200_TXFORMAT_ALPHA_IN_MAP;
	    break;
    default:
	    break;
    }

    if (bo->flags & RADEON_BO_FLAGS_MACRO_TILE)
	offset |= R200_TXO_MACRO_TILE;
    if (bo->flags & RADEON_BO_FLAGS_MICRO_TILE)
	offset |= R200_TXO_MICRO_TILE;

    switch (dst_mesa_format) {
    case MESA_FORMAT_ARGB8888:
    case MESA_FORMAT_XRGB8888:
    case MESA_FORMAT_RGB565:
    case MESA_FORMAT_ARGB4444:
    case MESA_FORMAT_ARGB1555:
    case MESA_FORMAT_A8:
    case MESA_FORMAT_L8:
    case MESA_FORMAT_I8:
    default:
	    /* no swizzle required */
	    BEGIN_BATCH(10);
	    OUT_BATCH_REGVAL(RADEON_PP_CNTL, (RADEON_TEX_0_ENABLE |
					      RADEON_TEX_BLEND_0_ENABLE));
	    OUT_BATCH_REGVAL(R200_PP_TXCBLEND_0, (R200_TXC_ARG_A_ZERO |
						  R200_TXC_ARG_B_ZERO |
						  R200_TXC_ARG_C_R0_COLOR |
						  R200_TXC_OP_MADD));
	    OUT_BATCH_REGVAL(R200_PP_TXCBLEND2_0, (R200_TXC_CLAMP_0_1 |
						   R200_TXC_OUTPUT_REG_R0));
	    OUT_BATCH_REGVAL(R200_PP_TXABLEND_0, (R200_TXA_ARG_A_ZERO |
						  R200_TXA_ARG_B_ZERO |
						  R200_TXA_ARG_C_R0_ALPHA |
						  R200_TXA_OP_MADD));
	    OUT_BATCH_REGVAL(R200_PP_TXABLEND2_0, (R200_TXA_CLAMP_0_1 |
						   R200_TXA_OUTPUT_REG_R0));
	    END_BATCH();
	    break;
    case MESA_FORMAT_RGBA8888:
	    BEGIN_BATCH(10);
	    OUT_BATCH_REGVAL(RADEON_PP_CNTL, (RADEON_TEX_0_ENABLE |
					      RADEON_TEX_BLEND_0_ENABLE));
	    OUT_BATCH_REGVAL(R200_PP_TXCBLEND_0, (R200_TXC_ARG_A_ZERO |
						  R200_TXC_ARG_B_ZERO |
						  R200_TXC_ARG_C_R0_COLOR |
						  R200_TXC_OP_MADD));
	    OUT_BATCH_REGVAL(R200_PP_TXCBLEND2_0, (R200_TXC_CLAMP_0_1 |
						   R200_TXC_OUTPUT_ROTATE_GBA |
						   R200_TXC_OUTPUT_REG_R0));
	    OUT_BATCH_REGVAL(R200_PP_TXABLEND_0, (R200_TXA_ARG_A_ZERO |
						  R200_TXA_ARG_B_ZERO |
						  R200_TXA_ARG_C_R0_ALPHA |
						  R200_TXA_OP_MADD));
	    OUT_BATCH_REGVAL(R200_PP_TXABLEND2_0, (R200_TXA_CLAMP_0_1 |
						   (R200_TXA_REPL_RED << R200_TXA_REPL_ARG_C_SHIFT) |
						   R200_TXA_OUTPUT_REG_R0));
	    END_BATCH();
	    break;
    case MESA_FORMAT_RGBA8888_REV:
	    BEGIN_BATCH(34);
	    OUT_BATCH_REGVAL(RADEON_PP_CNTL, (RADEON_TEX_0_ENABLE |
					      RADEON_TEX_BLEND_0_ENABLE |
					      RADEON_TEX_BLEND_1_ENABLE |
					      RADEON_TEX_BLEND_2_ENABLE |
					      RADEON_TEX_BLEND_3_ENABLE));
	    /* r1.r = r0.b */
	    OUT_BATCH_REGVAL(R200_PP_TXCBLEND_0, (R200_TXC_ARG_A_ZERO |
						  R200_TXC_ARG_B_ZERO |
						  R200_TXC_ARG_C_R0_COLOR |
						  R200_TXC_OP_MADD));
	    OUT_BATCH_REGVAL(R200_PP_TXCBLEND2_0, (R200_TXC_CLAMP_0_1 |
						   R200_TXC_OUTPUT_MASK_R |
						   (R200_TXC_REPL_BLUE << R200_TXC_REPL_ARG_C_SHIFT) |
						   R200_TXC_OUTPUT_REG_R1));
	    /* r1.a = r0.a */
	    OUT_BATCH_REGVAL(R200_PP_TXABLEND_0, (R200_TXA_ARG_A_ZERO |
						  R200_TXA_ARG_B_ZERO |
						  R200_TXA_ARG_C_R0_ALPHA |
						  R200_TXA_OP_MADD));
	    OUT_BATCH_REGVAL(R200_PP_TXABLEND2_0, (R200_TXA_CLAMP_0_1 |
						   R200_TXA_OUTPUT_REG_R1));
	    /* r1.g = r0.g */
	    OUT_BATCH_REGVAL(R200_PP_TXCBLEND_1, (R200_TXC_ARG_A_ZERO |
						  R200_TXC_ARG_B_ZERO |
						  R200_TXC_ARG_C_R0_COLOR |
						  R200_TXC_OP_MADD));
	    OUT_BATCH_REGVAL(R200_PP_TXCBLEND2_1, (R200_TXC_CLAMP_0_1 |
						   R200_TXC_OUTPUT_MASK_G |
						   (R200_TXC_REPL_GREEN << R200_TXC_REPL_ARG_C_SHIFT) |
						   R200_TXC_OUTPUT_REG_R1));
	    /* r1.a = r0.a */
	    OUT_BATCH_REGVAL(R200_PP_TXABLEND_1, (R200_TXA_ARG_A_ZERO |
						  R200_TXA_ARG_B_ZERO |
						  R200_TXA_ARG_C_R0_ALPHA |
						  R200_TXA_OP_MADD));
	    OUT_BATCH_REGVAL(R200_PP_TXABLEND2_1, (R200_TXA_CLAMP_0_1 |
						   R200_TXA_OUTPUT_REG_R1));
	    /* r1.b = r0.r */
	    OUT_BATCH_REGVAL(R200_PP_TXCBLEND_2, (R200_TXC_ARG_A_ZERO |
						  R200_TXC_ARG_B_ZERO |
						  R200_TXC_ARG_C_R0_COLOR |
						  R200_TXC_OP_MADD));
	    OUT_BATCH_REGVAL(R200_PP_TXCBLEND2_2, (R200_TXC_CLAMP_0_1 |
						   R200_TXC_OUTPUT_MASK_B |
						   (R200_TXC_REPL_RED << R200_TXC_REPL_ARG_C_SHIFT) |
						   R200_TXC_OUTPUT_REG_R1));
	    /* r1.a = r0.a */
	    OUT_BATCH_REGVAL(R200_PP_TXABLEND_2, (R200_TXA_ARG_A_ZERO |
						  R200_TXA_ARG_B_ZERO |
						  R200_TXA_ARG_C_R0_ALPHA |
						  R200_TXA_OP_MADD));
	    OUT_BATCH_REGVAL(R200_PP_TXABLEND2_2, (R200_TXA_CLAMP_0_1 |
						   R200_TXA_OUTPUT_REG_R1));
	    /* r0.rgb = r1.rgb */
	    OUT_BATCH_REGVAL(R200_PP_TXCBLEND_3, (R200_TXC_ARG_A_ZERO |
						  R200_TXC_ARG_B_ZERO |
						  R200_TXC_ARG_C_R1_COLOR |
						  R200_TXC_OP_MADD));
	    OUT_BATCH_REGVAL(R200_PP_TXCBLEND2_3, (R200_TXC_CLAMP_0_1 |
						   R200_TXC_OUTPUT_REG_R0));
	    /* r0.a = r1.a */
	    OUT_BATCH_REGVAL(R200_PP_TXABLEND_3, (R200_TXA_ARG_A_ZERO |
						  R200_TXA_ARG_B_ZERO |
						  R200_TXA_ARG_C_R1_ALPHA |
						  R200_TXA_OP_MADD));
	    OUT_BATCH_REGVAL(R200_PP_TXABLEND2_3, (R200_TXA_CLAMP_0_1 |
						   R200_TXA_OUTPUT_REG_R0));
	    END_BATCH();
	    break;
    }

    BEGIN_BATCH(18);
    OUT_BATCH_REGVAL(R200_PP_CNTL_X, 0);
    OUT_BATCH_REGVAL(R200_PP_TXMULTI_CTL_0, 0);
    OUT_BATCH_REGVAL(R200_PP_TXFILTER_0, (R200_CLAMP_S_CLAMP_LAST |
					  R200_CLAMP_T_CLAMP_LAST |
					  R200_MAG_FILTER_NEAREST |
					  R200_MIN_FILTER_NEAREST));
    OUT_BATCH_REGVAL(R200_PP_TXFORMAT_0, txformat);
    OUT_BATCH_REGVAL(R200_PP_TXFORMAT_X_0, 0);
    OUT_BATCH_REGVAL(R200_PP_TXSIZE_0, ((width - 1) |
					((height - 1) << RADEON_TEX_VSIZE_SHIFT)));
    OUT_BATCH_REGVAL(R200_PP_TXPITCH_0, pitch * _mesa_get_format_bytes(src_mesa_format) - 32);

    OUT_BATCH_REGSEQ(R200_PP_TXOFFSET_0, 1);
    OUT_BATCH_RELOC(offset, bo, offset, RADEON_GEM_DOMAIN_GTT|RADEON_GEM_DOMAIN_VRAM, 0, 0);

    END_BATCH();
}
Esempio n. 8
0
static void inline emit_tx_setup(struct r100_context *r100,
				 gl_format mesa_format,
				 struct radeon_bo *bo,
				 intptr_t offset,
				 unsigned width,
				 unsigned height,
				 unsigned pitch)
{
    uint32_t txformat = RADEON_TXFORMAT_NON_POWER2;
    BATCH_LOCALS(&r100->radeon);

    assert(width <= 2048);
    assert(height <= 2048);
    assert(offset % 32 == 0);

    /* XXX others?  BE/LE? */
    switch (mesa_format) {
    case MESA_FORMAT_ARGB8888:
	    txformat |= RADEON_TXFORMAT_ARGB8888 | RADEON_TXFORMAT_ALPHA_IN_MAP;
	    break;
    case MESA_FORMAT_RGBA8888:
            txformat |= RADEON_TXFORMAT_RGBA8888 | RADEON_TXFORMAT_ALPHA_IN_MAP;
            break;
    case MESA_FORMAT_XRGB8888:
	    txformat |= RADEON_TXFORMAT_ARGB8888;
	    break;
    case MESA_FORMAT_RGB565:
	    txformat |= RADEON_TXFORMAT_RGB565;
	    break;
    case MESA_FORMAT_ARGB4444:
	    txformat |= RADEON_TXFORMAT_ARGB4444 | RADEON_TXFORMAT_ALPHA_IN_MAP;
	    break;
    case MESA_FORMAT_ARGB1555:
	    txformat |= RADEON_TXFORMAT_ARGB1555 | RADEON_TXFORMAT_ALPHA_IN_MAP;
	    break;
    case MESA_FORMAT_A8:
    case MESA_FORMAT_I8:
	    txformat |= RADEON_TXFORMAT_I8 | RADEON_TXFORMAT_ALPHA_IN_MAP;
	    break;
    case MESA_FORMAT_L8:
            txformat |= RADEON_TXFORMAT_I8;
            break;
    case MESA_FORMAT_AL88:
            txformat |= RADEON_TXFORMAT_AI88 | RADEON_TXFORMAT_ALPHA_IN_MAP;
            break;
    default:
	    break;
    }
    
    if (bo->flags & RADEON_BO_FLAGS_MACRO_TILE)
       offset |= RADEON_TXO_MACRO_TILE;
    if (bo->flags & RADEON_BO_FLAGS_MICRO_TILE)
       offset |= RADEON_TXO_MICRO_TILE_X2;

    BEGIN_BATCH(18);
    OUT_BATCH_REGVAL(RADEON_PP_CNTL, RADEON_TEX_0_ENABLE | RADEON_TEX_BLEND_0_ENABLE);
    OUT_BATCH_REGVAL(RADEON_PP_TXCBLEND_0, (RADEON_COLOR_ARG_A_ZERO |
					    RADEON_COLOR_ARG_B_ZERO |
					    RADEON_COLOR_ARG_C_T0_COLOR |
					    RADEON_BLEND_CTL_ADD |
					    RADEON_CLAMP_TX));
    OUT_BATCH_REGVAL(RADEON_PP_TXABLEND_0, (RADEON_ALPHA_ARG_A_ZERO |
					    RADEON_ALPHA_ARG_B_ZERO |
					    RADEON_ALPHA_ARG_C_T0_ALPHA |
					    RADEON_BLEND_CTL_ADD |
					    RADEON_CLAMP_TX));
    OUT_BATCH_REGVAL(RADEON_PP_TXFILTER_0, (RADEON_CLAMP_S_CLAMP_LAST |
					    RADEON_CLAMP_T_CLAMP_LAST |
					    RADEON_MAG_FILTER_NEAREST |
					    RADEON_MIN_FILTER_NEAREST));
    OUT_BATCH_REGVAL(RADEON_PP_TXFORMAT_0, txformat);
    OUT_BATCH_REGVAL(RADEON_PP_TEX_SIZE_0, ((width - 1) |
					    ((height - 1) << RADEON_TEX_VSIZE_SHIFT)));
    OUT_BATCH_REGVAL(RADEON_PP_TEX_PITCH_0, pitch * _mesa_get_format_bytes(mesa_format) - 32);

    OUT_BATCH_REGSEQ(RADEON_PP_TXOFFSET_0, 1);
    OUT_BATCH_RELOC(offset, bo, offset, RADEON_GEM_DOMAIN_GTT|RADEON_GEM_DOMAIN_VRAM, 0, 0);

    END_BATCH();
}