nouveau: Fix nv20-40 swizzled miptree RTs
[mesa.git] / src / gallium / drivers / nv30 / nv30_transfer.c
index 5e429b4d85c9adf059d30d214dc7b86f959084eb..68047c47ec52f7f64d00d8f22f0a3c786d6147f0 100644 (file)
@@ -1,6 +1,7 @@
 #include <pipe/p_state.h>
 #include <pipe/p_defines.h>
 #include <pipe/p_inlines.h>
+#include <util/u_format.h>
 #include <util/u_memory.h>
 #include <util/u_math.h>
 #include <nouveau/nouveau_winsys.h>
@@ -11,7 +12,7 @@
 struct nv30_transfer {
        struct pipe_transfer base;
        struct pipe_surface *surface;
-       bool direct;
+       boolean direct;
 };
 
 static void
@@ -24,9 +25,6 @@ nv30_compatible_transfer_tex(struct pipe_texture *pt, unsigned level,
        template->width0 = u_minify(pt->width0, level);
        template->height0 = u_minify(pt->height0, level);
        template->depth0 = 1;
-       template->block = pt->block;
-       template->nblocksx[0] = pt->nblocksx[level];
-       template->nblocksy[0] = pt->nblocksx[level];
        template->last_level = 0;
        template->nr_samples = pt->nr_samples;
 
@@ -49,14 +47,10 @@ nv30_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
                return NULL;
 
        pipe_texture_reference(&tx->base.texture, pt);
-       tx->base.format = pt->format;
        tx->base.x = x;
        tx->base.y = y;
        tx->base.width = w;
        tx->base.height = h;
-       tx->base.block = pt->block;
-       tx->base.nblocksx = pt->nblocksx[level];
-       tx->base.nblocksy = pt->nblocksy[level];
        tx->base.stride = mt->level[level].pitch;
        tx->base.usage = usage;
        tx->base.face = face;
@@ -132,7 +126,7 @@ nv30_transfer_del(struct pipe_transfer *ptx)
 
                dst = pscreen->get_tex_surface(pscreen, ptx->texture,
                                               ptx->face, ptx->level, ptx->zslice,
-                                              PIPE_BUFFER_USAGE_GPU_WRITE);
+                                              PIPE_BUFFER_USAGE_GPU_WRITE | NOUVEAU_BUFFER_USAGE_NO_RENDER);
 
                /* TODO: Check if SIFM can deal with x,y,w,h when swizzling */
                nvscreen->eng2d->copy(nvscreen->eng2d,
@@ -158,7 +152,7 @@ nv30_transfer_map(struct pipe_screen *pscreen, struct pipe_transfer *ptx)
                                    pipe_transfer_buffer_flags(ptx));
 
        return map + ns->base.offset +
-              ptx->y * ns->pitch + ptx->x * ptx->block.size;
+              ptx->y * ns->pitch + ptx->x * util_format_get_blocksize(ptx->texture->format);
 }
 
 static void