From 227e2500050de49cfae838bfd99318c3731e253c Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Tue, 29 Dec 2015 15:18:05 -0800 Subject: [PATCH] nir/spirv/glsl450: Add a helper for doing fclamp(). --- src/glsl/nir/spirv/vtn_glsl450.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/glsl/nir/spirv/vtn_glsl450.c b/src/glsl/nir/spirv/vtn_glsl450.c index d4cb1bb9f3c..f4550baaf93 100644 --- a/src/glsl/nir/spirv/vtn_glsl450.c +++ b/src/glsl/nir/spirv/vtn_glsl450.c @@ -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. */ -- 2.30.2