iris: fix major refcounting bug with resources
authorKenneth Graunke <kenneth@whitecape.org>
Wed, 20 Jun 2018 02:22:47 +0000 (19:22 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 21 Feb 2019 18:26:07 +0000 (10:26 -0800)
DONTBLOCK -> NULL was happening after taking a reference, causing those
to live forever

This resolves the OOM problems

src/gallium/drivers/iris/iris_resource.c

index f4e9318d297cea8761f92dba16b52f737a0b11ac..df910a5b213ac5645f4c25d21f5249576b6073bd 100644 (file)
@@ -503,6 +503,14 @@ iris_transfer_map(struct pipe_context *ctx,
        (usage & PIPE_TRANSFER_MAP_DIRECTLY))
       return NULL;
 
+   if (!(usage & PIPE_TRANSFER_UNSYNCHRONIZED) &&
+       iris_batch_references(&ice->render_batch, res->bo)) {
+      iris_batch_flush(&ice->render_batch);
+   }
+
+   if ((usage & PIPE_TRANSFER_DONTBLOCK) && iris_bo_busy(res->bo))
+      return NULL;
+
    struct iris_transfer *map = calloc(1, sizeof(struct iris_transfer));
    struct pipe_transfer *xfer = &map->base;
 
@@ -522,14 +530,6 @@ iris_transfer_map(struct pipe_context *ctx,
    xfer->layer_stride = isl_surf_get_array_pitch(surf);
    *ptransfer = xfer;
 
-   if (!(usage & PIPE_TRANSFER_UNSYNCHRONIZED) &&
-       iris_batch_references(&ice->render_batch, res->bo)) {
-      iris_batch_flush(&ice->render_batch);
-   }
-
-   if ((usage & PIPE_TRANSFER_DONTBLOCK) && iris_bo_busy(res->bo))
-      return NULL;
-
    xfer->usage &= (PIPE_TRANSFER_READ |
                    PIPE_TRANSFER_WRITE |
                    PIPE_TRANSFER_UNSYNCHRONIZED |