From: Corbin Simpson Date: Tue, 2 Feb 2010 03:47:46 +0000 (-0800) Subject: r300g: Fix funky segfault. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=565f0cef26d6da49ae58462d0c1f9b832ee71174;p=mesa.git r300g: Fix funky segfault. --- diff --git a/src/gallium/drivers/r300/r300_tgsi_to_rc.c b/src/gallium/drivers/r300/r300_tgsi_to_rc.c index 6b2bc787994..941ec17016b 100644 --- a/src/gallium/drivers/r300/r300_tgsi_to_rc.c +++ b/src/gallium/drivers/r300/r300_tgsi_to_rc.c @@ -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); } diff --git a/src/gallium/drivers/r300/r300_tgsi_to_rc.h b/src/gallium/drivers/r300/r300_tgsi_to_rc.h index f1e66f46bbc..39b473c7bf5 100644 --- a/src/gallium/drivers/r300/r300_tgsi_to_rc.h +++ b/src/gallium/drivers/r300/r300_tgsi_to_rc.h @@ -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; };