aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/program
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2013-02-19 16:46:41 -0800
committerEric Anholt <[email protected]>2013-03-11 12:11:54 -0700
commit6aa3afbfd6b737350351e9ea22ba9de1accda52d (patch)
treeb54c3c7d1238cc734bb9623117a0b46c2b0e1f54 /src/mesa/program
parent5daf867f6c8984e6e025d8a0b0a7dfa162068420 (diff)
mesa: Reduce the memory usage for reg alloc with many graph nodes (part 1)
We were allocating an adjacency_list entry for every possible interference that could get created, but that usually doesn't happen. We can save a lot of memory by resizing the array on demand. Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/mesa/program')
-rw-r--r--src/mesa/program/register_allocate.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/mesa/program/register_allocate.c b/src/mesa/program/register_allocate.c
index 88793dbdc1e..5862c78661a 100644
--- a/src/mesa/program/register_allocate.c
+++ b/src/mesa/program/register_allocate.c
@@ -120,6 +120,7 @@ struct ra_node {
*/
GLboolean *adjacency;
unsigned int *adjacency_list;
+ unsigned int adjacency_list_size;
unsigned int adjacency_count;
/** @} */
@@ -307,6 +308,15 @@ static void
ra_add_node_adjacency(struct ra_graph *g, unsigned int n1, unsigned int n2)
{
g->nodes[n1].adjacency[n2] = GL_TRUE;
+
+ if (g->nodes[n1].adjacency_count >=
+ g->nodes[n1].adjacency_list_size) {
+ g->nodes[n1].adjacency_list_size *= 2;
+ g->nodes[n1].adjacency_list = reralloc(g, g->nodes[n1].adjacency_list,
+ unsigned int,
+ g->nodes[n1].adjacency_list_size);
+ }
+
g->nodes[n1].adjacency_list[g->nodes[n1].adjacency_count] = n2;
g->nodes[n1].adjacency_count++;
}
@@ -326,7 +336,9 @@ ra_alloc_interference_graph(struct ra_regs *regs, unsigned int count)
for (i = 0; i < count; i++) {
g->nodes[i].adjacency = rzalloc_array(g, GLboolean, count);
- g->nodes[i].adjacency_list = ralloc_array(g, unsigned int, count);
+ g->nodes[i].adjacency_list_size = 4;
+ g->nodes[i].adjacency_list =
+ ralloc_array(g, unsigned int, g->nodes[i].adjacency_list_size);
g->nodes[i].adjacency_count = 0;
ra_add_node_adjacency(g, i, i);
g->nodes[i].reg = NO_REG;