gallivm: make sure analysis works with large number of immediates

We need to handle a lot more immediates and in order to do that
we also switch from allocating this structure on the stack to
allocating it on the heap.

Signed-off-by: Zack Rusin <zackr@vmware.com>
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
This commit is contained in:
Zack Rusin 2014-02-04 19:32:04 -05:00
parent 69ee3f431f
commit efb152dd04
1 changed files with 9 additions and 8 deletions

View File

@ -47,7 +47,7 @@ struct analysis_context
struct lp_tgsi_info *info; struct lp_tgsi_info *info;
unsigned num_imms; unsigned num_imms;
float imm[128][4]; float imm[LP_MAX_TGSI_IMMEDIATES][4];
struct lp_tgsi_channel_info temp[32][4]; struct lp_tgsi_channel_info temp[32][4];
}; };
@ -487,7 +487,7 @@ lp_build_tgsi_info(const struct tgsi_token *tokens,
struct lp_tgsi_info *info) struct lp_tgsi_info *info)
{ {
struct tgsi_parse_context parse; struct tgsi_parse_context parse;
struct analysis_context ctx; struct analysis_context *ctx;
unsigned index; unsigned index;
unsigned chan; unsigned chan;
@ -495,8 +495,8 @@ lp_build_tgsi_info(const struct tgsi_token *tokens,
tgsi_scan_shader(tokens, &info->base); tgsi_scan_shader(tokens, &info->base);
memset(&ctx, 0, sizeof ctx); ctx = CALLOC(1, sizeof(struct analysis_context));
ctx.info = info; ctx->info = info;
tgsi_parse_init(&parse, tokens); tgsi_parse_init(&parse, tokens);
@ -518,7 +518,7 @@ lp_build_tgsi_info(const struct tgsi_token *tokens,
goto finished; goto finished;
} }
analyse_instruction(&ctx, inst); analyse_instruction(ctx, inst);
} }
break; break;
@ -527,16 +527,16 @@ lp_build_tgsi_info(const struct tgsi_token *tokens,
const unsigned size = const unsigned size =
parse.FullToken.FullImmediate.Immediate.NrTokens - 1; parse.FullToken.FullImmediate.Immediate.NrTokens - 1;
assert(size <= 4); assert(size <= 4);
if (ctx.num_imms < Elements(ctx.imm)) { if (ctx->num_imms < Elements(ctx->imm)) {
for (chan = 0; chan < size; ++chan) { for (chan = 0; chan < size; ++chan) {
float value = parse.FullToken.FullImmediate.u[chan].Float; float value = parse.FullToken.FullImmediate.u[chan].Float;
ctx.imm[ctx.num_imms][chan] = value; ctx->imm[ctx->num_imms][chan] = value;
if (value < 0.0f || value > 1.0f) { if (value < 0.0f || value > 1.0f) {
info->unclamped_immediates = TRUE; info->unclamped_immediates = TRUE;
} }
} }
++ctx.num_imms; ++ctx->num_imms;
} }
} }
break; break;
@ -551,6 +551,7 @@ lp_build_tgsi_info(const struct tgsi_token *tokens,
finished: finished:
tgsi_parse_free(&parse); tgsi_parse_free(&parse);
FREE(ctx);
/* /*