panfrost: Allocate tiler and scratchpad BOs per-batch

If we want to execute several batches in parallel they need to have
their own tiler and scratchpad BOs. Let move those objects to
panfrost_batch and allocate them on a per-batch basis.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
diff --git a/src/gallium/drivers/panfrost/pan_job.c b/src/gallium/drivers/panfrost/pan_job.c
index 5b9a513..69047ca 100644
--- a/src/gallium/drivers/panfrost/pan_job.c
+++ b/src/gallium/drivers/panfrost/pan_job.c
@@ -195,6 +195,43 @@
         return batch->polygon_list->gpu;
 }
 
+struct panfrost_bo *
+panfrost_batch_get_scratchpad(struct panfrost_batch *batch)
+{
+        if (batch->scratchpad)
+                return batch->scratchpad;
+
+        batch->scratchpad = panfrost_batch_create_bo(batch, 64 * 4 * 4096,
+                                                     PAN_BO_INVISIBLE);
+        assert(batch->scratchpad);
+        return batch->scratchpad;
+}
+
+struct panfrost_bo *
+panfrost_batch_get_tiler_heap(struct panfrost_batch *batch)
+{
+        if (batch->tiler_heap)
+                return batch->tiler_heap;
+
+        batch->tiler_heap = panfrost_batch_create_bo(batch, 4096 * 4096,
+                                                     PAN_BO_INVISIBLE |
+                                                     PAN_BO_GROWABLE);
+        assert(batch->tiler_heap);
+        return batch->tiler_heap;
+}
+
+struct panfrost_bo *
+panfrost_batch_get_tiler_dummy(struct panfrost_batch *batch)
+{
+        if (batch->tiler_dummy)
+                return batch->tiler_dummy;
+
+        batch->tiler_dummy = panfrost_batch_create_bo(batch, 4096,
+                                                      PAN_BO_INVISIBLE);
+        assert(batch->tiler_dummy);
+        return batch->tiler_dummy;
+}
+
 static void
 panfrost_batch_draw_wallpaper(struct panfrost_batch *batch)
 {
@@ -345,13 +382,9 @@
 static int
 panfrost_batch_submit_jobs(struct panfrost_batch *batch)
 {
-        struct panfrost_context *ctx = batch->ctx;
         bool has_draws = batch->first_job.gpu;
         int ret = 0;
 
-        panfrost_batch_add_bo(batch, ctx->scratchpad);
-        panfrost_batch_add_bo(batch, ctx->tiler_heap);
-
         if (has_draws) {
                 ret = panfrost_batch_submit_ioctl(batch, batch->first_job.gpu, 0);
                 assert(!ret);