Mesa (main): lima: fix blending with min/max ops
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Nov 29 19:45:01 UTC 2021
Module: Mesa
Branch: main
Commit: 34a75ce15ce1b264a27179081e97cb2e7248b555
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=34a75ce15ce1b264a27179081e97cb2e7248b555
Author: Vasily Khoruzhick <anarsoul at gmail.com>
Date: Tue Nov 23 18:10:19 2021 -0800
lima: fix blending with min/max ops
It turns out that BLEND_MIN and BLEND_MAX in Utgard take blend factors
into account. My guess is that actual equation looks like:
OP(As * S + Ad * D, Ad) for alpha, and
OP(Cs * S + Cd * D, Cd) for color.
So we have to set S factor to 1 and D factor to 0 to be compliant with
GL spec.
Fixes following piglit tests:
spec@!opengl 1.4 at blendminmax
spec at arb_blend_func_extended@arb_blend_func_extended-fbo-extended-blend
(with patch my for ES2_compatibility and EXT_blend_func_extended)
Reviewed-by: Andreas Baierl <ichgeh at imkreisrum.de>
Reviewed-by: Erico Nunes <nunes.erico at gmail.com>
Signed-off-by: Vasily Khoruzhick <anarsoul at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13873>
---
src/gallium/drivers/lima/lima_draw.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/src/gallium/drivers/lima/lima_draw.c b/src/gallium/drivers/lima/lima_draw.c
index 1d00fd40199..f1613a8d37a 100644
--- a/src/gallium/drivers/lima/lima_draw.c
+++ b/src/gallium/drivers/lima/lima_draw.c
@@ -517,6 +517,22 @@ lima_calculate_alpha_blend(enum pipe_blend_func rgb_func, enum pipe_blend_func a
if (alpha_dst_factor == PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE)
alpha_dst_factor = PIPE_BLENDFACTOR_ONE;
+ /* MIN and MAX ops actually do OP(As * S + Ad * D, Ad), so
+ * we need to set S to 1 and D to 0 to get correct result */
+ if (alpha_func == PIPE_BLEND_MIN ||
+ alpha_func == PIPE_BLEND_MAX) {
+ alpha_src_factor = PIPE_BLENDFACTOR_ONE;
+ alpha_dst_factor = PIPE_BLENDFACTOR_ZERO;
+ }
+
+ /* MIN and MAX ops actually do OP(Cs * S + Cd * D, Cd), so
+ * we need to set S to 1 and D to 0 to get correct result */
+ if (rgb_func == PIPE_BLEND_MIN ||
+ rgb_func == PIPE_BLEND_MAX) {
+ rgb_src_factor = PIPE_BLENDFACTOR_ONE;
+ rgb_dst_factor = PIPE_BLENDFACTOR_ZERO;
+ }
+
return lima_blend_func(rgb_func) |
(lima_blend_func(alpha_func) << 3) |
(lima_blend_factor(rgb_src_factor) << 6) |
More information about the mesa-commit
mailing list