[Mesa-dev] [PATCH] mesa: fix dstRowDiff computation in RGTC texstore functions

Ian Romanick idr at freedesktop.org
Fri Apr 8 09:05:30 PDT 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 04/05/2011 04:36 PM, Marek Olšák wrote:
> Copied from libtxc_dxtn, this fixes NPOT RGTC1 textures with r300g.
> I also did the same for RGTC2.
> ---
>  src/mesa/main/texcompress_rgtc.c |    8 ++++----
>  1 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/src/mesa/main/texcompress_rgtc.c b/src/mesa/main/texcompress_rgtc.c
> index c50df19..d9de9be 100644
> --- a/src/mesa/main/texcompress_rgtc.c
> +++ b/src/mesa/main/texcompress_rgtc.c
> @@ -121,7 +121,7 @@ _mesa_texstore_red_rgtc1(TEXSTORE_PARAMS)
>                                          texWidth, (GLubyte *) dstAddr);
>  
>     blkaddr = dst;
> -   dstRowDiff = dstRowStride >= (srcWidth * 4) ? dstRowStride - (((srcWidth + 3) & ~3) * 4) : 0;
> +   dstRowDiff = dstRowStride >= (srcWidth * 2) ? dstRowStride - (((srcWidth + 3) & ~3) * 2) : 0;

It took me a few minutes to convince myself why 2 and 4 (instead of 4
and 8) were correct.  It's because each block is 4 texels wide, and we
advance by 8 bytes.  8/4 = 2.  Right?  It's similar for the "* 4", but
that's 4 texels wide and 16 bytes.  Right?

A comment describing that would be nice for the next person that comes
along.

Other than that,

Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>

>     for (j = 0; j < srcHeight; j+=4) {
>        if (srcHeight > j + 3) numypixels = 4;
>        else numypixels = srcHeight - j;
> @@ -176,7 +176,7 @@ _mesa_texstore_signed_red_rgtc1(TEXSTORE_PARAMS)
>  						  texWidth, (GLubyte *) dstAddr);
>  
>     blkaddr = dst;
> -   dstRowDiff = dstRowStride >= (srcWidth * 4) ? dstRowStride - (((srcWidth + 3) & ~3) * 4) : 0;
> +   dstRowDiff = dstRowStride >= (srcWidth * 2) ? dstRowStride - (((srcWidth + 3) & ~3) * 2) : 0;
>     for (j = 0; j < srcHeight; j+=4) {
>        if (srcHeight > j + 3) numypixels = 4;
>        else numypixels = srcHeight - j;
> @@ -232,7 +232,7 @@ _mesa_texstore_rg_rgtc2(TEXSTORE_PARAMS)
>                                          texWidth, (GLubyte *) dstAddr);
>  
>     blkaddr = dst;
> -   dstRowDiff = dstRowStride >= (srcWidth * 8) ? dstRowStride - (((srcWidth + 7) & ~7) * 8) : 0;
> +   dstRowDiff = dstRowStride >= (srcWidth * 4) ? dstRowStride - (((srcWidth + 3) & ~3) * 4) : 0;
>     for (j = 0; j < srcHeight; j+=4) {
>        if (srcHeight > j + 3) numypixels = 4;
>        else numypixels = srcHeight - j;
> @@ -294,7 +294,7 @@ _mesa_texstore_signed_rg_rgtc2(TEXSTORE_PARAMS)
>  						  texWidth, (GLubyte *) dstAddr);
>  
>     blkaddr = dst;
> -   dstRowDiff = dstRowStride >= (srcWidth * 8) ? dstRowStride - (((srcWidth + 7) & ~7) * 8) : 0;
> +   dstRowDiff = dstRowStride >= (srcWidth * 4) ? dstRowStride - (((srcWidth + 3) & ~3) * 4) : 0;
>     for (j = 0; j < srcHeight; j += 4) {
>        if (srcHeight > j + 3) numypixels = 4;
>        else numypixels = srcHeight - j;

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAk2fMkkACgkQX1gOwKyEAw+0JwCfY3sujYseSkK3h2/0wZvUv6GZ
gDMAnAxyqhv1ACejhemyENLK/FJzOo+a
=CZwm
-----END PGP SIGNATURE-----


More information about the mesa-dev mailing list