commit 88bc75f004452fe3a2005de10e0b132f68b3abc5 Author: Owen W. Taylor Date: Thu Apr 3 00:54:15 2008 -0400 Fix pitch and clamp mode for repeating textures - We can always use TXPITCH on a R300 even when repeating, (previous check for pitch matching width was also wrong) - Fix clamp mode for repeating textures to be WRAP diff --git a/src/radeon_exa_render.c b/src/radeon_exa_render.c index 9496bb6..4e5ab81 100644 --- a/src/radeon_exa_render.c +++ b/src/radeon_exa_render.c @@ -870,6 +870,7 @@ static Bool FUNC_NAME(R300TextureSetup)(PicturePtr pPict, PixmapPtr pPix, if ((txpitch & 0x1f) != 0) RADEON_FALLBACK(("Bad texture pitch 0x%x\n", (int)txpitch)); + /* TXPITCH = pixels (texels) per line - 1 */ pixel_shift = pPix->drawable.bitsPerPixel >> 4; txpitch >>= pixel_shift; txpitch -= 1; @@ -894,20 +895,21 @@ static Bool FUNC_NAME(R300TextureSetup)(PicturePtr pPict, PixmapPtr pPix, if (IS_R500_3D && ((h - 1) & 0x800)) txpitch |= R500_TXHEIGHT_11; - if (pPict->repeat) { - if ((h != 1) && - (((w * pPix->drawable.bitsPerPixel / 8 + 31) & ~31) != txpitch)) - RADEON_FALLBACK(("Width %d and pitch %u not compatible for repeat\n", - w, (unsigned)txpitch)); - } else - txformat0 |= R300_TXPITCH_EN; - + /* Use TXPITCH instead of TXWIDTH for address computations: we could + * omit this if there is no padding, but there is no apparent advantage + * in doing so. + */ + txformat0 |= R300_TXPITCH_EN; info->texW[unit] = w; info->texH[unit] = h; - txfilter = (R300_TX_CLAMP_S(R300_TX_CLAMP_CLAMP_LAST) | - R300_TX_CLAMP_T(R300_TX_CLAMP_CLAMP_LAST)); + if (pPict->repeat) + txfilter = (R300_TX_CLAMP_S(R300_TX_CLAMP_WRAP) | + R300_TX_CLAMP_T(R300_TX_CLAMP_WRAP)); + else + txfilter = (R300_TX_CLAMP_S(R300_TX_CLAMP_CLAMP_LAST) | + R300_TX_CLAMP_T(R300_TX_CLAMP_CLAMP_LAST)); txfilter |= (unit << R300_TX_ID_SHIFT);