nv50: account for pesky prefetch in size calculation of linear textures
authorChristoph Bumiller <e0425955@student.tuwien.ac.at>
Tue, 2 Apr 2013 22:18:29 +0000 (00:18 +0200)
committerChristoph Bumiller <e0425955@student.tuwien.ac.at>
Wed, 3 Apr 2013 10:54:44 +0000 (12:54 +0200)
src/gallium/drivers/nv50/nv50_miptree.c

index 5c839a811041b71e251ff4fcb2720265aece63b3..ed0f8c2b2f1f4ad396f22c553223f43bf5c7ed3b 100644 (file)
@@ -217,6 +217,7 @@ nv50_miptree_init_layout_linear(struct nv50_miptree *mt)
 {
    struct pipe_resource *pt = &mt->base.base;
    const unsigned blocksize = util_format_get_blocksize(pt->format);
+   unsigned h = pt->height0;
 
    if (util_format_is_depth_or_stencil(pt->format))
       return FALSE;
@@ -228,7 +229,11 @@ nv50_miptree_init_layout_linear(struct nv50_miptree *mt)
 
    mt->level[0].pitch = align(pt->width0 * blocksize, 64);
 
-   mt->total_size = mt->level[0].pitch * pt->height0;
+   /* Account for very generous prefetch (allocate size as if tiled). */
+   h = MAX2(h, 8);
+   h = util_next_power_of_two(h);
+
+   mt->total_size = mt->level[0].pitch * h;
 
    return TRUE;
 }