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.c22
1 files changed, 17 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;