mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-25 00:00:11 +01:00
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]
This commit is contained in:
parent
e420e9d485
commit
c5ad88e9f1
1 changed files with 61 additions and 61 deletions
|
|
@ -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++) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue