nouveau: fix scratch buffer leak

...and create common function for destroying nouveau_context
This commit is contained in:
Marcin Slusarz 2012-06-05 23:26:05 +02:00
parent 3232a86efe
commit 17e047242e
4 changed files with 15 additions and 3 deletions

View file

@ -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

View file

@ -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) \

View file

@ -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 *

View file

@ -99,7 +99,7 @@ nvc0_destroy(struct pipe_context *pipe)
draw_destroy(nvc0->draw);
#endif
FREE(nvc0);
nouveau_context_destroy(&nvc0->base);
}
void