nv50: slightly better miptree allocation
authorBen Skeggs <skeggsb@gmail.com>
Mon, 5 Jan 2009 03:07:48 +0000 (14:07 +1100)
committerBen Skeggs <skeggsb@gmail.com>
Mon, 5 Jan 2009 21:05:57 +0000 (08:05 +1100)
I swear this didn't work last time I tried it..  Anyhow, still only
suitable for 2D miptrees - more coming once I know the layout.

src/gallium/drivers/nv50/nv50_miptree.c

index 28a8bdc0fab06526d2f7369f8b08612cecd7ddc4..0e46a2b0be084ccf55b7e9ec610909fb9fd0cc39 100644 (file)
@@ -31,7 +31,7 @@ nv50_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt)
 {
        struct pipe_winsys *ws = pscreen->winsys;
        struct nv50_miptree *mt = CALLOC_STRUCT(nv50_miptree);
-       unsigned usage, pitch;
+       unsigned usage, pitch, width, height;
 
        mt->base = *pt;
        mt->base.refcount = 1;
@@ -47,11 +47,12 @@ nv50_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt)
                break;
        }
 
-       pitch = ((pt->width[0] + 63) & ~63) * pt->block.size;
-       /*XXX*/
-       pitch *= 2;
+       width = align(pt->width[0], 8);
+       height = align(pt->height[0], 8);
+       pitch = width * pt->block.size;
+       pitch = (pitch + 63) & ~63;
 
-       mt->buffer = ws->buffer_create(ws, 256, usage, pitch * pt->height[0]);
+       mt->buffer = ws->buffer_create(ws, 256, usage, pitch * height);
        if (!mt->buffer) {
                FREE(mt);
                return NULL;