Module: Mesa Branch: master Commit: 17e047242e82111859eb8220369c601c79a26350 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=17e047242e82111859eb8220369c601c79a26350
Author: Marcin Slusarz <marcin.slus...@gmail.com> Date: Tue Jun 5 23:26:05 2012 +0200 nouveau: fix scratch buffer leak ...and create common function for destroying nouveau_context --- src/gallium/drivers/nouveau/nouveau_context.h | 12 ++++++++++++ src/gallium/drivers/nv30/nv30_context.c | 2 +- src/gallium/drivers/nv50/nv50_context.c | 2 +- src/gallium/drivers/nvc0/nvc0_context.c | 2 +- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/nouveau/nouveau_context.h b/src/gallium/drivers/nouveau/nouveau_context.h index 531c623..b3fe05b 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 <libdrm/nouveau.h> #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 b16cb23..42e844f 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 952dc03..cb9dd41 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 f930814..b021f2e 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 _______________________________________________ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit