From: Marcin Slusarz Date: Tue, 5 Jun 2012 21:26:05 +0000 (+0200) Subject: nouveau: fix scratch buffer leak X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=17e047242e82111859eb8220369c601c79a26350;p=mesa.git nouveau: fix scratch buffer leak ...and create common function for destroying nouveau_context --- diff --git a/src/gallium/drivers/nouveau/nouveau_context.h b/src/gallium/drivers/nouveau/nouveau_context.h index 531c6238b9f..b3fe05b1019 100644 --- a/src/gallium/drivers/nouveau/nouveau_context.h +++ b/src/gallium/drivers/nouveau/nouveau_context.h @@ -2,6 +2,7 @@ #define __NOUVEAU_CONTEXT_H__ #include "pipe/p_context.h" +#include #define NOUVEAU_MAX_SCRATCH_BUFS 4 @@ -72,4 +73,15 @@ void * nouveau_scratch_get(struct nouveau_context *, unsigned size, uint64_t *gpu_addr, struct nouveau_bo **); +static INLINE void +nouveau_context_destroy(struct nouveau_context *ctx) +{ + int i; + + for (i = 0; i < NOUVEAU_MAX_SCRATCH_BUFS; ++i) + if (ctx->scratch.bo[i]) + nouveau_bo_ref(NULL, &ctx->scratch.bo[i]); + + FREE(ctx); +} #endif diff --git a/src/gallium/drivers/nv30/nv30_context.c b/src/gallium/drivers/nv30/nv30_context.c index b16cb237873..42e844f141e 100644 --- a/src/gallium/drivers/nv30/nv30_context.c +++ b/src/gallium/drivers/nv30/nv30_context.c @@ -92,7 +92,7 @@ nv30_context_destroy(struct pipe_context *pipe) if (nv30->screen->cur_ctx == nv30) nv30->screen->cur_ctx = NULL; - FREE(nv30); + nouveau_context_destroy(&nv30->base); } #define FAIL_CONTEXT_INIT(str, err) \ diff --git a/src/gallium/drivers/nv50/nv50_context.c b/src/gallium/drivers/nv50/nv50_context.c index 952dc03b1a3..cb9dd413a2d 100644 --- a/src/gallium/drivers/nv50/nv50_context.c +++ b/src/gallium/drivers/nv50/nv50_context.c @@ -111,7 +111,7 @@ nv50_destroy(struct pipe_context *pipe) draw_destroy(nv50->draw); #endif - FREE(nv50); + nouveau_context_destroy(&nv50->base); } struct pipe_context * diff --git a/src/gallium/drivers/nvc0/nvc0_context.c b/src/gallium/drivers/nvc0/nvc0_context.c index f93081465bd..b021f2e99dc 100644 --- a/src/gallium/drivers/nvc0/nvc0_context.c +++ b/src/gallium/drivers/nvc0/nvc0_context.c @@ -99,7 +99,7 @@ nvc0_destroy(struct pipe_context *pipe) draw_destroy(nvc0->draw); #endif - FREE(nvc0); + nouveau_context_destroy(&nvc0->base); } void