nv50,nvc0: update the format tables
[mesa.git] / src / gallium / drivers / nvc0 / nvc0_transfer.c
index 82755113008a18740e6b400d2153a2124f9c2a1e..7bbfe057e58b6c798265614383fd509be2346848 100644 (file)
@@ -4,16 +4,17 @@
 #include "nvc0_context.h"
 #include "nvc0_transfer.h"
 
-#include "nv50_defs.xml.h"
+#include "nv50/nv50_defs.xml.h"
 
 struct nvc0_transfer {
    struct pipe_transfer base;
    struct nvc0_m2mf_rect rect[2];
    uint32_t nblocksx;
-   uint32_t nblocksy;
+   uint16_t nblocksy;
+   uint16_t nlayers;
 };
 
-static void
+void
 nvc0_m2mf_transfer_rect(struct pipe_screen *pscreen,
                         const struct nvc0_m2mf_rect *dst,
                         const struct nvc0_m2mf_rect *src,
@@ -103,11 +104,11 @@ nvc0_m2mf_transfer_rect(struct pipe_screen *pscreen,
 }
 
 void
-nvc0_m2mf_push_linear(struct nvc0_context *nvc0,
-                      struct nouveau_bo *dst, unsigned domain, int offset,
+nvc0_m2mf_push_linear(struct nouveau_context *nv,
+                      struct nouveau_bo *dst, unsigned offset, unsigned domain,
                       unsigned size, void *data)
 {
-   struct nouveau_channel *chan = nvc0->screen->base.channel;
+   struct nouveau_channel *chan = nv->screen->channel;
    uint32_t *src = (uint32_t *)data;
    unsigned count = (size + 3) / 4;
 
@@ -142,12 +143,12 @@ nvc0_m2mf_push_linear(struct nvc0_context *nvc0,
 }
 
 void
-nvc0_m2mf_copy_linear(struct nvc0_context *nvc0,
+nvc0_m2mf_copy_linear(struct nouveau_context *nv,
                       struct nouveau_bo *dst, unsigned dstoff, unsigned dstdom,
                       struct nouveau_bo *src, unsigned srcoff, unsigned srcdom,
                       unsigned size)
 {
-   struct nouveau_channel *chan = nvc0->screen->base.channel;
+   struct nouveau_channel *chan = nv->screen->channel;
 
    while (size) {
       unsigned bytes = MIN2(size, 1 << 17);
@@ -245,6 +246,10 @@ nvc0_miptree_transfer_new(struct pipe_context *pctx,
    uint32_t w, h, d, z, layer;
    int ret;
 
+   tx = CALLOC_STRUCT(nvc0_transfer);
+   if (!tx)
+      return NULL;
+
    if (mt->layout_3d) {
       z = box->z;
       d = u_minify(res->depth0, level);
@@ -254,10 +259,7 @@ nvc0_miptree_transfer_new(struct pipe_context *pctx,
       d = 1;
       layer = box->z;
    }
-
-   tx = CALLOC_STRUCT(nvc0_transfer);
-   if (!tx)
-      return NULL;
+   tx->nlayers = box->depth;
 
    pipe_resource_reference(&tx->base.resource, res);
 
@@ -291,7 +293,7 @@ nvc0_miptree_transfer_new(struct pipe_context *pctx,
    size = tx->base.layer_stride;
 
    ret = nouveau_bo_new(dev, NOUVEAU_BO_GART | NOUVEAU_BO_MAP, 0,
-                        size * tx->base.box.depth, &tx->rect[1].bo);
+                        size * tx->nlayers, &tx->rect[1].bo);
    if (ret) {
       FREE(tx);
       return NULL;
@@ -304,8 +306,9 @@ nvc0_miptree_transfer_new(struct pipe_context *pctx,
    tx->rect[1].domain = NOUVEAU_BO_GART;
 
    if (usage & PIPE_TRANSFER_READ) {
+      unsigned base = tx->rect[0].base;
       unsigned i;
-      for (i = 0; i < box->depth; ++i) {
+      for (i = 0; i < tx->nlayers; ++i) {
          nvc0_m2mf_transfer_rect(pscreen, &tx->rect[1], &tx->rect[0],
                                  tx->nblocksx, tx->nblocksy);
          if (mt->layout_3d)
@@ -314,8 +317,10 @@ nvc0_miptree_transfer_new(struct pipe_context *pctx,
             tx->rect[0].base += mt->layer_stride;
          tx->rect[1].base += size;
       }
+      tx->rect[0].z = z;
+      tx->rect[0].base = base;
+      tx->rect[1].base = 0;
    }
-   tx->rect[0].z = z;
 
    return &tx->base;
 }
@@ -330,7 +335,7 @@ nvc0_miptree_transfer_del(struct pipe_context *pctx,
    unsigned i;
 
    if (tx->base.usage & PIPE_TRANSFER_WRITE) {
-      for (i = 0; i < tx->base.box.depth; ++i) {
+      for (i = 0; i < tx->nlayers; ++i) {
          nvc0_m2mf_transfer_rect(pscreen, &tx->rect[0], &tx->rect[1],
                                  tx->nblocksx, tx->nblocksy);
          if (mt->layout_3d)