Different pools have different expected sizes.
Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10866>
/* Preallocate the main pool, since every batch has at least one job
* structure so it will be used */
- panfrost_pool_init(&batch->pool, NULL, dev, 0, "Batch pool", true, true);
+ panfrost_pool_init(&batch->pool, NULL, dev, 0, 65536, "Batch pool", true, true);
/* Don't preallocate the invisible pool, since not every batch will use
* the pre-allocation, particularly if the varyings are larger than the
* preallocation and a reallocation is needed after anyway. */
panfrost_pool_init(&batch->invisible_pool, NULL, dev,
- PAN_BO_INVISIBLE, "Varyings", false, true);
+ PAN_BO_INVISIBLE, 65536, "Varyings", false, true);
panfrost_batch_add_fbo_bos(batch);
}
struct pan_blit_context *ctx)
{
memset(ctx, 0, sizeof(*ctx));
- panfrost_pool_init(&ctx->pool, NULL, dev, 0, "Blitter pool", false, true);
+ panfrost_pool_init(&ctx->pool, NULL, dev, 0, 65536, "Blitter pool", false, true);
ctx->z_scale = (float)(info->dst.end.z - info->dst.start.z + 1) /
(info->src.end.z - info->src.start.z + 1);
_mesa_hash_table_create(NULL, pan_blit_blend_shader_key_hash,
pan_blit_blend_shader_key_equal);
panfrost_pool_init(&dev->blitter.shaders.pool, NULL, dev,
- PAN_BO_EXECUTE, "Blitter shaders", false, true);
+ PAN_BO_EXECUTE, 65536, "Blitter shaders", false, true);
pthread_mutex_init(&dev->blitter.shaders.lock, NULL);
pan_blitter_prefill_blit_shader_cache(dev);
- panfrost_pool_init(&dev->blitter.rsds.pool, NULL, dev, 0, "Blitter RSDs", false, true);
+ panfrost_pool_init(&dev->blitter.rsds.pool, NULL, dev, 0, 65536, "Blitter RSDs", false, true);
dev->blitter.rsds.rsds =
_mesa_hash_table_create(NULL, pan_blit_rsd_key_hash,
pan_blit_rsd_key_equal);
/* Driver limits */
#define PAN_MAX_CONST_BUFFERS 16
-/* Transient slab size. This is a balance between fragmentation against cache
- * locality and ease of bookkeeping */
-
-#define TRANSIENT_SLAB_PAGES (16) /* 64kb */
-#define TRANSIENT_SLAB_SIZE (4096 * TRANSIENT_SLAB_PAGES)
-
-/* Maximum number of transient slabs so we don't need dynamic arrays. Most
- * interesting Mali boards are 4GB RAM max, so if the entire RAM was filled
- * with transient slabs, you could never exceed (4GB / TRANSIENT_SLAB_SIZE)
- * allocations anyway. By capping, we can use a fixed-size bitset for tracking
- * free slabs, eliminating quite a bit of complexity. We can pack the free
- * state of 8 slabs into a single byte, so for 128kb transient slabs the bitset
- * occupies a cheap 4kb of memory */
-
-#define MAX_TRANSIENT_SLABS (1024*1024 / TRANSIENT_SLAB_PAGES)
-
/* How many power-of-two levels in the BO cache do we want? 2^12
* minimum chosen as it is the page size that all allocations are
* rounded to */
*/
pthread_mutex_init(&dev->indirect_draw_shaders.lock, NULL);
panfrost_pool_init(&dev->indirect_draw_shaders.bin_pool, NULL, dev,
- PAN_BO_EXECUTE, "Indirect draw shaders", false, true);
+ PAN_BO_EXECUTE, 65536, "Indirect draw shaders", false, true);
}
void
void
panfrost_pool_init(struct pan_pool *pool, void *memctx,
struct panfrost_device *dev,
- unsigned create_flags, const char *label,
+ unsigned create_flags, size_t slab_size, const char *label,
bool prealloc, bool owned)
{
memset(pool, 0, sizeof(*pool));
pool->create_flags = create_flags;
pool->owned = owned;
pool->label = label;
+ pool->slab_size = slab_size;
if (owned)
util_dynarray_init(&pool->bos, memctx);
if (prealloc)
- panfrost_pool_alloc_backing(pool, TRANSIENT_SLAB_SIZE);
+ panfrost_pool_alloc_backing(pool, pool->slab_size);
}
void
unsigned offset = ALIGN_POT(pool->transient_offset, alignment);
/* If we don't fit, allocate a new backing */
- if (unlikely(bo == NULL || (offset + sz) >= TRANSIENT_SLAB_SIZE)) {
+ if (unlikely(bo == NULL || (offset + sz) >= pool->slab_size)) {
bo = panfrost_pool_alloc_backing(pool,
- ALIGN_POT(MAX2(TRANSIENT_SLAB_SIZE, sz), 4096));
+ ALIGN_POT(MAX2(pool->slab_size, sz), 4096));
offset = 0;
}
/* BO flags to use in the pool */
unsigned create_flags;
+ /* Minimum size for allocated BOs. */
+ size_t slab_size;
+
/* Mode of the pool. BO management is in the pool for owned mode, but
* the consumed for unowned mode. */
bool owned;
void
panfrost_pool_init(struct pan_pool *pool, void *memctx,
struct panfrost_device *dev, unsigned create_flags,
- const char *label, bool prealloc, bool owned);
+ size_t slab_size, const char *label, bool prealloc, bool
+ owned);
void
panfrost_pool_cleanup(struct pan_pool *pool);