diff options
author | Rob Clark <[email protected]> | 2020-04-25 10:45:31 -0700 |
---|---|---|
committer | Marge Bot <[email protected]> | 2020-04-28 23:31:58 +0000 |
commit | 99d802ccc77c7897f27d75275d38c702f3db6fd8 (patch) | |
tree | f706cfea7fa49226319b3b6959eef756c38befe3 | |
parent | a9c255d70c303436bf4f9b1be08b2679373f17a2 (diff) |
freedreno: add helper to estimate # of bins per pipe
For vsc size calculation, we need to know the # of bins per pipe. Or at
least the worst-case # of bins, assuming we don't eliminate an unused depth/
stencil buffer.
Signed-off-by: Rob Clark <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4750>
-rw-r--r-- | src/gallium/drivers/freedreno/freedreno_gmem.c | 28 | ||||
-rw-r--r-- | src/gallium/drivers/freedreno/freedreno_gmem.h | 2 |
2 files changed, 24 insertions, 6 deletions
diff --git a/src/gallium/drivers/freedreno/freedreno_gmem.c b/src/gallium/drivers/freedreno/freedreno_gmem.c index 0af7388fe06..fee9ea2d747 100644 --- a/src/gallium/drivers/freedreno/freedreno_gmem.c +++ b/src/gallium/drivers/freedreno/freedreno_gmem.c @@ -353,7 +353,7 @@ __fd_gmem_destroy(struct fd_gmem_stateobj *gmem) } static struct gmem_key * -key_init(struct fd_batch *batch) +gmem_key_init(struct fd_batch *batch, bool assume_zs) { struct fd_screen *screen = batch->ctx->screen; struct pipe_framebuffer_state *pfb = &batch->framebuffer; @@ -361,7 +361,7 @@ key_init(struct fd_batch *batch) FD_GMEM_STENCIL_ENABLED | FD_GMEM_CLEARS_DEPTH_STENCIL)); struct gmem_key *key = rzalloc(screen->gmem_cache.ht, struct gmem_key); - if (has_zs) { + if (has_zs || assume_zs) { struct fd_resource *rsc = fd_resource(pfb->zsbuf->texture); key->zsbuf_cpp[0] = rsc->layout.cpp; if (rsc->stencil) @@ -412,12 +412,12 @@ key_init(struct fd_batch *batch) } static struct fd_gmem_stateobj * -lookup_gmem_state(struct fd_batch *batch) +lookup_gmem_state(struct fd_batch *batch, bool assume_zs) { struct fd_screen *screen = batch->ctx->screen; struct fd_gmem_cache *cache = &screen->gmem_cache; struct fd_gmem_stateobj *gmem = NULL; - struct gmem_key *key = key_init(batch); + struct gmem_key *key = gmem_key_init(batch, assume_zs); uint32_t hash = gmem_key_hash(key); mtx_lock(&screen->lock); @@ -610,7 +610,7 @@ fd_gmem_render_tiles(struct fd_batch *batch) render_sysmem(batch); ctx->stats.batch_sysmem++; } else { - struct fd_gmem_stateobj *gmem = lookup_gmem_state(batch); + struct fd_gmem_stateobj *gmem = lookup_gmem_state(batch, false); batch->gmem_state = gmem; fd_log(batch, "%p: rendering %dx%d tiles %ux%u (%s/%s)", batch, pfb->width, pfb->height, gmem->nbins_x, gmem->nbins_y, @@ -631,6 +631,24 @@ fd_gmem_render_tiles(struct fd_batch *batch) flush_ring(batch); } +/* Determine a worst-case estimate (ie. assuming we don't eliminate an + * unused depth/stencil) number of bins per vsc pipe. + */ +unsigned +fd_gmem_estimate_bins_per_pipe(struct fd_batch *batch) +{ + struct pipe_framebuffer_state *pfb = &batch->framebuffer; + struct fd_screen *screen = batch->ctx->screen; + struct fd_gmem_stateobj *gmem = lookup_gmem_state(batch, !!pfb->zsbuf); + unsigned nbins = gmem->maxpw * gmem->maxph; + + mtx_lock(&screen->lock); + fd_gmem_reference(&gmem, NULL); + mtx_unlock(&screen->lock); + + return nbins; +} + /* When deciding whether a tile needs mem2gmem, we need to take into * account the scissor rect(s) that were cleared. To simplify we only * consider the last scissor rect for each buffer, since the common diff --git a/src/gallium/drivers/freedreno/freedreno_gmem.h b/src/gallium/drivers/freedreno/freedreno_gmem.h index 84b0172fa22..35fc9c30549 100644 --- a/src/gallium/drivers/freedreno/freedreno_gmem.h +++ b/src/gallium/drivers/freedreno/freedreno_gmem.h @@ -88,7 +88,7 @@ struct fd_gmem_cache { struct fd_batch; void fd_gmem_render_tiles(struct fd_batch *batch); - +unsigned fd_gmem_estimate_bins_per_pipe(struct fd_batch *batch); bool fd_gmem_needs_restore(struct fd_batch *batch, const struct fd_tile *tile, uint32_t buffers); |