From: Kenneth Graunke Date: Wed, 20 Jun 2018 02:22:47 +0000 (-0700) Subject: iris: fix major refcounting bug with resources X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a6aeca972719ac85f6d333b4178375a626983e43;p=mesa.git iris: fix major refcounting bug with resources DONTBLOCK -> NULL was happening after taking a reference, causing those to live forever This resolves the OOM problems --- diff --git a/src/gallium/drivers/iris/iris_resource.c b/src/gallium/drivers/iris/iris_resource.c index f4e9318d297..df910a5b213 100644 --- a/src/gallium/drivers/iris/iris_resource.c +++ b/src/gallium/drivers/iris/iris_resource.c @@ -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 |