nir/spirv/glsl450: Add a helper for doing fclamp().
authorKenneth Graunke <kenneth@whitecape.org>
Tue, 29 Dec 2015 23:18:05 +0000 (15:18 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Tue, 29 Dec 2015 23:27:03 +0000 (15:27 -0800)
src/glsl/nir/spirv/vtn_glsl450.c

index d4cb1bb9f3c218272f969ada6dabe1777f129f08..f4550baaf93f49f33c7896f32c16c17285a8f466 100644 (file)
@@ -41,6 +41,13 @@ build_length(nir_builder *b, nir_ssa_def *vec)
    }
 }
 
+static inline nir_ssa_def *
+build_fclamp(nir_builder *b,
+             nir_ssa_def *x, nir_ssa_def *min_val, nir_ssa_def *max_val)
+{
+   return nir_fmin(b, nir_fmax(b, x, min_val), max_val);
+}
+
 /**
  * Return e^x.
  */