summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJerome Glisse <jglisse@redhat.com>2010-09-02 11:32:32 -0400
committerJerome Glisse <jglisse@redhat.com>2010-09-02 11:47:30 -0400
commite73c5501b2fe20290d1b691c85a5d82ac3a0431c (patch)
tree2f23b848a81709e9063841c0b36fe3352a0c009a
parentc9039fdb167865547dc9b3828d69b99209344999 (diff)
r600g: fix memory/bo leak
Signed-off-by: Jerome Glisse <jglisse@redhat.com>
-rw-r--r--src/gallium/drivers/r600/r600_context.c15
-rw-r--r--src/gallium/drivers/r600/r600_context.h1
-rw-r--r--src/gallium/drivers/r600/r600_draw.c4
-rw-r--r--src/gallium/winsys/r600/drm/radeon_ctx.c3
4 files changed, 21 insertions, 2 deletions
diff --git a/src/gallium/drivers/r600/r600_context.c b/src/gallium/drivers/r600/r600_context.c
index 0e5e0632bf..7a0e5b4049 100644
--- a/src/gallium/drivers/r600/r600_context.c
+++ b/src/gallium/drivers/r600/r600_context.c
@@ -39,6 +39,21 @@ static void r600_destroy_context(struct pipe_context *context)
{
struct r600_context *rctx = r600_context(context);
+ rctx->rasterizer = r600_context_state_decref(rctx->rasterizer);
+ rctx->poly_stipple = r600_context_state_decref(rctx->poly_stipple);
+ rctx->scissor = r600_context_state_decref(rctx->scissor);
+ rctx->clip = r600_context_state_decref(rctx->clip);
+ rctx->ps_shader = r600_context_state_decref(rctx->ps_shader);
+ rctx->vs_shader = r600_context_state_decref(rctx->vs_shader);
+ rctx->depth = r600_context_state_decref(rctx->depth);
+ rctx->stencil = r600_context_state_decref(rctx->stencil);
+ rctx->alpha = r600_context_state_decref(rctx->alpha);
+ rctx->dsa = r600_context_state_decref(rctx->dsa);
+ rctx->blend = r600_context_state_decref(rctx->blend);
+ rctx->stencil_ref = r600_context_state_decref(rctx->stencil_ref);
+ rctx->viewport = r600_context_state_decref(rctx->viewport);
+ rctx->framebuffer = r600_context_state_decref(rctx->framebuffer);
+ radeon_ctx_fini(&rctx->ctx);
FREE(rctx);
}
diff --git a/src/gallium/drivers/r600/r600_context.h b/src/gallium/drivers/r600/r600_context.h
index d4e3baa69d..cea0813054 100644
--- a/src/gallium/drivers/r600/r600_context.h
+++ b/src/gallium/drivers/r600/r600_context.h
@@ -131,6 +131,7 @@ struct r600_context {
struct radeon_state config;
/* FIXME get rid of those vs_resource,vs/ps_constant */
struct radeon_state vs_resource[160];
+ unsigned vs_nresource;
struct radeon_state vs_constant[256];
struct radeon_state ps_constant[256];
/* hw states */
diff --git a/src/gallium/drivers/r600/r600_draw.c b/src/gallium/drivers/r600/r600_draw.c
index 9cc26bbada..fabd337d23 100644
--- a/src/gallium/drivers/r600/r600_draw.c
+++ b/src/gallium/drivers/r600/r600_draw.c
@@ -94,6 +94,9 @@ static int r600_draw_common(struct r600_draw *draw)
radeon_draw_bind(&rctx->draw, &rctx->vs_shader->rstate[0]);
radeon_draw_bind(&rctx->draw, &rctx->ps_shader->rstate[0]);
+ for (i = 0 ; i < rctx->vs_nresource; i++) {
+ radeon_state_fini(&rctx->vs_resource[i]);
+ }
for (i = 0 ; i < rctx->vertex_elements->count; i++) {
vs_resource = &rctx->vs_resource[i];
j = rctx->vertex_elements->elements[i].vertex_buffer_index;
@@ -120,6 +123,7 @@ static int r600_draw_common(struct r600_draw *draw)
}
radeon_draw_bind(&rctx->draw, vs_resource);
}
+ rctx->vs_nresource = rctx->vertex_elements->count;
/* FIXME start need to change winsys */
radeon_state_init(&draw->draw, rscreen->rw, R600_STATE_DRAW, 0, 0);
draw->draw.states[R600_DRAW__VGT_NUM_INDICES] = draw->count;
diff --git a/src/gallium/winsys/r600/drm/radeon_ctx.c b/src/gallium/winsys/r600/drm/radeon_ctx.c
index 50c5e4741e..47fca76136 100644
--- a/src/gallium/winsys/r600/drm/radeon_ctx.c
+++ b/src/gallium/winsys/r600/drm/radeon_ctx.c
@@ -121,8 +121,7 @@ void radeon_ctx_fini(struct radeon_ctx *ctx)
free(ctx->bo);
free(ctx->pm4);
free(ctx->reloc);
- memset(ctx, 0, sizeof(*ctx));
- free(ctx);
+ memset(ctx, 0, sizeof(struct radeon_ctx));
}
static int radeon_ctx_state_bo(struct radeon_ctx *ctx, struct radeon_state *state)