Declare temporaries in a more compact fashion.
authormichal <michal@michal-laptop.(none)>
Sun, 28 Oct 2007 14:42:26 +0000 (14:42 +0000)
committerMichal Krol <michal@tungstengraphics.com>
Sun, 28 Oct 2007 17:34:33 +0000 (17:34 +0000)
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

index cb0c961..0e3533a 100644 (file)
@@ -572,36 +572,36 @@ make_output_decl(
 \r
    return decl;\r
 }\r
-
-
-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;
-}
-
+\r
+\r
+static struct tgsi_full_declaration\r
+make_temp_decl(\r
+   GLuint start_index,\r
+   GLuint end_index )\r
+{\r
+   struct tgsi_full_declaration decl;\r
+   decl = tgsi_default_full_declaration();\r
+   decl.Declaration.File = TGSI_FILE_TEMPORARY;\r
+   decl.Declaration.Declare = TGSI_DECLARE_RANGE;\r
+   decl.u.DeclarationRange.First = start_index;\r
+   decl.u.DeclarationRange.Last = end_index;\r
+   return decl;\r
+}\r
+\r
 \r
 /**\r
  * Find the temporaries which are used in the given program.\r
- * 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'.\r
+ * \return number of temporaries used\r
+ */\r
+static void\r
+find_temporaries(const struct gl_program *program,\r
+                 GLboolean tempsUsed[MAX_PROGRAM_TEMPS])\r
+{\r
+   GLuint i, j;\r
+\r
+   for (i = 0; i < MAX_PROGRAM_TEMPS; i++)\r
+      tempsUsed[i] = GL_FALSE;\r
 \r
    for (i = 0; i < program->NumInstructions; i++) {\r
       const struct prog_instruction *inst = program->Instructions + i;\r
@@ -610,12 +610,12 @@ find_temporaries(const struct gl_program *program,
          if (inst->SrcReg[j].File == PROGRAM_TEMPORARY)\r
             tempsUsed[inst->SrcReg[j].Index] = GL_TRUE;\r
          if (inst->DstReg.File == PROGRAM_TEMPORARY)\r
-            tempsUsed[inst->DstReg.Index] = GL_TRUE;
-      }
-   }
-}
-
-
+            tempsUsed[inst->DstReg.Index] = GL_TRUE;\r
+      }\r
+   }\r
+}\r
+\r
+\r
 \r
 \r
 /**\r
@@ -775,34 +775,34 @@ tgsi_translate_mesa_program(
                                            maxTokens - ti );\r
       }\r
    }\r
-
-   /* 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 );
-         }
-      }
-   }
-
+\r
+   /* temporary decls */\r
+   {\r
+      GLboolean tempsUsed[MAX_PROGRAM_TEMPS + 1];\r
+      GLboolean inside_range = GL_FALSE;\r
+      GLuint start_range;\r
+\r
+      find_temporaries(program, tempsUsed);\r
+      tempsUsed[MAX_PROGRAM_TEMPS] = GL_FALSE;\r
+      for (i = 0; i < MAX_PROGRAM_TEMPS + 1; i++) {\r
+         if (tempsUsed[i] && !inside_range) {\r
+            inside_range = GL_TRUE;\r
+            start_range = i;\r
+         }\r
+         else if (!tempsUsed[i] && inside_range) {\r
+            struct tgsi_full_declaration fulldecl;\r
+\r
+            inside_range = GL_FALSE;\r
+            fulldecl = make_temp_decl( start_range, i - 1 );\r
+            ti += tgsi_build_full_declaration(\r
+                                              &fulldecl,\r
+                                              &tokens[ti],\r
+                                              header,\r
+                                              maxTokens - ti );\r
+         }\r
+      }\r
+   }\r
+\r
    /* immediates/literals */\r
 #if EMIT_IMMEDIATES\r
    for (i = 0; i < program->Parameters->NumParameters; i++) {\r