diff --git a/src/gallium/drivers/panfrost/pan_assemble.c b/src/gallium/drivers/panfrost/pan_assemble.c index 302d1be4b1d..ce1932b1f3f 100644 --- a/src/gallium/drivers/panfrost/pan_assemble.c +++ b/src/gallium/drivers/panfrost/pan_assemble.c @@ -76,6 +76,10 @@ panfrost_shader_compile(struct panfrost_context *ctx, s = tgsi_to_nir(ir, ctx->base.screen, false); } + /* Lower this early so the backends don't have to worry about it */ + if (stage == MESA_SHADER_FRAGMENT) + NIR_PASS_V(s, nir_lower_fragcolor, state->nr_cbufs); + s->info.stage = stage; /* Call out to Midgard compiler given the above NIR */ diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c index b770ed38644..beb8ed3228e 100644 --- a/src/gallium/drivers/panfrost/pan_context.c +++ b/src/gallium/drivers/panfrost/pan_context.c @@ -959,6 +959,10 @@ panfrost_variant_matches( } } + if (variant->info.stage == MESA_SHADER_FRAGMENT && + variant->nr_cbufs != ctx->pipe_framebuffer.nr_cbufs) + return false; + /* Otherwise, we're good to go */ return true; } @@ -1054,6 +1058,8 @@ panfrost_bind_shader_state( if (type == PIPE_SHADER_FRAGMENT) { struct pipe_framebuffer_state *fb = &ctx->pipe_framebuffer; + v->nr_cbufs = fb->nr_cbufs; + for (unsigned i = 0; i < fb->nr_cbufs; ++i) { enum pipe_format fmt = PIPE_FORMAT_R8G8B8A8_UNORM; diff --git a/src/gallium/drivers/panfrost/pan_context.h b/src/gallium/drivers/panfrost/pan_context.h index 8194d6d25f3..34f83f69107 100644 --- a/src/gallium/drivers/panfrost/pan_context.h +++ b/src/gallium/drivers/panfrost/pan_context.h @@ -216,7 +216,9 @@ struct panfrost_shader_state { /* GPU-executable memory */ struct panfrost_bo *bo; + /* Variants */ enum pipe_format rt_formats[8]; + unsigned nr_cbufs; }; /* A collection of varyings (the CSO) */ diff --git a/src/panfrost/util/pan_ir.h b/src/panfrost/util/pan_ir.h index b09cb757a01..7b6f4fdfe3a 100644 --- a/src/panfrost/util/pan_ir.h +++ b/src/panfrost/util/pan_ir.h @@ -130,6 +130,7 @@ struct panfrost_compile_inputs { bool no_ubo_to_push; enum pipe_format rt_formats[8]; + unsigned nr_cbufs; }; struct pan_shader_varying {