panfrost: Pass size to panfrost_batch_get_scratchpad
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Mon, 9 Dec 2019 16:02:15 +0000 (11:02 -0500)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Fri, 13 Dec 2019 15:26:35 +0000 (10:26 -0500)
We'll compute the size with the new scratchpad helpers.

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

index a36edae2a2679fc5df2da8590d31542756776eb6..dbab1df1b834b88ec8c3e4a29e5447196dbf0ee7 100644 (file)
@@ -636,19 +636,21 @@ panfrost_batch_get_polygon_list(struct panfrost_batch *batch, unsigned size)
 }
 
 struct panfrost_bo *
-panfrost_batch_get_scratchpad(struct panfrost_batch *batch)
+panfrost_batch_get_scratchpad(struct panfrost_batch *batch,
+                unsigned shift,
+                unsigned thread_tls_alloc,
+                unsigned core_count)
 {
-        if (batch->scratchpad)
-                return batch->scratchpad;
-
-        batch->scratchpad = panfrost_batch_create_bo(batch, 64 * 4 * 4096,
-                                                     PAN_BO_INVISIBLE,
-                                                     PAN_BO_ACCESS_PRIVATE |
-                                                     PAN_BO_ACCESS_RW |
-                                                     PAN_BO_ACCESS_VERTEX_TILER |
-                                                     PAN_BO_ACCESS_FRAGMENT);
-        assert(batch->scratchpad);
-        return batch->scratchpad;
+        unsigned size = panfrost_get_total_stack_size(shift,
+                        thread_tls_alloc,
+                        core_count);
+
+        return 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);
 }
 
 struct panfrost_bo *
index aa4966f0633a9a67e0cf392624b13c9e41d43132..ab2db010ef951ae71b77332b8b6060c6bb098954 100644 (file)
@@ -202,12 +202,12 @@ panfrost_flush_batches_accessing_bo(struct panfrost_context *ctx,
 void
 panfrost_batch_set_requirements(struct panfrost_batch *batch);
 
+struct panfrost_bo *
+panfrost_batch_get_scratchpad(struct panfrost_batch *batch, unsigned shift, unsigned thread_tls_alloc, unsigned core_count);
+
 mali_ptr
 panfrost_batch_get_polygon_list(struct panfrost_batch *batch, unsigned size);
 
-struct panfrost_bo *
-panfrost_batch_get_scratchpad(struct panfrost_batch *batch);
-
 struct panfrost_bo *
 panfrost_batch_get_tiler_heap(struct panfrost_batch *batch);
 
index 211ef7e4944b6e222e1e09ef05517551e9af8a12..0f2931a58b3adece33965d00db0f18a12b4e4f2d 100644 (file)
@@ -354,9 +354,15 @@ panfrost_mfbd_upload(struct panfrost_batch *batch,
 static struct bifrost_framebuffer
 panfrost_emit_mfbd(struct panfrost_batch *batch, unsigned vertex_count)
 {
+        struct panfrost_context *ctx = batch->ctx;
+        struct pipe_context *gallium = (struct pipe_context *) ctx;
+        struct panfrost_screen *screen = pan_screen(gallium->screen);
+
         unsigned width = batch->key.width;
         unsigned height = batch->key.height;
 
+        unsigned shift = panfrost_get_stack_shift(batch->stack_size);
+
         struct bifrost_framebuffer framebuffer = {
                 .width1 = MALI_POSITIVE(width),
                 .height1 = MALI_POSITIVE(height),
@@ -371,9 +377,9 @@ panfrost_emit_mfbd(struct panfrost_batch *batch, unsigned vertex_count)
                 .unknown2 = 0x1f,
                 .tiler = panfrost_emit_midg_tiler(batch, vertex_count),
                 
-                .stack_shift = 0x5,
+                .stack_shift = shift,
                 .unk0 = 0x1e,
-                .scratchpad = panfrost_batch_get_scratchpad(batch)->gpu
+                .scratchpad = panfrost_batch_get_scratchpad(batch, shift, screen->thread_tls_alloc, screen->core_count)->gpu
         };
 
         return framebuffer;
index ccf23253b51de89c9f6dff16a4d7798d7d7b0f5a..eb0f24b0a8adb0dfafcd10a6096e3a33453c12ff 100644 (file)
@@ -198,9 +198,18 @@ panfrost_sfbd_set_zsbuf(
 static struct mali_single_framebuffer
 panfrost_emit_sfbd(struct panfrost_batch *batch, unsigned vertex_count)
 {
+        struct panfrost_context *ctx = batch->ctx;
+        struct pipe_context *gallium = (struct pipe_context *) ctx;
+        struct panfrost_screen *screen = pan_screen(gallium->screen);
+
         unsigned width = batch->key.width;
         unsigned height = batch->key.height;
 
+        /* TODO: Why do we need to make the stack bigger than other platforms? */
+        unsigned shift = panfrost_get_stack_shift(MAX2(batch->stack_size, 512));
+
+        /* TODO: where do we specify the shift? */
+
         struct mali_single_framebuffer framebuffer = {
                 .width = MALI_POSITIVE(width),
                 .height = MALI_POSITIVE(height),
@@ -209,7 +218,7 @@ panfrost_emit_sfbd(struct panfrost_batch *batch, unsigned vertex_count)
                         .unk3 = 0x3,
                 },
                 .clear_flags = 0x1000,
-                .scratchpad = panfrost_batch_get_scratchpad(batch)->gpu,
+                .scratchpad = panfrost_batch_get_scratchpad(batch, shift, screen->thread_tls_alloc, screen->core_count)->gpu,
                 .tiler = panfrost_emit_midg_tiler(batch, vertex_count),
         };