r300/compiler: fix repeat wrap mode for TXP and NPOTs
authorMarek Olšák <maraeo@gmail.com>
Thu, 15 Apr 2010 23:59:11 +0000 (01:59 +0200)
committerMarek Olšák <maraeo@gmail.com>
Fri, 16 Apr 2010 00:04:18 +0000 (02:04 +0200)
No idea why st/mesa unnecessarily inserts TXP where TEX is sufficient.
Also re-enabling the NPOT fallback for repeat in r300g.

src/gallium/drivers/r300/r300_fs.c
src/mesa/drivers/dri/r300/compiler/r500_fragprog.c

index 01fd67e536b75a4058c787be9332cbb8b7127358..a37f23aaef2ecc661f4eff0128ad13e1c0f9702f 100644 (file)
@@ -165,8 +165,7 @@ static void get_external_state(
                 switch (s->state.wrap_s) {
                     case PIPE_TEX_WRAP_REPEAT:
                         state->unit[i].wrap_mode = RC_WRAP_REPEAT;
-                        /* XXX Enable when REPEAT fallback works.
-                        state->unit[i].fake_npot = TRUE; */
+                        state->unit[i].fake_npot = TRUE;
                         break;
 
                     case PIPE_TEX_WRAP_MIRROR_REPEAT:
index 295e455d900f2a871cdd76de08468ad9f967caf1..0caff487b0c19fd38fbc04e319916cef1d4ceca4 100644 (file)
@@ -200,12 +200,22 @@ int r500_transform_TEX(
                        }
 
                        if (wrapmode == RC_WRAP_REPEAT) {
-                               inst_rect = rc_insert_new_instruction(c, inst->Prev);
-
-                               inst_rect->U.I.Opcode = RC_OPCODE_FRC;
-                               inst_rect->U.I.DstReg.File = RC_FILE_TEMPORARY;
-                               inst_rect->U.I.DstReg.Index = temp;
-                               inst_rect->U.I.SrcReg[0] = inst->U.I.SrcReg[0];
+                               /* Both instructions will be paired up. */
+                               struct rc_instruction *inst_frc = rc_insert_new_instruction(c, inst->Prev);
+                               struct rc_instruction *inst_mov = rc_insert_new_instruction(c, inst_frc);
+
+                               inst_frc->U.I.Opcode = RC_OPCODE_FRC;
+                               inst_frc->U.I.DstReg.File = RC_FILE_TEMPORARY;
+                               inst_frc->U.I.DstReg.Index = temp;
+                               inst_frc->U.I.DstReg.WriteMask = RC_MASK_XYZ;
+                               inst_frc->U.I.SrcReg[0] = inst->U.I.SrcReg[0];
+
+                               /* Preserve W for TXP. */
+                               inst_mov->U.I.Opcode = RC_OPCODE_MOV;
+                               inst_mov->U.I.DstReg.File = RC_FILE_TEMPORARY;
+                               inst_mov->U.I.DstReg.Index = temp;
+                               inst_mov->U.I.DstReg.WriteMask = RC_MASK_W;
+                               inst_mov->U.I.SrcReg[0] = inst->U.I.SrcReg[0];
 
                                reset_srcreg(&inst->U.I.SrcReg[0]);
                                inst->U.I.SrcReg[0].File = RC_FILE_TEMPORARY;