summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarcin Slusarz <[email protected]>2012-06-05 23:26:05 +0200
committerMarcin Slusarz <[email protected]>2012-06-05 23:58:43 +0200
commit17e047242e82111859eb8220369c601c79a26350 (patch)
tree55f96793192a87f0d0e998abaf3bd2845ecbbc1c /src
parent3232a86efe76df9fcee869c4ed4af8d68824920c (diff)
nouveau: fix scratch buffer leak
...and create common function for destroying nouveau_context
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/nouveau/nouveau_context.h12
-rw-r--r--src/gallium/drivers/nv30/nv30_context.c2
-rw-r--r--src/gallium/drivers/nv50/nv50_context.c2
-rw-r--r--src/gallium/drivers/nvc0/nvc0_context.c2
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 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 <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 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