Mesa (master): compiler: Add lowering support for 64-bit saturate operations to software

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed May 15 23:38:45 UTC 2019


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

Author: Anuj Phogat <anuj.phogat at gmail.com>
Date:   Fri May 10 13:22:31 2019 -0700

compiler: Add lowering support for 64-bit saturate operations to software

Fixes 7 Khronos GL CTS tests:
KHR-GL45.gpu_shader_fp64.builtin.smoothstep_dvec{double, 2, 3, 4}
KHR-GL45.gpu_shader_fp64.builtin.smoothstep_against_scalar_dvec{2, 3, 4}

Suggested-by: Jason Ekstrand <jason at jlekstrand.net>
Signed-off-by: Anuj Phogat <anuj.phogat at gmail.com>
Reviewed-by: Matt Turner <mattst88 at gmail.com>

---

 src/compiler/glsl/float64.glsl          | 12 ++++++++++++
 src/compiler/nir/nir_lower_double_ops.c |  3 +++
 2 files changed, 15 insertions(+)

diff --git a/src/compiler/glsl/float64.glsl b/src/compiler/glsl/float64.glsl
index 415dde3907c..babfad20e9c 100644
--- a/src/compiler/glsl/float64.glsl
+++ b/src/compiler/glsl/float64.glsl
@@ -218,6 +218,18 @@ __fge64(uint64_t a, uint64_t b)
    return !__flt64_nonnan(a, b);
 }
 
+uint64_t
+__fsat64(uint64_t __a)
+{
+   if (__flt64(__a, 0ul))
+      return 0ul;
+
+   if (__fge64(__a, 0x3FF0000000000000ul /* 1.0 */))
+      return 0x3FF0000000000000ul;
+
+   return __a;
+}
+
 /* Adds the 64-bit value formed by concatenating `a0' and `a1' to the 64-bit
  * value formed by concatenating `b0' and `b1'.  Addition is modulo 2^64, so
  * any carry out is lost.  The result is broken into two 32-bit pieces which
diff --git a/src/compiler/nir/nir_lower_double_ops.c b/src/compiler/nir/nir_lower_double_ops.c
index 18fe08c7d5d..04ec2a82801 100644
--- a/src/compiler/nir/nir_lower_double_ops.c
+++ b/src/compiler/nir/nir_lower_double_ops.c
@@ -550,6 +550,9 @@ lower_doubles_instr_to_soft(nir_builder *b, nir_alu_instr *instr,
    case nir_op_ffma:
       name = "__ffma64";
       break;
+   case nir_op_fsat:
+      name = "__fsat64";
+      break;
    default:
       return false;
    }




More information about the mesa-commit mailing list