diff options
author | Eric Anholt <[email protected]> | 2012-01-12 12:51:34 -0800 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2012-01-18 09:59:11 -0800 |
commit | b972744c78e45928876ea781b9eeef09b3baf083 (patch) | |
tree | 0c1b8358937df391ae0f28d7f253195409b29999 | |
parent | a9eda41539bd63ed1835556ad3afc77ee01f6a6a (diff) |
mesa: Make the register allocator allocation take a ralloc context.
This fixes a memory leak on i965 context destruction.
NOTE: This is a candidate for the 8.0 branch.
-rw-r--r-- | src/gallium/drivers/r300/compiler/radeon_pair_regalloc.c | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_vec4_reg_allocate.cpp | 2 | ||||
-rw-r--r-- | src/mesa/program/register_allocate.c | 10 | ||||
-rw-r--r-- | src/mesa/program/register_allocate.h | 2 |
5 files changed, 12 insertions, 6 deletions
diff --git a/src/gallium/drivers/r300/compiler/radeon_pair_regalloc.c b/src/gallium/drivers/r300/compiler/radeon_pair_regalloc.c index 30716a34843..bb5b43f2f95 100644 --- a/src/gallium/drivers/r300/compiler/radeon_pair_regalloc.c +++ b/src/gallium/drivers/r300/compiler/radeon_pair_regalloc.c @@ -547,7 +547,7 @@ static void do_advanced_regalloc(struct regalloc_state * s) struct ra_graph * graph; /* Allocate the main ra data structure */ - regs = ra_alloc_reg_set(s->C->max_temp_regs * RC_MASK_XYZW); + regs = ra_alloc_reg_set(NULL, s->C->max_temp_regs * RC_MASK_XYZW); /* Get list of program variables */ variables = rc_get_variables(s->C); diff --git a/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp b/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp index 3f875cc63d9..d4dd1240b70 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp @@ -88,7 +88,7 @@ brw_alloc_reg_set_for_classes(struct brw_context *brw, ralloc_free(brw->wm.ra_reg_to_grf); brw->wm.ra_reg_to_grf = ralloc_array(brw, uint8_t, ra_reg_count); ralloc_free(brw->wm.regs); - brw->wm.regs = ra_alloc_reg_set(ra_reg_count); + brw->wm.regs = ra_alloc_reg_set(brw, ra_reg_count); ralloc_free(brw->wm.classes); brw->wm.classes = ralloc_array(brw, int, class_count + 1); diff --git a/src/mesa/drivers/dri/i965/brw_vec4_reg_allocate.cpp b/src/mesa/drivers/dri/i965/brw_vec4_reg_allocate.cpp index 1ace91fafef..2efe235bff9 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_reg_allocate.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_reg_allocate.cpp @@ -108,7 +108,7 @@ brw_alloc_reg_set_for_classes(struct brw_context *brw, ralloc_free(brw->vs.ra_reg_to_grf); brw->vs.ra_reg_to_grf = ralloc_array(brw, uint8_t, ra_reg_count); ralloc_free(brw->vs.regs); - brw->vs.regs = ra_alloc_reg_set(ra_reg_count); + brw->vs.regs = ra_alloc_reg_set(brw, ra_reg_count); ralloc_free(brw->vs.classes); brw->vs.classes = ralloc_array(brw, int, class_count + 1); diff --git a/src/mesa/program/register_allocate.c b/src/mesa/program/register_allocate.c index f5b5174fc18..f08c9d28d6b 100644 --- a/src/mesa/program/register_allocate.c +++ b/src/mesa/program/register_allocate.c @@ -154,13 +154,19 @@ struct ra_graph { unsigned int stack_count; }; +/** + * Creates a set of registers for the allocator. + * + * mem_ctx is a ralloc context for the allocator. The reg set may be freed + * using ralloc_free(). + */ struct ra_regs * -ra_alloc_reg_set(unsigned int count) +ra_alloc_reg_set(void *mem_ctx, unsigned int count) { unsigned int i; struct ra_regs *regs; - regs = rzalloc(NULL, struct ra_regs); + regs = rzalloc(mem_ctx, struct ra_regs); regs->count = count; regs->regs = rzalloc_array(regs, struct ra_reg, count); diff --git a/src/mesa/program/register_allocate.h b/src/mesa/program/register_allocate.h index ee2e58a4756..00b851ec21b 100644 --- a/src/mesa/program/register_allocate.h +++ b/src/mesa/program/register_allocate.h @@ -36,7 +36,7 @@ struct ra_regs; * registers, such as aligned register pairs that conflict with the * two real registers from which they are composed. */ -struct ra_regs *ra_alloc_reg_set(unsigned int count); +struct ra_regs *ra_alloc_reg_set(void *mem_ctx, unsigned int count); unsigned int ra_alloc_reg_class(struct ra_regs *regs); void ra_add_reg_conflict(struct ra_regs *regs, unsigned int r1, unsigned int r2); |