From 28ac4d1e00553b38691966b4b9b95fee826c97d4 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Wed, 21 Apr 2021 14:13:04 -0400 Subject: [PATCH] panfrost: Call nir_lower_fragcolor based on key We only want it to trigger if MRT is actually in use. This is a cheap key (only require multiple variants for an obscure edge case) and avoids the perf regression of using this pass which is needed for conformance. Signed-off-by: Alyssa Rosenzweig Cc: mesa-stable Part-of: --- src/gallium/drivers/panfrost/pan_assemble.c | 4 ++++ src/gallium/drivers/panfrost/pan_context.c | 6 ++++++ src/gallium/drivers/panfrost/pan_context.h | 2 ++ src/panfrost/util/pan_ir.h | 1 + 4 files changed, 13 insertions(+) diff --git a/src/gallium/drivers/panfrost/pan_assemble.c b/src/gallium/drivers/panfrost/pan_assemble.c index 302d1be..ce1932b 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 b770ed3..beb8ed3 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 8194d6d..34f83f6 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 b09cb75..7b6f4fd 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 { -- 2.7.4