r300g: disable macrotiling when the texture height is smaller than a macrotile
authorMarek Olšák <maraeo@gmail.com>
Fri, 19 Feb 2010 02:02:34 +0000 (03:02 +0100)
committerMarek Olšák <maraeo@gmail.com>
Sun, 7 Mar 2010 15:24:09 +0000 (16:24 +0100)
Otherwise incorrect rendering occurs (no idea why).

src/gallium/drivers/r300/r300_texture.c

index 0736155d52898020f6a66aa402fc848858ca07b4..c0da339916e5d42909f538fd014e433ce3f09919 100644 (file)
@@ -617,18 +617,23 @@ static unsigned r300_texture_get_tile_size(struct r300_texture* tex,
 /* Return true if macrotiling should be enabled on the miplevel. */
 static boolean r300_texture_macro_switch(struct r300_texture *tex,
                                          unsigned level,
-                                         boolean rv350_mode)
+                                         boolean rv350_mode,
+                                         int dim)
 {
-    unsigned tile_width, width;
+    unsigned tile, texdim;
 
-    tile_width = r300_texture_get_tile_size(tex, TILE_WIDTH, TRUE);
-    width = u_minify(tex->tex.width0, level);
+    tile = r300_texture_get_tile_size(tex, dim, TRUE);
+    if (dim == TILE_WIDTH) {
+        texdim = u_minify(tex->tex.width0, level);
+    } else {
+        texdim = u_minify(tex->tex.height0, level);
+    }
 
     /* See TX_FILTER1_n.MACRO_SWITCH. */
     if (rv350_mode) {
-        return width >= tile_width;
+        return texdim >= tile;
     } else {
-        return width > tile_width;
+        return texdim > tile;
     }
 }
 
@@ -692,9 +697,10 @@ static void r300_setup_miptree(struct r300_screen* screen,
 
     for (i = 0; i <= base->last_level; i++) {
         /* Let's see if this miplevel can be macrotiled. */
-        tex->mip_macrotile[i] = (tex->macrotile == R300_BUFFER_TILED &&
-                                 r300_texture_macro_switch(tex, i, rv350_mode)) ?
-                                 R300_BUFFER_TILED : R300_BUFFER_LINEAR;
+        tex->mip_macrotile[i] =
+            (tex->macrotile == R300_BUFFER_TILED &&
+             r300_texture_macro_switch(tex, i, rv350_mode, TILE_WIDTH)) ?
+             R300_BUFFER_TILED : R300_BUFFER_LINEAR;
 
         stride = r300_texture_get_stride(screen, tex, i);
         nblocksy = r300_texture_get_nblocksy(tex, i);
@@ -755,7 +761,8 @@ static void r300_setup_tiling(struct pipe_screen *screen,
     }
 
     /* Set macrotiling. */
-    if (r300_texture_macro_switch(tex, 0, rv350_mode)) {
+    if (r300_texture_macro_switch(tex, 0, rv350_mode, TILE_WIDTH) &&
+        r300_texture_macro_switch(tex, 0, rv350_mode, TILE_HEIGHT)) {
         tex->macrotile = R300_BUFFER_TILED;
     }
 }