From 71ea414782d5a4e908a0412d7491f2b1ecf0a272 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tapani=20P=C3=A4lli?= Date: Fri, 27 Oct 2017 12:54:02 +0300 Subject: [PATCH] i965: unref push_const_bo in intelDestroyContext MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Valgrind shows that leak is caused by gen6_upload_push_constant, add unref push_const_bo per stage to destructor to fix this (like done for scratch_bo). ==10952== 144 bytes in 1 blocks are definitely lost in loss record 44 of 66 ==10952== at 0x4C30A1E: calloc (vg_replace_malloc.c:711) ==10952== by 0x8C02847: bo_alloc_internal.constprop.10 (brw_bufmgr.c:344) ==10952== by 0x8C425C4: intel_upload_space (intel_upload.c:101) ==10952== by 0x8C22ED0: gen6_upload_push_constants (gen6_constant_state.c:154) v2: remove if conditions, brw_bo_unreference handles NULL (Ken, Emil) Fixes: 24891d7c05 ("i965: Store per-stage push constant BO pointers.") Signed-off-by: Tapani Pälli Reviewed-by: Emil Velikov Reviewed-by: Kenneth Graunke Cc: mesa-stable@lists.freedesktop.org (cherry picked from commit 0b131ca427d788ae08426bdeddb8f4bd3c7da202) --- src/mesa/drivers/dri/i965/brw_context.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index 60b14571ed0..1ca74387426 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -1048,6 +1048,12 @@ intelDestroyContext(__DRIcontext * driContextPriv) if (brw->wm.base.scratch_bo) brw_bo_unreference(brw->wm.base.scratch_bo); + brw_bo_unreference(brw->vs.base.push_const_bo); + brw_bo_unreference(brw->tcs.base.push_const_bo); + brw_bo_unreference(brw->tes.base.push_const_bo); + brw_bo_unreference(brw->gs.base.push_const_bo); + brw_bo_unreference(brw->wm.base.push_const_bo); + brw_destroy_hw_context(brw->bufmgr, brw->hw_ctx); if (ctx->swrast_context) {