From c40a7aa3989576a8144213e2f31b892d21df8686 Mon Sep 17 00:00:00 2001 From: "Owen W. Taylor" Date: Thu, 3 Apr 2008 14:43:55 -0400 Subject: R3xx/R5xx: 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 --- src/radeon_exa_render.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/radeon_exa_render.c b/src/radeon_exa_render.c index 9496bb66..4e5ab81f 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); -- cgit v1.2.3