panfrost: Don't double-create scratchpad
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Fri, 13 Dec 2019 19:12:48 +0000 (14:12 -0500)
committerMarge Bot <eric+marge@anholt.net>
Mon, 16 Dec 2019 23:32:07 +0000 (23:32 +0000)
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Fixes: 4f7fddbd716 ("panfrost: Pass size to panfrost_batch_get_scratchpad")
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3119>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3119>

src/gallium/drivers/panfrost/pan_job.c

index 5722f4a..b193ce6 100644 (file)
@@ -646,12 +646,18 @@ panfrost_batch_get_scratchpad(struct panfrost_batch *batch,
                         thread_tls_alloc,
                         core_count);
 
-        return panfrost_batch_create_bo(batch, size,
+        if (batch->scratchpad) {
+                assert(batch->scratchpad->size >= size);
+        } else {
+                batch->scratchpad = panfrost_batch_create_bo(batch, size,
                                              PAN_BO_INVISIBLE,
                                              PAN_BO_ACCESS_PRIVATE |
                                              PAN_BO_ACCESS_RW |
                                              PAN_BO_ACCESS_VERTEX_TILER |
                                              PAN_BO_ACCESS_FRAGMENT);
+        }
+
+        return batch->scratchpad;
 }
 
 struct panfrost_bo *