Mesa (master): vc4: Clamp the inputs to the blend equation to [0, 1].

Eric Anholt anholt at kemper.freedesktop.org
Sun Jan 11 04:38:07 UTC 2015


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

Author: Eric Anholt <eric at anholt.net>
Date:   Sun Jan 11 15:30:39 2015 +1300

vc4: Clamp the inputs to the blend equation to [0, 1].

Fixes the remaining ARB_color_buffer_float rendering tests.

---

 src/gallium/drivers/vc4/vc4_program.c |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/vc4/vc4_program.c b/src/gallium/drivers/vc4/vc4_program.c
index 2b546ee..ff2bdf2 100644
--- a/src/gallium/drivers/vc4/vc4_program.c
+++ b/src/gallium/drivers/vc4/vc4_program.c
@@ -1596,6 +1596,15 @@ vc4_blend(struct vc4_compile *c, struct qreg *result,
                 return;
         }
 
+        struct qreg clamped_src[4];
+        struct qreg clamped_dst[4];
+        for (int i = 0; i < 4; i++) {
+                clamped_src[i] = qir_SAT(c, src_color[i]);
+                clamped_dst[i] = qir_SAT(c, dst_color[i]);
+        }
+        src_color = clamped_src;
+        dst_color = clamped_dst;
+
         struct qreg src_blend[4], dst_blend[4];
         for (int i = 0; i < 3; i++) {
                 src_blend[i] = vc4_blend_channel(c,
@@ -2793,7 +2802,7 @@ vc4_write_uniforms(struct vc4_context *vc4, struct vc4_compiled_shader *shader,
 
                 case QUNIFORM_BLEND_CONST_COLOR:
                         cl_aligned_f(&vc4->uniforms,
-                                     vc4->blend_color.color[uinfo->data[i]]);
+                                     CLAMP(vc4->blend_color.color[uinfo->data[i]], 0, 1));
                         break;
 
                 case QUNIFORM_STENCIL:




More information about the mesa-commit mailing list