summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/radeon
diff options
context:
space:
mode:
authorPauli Nieminen <suokkos@gmail.com>2010-02-06 03:01:57 +0200
committerPauli Nieminen <suokkos@gmail.com>2010-02-06 19:14:20 +0200
commit9d5f88250379666961f92a7e20cf0d48907c38e2 (patch)
tree4cce54e50209a050d66ce11303fe50df271f6a70 /src/mesa/drivers/dri/radeon
parent78572ebcb3bf6b1c931ee6ea4ba2fda831c11c94 (diff)
radeon: Remove the loop from stride size calculation.
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.
Diffstat (limited to 'src/mesa/drivers/dri/radeon')
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c b/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c
index 90a4e4f00a..836b042ca4 100644
--- a/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c
+++ b/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c
@@ -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(