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 <alyssa@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17841>
This commit is contained in:
Alyssa Rosenzweig 2022-08-01 18:57:46 -04:00 committed by Marge Bot
parent e59c74ec56
commit d849d9779a
2 changed files with 10 additions and 0 deletions

View file

@ -179,6 +179,14 @@ panfrost_get_blend(struct panfrost_batch *batch, unsigned rti, struct panfrost_b
return 0; 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 */ /* Otherwise, we need to grab a shader */
struct pan_blend_state pan_blend = blend->pan; struct pan_blend_state pan_blend = blend->pan;
unsigned nr_samples = surf->nr_samples ? : surf->texture->nr_samples; unsigned nr_samples = surf->nr_samples ? : surf->texture->nr_samples;

View file

@ -331,6 +331,7 @@ pan_blitter_get_blend_shaders(struct panfrost_device *dev,
const struct pan_blit_shader_data *blit_shader, const struct pan_blit_shader_data *blit_shader,
mali_ptr *blend_shaders) mali_ptr *blend_shaders)
{ {
#if PAN_ARCH <= 5
if (!rt_count) if (!rt_count)
return; return;
@ -403,6 +404,7 @@ pan_blitter_get_blend_shaders(struct panfrost_device *dev,
pthread_mutex_unlock(&dev->blitter.shaders.lock); pthread_mutex_unlock(&dev->blitter.shaders.lock);
blend_shaders[i] = blend_shader->address; blend_shaders[i] = blend_shader->address;
} }
#endif
} }
static const struct pan_blit_shader_data * static const struct pan_blit_shader_data *