panfrost: Don't take ctx in panfrost_shader_compile

Complicates validation of PIPE_CAP_SHAREABLE_SHADERS.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10976>
This commit is contained in:
Alyssa Rosenzweig 2021-05-24 17:29:18 -04:00 committed by Marge Bot
parent 7b4a76f493
commit 4b984c494c
4 changed files with 21 additions and 12 deletions

View file

@ -40,13 +40,15 @@
#include "tgsi/tgsi_dump.h"
void
panfrost_shader_compile(struct panfrost_context *ctx,
panfrost_shader_compile(struct pipe_screen *pscreen,
struct pan_pool *shader_pool,
struct pan_pool *desc_pool,
enum pipe_shader_ir ir_type,
const void *ir,
gl_shader_stage stage,
struct panfrost_shader_state *state)
{
struct panfrost_device *dev = pan_device(ctx->base.screen);
struct panfrost_device *dev = pan_device(pscreen);
nir_shader *s;
@ -54,7 +56,7 @@ panfrost_shader_compile(struct panfrost_context *ctx,
s = nir_shader_clone(NULL, ir);
} else {
assert (ir_type == PIPE_SHADER_IR_TGSI);
s = tgsi_to_nir(ir, ctx->base.screen, false);
s = tgsi_to_nir(ir, pscreen, false);
}
/* Lower this early so the backends don't have to worry about it */
@ -77,8 +79,8 @@ panfrost_shader_compile(struct panfrost_context *ctx,
pan_shader_compile(dev, s, &inputs, &binary, &state->info);
if (binary.size) {
state->bin = pan_take_ref(&ctx->shaders,
panfrost_pool_upload_aligned(&ctx->shaders,
state->bin = pan_take_ref(shader_pool,
panfrost_pool_upload_aligned(shader_pool,
binary.data, binary.size, 128));
}
@ -88,9 +90,9 @@ panfrost_shader_compile(struct panfrost_context *ctx,
* time finalization based on the renderer state. */
if (stage != MESA_SHADER_FRAGMENT) {
struct panfrost_ptr ptr =
panfrost_pool_alloc_desc(&ctx->descs, RENDERER_STATE);
panfrost_pool_alloc_desc(desc_pool, RENDERER_STATE);
state->state = pan_take_ref(&ctx->descs, ptr.gpu);
state->state = pan_take_ref(desc_pool, ptr.gpu);
out = ptr.cpu;
}

View file

@ -71,8 +71,9 @@ panfrost_create_compute_state(
so->cbase.ir_type = PIPE_SHADER_IR_NIR;
}
panfrost_shader_compile(ctx, so->cbase.ir_type, so->cbase.prog,
MESA_SHADER_COMPUTE, v);
panfrost_shader_compile(pctx->screen, &ctx->shaders, &ctx->descs,
so->cbase.ir_type, so->cbase.prog, MESA_SHADER_COMPUTE,
v);
return so;
}

View file

@ -953,7 +953,9 @@ panfrost_create_shader_state(
struct panfrost_shader_state state = { 0 };
panfrost_shader_compile(ctx, PIPE_SHADER_IR_NIR,
panfrost_shader_compile(pctx->screen,
&ctx->shaders, &ctx->descs,
PIPE_SHADER_IR_NIR,
so->base.ir.nir,
tgsi_processor_to_shader_stage(stage),
&state);
@ -1177,7 +1179,9 @@ panfrost_bind_shader_state(
/* We finally have a variant, so compile it */
if (!shader_state->compiled) {
panfrost_shader_compile(ctx, variants->base.type,
panfrost_shader_compile(ctx->base.screen,
&ctx->shaders, &ctx->descs,
variants->base.type,
variants->base.type == PIPE_SHADER_IR_NIR ?
variants->base.ir.nir :
variants->base.tokens,

View file

@ -380,7 +380,9 @@ bool
panfrost_render_condition_check(struct panfrost_context *ctx);
void
panfrost_shader_compile(struct panfrost_context *ctx,
panfrost_shader_compile(struct pipe_screen *pscreen,
struct pan_pool *shader_pool,
struct pan_pool *desc_pool,
enum pipe_shader_ir ir_type,
const void *ir,
gl_shader_stage stage,