freedreno: fix bug in tile/slot calculation
authorRob Clark <robclark@freedesktop.org>
Wed, 13 May 2015 18:36:03 +0000 (14:36 -0400)
committerRob Clark <robclark@freedesktop.org>
Thu, 14 May 2015 18:46:14 +0000 (14:46 -0400)
This was causing corruption with hw binning on a306.  Unlikely that it
is a306 specific, but rather the smaller gmem size resulted in different
tile configuration which was triggering the bug at certain resolutions.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
Cc: "10.4" and "10.5" and "10.6" <mesa-stable@lists.freedesktop.org>
src/gallium/drivers/freedreno/freedreno_gmem.c

index 11a1b62b26b721d0c6a0da87efb525326bced255..c105378ec4e67e3ba23bb8e5eaa4fd50acb9caf6 100644 (file)
@@ -117,6 +117,7 @@ calculate_tiles(struct fd_context *ctx)
        uint32_t i, j, t, xoff, yoff;
        uint32_t tpp_x, tpp_y;
        bool has_zs = !!(ctx->resolve & (FD_BUFFER_DEPTH | FD_BUFFER_STENCIL));
+       int tile_n[ARRAY_SIZE(ctx->pipe)];
 
        if (has_zs) {
                struct fd_resource *rsc = fd_resource(pfb->zsbuf->texture);
@@ -247,6 +248,7 @@ calculate_tiles(struct fd_context *ctx)
        /* configure tiles: */
        t = 0;
        yoff = miny;
+       memset(tile_n, 0, sizeof(tile_n));
        for (i = 0; i < nbins_y; i++) {
                uint32_t bw, bh;
 
@@ -257,20 +259,17 @@ calculate_tiles(struct fd_context *ctx)
 
                for (j = 0; j < nbins_x; j++) {
                        struct fd_tile *tile = &ctx->tile[t];
-                       uint32_t n, p;
+                       uint32_t p;
 
                        assert(t < ARRAY_SIZE(ctx->tile));
 
                        /* pipe number: */
                        p = ((i / tpp_y) * div_round_up(nbins_x, tpp_x)) + (j / tpp_x);
 
-                       /* slot number: */
-                       n = ((i % tpp_y) * tpp_x) + (j % tpp_x);
-
                        /* clip bin width: */
                        bw = MIN2(bin_w, minx + width - xoff);
 
-                       tile->n = n;
+                       tile->n = tile_n[p]++;
                        tile->p = p;
                        tile->bin_w = bw;
                        tile->bin_h = bh;