From: Rob Clark Date: Sat, 23 May 2020 19:21:20 +0000 (-0700) Subject: freedreno/gmem: add some asserts X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9b91d88b3390d264d06ccc11142325e99780e808;p=mesa.git freedreno/gmem: add some asserts Signed-off-by: Rob Clark Part-of: --- diff --git a/src/gallium/drivers/freedreno/freedreno_gmem.c b/src/gallium/drivers/freedreno/freedreno_gmem.c index a2bbd0acb29..3becea434df 100644 --- a/src/gallium/drivers/freedreno/freedreno_gmem.c +++ b/src/gallium/drivers/freedreno/freedreno_gmem.c @@ -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; diff --git a/src/gallium/drivers/freedreno/gmemtool.c b/src/gallium/drivers/freedreno/gmemtool.c index 2185f58c351..c0862bc5ad9 100644 --- a/src/gallium/drivers/freedreno/gmemtool.c +++ b/src/gallium/drivers/freedreno/gmemtool.c @@ -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); }