diff options
author | Alyssa Rosenzweig <[email protected]> | 2019-07-12 13:05:14 -0700 |
---|---|---|
committer | Alyssa Rosenzweig <[email protected]> | 2019-07-12 15:31:48 -0700 |
commit | 37097b2f3818e3a30319600f3441b96dc1261382 (patch) | |
tree | 6ffbe1f243b92d291ec7746005150878e34d1277 /src/gallium/drivers/panfrost/pan_allocate.c | |
parent | 0f5ad9efccc28fc78883ef10a1aad83d1013a4c3 (diff) |
panfrost: Recycle fixed-size transient BOs
The usual case. We use the bitset to mark freedom and seize it.
Signed-off-by: Alyssa Rosenzweig <[email protected]>
Diffstat (limited to 'src/gallium/drivers/panfrost/pan_allocate.c')
-rw-r--r-- | src/gallium/drivers/panfrost/pan_allocate.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/gallium/drivers/panfrost/pan_allocate.c b/src/gallium/drivers/panfrost/pan_allocate.c index 4febb001033..a0a96c15b94 100644 --- a/src/gallium/drivers/panfrost/pan_allocate.c +++ b/src/gallium/drivers/panfrost/pan_allocate.c @@ -97,12 +97,27 @@ panfrost_allocate_transient(struct panfrost_context *ctx, size_t sz) bool update_offset = false; if (sz < TRANSIENT_SLAB_SIZE) { - /* TODO: Lookup free */ - + /* First, look for a free slot */ + unsigned count = util_dynarray_num_elements(&screen->transient_bo, void *); unsigned index = 0; - if (!bo) + unsigned free = __bitset_ffs( + screen->free_transient, + count / BITSET_WORDBITS); + + if (likely(free)) { + /* Use this one */ + index = free - 1; + + /* It's ours, so no longer free */ + BITSET_CLEAR(screen->free_transient, index); + + /* Grab the BO */ + bo = pan_bo_for_index(screen, index); + } else { + /* Otherwise, create a new BO */ bo = panfrost_create_slab(screen, &index); + } /* Remember we created this */ util_dynarray_append(&batch->transient_indices, unsigned, index); |