freedreno/gmem: add some asserts
authorRob Clark <robdclark@chromium.org>
Sat, 23 May 2020 19:21:20 +0000 (12:21 -0700)
committerMarge Bot <eric+marge@anholt.net>
Tue, 26 May 2020 19:29:34 +0000 (19:29 +0000)
Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5189>

src/gallium/drivers/freedreno/freedreno_gmem.c
src/gallium/drivers/freedreno/gmemtool.c

index a2bbd0acb29142430a62ea1cdb3143060f4776e6..3becea434dffe360b4fa5844f86cc549571d4f17 100644 (file)
@@ -364,12 +364,13 @@ gmem_stateobj_init(struct fd_screen *screen, struct gmem_key *key)
        yoff = key->miny;
        memset(tile_n, 0, sizeof(tile_n));
        for (i = 0; i < nbins_y; i++) {
-               uint32_t bw, bh;
+               int bw, bh;
 
                xoff = key->minx;
 
                /* clip bin height: */
                bh = MIN2(gmem->bin_h, key->miny + key->height - yoff);
+               assert(bh > 0);
 
                for (j = 0; j < nbins_x; j++) {
                        struct fd_tile *tile = &gmem->tile[t];
@@ -383,6 +384,8 @@ gmem_stateobj_init(struct fd_screen *screen, struct gmem_key *key)
 
                        /* clip bin width: */
                        bw = MIN2(gmem->bin_w, key->minx + key->width - xoff);
+                       assert(bw > 0);
+
                        tile->n = !is_a20x(screen) ? tile_n[p]++ :
                                ((i % tpp_y + 1) << 3 | (j % tpp_x + 1));
                        tile->p = p;
index 2185f58c35155d087a2faf1cbbe2b297defca4cf..c0862bc5ad905e80d3f27ee5b75843b822c190c2 100644 (file)
@@ -177,6 +177,10 @@ main(int argc, char **argv)
                key.gmem_page_align = gpu_info->gmem_page_align;
                struct fd_gmem_stateobj *gmem = gmem_stateobj_init(&screen, &key);
                dump_gmem_state(gmem);
+
+               assert((gmem->bin_w * gmem->nbins_x) >= key.width);
+               assert((gmem->bin_h * gmem->nbins_y) >= key.height);
+
                ralloc_free(gmem);
        }