Mesa (refs/tags/black-loading-screen-fked-after): nouveau: transfer_map misc

Emil Velikov evelikov at kemper.freedesktop.org
Mon Sep 1 00:17:34 UTC 2014


Module: Mesa
Branch: refs/tags/black-loading-screen-fked-after
Commit: cf6e870e618ca2e1877b54e0a51036ceecf3917d
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=cf6e870e618ca2e1877b54e0a51036ceecf3917d

Author: Emil Velikov <emil.l.velikov at gmail.com>
Date:   Thu Jun 13 14:42:50 2013 +0100

nouveau: transfer_map misc

create transfer_init() helper
thus, calloc_struct(nouveau_transfer)
set ptransfer at the top
convert != BO_GART to 'else'

Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>

---

 src/gallium/drivers/nouveau/nouveau_buffer.c |   34 ++++++++++++++++++--------
 1 file changed, 24 insertions(+), 10 deletions(-)

diff --git a/src/gallium/drivers/nouveau/nouveau_buffer.c b/src/gallium/drivers/nouveau/nouveau_buffer.c
index 2335d18..708b47e 100644
--- a/src/gallium/drivers/nouveau/nouveau_buffer.c
+++ b/src/gallium/drivers/nouveau/nouveau_buffer.c
@@ -225,6 +225,25 @@ nouveau_buffer_busy(struct nv04_resource *buf, unsigned rw)
       return (buf->fence && !nouveau_fence_signalled(buf->fence));
 }
 
+static INLINE void
+nouveau_buffer_transfer_init(struct nouveau_transfer *tx,
+                             struct pipe_resource *resource,
+                             const struct pipe_box *box,
+                             unsigned usage)
+{
+   tx->base.resource = resource;
+   tx->base.level = 0;
+   tx->base.usage = usage;
+   tx->base.box.x = box->x;
+   tx->base.box.y = 0;
+   tx->base.box.z = 0;
+   tx->base.box.width = box->width;
+   tx->base.box.height = 1;
+   tx->base.box.depth = 1;
+   tx->base.stride = 0;
+   tx->base.layer_stride = 0;
+}
+
 static void *
 nouveau_buffer_transfer_map(struct pipe_context *pipe,
                             struct pipe_resource *resource,
@@ -234,17 +253,15 @@ nouveau_buffer_transfer_map(struct pipe_context *pipe,
 {
    struct nouveau_context *nv = nouveau_context(pipe);
    struct nv04_resource *buf = nv04_resource(resource);
-   struct nouveau_transfer *tx = MALLOC_STRUCT(nouveau_transfer);
+   struct nouveau_transfer *tx = CALLOC_STRUCT(nouveau_transfer);
    uint8_t *map;
    int ret;
 
    if (!tx)
       return NULL;
 
-   tx->base.resource = resource;
-   tx->base.box.x = box->x;
-   tx->base.box.width = box->width;
-   tx->base.usage = usage;
+   nouveau_buffer_transfer_init(tx, resource, box, usage);
+   *ptransfer = &tx->base;
 
    if (usage & PIPE_TRANSFER_READ)
       NOUVEAU_DRV_STAT(nv->screen, buf_transfers_rd, 1);
@@ -256,10 +273,8 @@ nouveau_buffer_transfer_map(struct pipe_context *pipe,
          if (buf->status & NOUVEAU_BUFFER_STATUS_GPU_WRITING)
             nouveau_buffer_download(nv, buf, 0, buf->base.width0);
       }
-   }
-
-   if (buf->domain != NOUVEAU_BO_GART) {
-      *ptransfer = &tx->base;
+   } else
+   if (unlikely(buf->domain == 0)) {
       return buf->data + box->x;
    }
 
@@ -283,7 +298,6 @@ nouveau_buffer_transfer_map(struct pipe_context *pipe,
          nouveau_buffer_sync(buf, tx->base.usage & PIPE_TRANSFER_READ_WRITE);
       }
    }
-   *ptransfer = &tx->base;
    return map;
 }
 




More information about the mesa-commit mailing list