From c5ad88e9f1d6a915d9464df0b8fa4de65a3513d2 Mon Sep 17 00:00:00 2001 From: michal Date: Sun, 28 Oct 2007 14:42:26 +0000 Subject: Declare temporaries in a more compact fashion. The following declarations: DCL TEMP[0] DCL TEMP[1] DCL TEMP[2] DCL TEMP[4] become: DCL TEMP[0..2] DCL TEMP[4] --- src/mesa/state_tracker/st_mesa_to_tgsi.c | 122 +++++++++++++++---------------- 1 file changed, 61 insertions(+), 61 deletions(-) (limited to 'src/mesa/state_tracker/st_mesa_to_tgsi.c') diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c index cb0c96169e..0e3533af4d 100644 --- a/src/mesa/state_tracker/st_mesa_to_tgsi.c +++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c @@ -572,36 +572,36 @@ make_output_decl( return decl; } - - -static struct tgsi_full_declaration -make_temp_decl( - GLuint start_index, - GLuint end_index ) -{ - struct tgsi_full_declaration decl; - decl = tgsi_default_full_declaration(); - decl.Declaration.File = TGSI_FILE_TEMPORARY; - decl.Declaration.Declare = TGSI_DECLARE_RANGE; - decl.u.DeclarationRange.First = start_index; - decl.u.DeclarationRange.Last = end_index; - return decl; -} - + + +static struct tgsi_full_declaration +make_temp_decl( + GLuint start_index, + GLuint end_index ) +{ + struct tgsi_full_declaration decl; + decl = tgsi_default_full_declaration(); + decl.Declaration.File = TGSI_FILE_TEMPORARY; + decl.Declaration.Declare = TGSI_DECLARE_RANGE; + decl.u.DeclarationRange.First = start_index; + decl.u.DeclarationRange.Last = end_index; + return decl; +} + /** * Find the temporaries which are used in the given program. - * Put the indices of the temporaries in 'tempsUsed'. - * \return number of temporaries used - */ -static void -find_temporaries(const struct gl_program *program, - GLboolean tempsUsed[MAX_PROGRAM_TEMPS]) -{ - GLuint i, j; - - for (i = 0; i < MAX_PROGRAM_TEMPS; i++) - tempsUsed[i] = GL_FALSE; + * Put the indices of the temporaries in 'tempsUsed'. + * \return number of temporaries used + */ +static void +find_temporaries(const struct gl_program *program, + GLboolean tempsUsed[MAX_PROGRAM_TEMPS]) +{ + GLuint i, j; + + for (i = 0; i < MAX_PROGRAM_TEMPS; i++) + tempsUsed[i] = GL_FALSE; for (i = 0; i < program->NumInstructions; i++) { const struct prog_instruction *inst = program->Instructions + i; @@ -610,12 +610,12 @@ find_temporaries(const struct gl_program *program, if (inst->SrcReg[j].File == PROGRAM_TEMPORARY) tempsUsed[inst->SrcReg[j].Index] = GL_TRUE; if (inst->DstReg.File == PROGRAM_TEMPORARY) - tempsUsed[inst->DstReg.Index] = GL_TRUE; - } - } -} - - + tempsUsed[inst->DstReg.Index] = GL_TRUE; + } + } +} + + /** @@ -775,34 +775,34 @@ tgsi_translate_mesa_program( maxTokens - ti ); } } - - /* temporary decls */ - { - GLboolean tempsUsed[MAX_PROGRAM_TEMPS + 1]; - GLboolean inside_range = GL_FALSE; - GLuint start_range; - - find_temporaries(program, tempsUsed); - tempsUsed[MAX_PROGRAM_TEMPS] = GL_FALSE; - for (i = 0; i < MAX_PROGRAM_TEMPS + 1; i++) { - if (tempsUsed[i] && !inside_range) { - inside_range = GL_TRUE; - start_range = i; - } - else if (!tempsUsed[i] && inside_range) { - struct tgsi_full_declaration fulldecl; - - inside_range = GL_FALSE; - fulldecl = make_temp_decl( start_range, i - 1 ); - ti += tgsi_build_full_declaration( - &fulldecl, - &tokens[ti], - header, - maxTokens - ti ); - } - } - } - + + /* temporary decls */ + { + GLboolean tempsUsed[MAX_PROGRAM_TEMPS + 1]; + GLboolean inside_range = GL_FALSE; + GLuint start_range; + + find_temporaries(program, tempsUsed); + tempsUsed[MAX_PROGRAM_TEMPS] = GL_FALSE; + for (i = 0; i < MAX_PROGRAM_TEMPS + 1; i++) { + if (tempsUsed[i] && !inside_range) { + inside_range = GL_TRUE; + start_range = i; + } + else if (!tempsUsed[i] && inside_range) { + struct tgsi_full_declaration fulldecl; + + inside_range = GL_FALSE; + fulldecl = make_temp_decl( start_range, i - 1 ); + ti += tgsi_build_full_declaration( + &fulldecl, + &tokens[ti], + header, + maxTokens - ti ); + } + } + } + /* immediates/literals */ #if EMIT_IMMEDIATES for (i = 0; i < program->Parameters->NumParameters; i++) { -- cgit v1.2.3