r300g: mask out the mirrored bit correctly in the registers
authorMarek Olšák <maraeo@gmail.com>
Thu, 15 Apr 2010 21:15:41 +0000 (23:15 +0200)
committerMarek Olšák <maraeo@gmail.com>
Thu, 15 Apr 2010 21:17:35 +0000 (23:17 +0200)
It was previously done wrong + now it shouldn't render garbage,
so that the NPOT fallback can get in.

src/gallium/drivers/r300/r300_state_derived.c

index a36cff98c38ad0afbd5c1ecde688711a248b5d5e..46c192eae14b9513e7f4ea0e2cdf58afd358387f 100644 (file)
@@ -514,22 +514,22 @@ static void r300_merge_textures_and_samplers(struct r300_context* r300)
                  * This prevents incorrect rendering. */
                 texstate->filter0 &= ~R300_TX_MIN_FILTER_MIP_MASK;
 
-                /* Set repeat or mirrored-repeat to clamp-to-edge. */
-                /* Wrap S. */
+                /* Mask out the mirrored flag. */
+                if (texstate->filter0 & R300_TX_WRAP_S(R300_TX_MIRRORED)) {
+                    texstate->filter0 &= ~R300_TX_WRAP_S(R300_TX_MIRRORED);
+                }
+                if (texstate->filter0 & R300_TX_WRAP_T(R300_TX_MIRRORED)) {
+                    texstate->filter0 &= ~R300_TX_WRAP_T(R300_TX_MIRRORED);
+                }
+
+                /* Change repeat to clamp-to-edge.
+                 * (the repeat bit has a value of 0, no masking needed). */
                 if ((texstate->filter0 & R300_TX_WRAP_S_MASK) ==
-                     R300_TX_WRAP_S(R300_TX_REPEAT) ||
-                    (texstate->filter0 & R300_TX_WRAP_S_MASK) ==
-                     R300_TX_WRAP_S(R300_TX_MIRRORED)) {
-                    texstate->filter0 &= ~R300_TX_WRAP_S_MASK;
+                    R300_TX_WRAP_S(R300_TX_REPEAT)) {
                     texstate->filter0 |= R300_TX_WRAP_S(R300_TX_CLAMP_TO_EDGE);
                 }
-
-                /* Wrap T. */
                 if ((texstate->filter0 & R300_TX_WRAP_T_MASK) ==
-                     R300_TX_WRAP_T(R300_TX_REPEAT) ||
-                    (texstate->filter0 & R300_TX_WRAP_T_MASK) ==
-                     R300_TX_WRAP_T(R300_TX_MIRRORED)) {
-                    texstate->filter0 &= ~R300_TX_WRAP_T_MASK;
+                    R300_TX_WRAP_T(R300_TX_REPEAT)) {
                     texstate->filter0 |= R300_TX_WRAP_T(R300_TX_CLAMP_TO_EDGE);
                 }
             } else {