From d849d9779a77f05d7acd418516e154a4e9018f40 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Mon, 1 Aug 2022 18:57:46 -0400 Subject: [PATCH] panfrost: Avoid blend shader when not blending On Midgard, we need a "blend" shader even if blending is disabled, if the format isn't blendable. This is inefficient. Bifrost solves this by decoupling the format conversion from the blending, allowing opaque (unblended) output to any format without a blend shader or fragment key. Unfortunately, our blend code is from the Midgard era -- I wrote an early version of nir_lower_blend when I was still in high school! -- so we've been using blend shaders for opaque output even on Bifrost. Whoops! In SuperTuxKart, reduces blend shader calls by 30%, translating to a 15% reduction in i-cache misses. Signed-off-by: Alyssa Rosenzweig Reviewed-by: Boris Brezillon Part-of: --- src/gallium/drivers/panfrost/pan_context.c | 8 ++++++++ src/panfrost/lib/pan_blitter.c | 2 ++ 2 files changed, 10 insertions(+) diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c index 0d6255112e7..e005a0a04bc 100644 --- a/src/gallium/drivers/panfrost/pan_context.c +++ b/src/gallium/drivers/panfrost/pan_context.c @@ -179,6 +179,14 @@ panfrost_get_blend(struct panfrost_batch *batch, unsigned rti, struct panfrost_b return 0; } + /* On Bifrost and newer, we can also use fixed-function for opaque + * output regardless of the format by configuring the appropriate + * conversion descriptor in the internal blend descriptor. (Midgard + * requires a blend shader even for this case.) + */ + if (dev->arch >= 6 && info.opaque) + return 0; + /* Otherwise, we need to grab a shader */ struct pan_blend_state pan_blend = blend->pan; unsigned nr_samples = surf->nr_samples ? : surf->texture->nr_samples; diff --git a/src/panfrost/lib/pan_blitter.c b/src/panfrost/lib/pan_blitter.c index d182f62e453..5e4d2f3a883 100644 --- a/src/panfrost/lib/pan_blitter.c +++ b/src/panfrost/lib/pan_blitter.c @@ -331,6 +331,7 @@ pan_blitter_get_blend_shaders(struct panfrost_device *dev, const struct pan_blit_shader_data *blit_shader, mali_ptr *blend_shaders) { +#if PAN_ARCH <= 5 if (!rt_count) return; @@ -403,6 +404,7 @@ pan_blitter_get_blend_shaders(struct panfrost_device *dev, pthread_mutex_unlock(&dev->blitter.shaders.lock); blend_shaders[i] = blend_shader->address; } +#endif } static const struct pan_blit_shader_data *