panfrost: Bookkeep transient indices
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Fri, 12 Jul 2019 19:53:36 +0000 (12:53 -0700)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Fri, 12 Jul 2019 22:31:48 +0000 (15:31 -0700)
The batch now temporarily possesses the transient buffer, so it'll need
to remember that to free it later.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
src/gallium/drivers/panfrost/pan_allocate.c
src/gallium/drivers/panfrost/pan_job.c
src/gallium/drivers/panfrost/pan_job.h

index 15c5f8aa671820a82c956d47b28ab555dc7a64ff..4febb001033a2c397546175c416573d9b389c967 100644 (file)
@@ -59,7 +59,7 @@ panfrost_allocate_chunk(struct panfrost_context *ctx, size_t size, unsigned heap
 /* Allocate a new transient slab */
 
 static struct panfrost_bo *
-panfrost_create_slab(struct panfrost_screen *screen)
+panfrost_create_slab(struct panfrost_screen *screen, unsigned *index)
 {
         /* Allocate a new slab on the screen */
 
@@ -70,6 +70,10 @@ panfrost_create_slab(struct panfrost_screen *screen)
         struct panfrost_bo *alloc = panfrost_drm_create_bo(screen, TRANSIENT_SLAB_SIZE, 0);
 
         *new = alloc;
+
+        /* Return the BO as well as the index we just added */
+
+        *index = util_dynarray_num_elements(&screen->transient_bo, void *) - 1;
         return alloc;
 }
 
@@ -81,6 +85,7 @@ struct panfrost_transfer
 panfrost_allocate_transient(struct panfrost_context *ctx, size_t sz)
 {
         struct panfrost_screen *screen = pan_screen(ctx->base.screen);
+        struct panfrost_job *batch = panfrost_get_job_for_fbo(ctx);
 
         /* Pad the size */
         sz = ALIGN_POT(sz, ALIGNMENT);
@@ -94,8 +99,13 @@ panfrost_allocate_transient(struct panfrost_context *ctx, size_t sz)
         if (sz < TRANSIENT_SLAB_SIZE) {
                 /* TODO: Lookup free */
 
+                unsigned index = 0;
+
                 if (!bo)
-                        bo = panfrost_create_slab(screen);
+                        bo = panfrost_create_slab(screen, &index);
+
+                /* Remember we created this */
+                util_dynarray_append(&batch->transient_indices, unsigned, index);
 
                 update_offset = true;
         } else {
index ea3747bbad5b55b8f82abe200a571de3fc7d0bee..a802030769fff22fd5f8f98c847663cb7c5d29e5 100644 (file)
@@ -45,6 +45,7 @@ panfrost_create_job(struct panfrost_context *ctx)
 
         util_dynarray_init(&job->headers, job);
         util_dynarray_init(&job->gpu_headers, job);
+        util_dynarray_init(&job->transient_indices, job);
 
         return job;
 }
index 5e62c818f7107cf4ab92471e3eff9bb1398b0a77..9dce1e69415ebebf76622e435c928831f8c1fed9 100644 (file)
@@ -106,6 +106,9 @@ struct panfrost_job {
 
         /* BOs referenced -- will be used for flushing logic */
         struct set *bos;
+
+        /* Indices of transient BOs referenced */
+        struct util_dynarray transient_indices;
 };
 
 /* Functions for managing the above */