vc4: Make the last static array in vc4_program.c dynamically sized.
authorEric Anholt <eric@anholt.net>
Wed, 1 Oct 2014 17:58:02 +0000 (10:58 -0700)
committerEric Anholt <eric@anholt.net>
Thu, 2 Oct 2014 00:03:35 +0000 (17:03 -0700)
src/gallium/drivers/vc4/vc4_program.c
src/gallium/drivers/vc4/vc4_qir.h

index 589d33ab1a0eea2ba7915933c7be9b72ea8f591f..c3da5fe2c6f2334fe88347ef4baa560df84d57a0 100644 (file)
@@ -104,6 +104,18 @@ add_uniform(struct vc4_compile *c,
         uint32_t uniform = c->num_uniforms++;
         struct qreg u = { QFILE_UNIF, uniform };
 
+        if (uniform >= c->uniform_array_size) {
+                c->uniform_array_size = MAX2(MAX2(16, uniform + 1),
+                                             c->uniform_array_size * 2);
+
+                c->uniform_data = reralloc(c, c->uniform_data,
+                                           uint32_t,
+                                           c->uniform_array_size);
+                c->uniform_contents = reralloc(c, c->uniform_contents,
+                                               enum quniform_contents,
+                                               c->uniform_array_size);
+        }
+
         c->uniform_contents[uniform] = contents;
         c->uniform_data[uniform] = data;
 
@@ -1573,9 +1585,6 @@ vc4_shader_tgsi_to_qir(struct vc4_context *vc4,
 
         c->stage = stage;
 
-        c->uniform_data = ralloc_array(c, uint32_t, 1024);
-        c->uniform_contents = ralloc_array(c, enum quniform_contents, 1024);
-
         c->shader_state = key->shader_state;
         ret = tgsi_parse_init(&c->parser, c->shader_state->tokens);
         assert(ret == TGSI_PARSE_OK);
index ddd1f063a3855900673fc2152c2a6d11b77e02d1..3d8caeb8a29bc7f57eb38e2513f910310a400e19 100644 (file)
@@ -238,6 +238,7 @@ struct vc4_compile {
 
         uint32_t *uniform_data;
         enum quniform_contents *uniform_contents;
+        uint32_t uniform_array_size;
         uint32_t num_uniforms;
         uint32_t num_outputs;
         uint32_t num_texture_samples;