vc4: Handle a couple of the transfer map flags.
authorEric Anholt <eric@anholt.net>
Fri, 22 Aug 2014 20:47:19 +0000 (13:47 -0700)
committerEric Anholt <eric@anholt.net>
Tue, 2 Sep 2014 19:10:56 +0000 (12:10 -0700)
This is part of fixing extremely long runtimes on some piglit tests that
involve streaming vertex reuploads due to format conversions, and will
similarly be important for X performance, which relies on these flags.

src/gallium/drivers/vc4/vc4_bufmgr.h
src/gallium/drivers/vc4/vc4_resource.c

index 14bfa2466dffd7ff4bac506bb9a8fbc4c79bb55d..00ea149bd5f888b4ee2b3b413a0abd77a90cab5f 100644 (file)
@@ -70,6 +70,9 @@ vc4_bo_reference(struct vc4_bo *bo)
 static inline void
 vc4_bo_unreference(struct vc4_bo **bo)
 {
+        if (!*bo)
+                return;
+
         if (pipe_reference(&(*bo)->reference, NULL))
                 vc4_bo_free(*bo);
         *bo = NULL;
index 98c8f89fdec48c142d717dd1111e32a694bb86b1..a71ae5bab136d1559f8092d1c47547eb2b28c31f 100644 (file)
@@ -73,15 +73,20 @@ vc4_resource_transfer_map(struct pipe_context *pctx,
         enum pipe_format format = prsc->format;
         char *buf;
 
-        vc4_flush_for_bo(pctx, rsc->bo);
+        if (usage & PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE) {
+                uint32_t size = rsc->bo->size;
+                vc4_bo_unreference(&rsc->bo);
+                rsc->bo = vc4_bo_alloc(vc4->screen, size, "resource");
+        }
+
+        if (!(usage & PIPE_TRANSFER_UNSYNCHRONIZED))
+                vc4_flush_for_bo(pctx, rsc->bo);
 
         trans = util_slab_alloc(&vc4->transfer_pool);
         if (!trans)
                 return NULL;
 
-        /* XXX: Handle DISCARD_WHOLE_RESOURCE, DONTBLOCK, UNSYNCHRONIZED,
-         * DISCARD_WHOLE_RESOURCE, PERSISTENT, COHERENT.
-         */
+        /* XXX: Handle DONTBLOCK, DISCARD_RANGE, PERSISTENT, COHERENT. */
 
         /* util_slab_alloc() doesn't zero: */
         memset(trans, 0, sizeof(*trans));