panfrost: Honour cso->req_local_mem
authorAlyssa Rosenzweig <alyssa@collabora.com>
Mon, 27 Jun 2022 14:19:47 +0000 (10:19 -0400)
committerMarge Bot <emma+marge@anholt.net>
Tue, 13 Sep 2022 15:36:08 +0000 (15:36 +0000)
Fixes api.min_max_local_mem_size.

nir->info.shared_size can't be trusted in OpenCL.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18559>

src/gallium/drivers/panfrost/pan_assemble.c
src/gallium/drivers/panfrost/pan_compute.c
src/gallium/drivers/panfrost/pan_context.c
src/gallium/drivers/panfrost/pan_context.h

index f855a5f..20707ff 100644 (file)
@@ -41,7 +41,8 @@ panfrost_shader_compile(struct pipe_screen *pscreen,
                         struct panfrost_pool *desc_pool,
                         const nir_shader *ir,
                         struct util_debug_callback *dbg,
-                        struct panfrost_shader_state *state)
+                        struct panfrost_shader_state *state,
+                        unsigned req_local_mem)
 {
         struct panfrost_screen *screen = pan_screen(pscreen);
         struct panfrost_device *dev = pan_device(pscreen);
@@ -55,7 +56,7 @@ panfrost_shader_compile(struct pipe_screen *pscreen,
                 xfb->info.internal = true;
 
                 state->xfb = calloc(1, sizeof(struct panfrost_shader_state));
-                panfrost_shader_compile(pscreen, shader_pool, desc_pool, xfb, dbg, state->xfb);
+                panfrost_shader_compile(pscreen, shader_pool, desc_pool, xfb, dbg, state->xfb, 0);
 
                 /* Main shader no longer uses XFB */
                 s->info.has_transform_feedback_varyings = false;
@@ -98,6 +99,9 @@ panfrost_shader_compile(struct pipe_screen *pscreen,
         util_dynarray_init(&binary, NULL);
         screen->vtbl.compile_shader(s, &inputs, &binary, &state->info);
 
+        assert(req_local_mem >= state->info.wls_size);
+        state->info.wls_size = req_local_mem;
+
         if (binary.size) {
                 state->bin = panfrost_pool_take_ref(shader_pool,
                         pan_pool_upload_aligned(&shader_pool->base,
index 2e74c3b..197e9b1 100644 (file)
@@ -72,7 +72,7 @@ panfrost_create_compute_state(
 
         panfrost_shader_compile(pctx->screen, &ctx->shaders, &ctx->descs,
                                 deserialized ?: cso->prog,
-                                &ctx->base.debug, v);
+                                &ctx->base.debug, v, cso->req_local_mem);
 
         /* There are no variants so we won't need the NIR again */
         ralloc_free(deserialized);
index 1ad8d16..4976030 100644 (file)
@@ -345,7 +345,7 @@ panfrost_create_shader_state(
 
                 panfrost_shader_compile(pctx->screen,
                                         &ctx->shaders, &ctx->descs,
-                                        so->nir, &ctx->base.debug, &state);
+                                        so->nir, &ctx->base.debug, &state, 0);
         }
 
         return so;
@@ -517,7 +517,7 @@ panfrost_new_variant_locked(
         /* We finally have a variant, so compile it */
         panfrost_shader_compile(ctx->base.screen,
                                 &ctx->shaders, &ctx->descs,
-                                variants->nir, &ctx->base.debug, shader_state);
+                                variants->nir, &ctx->base.debug, shader_state, 0);
 
         /* Fixup the stream out information */
         shader_state->stream_output = variants->stream_output;
index 5fc10ca..76979a6 100644 (file)
@@ -405,7 +405,8 @@ panfrost_shader_compile(struct pipe_screen *pscreen,
                         struct panfrost_pool *desc_pool,
                         const nir_shader *ir,
                         struct util_debug_callback *dbg,
-                        struct panfrost_shader_state *state);
+                        struct panfrost_shader_state *state,
+                        unsigned req_local_mem);
 
 void
 panfrost_analyze_sysvals(struct panfrost_shader_state *ss);