r300g: fixup rs690 tiling stride alignment calculations.
authorDave Airlie <airlied@redhat.com>
Fri, 10 Dec 2010 05:40:48 +0000 (15:40 +1000)
committerDave Airlie <airlied@redhat.com>
Mon, 13 Dec 2010 01:29:21 +0000 (11:29 +1000)
The RS690 memory controller prefers things to be on a different
boundary than the discrete GPUs, we had an attempt to fix this,
but it still failed, this consolidates the stride calculation
into one place and removes the really special case check.

This fixes gnome-shell and 16 piglit tests on my rs690 system.

NOTE: This is a candidate for both the 7.9 and 7.10 branches.

Signed-off-by: Dave Airlie <airlied@redhat.com>
src/gallium/drivers/r300/r300_texture.c
src/gallium/drivers/r300/r300_texture_desc.c
src/gallium/drivers/r300/r300_texture_desc.h

index 70fc5d96d83689b48c3adfaa312c6a94349a8ffb..6d86bc282ffd0ccdab57c4ed87d4c449a75ee174 100644 (file)
@@ -899,7 +899,7 @@ struct pipe_surface* r300_create_surface(struct pipe_context * ctx,
                                                tex->desc.b.b.nr_samples,
                                                tex->desc.microtile,
                                                tex->desc.macrotile[level],
-                                               DIM_HEIGHT);
+                                               DIM_HEIGHT, 0);
 
         surface->cbzb_height = align((surface->base.height + 1) / 2,
                                      tile_height);
index aa82c47151a14dcc0931948cb1c38324f0cb8523..7b1739142d49083f97f88b7734fe70feb3c21317 100644 (file)
@@ -34,7 +34,7 @@ unsigned r300_get_pixel_alignment(enum pipe_format format,
                                   unsigned num_samples,
                                   enum r300_buffer_tiling microtile,
                                   enum r300_buffer_tiling macrotile,
-                                  enum r300_dim dim)
+                                  enum r300_dim dim, boolean is_rs690)
 {
     static const unsigned table[2][5][3][2] =
     {
@@ -57,6 +57,7 @@ unsigned r300_get_pixel_alignment(enum pipe_format format,
             {{ 16, 8}, { 0,  0}, { 0,  0}}  /* 128 bits per pixel */
         }
     };
+
     static const unsigned aa_block[2] = {4, 8};
     unsigned tile = 0;
     unsigned pixsize = util_format_get_blocksize(format);
@@ -74,6 +75,14 @@ unsigned r300_get_pixel_alignment(enum pipe_format format,
     } else {
         /* Standard alignment. */
         tile = table[macrotile][util_logbase2(pixsize)][microtile][dim];
+        if (macrotile == 0 && is_rs690 && dim == DIM_WIDTH) {
+            int align;
+            int h_tile;
+            h_tile = table[macrotile][util_logbase2(pixsize)][microtile][DIM_HEIGHT];
+            align = 64 / (pixsize * h_tile);
+            if (tile < align)
+                tile = align;
+        }
     }
 
     assert(tile);
@@ -89,7 +98,7 @@ static boolean r300_texture_macro_switch(struct r300_texture_desc *desc,
     unsigned tile, texdim;
 
     tile = r300_get_pixel_alignment(desc->b.b.format, desc->b.b.nr_samples,
-                                    desc->microtile, R300_BUFFER_TILED, dim);
+                                    desc->microtile, R300_BUFFER_TILED, dim, 0);
     if (dim == DIM_WIDTH) {
         texdim = u_minify(desc->width0, level);
     } else {
@@ -113,6 +122,9 @@ static unsigned r300_texture_get_stride(struct r300_screen *screen,
                                         unsigned level)
 {
     unsigned tile_width, width, stride;
+    boolean is_rs690 = (screen->caps.family == CHIP_FAMILY_RS600 ||
+                        screen->caps.family == CHIP_FAMILY_RS690 ||
+                        screen->caps.family == CHIP_FAMILY_RS740);
 
     if (desc->stride_in_bytes_override)
         return desc->stride_in_bytes_override;
@@ -131,38 +143,14 @@ static unsigned r300_texture_get_stride(struct r300_screen *screen,
                                               desc->b.b.nr_samples,
                                               desc->microtile,
                                               desc->macrotile[level],
-                                              DIM_WIDTH);
+                                              DIM_WIDTH, is_rs690);
         width = align(width, tile_width);
 
         stride = util_format_get_stride(desc->b.b.format, width);
-
-        /* Some IGPs need a minimum stride of 64 bytes, hmm... */
-        if (!desc->macrotile[level] &&
-            (screen->caps.family == CHIP_FAMILY_RS600 ||
-             screen->caps.family == CHIP_FAMILY_RS690 ||
-             screen->caps.family == CHIP_FAMILY_RS740)) {
-            unsigned min_stride;
-
-            if (desc->microtile) {
-                unsigned tile_height =
-                        r300_get_pixel_alignment(desc->b.b.format,
-                                                 desc->b.b.nr_samples,
-                                                 desc->microtile,
-                                                 desc->macrotile[level],
-                                                 DIM_HEIGHT);
-
-                min_stride = 64 / tile_height;
-            } else {
-                min_stride = 64;
-            }
-
-            return stride < min_stride ? min_stride : stride;
-        }
-
         /* The alignment to 32 bytes is sort of implied by the layout... */
         return stride;
     } else {
-        return align(util_format_get_stride(desc->b.b.format, width), 32);
+        return align(util_format_get_stride(desc->b.b.format, width), is_rs690 ? 64 : 32);
     }
 }
 
@@ -179,7 +167,7 @@ static unsigned r300_texture_get_nblocksy(struct r300_texture_desc *desc,
                                                desc->b.b.nr_samples,
                                                desc->microtile,
                                                desc->macrotile[level],
-                                               DIM_HEIGHT);
+                                               DIM_HEIGHT, 0);
         height = align(height, tile_height);
 
         /* This is needed for the kernel checker, unfortunately. */
index 44d88794a125707e5597a73cdc526b91c1e717b2..121d215b4cbab2ddcedd6a4dd81c85b6bc36460c 100644 (file)
@@ -41,7 +41,7 @@ unsigned r300_get_pixel_alignment(enum pipe_format format,
                                   unsigned num_samples,
                                   enum r300_buffer_tiling microtile,
                                   enum r300_buffer_tiling macrotile,
-                                  enum r300_dim dim);
+                                  enum r300_dim dim, boolean is_rs690);
 
 boolean r300_texture_desc_init(struct r300_screen *rscreen,
                                struct r300_texture_desc *desc,