diff options
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/drivers/panfrost/pan_allocate.c | 22 | ||||
-rw-r--r-- | src/gallium/drivers/panfrost/pan_job.c | 1 | ||||
-rw-r--r-- | src/gallium/drivers/panfrost/pan_job.h | 3 |
3 files changed, 21 insertions, 5 deletions
diff --git a/src/gallium/drivers/panfrost/pan_allocate.c b/src/gallium/drivers/panfrost/pan_allocate.c index a0a96c15b94..a07eba8b8f6 100644 --- a/src/gallium/drivers/panfrost/pan_allocate.c +++ b/src/gallium/drivers/panfrost/pan_allocate.c @@ -96,8 +96,21 @@ panfrost_allocate_transient(struct panfrost_context *ctx, size_t sz) unsigned offset = 0; bool update_offset = false; - if (sz < TRANSIENT_SLAB_SIZE) { - /* First, look for a free slot */ + bool has_current = batch->transient_indices.size; + bool fits_in_current = (batch->transient_offset + sz) < TRANSIENT_SLAB_SIZE; + + if (likely(has_current && fits_in_current)) { + /* We can reuse the topmost BO, so get it */ + unsigned idx = util_dynarray_top(&batch->transient_indices, unsigned); + bo = pan_bo_for_index(screen, idx); + + /* Use the specified offset */ + offset = batch->transient_offset; + update_offset = true; + } else if (sz < TRANSIENT_SLAB_SIZE) { + /* We can't reuse the topmost BO, but we can get a new one. + * First, look for a free slot */ + unsigned count = util_dynarray_num_elements(&screen->transient_bo, void *); unsigned index = 0; @@ -134,9 +147,8 @@ panfrost_allocate_transient(struct panfrost_context *ctx, size_t sz) .gpu = bo->gpu + offset, }; - if (update_offset) { - /* TODO: Update the offset */ - } + if (update_offset) + batch->transient_offset = offset + sz; return ret; diff --git a/src/gallium/drivers/panfrost/pan_job.c b/src/gallium/drivers/panfrost/pan_job.c index 0faefe2157a..6339b39d29a 100644 --- a/src/gallium/drivers/panfrost/pan_job.c +++ b/src/gallium/drivers/panfrost/pan_job.c @@ -42,6 +42,7 @@ panfrost_create_job(struct panfrost_context *ctx) job->minx = job->miny = ~0; job->maxx = job->maxy = 0; + job->transient_offset = 0; util_dynarray_init(&job->headers, job); util_dynarray_init(&job->gpu_headers, job); diff --git a/src/gallium/drivers/panfrost/pan_job.h b/src/gallium/drivers/panfrost/pan_job.h index 9dce1e69415..c6ae2a4eb9f 100644 --- a/src/gallium/drivers/panfrost/pan_job.h +++ b/src/gallium/drivers/panfrost/pan_job.h @@ -109,6 +109,9 @@ struct panfrost_job { /* Indices of transient BOs referenced */ struct util_dynarray transient_indices; + + /* Within the topmost transient BO, how much has been used? */ + unsigned transient_offset; }; /* Functions for managing the above */ |