From 134b24ac63b01e7ab49b45efef4113f8debba5bc Mon Sep 17 00:00:00 2001 From: Owen Taylor Date: Sun, 13 Apr 2008 11:37:55 -0400 Subject: [PATCH] On R100 + R200, use border color for RepeatNone If the repeat is None, use the GL "CLAMP_TO_BORDER" mode with a transparent border pixel to get the right handling of transparency at the edges. This change does not produce correct rendering results on R100. http://bugs.freedesktop.org/show_bug.cgi?id=15333 --- src/radeon_exa_render.c | 42 ++++++++++++++++++++++++++++-------------- src/radeon_reg.h | 7 +++++++ 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/src/radeon_exa_render.c b/src/radeon_exa_render.c index 69a0ebf..8a60958 100644 --- a/src/radeon_exa_render.c +++ b/src/radeon_exa_render.c @@ -339,6 +339,7 @@ static Bool FUNC_NAME(R100TextureSetup)(PicturePtr pPict, PixmapPtr pPix, CARD32 txfilter, txformat, txoffset, txpitch; int w = pPict->pDrawable->width; int h = pPict->pDrawable->height; + Bool repeat = pPict->repeat && !(unit == 0 && (need_src_tile_x || need_src_tile_y)); int i; ACCEL_PREAMBLE(); @@ -359,7 +360,7 @@ static Bool FUNC_NAME(R100TextureSetup)(PicturePtr pPict, PixmapPtr pPix, if (RADEONPixmapIsColortiled(pPix)) txoffset |= RADEON_TXO_MACRO_TILE; - if (pPict->repeat && !(unit == 0 && (need_src_tile_x || need_src_tile_y))) { + if (repeat) { if (!RADEONPitchMatches(pPix)) RADEON_FALLBACK(("Width %d and pitch %u not compatible for repeat\n", w, (unsigned)txpitch)); @@ -384,13 +385,15 @@ static Bool FUNC_NAME(R100TextureSetup)(PicturePtr pPict, PixmapPtr pPix, RADEON_FALLBACK(("Bad filter 0x%x\n", pPict->filter)); } - if (pPict->repeat && !(unit == 0 && need_src_tile_x)) - txfilter |= RADEON_CLAMP_S_WRAP; - - if (pPict->repeat && !(unit == 0 && need_src_tile_y)) - txfilter |= RADEON_CLAMP_T_WRAP; + if (repeat) + txfilter |= RADEON_CLAMP_S_WRAP | + RADEON_CLAMP_T_WRAP; + else + txfilter |= RADEON_CLAMP_S_CLAMP_GL | + RADEON_CLAMP_T_CLAMP_GL | + RADEON_BORDER_MODE_D3D; - BEGIN_ACCEL(5); + BEGIN_ACCEL(!repeat ? 6 : 5); if (unit == 0) { OUT_ACCEL_REG(RADEON_PP_TXFILTER_0, txfilter); OUT_ACCEL_REG(RADEON_PP_TXFORMAT_0, txformat); @@ -399,6 +402,8 @@ static Bool FUNC_NAME(R100TextureSetup)(PicturePtr pPict, PixmapPtr pPix, (pPix->drawable.width - 1) | ((pPix->drawable.height - 1) << RADEON_TEX_VSIZE_SHIFT)); OUT_ACCEL_REG(RADEON_PP_TEX_PITCH_0, txpitch - 32); + if (!repeat) + OUT_ACCEL_REG(RADEON_PP_BORDER_COLOR_0, 0); } else { OUT_ACCEL_REG(RADEON_PP_TXFILTER_1, txfilter); OUT_ACCEL_REG(RADEON_PP_TXFORMAT_1, txformat); @@ -407,6 +412,8 @@ static Bool FUNC_NAME(R100TextureSetup)(PicturePtr pPict, PixmapPtr pPix, (pPix->drawable.width - 1) | ((pPix->drawable.height - 1) << RADEON_TEX_VSIZE_SHIFT)); OUT_ACCEL_REG(RADEON_PP_TEX_PITCH_1, txpitch - 32); + if (!repeat) + OUT_ACCEL_REG(RADEON_PP_BORDER_COLOR_1, 0); } FINISH_ACCEL(); @@ -645,6 +652,7 @@ static Bool FUNC_NAME(R200TextureSetup)(PicturePtr pPict, PixmapPtr pPix, CARD32 txfilter, txformat, txoffset, txpitch; int w = pPict->pDrawable->width; int h = pPict->pDrawable->height; + Bool repeat = pPict->repeat && !(unit == 0 && (need_src_tile_x || need_src_tile_y)); int i; ACCEL_PREAMBLE(); @@ -665,7 +673,7 @@ static Bool FUNC_NAME(R200TextureSetup)(PicturePtr pPict, PixmapPtr pPix, if (RADEONPixmapIsColortiled(pPix)) txoffset |= R200_TXO_MACRO_TILE; - if (pPict->repeat && !(unit == 0 && (need_src_tile_x || need_src_tile_y))) { + if (repeat) { #ifdef R200_NEEDS_MATCHING_PITCH if (!RADEONPitchMatches(pPix)) RADEON_FALLBACK(("Width %d and pitch %u not compatible for repeat\n", @@ -694,13 +702,15 @@ static Bool FUNC_NAME(R200TextureSetup)(PicturePtr pPict, PixmapPtr pPix, RADEON_FALLBACK(("Bad filter 0x%x\n", pPict->filter)); } - if (pPict->repeat && !(unit == 0 && need_src_tile_x)) - txfilter |= R200_CLAMP_S_WRAP; - - if (pPict->repeat && !(unit == 0 && need_src_tile_y)) - txfilter |= R200_CLAMP_T_WRAP; + if (repeat) + txfilter |= R200_CLAMP_S_WRAP | + R200_CLAMP_T_WRAP; + else + txfilter |= R200_CLAMP_S_CLAMP_GL | + R200_CLAMP_T_CLAMP_GL | + R200_BORDER_MODE_D3D; - BEGIN_ACCEL(6); + BEGIN_ACCEL(!repeat ? 7 : 6); if (unit == 0) { OUT_ACCEL_REG(R200_PP_TXFILTER_0, txfilter); OUT_ACCEL_REG(R200_PP_TXFORMAT_0, txformat); @@ -709,6 +719,8 @@ static Bool FUNC_NAME(R200TextureSetup)(PicturePtr pPict, PixmapPtr pPix, ((pPix->drawable.height - 1) << RADEON_TEX_VSIZE_SHIFT)); OUT_ACCEL_REG(R200_PP_TXPITCH_0, txpitch - 32); OUT_ACCEL_REG(R200_PP_TXOFFSET_0, txoffset); + if (!repeat) + OUT_ACCEL_REG(R200_PP_BORDER_COLOR_0, 0); } else { OUT_ACCEL_REG(R200_PP_TXFILTER_1, txfilter); OUT_ACCEL_REG(R200_PP_TXFORMAT_1, txformat); @@ -717,6 +729,8 @@ static Bool FUNC_NAME(R200TextureSetup)(PicturePtr pPict, PixmapPtr pPix, ((pPix->drawable.height - 1) << RADEON_TEX_VSIZE_SHIFT)); OUT_ACCEL_REG(R200_PP_TXPITCH_1, txpitch - 32); OUT_ACCEL_REG(R200_PP_TXOFFSET_1, txoffset); + if (!repeat) + OUT_ACCEL_REG(R200_PP_BORDER_COLOR_1, 0); } FINISH_ACCEL(); diff --git a/src/radeon_reg.h b/src/radeon_reg.h index aebc7ac..4d400a9 100644 --- a/src/radeon_reg.h +++ b/src/radeon_reg.h @@ -2677,6 +2677,13 @@ #define R200_PP_TXPITCH_4 0x2c90 /* NPOT only */ #define R200_PP_TXPITCH_5 0x2cb0 /* NPOT only */ +#define R200_PP_BORDER_COLOR_0 0x2c14 +#define R200_PP_BORDER_COLOR_1 0x2c34 +#define R200_PP_BORDER_COLOR_2 0x2c54 +#define R200_PP_BORDER_COLOR_3 0x2c74 +#define R200_PP_BORDER_COLOR_4 0x2c94 +#define R200_PP_BORDER_COLOR_5 0x2cb4 + #define R200_PP_TXOFFSET_0 0x2d00 # define R200_TXO_ENDIAN_NO_SWAP (0 << 0) # define R200_TXO_ENDIAN_BYTE_SWAP (1 << 0) -- 1.5.4.5