}\r
\r
\r
+\r
+\r
+/**\r
+ * Translate Mesa program to TGSI format.\r
+ * \param program the program to translate\r
+ * \param numInputs number of input registers used\r
+ * \param inputMapping maps Mesa fragment program inputs to TGSI generic\r
+ * input indexes\r
+ * \param inputSemanticName the TGSI_SEMANTIC flag for each input\r
+ * \param inputSemanticIndex the semantic index (ex: which texcoord) for each input\r
+ * \param interpMode the TGSI_INTERPOLATE_LINEAR/PERSP mode for each input\r
+\r
+ * \param numOutputs number of output registers used\r
+ * \param outputMapping maps Mesa fragment program outputs to TGSI\r
+ * generic outputs\r
+ * \param outputSemanticName the TGSI_SEMANTIC flag for each output\r
+ * \param outputSemanticIndex the semantic index (ex: which texcoord) for each output\r
+ * \param tokens array to store translated tokens in\r
+ * \param maxTokens size of the tokens array\r
+ *\r
+ */\r
+#if 0\r
+static GLboolean\r
+tgsi_translate_program(\r
+ uint procType,\r
+ const struct gl_program *program,\r
+ GLuint numInputs,\r
+ const GLuint inputMapping[],\r
+ const ubyte inputSemanticName[],\r
+ const ubyte inputSemanticIndex[],\r
+ const GLuint interpMode[],\r
+ GLuint numOutputs,\r
+ const GLuint outputMapping[],\r
+ const ubyte outputSemanticName[],\r
+ const ubyte outputSemanticIndex[],\r
+ struct tgsi_token *tokens,\r
+ GLuint maxTokens )\r
+{\r
+ GLuint i;\r
+ GLuint ti; /* token index */\r
+ struct tgsi_header *header;\r
+ struct tgsi_processor *processor;\r
+ struct tgsi_full_instruction fullinst;\r
+ GLuint preamble_size = 0;\r
+\r
+ assert(procType == TGSI_PROCESSOR_FRAGMENT ||\r
+ procType == TGSI_PROCESSOR_VERTEX);\r
+\r
+ *(struct tgsi_version *) &tokens[0] = tgsi_build_version();\r
+\r
+ header = (struct tgsi_header *) &tokens[1];\r
+ *header = tgsi_build_header();\r
+\r
+ processor = (struct tgsi_processor *) &tokens[2];\r
+ *processor = tgsi_build_processor( procType, header );\r
+\r
+ ti = 3;\r
+\r
+ /*\r
+ * Declare input attributes.\r
+ */\r
+ if (procType == TGSI_PROCESSOR_FRAGMENT) {\r
+ for (i = 0; i < numInputs; i++) {\r
+ struct tgsi_full_declaration fulldecl;\r
+ switch (inputSemanticName[i]) {\r
+ case TGSI_SEMANTIC_POSITION:\r
+ /* Fragment XY pos */\r
+ fulldecl = make_input_decl(i,\r
+ TGSI_INTERPOLATE_CONSTANT,\r
+ TGSI_WRITEMASK_XY,\r
+ GL_TRUE, TGSI_SEMANTIC_POSITION, 0 );\r
+ ti += tgsi_build_full_declaration(\r
+ &fulldecl,\r
+ &tokens[ti],\r
+ header,\r
+ maxTokens - ti );\r
+ /* Fragment ZW pos */\r
+ fulldecl = make_input_decl(i,\r
+ TGSI_INTERPOLATE_LINEAR,\r
+ TGSI_WRITEMASK_ZW,\r
+ GL_TRUE, TGSI_SEMANTIC_POSITION, 0 );\r
+ ti += tgsi_build_full_declaration(&fulldecl,\r
+ &tokens[ti],\r
+ header,\r
+ maxTokens - ti );\r
+ break;\r
+ default:\r
+ fulldecl = make_input_decl(i,\r
+ interpMode[i],\r
+ TGSI_WRITEMASK_XYZW,\r
+ GL_TRUE, inputSemanticName[i],\r
+ inputSemanticIndex[i]);\r
+ ti += tgsi_build_full_declaration(&fulldecl,\r
+ &tokens[ti],\r
+ header,\r
+ maxTokens - ti );\r
+ break;\r
+ }\r
+ }\r
+ }\r
+ else {\r
+ /* vertex prog */\r
+ for (i = 0; i < numInputs; i++) {\r
+ struct tgsi_full_declaration fulldecl;\r
+ fulldecl = make_input_decl(i,\r
+ TGSI_INTERPOLATE_ATTRIB,\r
+ TGSI_WRITEMASK_XYZW,\r
+ GL_FALSE, inputSemanticName[i],\r
+ inputSemanticIndex[i]);\r
+ ti += tgsi_build_full_declaration(&fulldecl,\r
+ &tokens[ti],\r
+ header,\r
+ maxTokens - ti );\r
+ }\r
+ }\r
+\r
+ /*\r
+ * Declare output attributes.\r
+ */\r
+ if (procType == TGSI_PROCESSOR_FRAGMENT) {\r
+ for (i = 0; i < numOutputs; i++) {\r
+ struct tgsi_full_declaration fulldecl;\r
+ switch (outputSemanticName[i]) {\r
+ case TGSI_SEMANTIC_POSITION:\r
+ fulldecl = make_output_decl(i,\r
+ TGSI_SEMANTIC_POSITION, 0, /* Z / Depth */\r
+ TGSI_WRITEMASK_Z );\r
+ break;\r
+ case TGSI_SEMANTIC_COLOR:\r
+ fulldecl = make_output_decl(i,\r
+ TGSI_SEMANTIC_COLOR, 0,\r
+ TGSI_WRITEMASK_XYZW );\r
+ break;\r
+ default:\r
+ abort();\r
+ }\r
+ ti += tgsi_build_full_declaration(&fulldecl,\r
+ &tokens[ti],\r
+ header,\r
+ maxTokens - ti );\r
+ }\r
+ }\r
+ else {\r
+ /* vertex prog */\r
+ for (i = 0; i < numOutputs; i++) {\r
+ struct tgsi_full_declaration fulldecl;\r
+ fulldecl = make_output_decl(i,\r
+ outputSemanticName[i],\r
+ outputSemanticIndex[i],\r
+ TGSI_WRITEMASK_XYZW );\r
+ ti += tgsi_build_full_declaration(&fulldecl,\r
+ &tokens[ti],\r
+ header,\r
+ maxTokens - ti );\r
+ }\r
+ }\r
+\r
+ /* temporary decls */\r
+ {\r
+ GLuint tempsUsed[MAX_PROGRAM_TEMPS];\r
+ uint numTemps = find_temporaries(program, tempsUsed);\r
+ for (i = 0; i < numTemps; i++) {\r
+ struct tgsi_full_declaration fulldecl;\r
+ fulldecl = make_temp_decl(tempsUsed[i]);\r
+ ti += tgsi_build_full_declaration(\r
+ &fulldecl,\r
+ &tokens[ti],\r
+ header,\r
+ maxTokens - ti );\r
+ }\r
+ }\r
+\r
+ for( i = 0; i < program->NumInstructions; i++ ) {\r
+ compile_instruction(\r
+ &program->Instructions[i],\r
+ &fullinst,\r
+ inputMapping,\r
+ outputMapping,\r
+ preamble_size,\r
+ procType );\r
+\r
+ ti += tgsi_build_full_instruction(\r
+ &fullinst,\r
+ &tokens[ti],\r
+ header,\r
+ maxTokens - ti );\r
+ }\r
+\r
+ return GL_TRUE;\r
+}\r
+#endif\r
+\r
+\r
+\r
/**\r
* Convert Mesa fragment program to TGSI format.\r
* \param inputMapping maps Mesa fragment program inputs to TGSI generic\r