r300g: Fix funky segfault.
authorCorbin Simpson <MostAwesomeDude@gmail.com>
Tue, 2 Feb 2010 03:47:46 +0000 (19:47 -0800)
committerCorbin Simpson <MostAwesomeDude@gmail.com>
Tue, 2 Feb 2010 03:48:24 +0000 (19:48 -0800)
src/gallium/drivers/r300/r300_tgsi_to_rc.c
src/gallium/drivers/r300/r300_tgsi_to_rc.h

index 6b2bc7879941db92d2d9b8e784cf38597c86c038..941ec17016b1e670890d309a7c786a9486264f70 100644 (file)
@@ -317,11 +317,8 @@ static void handle_immediate(struct tgsi_to_rc * ttr,
     }
 
     if (can_swizzle) {
-        struct swizzled_imms* si =
-            &ttr->imms_to_swizzle[ttr->imms_to_swizzle_count];
-
-        si->index = index;
-        si->swizzle = swizzle;
+        ttr->imms_to_swizzle[ttr->imms_to_swizzle_count].index = index;
+        ttr->imms_to_swizzle[ttr->imms_to_swizzle_count].swizzle = swizzle;
         ttr->imms_to_swizzle_count++;
     } else {
         constant.Type = RC_CONSTANT_IMMEDIATE;
@@ -352,6 +349,9 @@ void r300_tgsi_to_rc(struct tgsi_to_rc * ttr, const struct tgsi_token * tokens)
 
     ttr->immediate_offset = ttr->compiler->Program.Constants.Count;
 
+    ttr->imms_to_swizzle = malloc(ttr->info->immediate_count * sizeof(struct swizzled_imms));
+    ttr->imms_to_swizzle_count = 0;
+
     tgsi_parse_init(&parser, tokens);
 
     while (!tgsi_parse_end_of_tokens(&parser)) {
@@ -372,6 +372,8 @@ void r300_tgsi_to_rc(struct tgsi_to_rc * ttr, const struct tgsi_token * tokens)
 
     tgsi_parse_free(&parser);
 
+    free(ttr->imms_to_swizzle);
+
     rc_calculate_inputs_outputs(ttr->compiler);
 }
 
index f1e66f46bbc50b84968e7e242754c4883fac6dd5..39b473c7bf5cc35762c67c034fb8920bbd4fb680 100644 (file)
@@ -39,7 +39,7 @@ struct tgsi_to_rc {
     const struct tgsi_shader_info * info;
 
     int immediate_offset;
-    struct swizzled_imms imms_to_swizzle[10];
+    struct swizzled_imms * imms_to_swizzle;
     unsigned imms_to_swizzle_count;
 };