panfrost: Reserve thread storage descriptor in panfrost_launch_grid()
authorBoris Brezillon <boris.brezillon@collabora.com>
Mon, 19 Apr 2021 07:43:48 +0000 (09:43 +0200)
committerMarge Bot <eric+marge@anholt.net>
Tue, 20 Apr 2021 11:41:11 +0000 (11:41 +0000)
If we don't do that the compute batch is left with an empty thread
storage descriptor, and panfrost_batch_submit() tries to emit an FB
descriptors using invalid FB information.

Reported-by: Italo Nicola <italonicola@collabora.com>
Fixes: ff3eada7eb4e ("panfrost: Use the generic preload and FB helpers in the gallium driver")
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa@collabora.com>
Tested-by: Italo Nicola <italonicola@collabora.com>
Reviewed-by: Italo Nicola <italonicola@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10312>

src/gallium/drivers/panfrost/pan_cmdstream.c
src/gallium/drivers/panfrost/pan_compute.c
src/gallium/drivers/panfrost/pan_context.c
src/gallium/drivers/panfrost/pan_job.c
src/gallium/drivers/panfrost/pan_job.h

index 660cf31..c16606b 100644 (file)
@@ -2267,7 +2267,7 @@ panfrost_emit_tls(struct panfrost_batch *batch)
         struct panfrost_device *dev = pan_device(batch->ctx->base.screen);
 
         /* Emitted with the FB descriptor on Midgard. */
-        if (!pan_is_bifrost(dev))
+        if (!pan_is_bifrost(dev) && batch->framebuffer.gpu)
                 return;
 
         struct panfrost_bo *tls_bo =
index b25e191..9624b7d 100644 (file)
@@ -101,6 +101,11 @@ panfrost_launch_grid(struct pipe_context *pipe,
         struct panfrost_device *dev = pan_device(pipe->screen);
         struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx);
 
+        /* Reserve a thread storage descriptor now (will be emitted at submit
+         * time).
+         */
+        panfrost_batch_reserve_tls(batch, true);
+
         /* TODO: Indirect compute dispatch */
         assert(!info->indirect);
 
index c158cb4..47f1551 100644 (file)
@@ -460,7 +460,7 @@ panfrost_direct_draw(struct panfrost_context *ctx,
 
         unsigned vertex_count = ctx->vertex_count;
 
-        mali_ptr shared_mem = panfrost_batch_reserve_tls(batch);
+        mali_ptr shared_mem = panfrost_batch_reserve_tls(batch, false);
 
         unsigned min_index = 0, max_index = 0;
         mali_ptr indices = 0;
index 0b47f87..72dffad 100644 (file)
@@ -910,7 +910,7 @@ panfrost_batch_reserve_framebuffer(struct panfrost_batch *batch)
 }
 
 mali_ptr
-panfrost_batch_reserve_tls(struct panfrost_batch *batch)
+panfrost_batch_reserve_tls(struct panfrost_batch *batch, bool compute)
 {
         struct panfrost_device *dev = pan_device(batch->ctx->base.screen);
 
@@ -919,7 +919,7 @@ panfrost_batch_reserve_tls(struct panfrost_batch *batch)
         if (batch->tls.gpu)
                 return batch->tls.gpu;
 
-        if (pan_is_bifrost(dev)) {
+        if (pan_is_bifrost(dev) || compute) {
                 batch->tls = panfrost_pool_alloc_desc(&batch->pool, LOCAL_STORAGE);
         } else {
                 /* On Midgard, the FB descriptor contains a thread storage
@@ -1122,7 +1122,7 @@ panfrost_batch_submit(struct panfrost_batch *batch,
 
         panfrost_batch_to_fb_info(batch, &fb, rts, &zs, &s, false);
 
-        panfrost_batch_reserve_tls(batch);
+        panfrost_batch_reserve_tls(batch, false);
         panfrost_batch_draw_wallpaper(batch, &fb);
 
 
index 080c7b9..ed15ed0 100644 (file)
@@ -200,6 +200,6 @@ mali_ptr
 panfrost_batch_reserve_framebuffer(struct panfrost_batch *batch);
 
 mali_ptr
-panfrost_batch_reserve_tls(struct panfrost_batch *batch);
+panfrost_batch_reserve_tls(struct panfrost_batch *batch, bool compute);
 
 #endif