panfrost: Avoid blend shader when not blending
authorAlyssa Rosenzweig <alyssa@collabora.com>
Mon, 1 Aug 2022 22:57:46 +0000 (18:57 -0400)
committerMarge Bot <emma+marge@anholt.net>
Sun, 21 Aug 2022 19:37:10 +0000 (19:37 +0000)
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 <alyssa@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17841>

src/gallium/drivers/panfrost/pan_context.c
src/panfrost/lib/pan_blitter.c

index 0d62551..e005a0a 100644 (file)
@@ -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;
index d182f62..5e4d2f3 100644 (file)
@@ -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 *