From 08746d7b527eef7b291e5374f23276a6443f870b Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Fri, 5 Aug 2022 17:29:36 -0400 Subject: [PATCH] panfrost: Don't saturate in Bifrost blend shaders It's unnecessary since the hardware already does the conversion for us. Signed-off-by: Alyssa Rosenzweig Reviewed-by: Boris Brezillon Part-of: --- src/panfrost/lib/pan_blend.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/panfrost/lib/pan_blend.c b/src/panfrost/lib/pan_blend.c index 0ffcd0162db..07717b44cc2 100644 --- a/src/panfrost/lib/pan_blend.c +++ b/src/panfrost/lib/pan_blend.c @@ -681,13 +681,18 @@ GENX(pan_blend_create_shader)(const struct panfrost_device *dev, nir_ssa_def *s_src[] = {nir_load_var(&b, c_src), nir_load_var(&b, c_src1)}; - /* Saturate integer conversions */ + /* On Midgard, the blend shader is responsible for format conversion. + * As the OpenGL spec requires integer conversions to saturate, we must + * saturate ourselves here. On Bifrost and later, the conversion + * hardware handles this automatically. + */ for (int i = 0; i < ARRAY_SIZE(s_src); ++i) { nir_alu_type T = nir_alu_type_get_base_type(nir_type); + bool should_saturate = (PAN_ARCH <= 5) && (T != nir_type_float); s_src[i] = nir_convert_with_rounding(&b, s_src[i], src_types[i], nir_type, nir_rounding_mode_undef, - T != nir_type_float); + should_saturate); } /* Build a trivial blend shader */