[Mesa-dev] [PATCH] u_threaded_context: fix a memory leak
Nicolai Hähnle
nhaehnle at gmail.com
Fri Oct 6 20:20:20 UTC 2017
From: Nicolai Hähnle <nicolai.haehnle at amd.com>
The uploaders can own transfers which need to be unmapped. Destroy them
before the final sync (they're not used from the driver thread anyway)
so that the transfer_unmap call is processed by the driver.
---
src/gallium/auxiliary/util/u_threaded_context.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/src/gallium/auxiliary/util/u_threaded_context.c b/src/gallium/auxiliary/util/u_threaded_context.c
index 043d4e67df1..7e28b87a7ff 100644
--- a/src/gallium/auxiliary/util/u_threaded_context.c
+++ b/src/gallium/auxiliary/util/u_threaded_context.c
@@ -2226,37 +2226,38 @@ tc_resource_commit(struct pipe_context *_pipe, struct pipe_resource *res,
/********************************************************************
* create & destroy
*/
static void
tc_destroy(struct pipe_context *_pipe)
{
struct threaded_context *tc = threaded_context(_pipe);
struct pipe_context *pipe = tc->pipe;
+ if (tc->base.const_uploader &&
+ tc->base.stream_uploader != tc->base.const_uploader)
+ u_upload_destroy(tc->base.const_uploader);
+
+ if (tc->base.stream_uploader)
+ u_upload_destroy(tc->base.stream_uploader);
+
tc_sync(tc);
if (util_queue_is_initialized(&tc->queue)) {
util_queue_destroy(&tc->queue);
for (unsigned i = 0; i < TC_MAX_BATCHES; i++)
util_queue_fence_destroy(&tc->batch_slots[i].fence);
}
- if (tc->base.const_uploader &&
- tc->base.stream_uploader != tc->base.const_uploader)
- u_upload_destroy(tc->base.const_uploader);
-
- if (tc->base.stream_uploader)
- u_upload_destroy(tc->base.stream_uploader);
-
slab_destroy_child(&tc->pool_transfers);
+ assert(tc->batch_slots[tc->next].num_total_call_slots == 0);
pipe->destroy(pipe);
os_free_aligned(tc);
}
static const tc_execute execute_func[TC_NUM_CALLS] = {
#define CALL(name) tc_call_##name,
#include "u_threaded_context_calls.h"
#undef CALL
};
--
2.11.0
More information about the mesa-dev
mailing list