r300g: do not use TXPITCH_EN if the width is POT and the height is NPOT
authorMarek Olšák <maraeo@gmail.com>
Sat, 24 Jul 2010 21:05:40 +0000 (23:05 +0200)
committerMarek Olšák <maraeo@gmail.com>
Sun, 25 Jul 2010 08:25:21 +0000 (10:25 +0200)
src/gallium/drivers/r300/r300_context.h
src/gallium/drivers/r300/r300_fs.c
src/gallium/drivers/r300/r300_state.c
src/gallium/drivers/r300/r300_state_derived.c
src/gallium/drivers/r300/r300_texture.c
src/gallium/drivers/r300/r300_texture_desc.c

index 06e4e12558fd5e6a9f1321a208bebba8e08a35db..b4256c62786e47ab6f493742cd1a9de95fbda17b 100644 (file)
@@ -361,13 +361,12 @@ struct r300_texture_desc {
      */
     unsigned stride_in_bytes_override;
 
-    /* Whether this texture has non-power-of-two dimensions
-     * or a user-specified stride.
-     * It can be either a regular texture or a rectangle one.
-     *
-     * This flag says that hardware must use the stride for addressing
-     * instead of the width.
-     */
+    /* Whether this texture has non-power-of-two dimensions.
+     * It can be either a regular texture or a rectangle one. */
+    boolean is_npot;
+
+    /* This flag says that hardware must use the stride for addressing
+     * instead of the width. */
     boolean uses_stride_addressing;
 
     /* Whether CBZB fast color clear is allowed on the miplevel. */
index 6eac12bfb9f6ccdd877d5008474102ceeb026314..db5269912e2d1e6db5f648ca6e5c15b92181fd67 100644 (file)
@@ -173,7 +173,7 @@ static void get_external_state(
             t = (struct r300_texture*)texstate->sampler_views[i]->base.texture;
 
             /* XXX this should probably take into account STR, not just S. */
-            if (t->desc.uses_stride_addressing) {
+            if (t->desc.is_npot) {
                 switch (s->state.wrap_s) {
                     case PIPE_TEX_WRAP_REPEAT:
                         state->unit[i].wrap_mode = RC_WRAP_REPEAT;
index 6e2a6ca0e42d87f850ecc3b409d5beeeacac975f..bbea7e1589e279314b0e22d8ba4778a0ba9c07cc 100644 (file)
@@ -1296,7 +1296,7 @@ static void r300_set_fragment_sampler_views(struct pipe_context* pipe,
             /* Set the texrect factor in the fragment shader.
              * Needed for RECT and NPOT fallback. */
             texture = r300_texture(views[i]->texture);
-            if (texture->desc.uses_stride_addressing) {
+            if (texture->desc.is_npot) {
                 r300->fs_rc_constant_state.dirty = TRUE;
             }
 
index e20d8d0fdf00c2e4b3eb2bdb2b75d8458dc34b49..48912e1555c28ac67f2696db4942993ce6fdf878 100644 (file)
@@ -583,7 +583,7 @@ static void r300_merge_textures_and_samplers(struct r300_context* r300)
                 texstate->filter0 |= R300_TX_WRAP_T(R300_TX_CLAMP_TO_EDGE);
             }
 
-            if (tex->desc.uses_stride_addressing) {
+            if (tex->desc.is_npot) {
                 /* NPOT textures don't support mip filter, unfortunately.
                  * This prevents incorrect rendering. */
                 texstate->filter0 &= ~R300_TX_MIN_FILTER_MIP_MASK;
index e99a4630ee4294e40a818ad819c213c08e561a2e..f1118dfd7ddc89be2c5748069269fed4d39fef1d 100644 (file)
@@ -552,7 +552,8 @@ static void r300_texture_setup_immutable_state(struct r300_screen* screen,
         f->format0 |= R300_TX_PITCH_EN;
         f->format2 = (tex->desc.stride_in_pixels[0] - 1) & 0x1fff;
     } else {
-        /* power of two textures (3D, mipmaps, and no pitch) */
+        /* Power of two textures (3D, mipmaps, and no pitch),
+         * also NPOT textures with a width being POT. */
         f->format0 |= R300_TX_DEPTH(util_logbase2(pt->depth0) & 0xf);
     }
 
index becaa59bea34396b5ce975e2939809e2fec43272..02591aa01f14e3a12883eef8b1007a78d072d764 100644 (file)
@@ -272,6 +272,10 @@ static void r300_setup_flags(struct r300_texture_desc *desc)
         (desc->stride_in_bytes_override &&
          stride_to_width(desc->b.b.format,
                          desc->stride_in_bytes_override) != desc->b.b.width0);
+
+    desc->is_npot =
+        desc->uses_stride_addressing ||
+        !util_is_power_of_two(desc->b.b.height0);
 }
 
 static void r300_setup_cbzb_flags(struct r300_screen *rscreen,