diff options
author | Maciej Cencora <m.cencora@gmail.com> | 2010-01-16 21:44:24 +0100 |
---|---|---|
committer | Maciej Cencora <m.cencora@gmail.com> | 2010-01-16 23:38:29 +0100 |
commit | f24a6f43b40e1da2a8fe4f1737b89c3e0c82454b (patch) | |
tree | 94bf638180116f0fdaec4d51542f3fb90665b412 | |
parent | 1807a0fe296ea9f7efd42becf30b88ce4808f4f8 (diff) |
radeon: properly calculate rowstride for NPOT textures
-rw-r--r-- | src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c b/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c index 55f67004c8..a825ee1f28 100644 --- a/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c +++ b/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c @@ -82,12 +82,28 @@ static int find_next_power_of_two(GLuint value) return (1 << i); } +static unsigned is_pow(unsigned value) +{ + unsigned m; + + for (m = 1; m < value; m *= 2) {} + + return value == m; +} + unsigned get_texture_image_row_stride(radeonContextPtr rmesa, gl_format format, unsigned width) { if (_mesa_is_format_compressed(format)) { return get_aligned_compressed_row_stride(format, width, rmesa->texture_compressed_row_align); } else { - unsigned row_align = rmesa->texture_row_align - 1; + unsigned row_align; + + if (is_pow(width)) { + row_align = rmesa->texture_row_align - 1; + } else { + row_align = rmesa->texture_rect_row_align - 1; + } + return (_mesa_format_row_stride(format, width) + row_align) & ~row_align; } } |