From: Rob Clark Date: Tue, 20 Aug 2013 17:54:01 +0000 (-0400) Subject: freedreno/a3xx/compiler: use max_reg rather than file_count X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2effac5a67d8ed91802f96d2c59c0a5e1574e3f6;p=mesa.git freedreno/a3xx/compiler: use max_reg rather than file_count Our current (rather naive) register assignment is based on mapping different register files (INPUT, OUTPUT, TEMP, CONST, etc) based on the max register index of the preceding file. But in some cases, the lowest used register in a file might not be zero. In which case file_count[file] != file_max[file] + 1. Signed-off-by: Rob Clark --- diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_compiler.c b/src/gallium/drivers/freedreno/a3xx/fd3_compiler.c index e2c78531d1e..dc5c87395f6 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_compiler.c +++ b/src/gallium/drivers/freedreno/a3xx/fd3_compiler.c @@ -159,19 +159,19 @@ compile_init(struct fd3_compile_context *ctx, struct fd3_shader_stateobj *so, /* Immediates go after constants: */ ctx->base_reg[TGSI_FILE_CONSTANT] = 0; ctx->base_reg[TGSI_FILE_IMMEDIATE] = - ctx->info.file_count[TGSI_FILE_CONSTANT]; + ctx->info.file_max[TGSI_FILE_CONSTANT] + 1; /* Temporaries after outputs after inputs: */ ctx->base_reg[TGSI_FILE_INPUT] = 0; ctx->base_reg[TGSI_FILE_OUTPUT] = - ctx->info.file_count[TGSI_FILE_INPUT]; + ctx->info.file_max[TGSI_FILE_INPUT] + 1; ctx->base_reg[TGSI_FILE_TEMPORARY] = - ctx->info.file_count[TGSI_FILE_INPUT] + - ctx->info.file_count[TGSI_FILE_OUTPUT]; + ctx->info.file_max[TGSI_FILE_INPUT] + 1 + + ctx->info.file_max[TGSI_FILE_OUTPUT] + 1; so->first_immediate = ctx->base_reg[TGSI_FILE_IMMEDIATE]; - ctx->immediate_idx = 4 * (ctx->info.file_count[TGSI_FILE_CONSTANT] + - ctx->info.file_count[TGSI_FILE_IMMEDIATE]); + ctx->immediate_idx = 4 * (ctx->info.file_max[TGSI_FILE_CONSTANT] + 1 + + ctx->info.file_max[TGSI_FILE_IMMEDIATE] + 1); ret = tgsi_parse_init(&ctx->parser, tokens); if (ret != TGSI_PARSE_OK) @@ -309,7 +309,7 @@ get_internal_temp(struct fd3_compile_context *ctx, /* assign next temporary: */ n = ctx->num_internal_temps++; - tmp_dst->Index = ctx->info.file_count[TGSI_FILE_TEMPORARY] + n; + tmp_dst->Index = ctx->info.file_max[TGSI_FILE_TEMPORARY] + n + 1; src_from_dst(tmp_src, tmp_dst); }