Mesa (main): pan/bi: Simplify bi_compose_clamp

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Aug 11 19:19:58 UTC 2021


Module: Mesa
Branch: main
Commit: c27af4ad36a30330d128d00e7164a28b15799587
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=c27af4ad36a30330d128d00e7164a28b15799587

Author: Alyssa Rosenzweig <alyssa at collabora.com>
Date:   Tue Aug  3 13:47:59 2021 -0400

pan/bi: Simplify bi_compose_clamp

Realized this trick when reversing Valhall.

Signed-off-by: Alyssa Rosenzweig <alyssa at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12205>

---

 src/panfrost/bifrost/bi_opt_mod_props.c | 17 ++---------------
 1 file changed, 2 insertions(+), 15 deletions(-)

diff --git a/src/panfrost/bifrost/bi_opt_mod_props.c b/src/panfrost/bifrost/bi_opt_mod_props.c
index 679fe45357c..76a6c951cf2 100644
--- a/src/panfrost/bifrost/bi_opt_mod_props.c
+++ b/src/panfrost/bifrost/bi_opt_mod_props.c
@@ -157,20 +157,6 @@ bi_takes_clamp(bi_instr *I)
         }
 }
 
-/* Treating clamps as functions, compute the composition f circ g. For {NONE,
- * SAT, SAT_SIGNED, CLAMP_POS}, anything left- or right-composed with NONE is
- * unchanged, anything composed with itself is unchanged, and any two
- * nontrivial distinct clamps compose to SAT (left as an exercise) */
-
-static enum bi_clamp
-bi_compose_clamp(enum bi_clamp f, enum bi_clamp g)
-{
-        return  (f == BI_CLAMP_NONE) ? g :
-                (g == BI_CLAMP_NONE) ? f :
-                (f == g)             ? f :
-                BI_CLAMP_CLAMP_0_1;
-}
-
 static bool
 bi_is_fclamp(bi_instr *I)
 {
@@ -187,7 +173,8 @@ bi_optimizer_clamp(bi_instr *I, bi_instr *use)
         if (!bi_is_fclamp(use)) return false;
         if (!bi_takes_clamp(I)) return false;
 
-        I->clamp = bi_compose_clamp(I->clamp, use->clamp);
+        /* Clamps are bitfields (clamp_m1_1/clamp_0_inf) so composition is OR */
+        I->clamp |= use->clamp;
         I->dest[0] = use->dest[0];
         return true;
 }



More information about the mesa-commit mailing list