summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2015-12-28 23:52:10 -0800
committerKenneth Graunke <[email protected]>2015-12-29 15:27:03 -0800
commitb10af36d93c44537bf0858d0508020058e375d34 (patch)
tree2c18e39a3e80644838e8c00b4306984601893d83 /src
parent6a0fa2d758bc67041f2b66c3b7520a0ca041817e (diff)
nir/spirv/glsl450: Implement SmoothStep.
Diffstat (limited to 'src')
-rw-r--r--src/glsl/nir/spirv/vtn_glsl450.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/glsl/nir/spirv/vtn_glsl450.c b/src/glsl/nir/spirv/vtn_glsl450.c
index cec7592a5e8..1b7751a6a88 100644
--- a/src/glsl/nir/spirv/vtn_glsl450.c
+++ b/src/glsl/nir/spirv/vtn_glsl450.c
@@ -176,6 +176,20 @@ handle_glsl450_alu(struct vtn_builder *b, enum GLSLstd450 entrypoint,
return;
}
+ case GLSLstd450SmoothStep: {
+ /* t = clamp((x - edge0) / (edge1 - edge0), 0, 1) */
+ nir_ssa_def *t =
+ build_fclamp(nb, nir_fdiv(nb, nir_fsub(nb, src[2], src[0]),
+ nir_fsub(nb, src[1], src[0])),
+ nir_imm_float(nb, 0.0), nir_imm_float(nb, 1.0));
+ /* result = t * t * (3 - 2 * t) */
+ val->ssa->def =
+ nir_fmul(nb, t, nir_fmul(nb, t,
+ nir_fsub(nb, nir_imm_float(nb, 3.0),
+ nir_fmul(nb, nir_imm_float(nb, 2.0), t))));
+ return;
+ }
+
case GLSLstd450Asin:
case GLSLstd450Acos:
case GLSLstd450Atan:
@@ -186,7 +200,6 @@ handle_glsl450_alu(struct vtn_builder *b, enum GLSLstd450 entrypoint,
case GLSLstd450Asinh:
case GLSLstd450Acosh:
case GLSLstd450Atanh:
- case GLSLstd450SmoothStep:
case GLSLstd450Frexp:
case GLSLstd450PackDouble2x32:
case GLSLstd450UnpackDouble2x32: