gallium/u_threaded: fix pipe_resource leak for staging transfer
authorPierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Thu, 10 Dec 2020 13:35:34 +0000 (14:35 +0100)
committerMarge Bot <eric+marge@anholt.net>
Fri, 11 Dec 2020 21:32:31 +0000 (21:32 +0000)
In 2900f82e191 I mistakenly used tc_set_resource_reference in both
tc_transfer_unmap and tc_call_transfer_unmap.

This causes a leak because tc_call_transfer_unmap clears dst before
acquiring a reference, so it must only be used when initializing
tc_payloads.

This fixes the perf drop reported by Marek in MR 7098.

Fixes: 2900f82e191 ("gallium/u_threaded: fix staging and non-staging conflicts")
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8035>

src/gallium/auxiliary/util/u_threaded_context.c

index 05dfb2e350ebac2e1d49ccbd610bc7282f73a6e0..249bf82ad35ccb69f86b375d6cd28cac23fc9a23 100644 (file)
@@ -1770,7 +1770,7 @@ tc_call_transfer_unmap(struct pipe_context *pipe, union tc_payload *payload)
       /* Nothing to do except keeping track of staging uploads */
       assert(tres->pending_staging_uploads > 0);
       p_atomic_dec(&tres->pending_staging_uploads);
-      tc_set_resource_reference(&p->resource, NULL);
+      pipe_resource_reference(&p->resource, NULL);
       return;
    }
    pipe->transfer_unmap(pipe, p->transfer);