Mesa (master): gallium: Add util_blend_factor_uses_dest helper

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Aug 24 11:56:35 UTC 2020


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

Author: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Date:   Tue Aug 18 17:28:38 2020 -0400

gallium: Add util_blend_factor_uses_dest helper

Drivers may be able to optimize cases where blending is enabled but the
destination colour is not used. This helps detect that case.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Reviewed-by: Eric Anholt <eric at anholt.net>
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6407>

---

 src/gallium/auxiliary/util/u_blend.h | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/src/gallium/auxiliary/util/u_blend.h b/src/gallium/auxiliary/util/u_blend.h
index d5f9050bc32..7fca2fab6d1 100644
--- a/src/gallium/auxiliary/util/u_blend.h
+++ b/src/gallium/auxiliary/util/u_blend.h
@@ -114,4 +114,22 @@ util_blend_factor_is_inverted(enum pipe_blendfactor factor)
    }
 }
 
+/* To determine if the destination needs to be read while blending */
+
+static inline bool
+util_blend_factor_uses_dest(enum pipe_blendfactor factor, bool alpha)
+{
+   switch (factor) {
+      case PIPE_BLENDFACTOR_DST_ALPHA:
+      case PIPE_BLENDFACTOR_DST_COLOR:
+      case PIPE_BLENDFACTOR_INV_DST_ALPHA:
+      case PIPE_BLENDFACTOR_INV_DST_COLOR:
+         return true;
+      case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE:
+         return !alpha;
+      default:
+         return false;
+   }
+}
+
 #endif /* U_BLEND_H */



More information about the mesa-commit mailing list