Mesa (master): llvmpipe: Use saturating add/sub for UNORM formats

Adam Jackson ajax at kemper.freedesktop.org
Mon Jun 10 20:29:25 UTC 2013


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

Author: Richard Sandiford <rsandifo at linux.vnet.ibm.com>
Date:   Fri Jun  7 13:31:58 2013 +0100

llvmpipe: Use saturating add/sub for UNORM formats

lp_build_add and lp_build_sub have fallback code for cases
that cannot be handled by known intrinsics.  For UNORM formats,
this code was using modulo rather than saturating arithmetic.

This fixes some rendering issues for a gnome session on System z.
It also fixes various piglit tests on z, such as
spec/ARB_color_buffer_float/GL_RGBA8-render.

The patch deliberately doesn't tackle the more complicated
SNORM case.

Tested against piglit on x86_64 and System z with no regressions.

Reviewed-by: Adam Jackson <ajax at redhat.com>
Signed-off-by: Richard Sandiford <rsandifo at linux.vnet.ibm.com>

---

 src/gallium/auxiliary/gallivm/lp_bld_arit.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.c b/src/gallium/auxiliary/gallivm/lp_bld_arit.c
index 3291ec4..08aec79 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_arit.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.c
@@ -386,6 +386,10 @@ lp_build_add(struct lp_build_context *bld,
          return lp_build_intrinsic_binary(builder, intrinsic, lp_build_vec_type(bld->gallivm, bld->type), a, b);
    }
 
+   /* TODO: handle signed case */
+   if(type.norm && !type.floating && !type.fixed && !type.sign)
+      a = lp_build_min_simple(bld, a, lp_build_comp(bld, b));
+
    if(LLVMIsConstant(a) && LLVMIsConstant(b))
       if (type.floating)
          res = LLVMConstFAdd(a, b);
@@ -663,6 +667,10 @@ lp_build_sub(struct lp_build_context *bld,
          return lp_build_intrinsic_binary(builder, intrinsic, lp_build_vec_type(bld->gallivm, bld->type), a, b);
    }
 
+   /* TODO: handle signed case */
+   if(type.norm && !type.floating && !type.fixed && !type.sign)
+      a = lp_build_max_simple(bld, a, b);
+
    if(LLVMIsConstant(a) && LLVMIsConstant(b))
       if (type.floating)
          res = LLVMConstFSub(a, b);




More information about the mesa-commit mailing list