summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/panfrost/pan_allocate.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/drivers/panfrost/pan_allocate.c')
-rw-r--r--src/gallium/drivers/panfrost/pan_allocate.c49
1 files changed, 20 insertions, 29 deletions
diff --git a/src/gallium/drivers/panfrost/pan_allocate.c b/src/gallium/drivers/panfrost/pan_allocate.c
index 73da1ec5ed0..15c5f8aa671 100644
--- a/src/gallium/drivers/panfrost/pan_allocate.c
+++ b/src/gallium/drivers/panfrost/pan_allocate.c
@@ -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];
-
- if ((pool->entry_offset + sz) > pool->entry_size) {
- /* Don't overflow this entry -- advance to the next */
-
- pool->entry_offset = 0;
-
- pool->entry_index++;
- assert(pool->entry_index < PANFROST_MAX_TRANSIENT_ENTRIES);
+ /* Find or create a suitable BO */
+ struct panfrost_bo *bo = NULL;
- /* Check if this entry exists */
+ unsigned offset = 0;
+ bool update_offset = false;
- 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);
+ if (sz < TRANSIENT_SLAB_SIZE) {
+ /* TODO: Lookup free */
- pool->entry_count++;
- pool->entries[pool->entry_index] = (struct panfrost_memory_entry *) entry;
- }
+ if (!bo)
+ bo = panfrost_create_slab(screen);
- /* 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;