radeon: properly calculate rowstride for tiled images
authorMaciej Cencora <m.cencora@gmail.com>
Sun, 7 Mar 2010 11:09:43 +0000 (12:09 +0100)
committerMaciej Cencora <m.cencora@gmail.com>
Sun, 7 Mar 2010 11:21:30 +0000 (12:21 +0100)
src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c
src/mesa/drivers/dri/radeon/radeon_mipmap_tree.h
src/mesa/drivers/dri/radeon/radeon_texture.c
src/mesa/drivers/dri/radeon/radeon_tile.c

index 8c1f96ede0481663deeaba4399916cb1527983b9..ee91f30be5cc0ab79f3597398d8d1cae3d2dd2d0 100644 (file)
@@ -105,17 +105,21 @@ static unsigned is_pot(unsigned value)
        return value == m;
 }
 
-unsigned get_texture_image_row_stride(radeonContextPtr rmesa, gl_format format, unsigned width)
+unsigned get_texture_image_row_stride(radeonContextPtr rmesa, gl_format format, unsigned width, unsigned tiling)
 {
        if (_mesa_is_format_compressed(format)) {
                return get_aligned_compressed_row_stride(format, width, rmesa->texture_compressed_row_align);
        } else {
                unsigned row_align;
 
-               if (is_pot(width)) {
-                       row_align = rmesa->texture_row_align - 1;
-               } else {
+               if (!is_pot(width)) {
                        row_align = rmesa->texture_rect_row_align - 1;
+               } else if (tiling) {
+                       unsigned tileWidth, tileHeight;
+                       get_tile_size(format, &tileWidth, &tileHeight);
+                       row_align = tileWidth * _mesa_get_format_bytes(format) - 1;
+               } else {
+                       row_align = rmesa->texture_row_align - 1;
                }
 
                return (_mesa_format_row_stride(format, width) + row_align) & ~row_align;
@@ -137,7 +141,7 @@ static void compute_tex_image_offset(radeonContextPtr rmesa, radeon_mipmap_tree
 
        height = _mesa_next_pow_two_32(lvl->height);
 
-       lvl->rowstride = get_texture_image_row_stride(rmesa, mt->mesaFormat, lvl->width);
+       lvl->rowstride = get_texture_image_row_stride(rmesa, mt->mesaFormat, lvl->width, mt->tilebits);
        lvl->size = get_texture_image_size(mt->mesaFormat, lvl->rowstride, lvl->height, lvl->depth, mt->tilebits);
 
        assert(lvl->size > 0);
index 69103e68de1e8d126f32f16042ddf54011f53ffa..088f97017223dcd6222afe7591ca838c46c6e48d 100644 (file)
@@ -90,7 +90,7 @@ GLuint radeon_miptree_image_offset(radeon_mipmap_tree *mt,
                                   GLuint face, GLuint level);
 uint32_t get_base_teximage_offset(radeonTexObj *texObj);
 
-unsigned get_texture_image_row_stride(radeonContextPtr rmesa, gl_format format, unsigned width);
+unsigned get_texture_image_row_stride(radeonContextPtr rmesa, gl_format format, unsigned width, unsigned tiling);
 
 unsigned get_texture_image_size(
                gl_format format,
index ff37fd3e86e645b3d64665a853dce1a647c63a0a..62dec2d4e06712d7f44d8808d1c71ac15897eaa1 100644 (file)
@@ -664,6 +664,7 @@ static void radeon_store_teximage(GLcontext* ctx, int dims,
                struct gl_texture_image *texImage,
                int compressed)
 {
+       radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
        radeonTexObj *t = radeon_tex_obj(texObj);
        radeon_texture_image* image = get_radeon_texture_image(texImage);
 
@@ -678,8 +679,7 @@ static void radeon_store_teximage(GLcontext* ctx, int dims,
                dstRowStride = image->mt->levels[image->mtlevel].rowstride;
        } else if (t->bo) {
                /* TFP case */
-               /* TODO */
-               assert(0);
+               dstRowStride = get_texture_image_row_stride(rmesa, texImage->TexFormat, width, 0);
        } else {
                dstRowStride = _mesa_format_row_stride(texImage->TexFormat, texImage->Width);
        }
index 935fa45e04170c705ce3d8fbb2e4b0c3a1a2258b..403da1101063c2ff70307b67b50b6191848db208 100644 (file)
@@ -214,7 +214,6 @@ void tile_image(const void * src, unsigned src_pitch,
 {
     assert(src_pitch >= width);
     assert(dst_pitch >= width);
-    assert(dst_pitch * _mesa_get_format_bytes(format) % MICRO_TILE_SIZE == 0);
 
     radeon_print(RADEON_TEXTURE, RADEON_TRACE,
                  "Software tiling: src_pitch %d, dst_pitch %d, width %d, height %d, bpp %d\n",
@@ -439,7 +438,6 @@ void untile_image(const void * src, unsigned src_pitch,
 {
     assert(src_pitch >= width);
     assert(dst_pitch >= width);
-    assert(src_pitch * _mesa_get_format_bytes(format) % MICRO_TILE_SIZE == 0);
 
     radeon_print(RADEON_TEXTURE, RADEON_TRACE,
                  "Software untiling: src_pitch %d, dst_pitch %d, width %d, height %d, bpp %d\n",