From ef75dbfddd0bd819e44ef03b043716678ebb9c8f Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Mon, 27 Jun 2022 10:19:47 -0400 Subject: [PATCH] panfrost: Honour cso->req_local_mem Fixes api.min_max_local_mem_size. nir->info.shared_size can't be trusted in OpenCL. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/gallium/drivers/panfrost/pan_assemble.c | 8 ++++++-- src/gallium/drivers/panfrost/pan_compute.c | 2 +- src/gallium/drivers/panfrost/pan_context.c | 4 ++-- src/gallium/drivers/panfrost/pan_context.h | 3 ++- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/gallium/drivers/panfrost/pan_assemble.c b/src/gallium/drivers/panfrost/pan_assemble.c index f855a5f..20707ff 100644 --- a/src/gallium/drivers/panfrost/pan_assemble.c +++ b/src/gallium/drivers/panfrost/pan_assemble.c @@ -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, diff --git a/src/gallium/drivers/panfrost/pan_compute.c b/src/gallium/drivers/panfrost/pan_compute.c index 2e74c3b..197e9b1 100644 --- a/src/gallium/drivers/panfrost/pan_compute.c +++ b/src/gallium/drivers/panfrost/pan_compute.c @@ -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); diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c index 1ad8d16..4976030 100644 --- a/src/gallium/drivers/panfrost/pan_context.c +++ b/src/gallium/drivers/panfrost/pan_context.c @@ -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; diff --git a/src/gallium/drivers/panfrost/pan_context.h b/src/gallium/drivers/panfrost/pan_context.h index 5fc10ca..76979a6 100644 --- a/src/gallium/drivers/panfrost/pan_context.h +++ b/src/gallium/drivers/panfrost/pan_context.h @@ -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); -- 2.7.4