panfrost: Don't saturate in Bifrost blend shaders
authorAlyssa Rosenzweig <alyssa@collabora.com>
Fri, 5 Aug 2022 21:29:36 +0000 (17:29 -0400)
committerMarge Bot <emma+marge@anholt.net>
Sun, 21 Aug 2022 19:37:10 +0000 (19:37 +0000)
It's unnecessary since the hardware already does the conversion for us.

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/panfrost/lib/pan_blend.c

index 0ffcd01..07717b4 100644 (file)
@@ -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 */