radeon: Remove the loop from stride size calculation.
authorPauli Nieminen <suokkos@gmail.com>
Sat, 6 Feb 2010 01:01:57 +0000 (03:01 +0200)
committerPauli Nieminen <suokkos@gmail.com>
Sat, 6 Feb 2010 17:14:20 +0000 (19:14 +0200)
Changed stride size calculation to do the math by rounding
the value instead of loop. r600 minimum stride is 256 which
might might cause up to about 60 rounds of the loop.

src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c

index 90a4e4f00adcb5675584fd68ef0283c808da3be3..836b042ca4cede3b1b9f0e9cc8e0c33b6fb6277d 100644 (file)
@@ -41,18 +41,24 @@ static unsigned get_aligned_compressed_row_stride(
                unsigned width,
                unsigned minStride)
 {
-       const unsigned blockSize = _mesa_get_format_bytes(format);
-       unsigned blockWidth, blockHeight, numXBlocks;
+       const unsigned blockBytes = _mesa_get_format_bytes(format);
+       unsigned blockWidth, blockHeight;
+       unsigned stride;
 
        _mesa_get_format_block_size(format, &blockWidth, &blockHeight);
-       numXBlocks = (width + blockWidth - 1) / blockWidth;
 
-       while (numXBlocks * blockSize < minStride)
-       {
-               ++numXBlocks;
-       }
+       /* Count number of blocks required to store the given width.
+        * And then multiple it with bytes required to store a block.
+        */
+       stride = (width + blockWidth - 1) / blockWidth * blockBytes;
+
+       /* Round the given minimum stride to the next full blocksize.
+        * (minStride + blockBytes - 1) / blockBytes * blockBytes
+        */
+       if ( stride < minStride )
+               stride = (minStride + blockBytes - 1) / blockBytes * blockBytes;
 
-       return numXBlocks * blockSize;
+       return stride;
 }
 
 static unsigned get_compressed_image_size(