Copy fragment z if the fragment shader does not write depth on its own.`
authormichal <michal@michal-laptop.(none)>
Thu, 16 Aug 2007 11:40:46 +0000 (12:40 +0100)
committermichal <michal@michal-laptop.(none)>
Thu, 16 Aug 2007 11:44:04 +0000 (12:44 +0100)
src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c

index 2ac04e8..2c8deac 100644 (file)
@@ -4,7 +4,7 @@
 #define TGSI_DEBUG 1\r
 \r
 /*\r
- * Map mesa register file to SBIR register file.\r
+ * Map mesa register file to TGSI register file.\r
  */\r
 static GLuint\r
 map_register_file(\r
@@ -35,7 +35,7 @@ map_register_file(
 }\r
 \r
 /**\r
- * Map mesa register file index to SBIR index.\r
+ * Map mesa register file index to TGSI index.\r
  * Take special care when processing input and output indices.\r
  * \param processor  either TGSI_PROCESSOR_FRAGMENT or  TGSI_PROCESSOR_VERTEX\r
  * \param file  one of TGSI_FILE_x\r
@@ -101,7 +101,7 @@ map_register_file_index(
 }\r
 \r
 /*\r
- * Map mesa texture target to SBIR texture target.\r
+ * Map mesa texture target to TGSI texture target.\r
  */\r
 static GLuint\r
 map_texture_target(\r
@@ -609,6 +609,33 @@ tgsi_mesa_compile_fp_program(
          maxTokens - ti );\r
    }\r
 \r
+   /*\r
+    * Copy fragment z if the shader does not write it.\r
+    */\r
+   if( !(program->Base.OutputsWritten & (1 << FRAG_RESULT_DEPR)) ) {\r
+      fullinst = tgsi_default_full_instruction();\r
+\r
+      fullinst.Instruction.Opcode = TGSI_OPCODE_MOV;\r
+      fullinst.Instruction.NumDstRegs = 1;\r
+      fullinst.Instruction.NumSrcRegs = 1;\r
+\r
+      fulldst = &fullinst.FullDstRegisters[0];\r
+      fulldst->DstRegister.File = TGSI_FILE_OUTPUT;\r
+      fulldst->DstRegister.Index = 0;\r
+      fulldst->DstRegister.WriteMask = TGSI_WRITEMASK_Z;\r
+\r
+      fullsrc = &fullinst.FullSrcRegisters[0];\r
+      fullsrc->SrcRegister.File = TGSI_FILE_INPUT;\r
+      fullsrc->SrcRegister.Index = 0;\r
+\r
+      ti += tgsi_build_full_instruction(\r
+         &fullinst,\r
+         &tokens[ti],\r
+         header,\r
+         maxTokens - ti );\r
+      preamble_size++;\r
+   }\r
+\r
    for( i = 0; i < program->Base.NumInstructions; i++ ) {\r
       if( compile_instruction(\r
             &program->Base.Instructions[i],\r