mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 09:28:07 +02:00
panfrost: Rewrite allocate_transient with new abstraction
We use a fixed size slab if we can, otherwise we create a dedicated
("oversized") BO and add that to the job. In the latter case we'll get
reference counting for free so we can forget about this corner case for
the rest of the series.
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
This commit is contained in:
parent
ba02cf0e75
commit
00c9a1cb75
1 changed files with 20 additions and 29 deletions
|
|
@ -80,47 +80,38 @@ panfrost_create_slab(struct panfrost_screen *screen)
|
|||
struct panfrost_transfer
|
||||
panfrost_allocate_transient(struct panfrost_context *ctx, size_t sz)
|
||||
{
|
||||
struct panfrost_screen *screen = pan_screen(ctx->base.screen);
|
||||
|
||||
/* Pad the size */
|
||||
sz = ALIGN_POT(sz, ALIGNMENT);
|
||||
|
||||
/* Check if there is room in the current entry */
|
||||
struct panfrost_transient_pool *pool = &ctx->transient_pools[ctx->cmdstream_i];
|
||||
/* Find or create a suitable BO */
|
||||
struct panfrost_bo *bo = NULL;
|
||||
|
||||
if ((pool->entry_offset + sz) > pool->entry_size) {
|
||||
/* Don't overflow this entry -- advance to the next */
|
||||
unsigned offset = 0;
|
||||
bool update_offset = false;
|
||||
|
||||
pool->entry_offset = 0;
|
||||
if (sz < TRANSIENT_SLAB_SIZE) {
|
||||
/* TODO: Lookup free */
|
||||
|
||||
pool->entry_index++;
|
||||
assert(pool->entry_index < PANFROST_MAX_TRANSIENT_ENTRIES);
|
||||
if (!bo)
|
||||
bo = panfrost_create_slab(screen);
|
||||
|
||||
/* Check if this entry exists */
|
||||
|
||||
if (pool->entry_index >= pool->entry_count) {
|
||||
/* Don't overflow the pool -- allocate a new one */
|
||||
struct pipe_context *gallium = (struct pipe_context *) ctx;
|
||||
struct panfrost_screen *screen = pan_screen(gallium->screen);
|
||||
struct pb_slab_entry *entry = pb_slab_alloc(&screen->slabs, pool->entry_size, HEAP_TRANSIENT);
|
||||
|
||||
pool->entry_count++;
|
||||
pool->entries[pool->entry_index] = (struct panfrost_memory_entry *) entry;
|
||||
}
|
||||
|
||||
/* Make sure we -still- won't overflow */
|
||||
assert(sz < pool->entry_size);
|
||||
update_offset = true;
|
||||
} else {
|
||||
/* Create a new BO and reference it */
|
||||
bo = panfrost_drm_create_bo(screen, ALIGN_POT(sz, 4096), 0);
|
||||
panfrost_job_add_bo(batch, bo);
|
||||
}
|
||||
|
||||
/* We have an entry we can write to, so do the upload! */
|
||||
struct panfrost_memory_entry *p_entry = pool->entries[pool->entry_index];
|
||||
struct panfrost_memory *backing = (struct panfrost_memory *) p_entry->base.slab;
|
||||
|
||||
struct panfrost_transfer ret = {
|
||||
.cpu = backing->bo->cpu + p_entry->offset + pool->entry_offset,
|
||||
.gpu = backing->bo->gpu + p_entry->offset + pool->entry_offset
|
||||
.cpu = bo->cpu + offset,
|
||||
.gpu = bo->gpu + offset,
|
||||
};
|
||||
|
||||
/* Advance the pointer */
|
||||
pool->entry_offset += sz;
|
||||
if (update_offset) {
|
||||
/* TODO: Update the offset */
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue