broadcom/compiler: always clamp results from logic ops
authorIago Toral Quiroga <itoral@igalia.com>
Mon, 31 Jul 2023 08:26:55 +0000 (10:26 +0200)
committerMarge Bot <emma+marge@anholt.net>
Thu, 3 Aug 2023 06:32:41 +0000 (06:32 +0000)
We have also been clamping our integer RTs in GL for a while now.

Reviewed-by: Alejandro PiƱeiro <apinheiro@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24396>

src/broadcom/compiler/v3d_nir_lower_logic_ops.c

index f2b9341..932d94d 100644 (file)
@@ -236,19 +236,17 @@ v3d_emit_logic_op_raw(struct v3d_compile *c, nir_builder *b,
                         v3d_nir_get_swizzled_channel(b, dst_chans, fmt_swz[i]);
                 op_res[i] = v3d_logicop(b, c->fs_key->logicop_func, src, dst);
 
-                /* In Vulkan we configure our integer RTs to clamp, so we need
-                 * to ignore result bits that don't fit in the destination RT
-                 * component size.
+                /* We configure our integer RTs to clamp, so we need to ignore
+                 * result bits that don't fit in the destination RT component
+                 * size.
                  */
-                if (c->key->environment == V3D_ENVIRONMENT_VULKAN) {
-                        uint32_t bits =
-                                util_format_get_component_bits(
-                                        c->fs_key->color_fmt[rt].format,
-                                        UTIL_FORMAT_COLORSPACE_RGB, i);
-                        if (bits > 0 && bits < 32) {
-                                op_res[i] = nir_iand_imm(b, op_res[i],
-                                                         (1u << bits) - 1);
-                        }
+                uint32_t bits =
+                        util_format_get_component_bits(
+                                c->fs_key->color_fmt[rt].format,
+                                UTIL_FORMAT_COLORSPACE_RGB, i);
+                if (bits > 0 && bits < 32) {
+                        op_res[i] =
+                                nir_iand_imm(b, op_res[i], (1u << bits) - 1);
                 }
         }