Implement version of step() that takes a scalar edge and a vector for the other argument.

Tests to be done in another CL.

Bug: 12112379

Change-Id: I28a865a9a8f272e9ac4808dacd1ad35a16731a0b
diff --git a/api/runtime.spec b/api/runtime.spec
index 279d67f..e005a1e 100644
--- a/api/runtime.spec
+++ b/api/runtime.spec
@@ -1213,6 +1213,21 @@
 end:
 
 start:
+w: 2, 3, 4
+t: f32
+name: step
+ret: #2#1
+arg: #2 edge
+arg: #2#1 v
+comment:
+ if (v < edge)
+     return 0.f;
+ else
+     return 1.f;
+version: 20
+end:
+
+start:
 w: 1, 2, 3, 4
 t: f32
 name: sign
diff --git a/driver/runtime/rs_cl.c b/driver/runtime/rs_cl.c
old mode 100755
new mode 100644
index 8da343c..83327bc
--- a/driver/runtime/rs_cl.c
+++ b/driver/runtime/rs_cl.c
@@ -867,6 +867,27 @@
     r.w = (v < edge.w) ? 0.f : 1.f;
     return r;
 }
+extern float2 __attribute__((overloadable)) step(float edge, float2 v) {
+    float2 r;
+    r.x = (v.x < edge) ? 0.f : 1.f;
+    r.y = (v.y < edge) ? 0.f : 1.f;
+    return r;
+}
+extern float3 __attribute__((overloadable)) step(float edge, float3 v) {
+    float3 r;
+    r.x = (v.x < edge) ? 0.f : 1.f;
+    r.y = (v.y < edge) ? 0.f : 1.f;
+    r.z = (v.z < edge) ? 0.f : 1.f;
+    return r;
+}
+extern float4 __attribute__((overloadable)) step(float edge, float4 v) {
+    float4 r;
+    r.x = (v.x < edge) ? 0.f : 1.f;
+    r.y = (v.y < edge) ? 0.f : 1.f;
+    r.z = (v.z < edge) ? 0.f : 1.f;
+    r.w = (v.w < edge) ? 0.f : 1.f;
+    return r;
+}
 
 extern float __attribute__((overloadable)) smoothstep(float, float, float);
 extern float2 __attribute__((overloadable)) smoothstep(float2, float2, float2);
diff --git a/java/tests/RsTest/src/com/android/rs/test/math.rs b/java/tests/RsTest/src/com/android/rs/test/math.rs
index edde9d8..2c0521b 100644
--- a/java/tests/RsTest/src/com/android/rs/test/math.rs
+++ b/java/tests/RsTest/src/com/android/rs/test/math.rs
@@ -172,6 +172,13 @@
     f3 = fnc(f3, f1);               \
     f4 = fnc(f4, f1);
 
+#define TEST_FN_FUNC_F_FN(fnc)      \
+    rsDebug("Testing " #fnc, 0);    \
+    f1 = fnc(f1, f1);               \
+    f2 = fnc(f1, f2);               \
+    f3 = fnc(f1, f3);               \
+    f4 = fnc(f1, f4);
+
 #define TEST_F_FUNC_FN(fnc)         \
     rsDebug("Testing " #fnc, 0);    \
     f1 = fnc(f1);                   \
@@ -321,6 +328,7 @@
     TEST_FN_FUNC_FN(sqrt);
     TEST_FN_FUNC_FN_FN(step);
     TEST_FN_FUNC_FN_F(step);
+    TEST_FN_FUNC_F_FN(step);
     TEST_FN_FUNC_FN(tan);
     TEST_FN_FUNC_FN(tanh);
     TEST_FN_FUNC_FN(tanpi);
diff --git a/scriptc/rs_core_math.rsh b/scriptc/rs_core_math.rsh
index 3984c6d..848740d 100644
--- a/scriptc/rs_core_math.rsh
+++ b/scriptc/rs_core_math.rsh
@@ -8129,6 +8129,42 @@
 extern float4 __attribute__((const, overloadable))step(float4 edge, float v);
 #endif
 
+#if (defined(RS_VERSION) && (RS_VERSION >= 20))
+/*
+ * if (v < edge)
+ * return 0.f;
+ * else
+ * return 1.f;
+ *
+ * Supported by API versions 20 and newer.
+ */
+extern float2 __attribute__((const, overloadable))step(float edge, float2 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 20))
+/*
+ * if (v < edge)
+ * return 0.f;
+ * else
+ * return 1.f;
+ *
+ * Supported by API versions 20 and newer.
+ */
+extern float3 __attribute__((const, overloadable))step(float edge, float3 v);
+#endif
+
+#if (defined(RS_VERSION) && (RS_VERSION >= 20))
+/*
+ * if (v < edge)
+ * return 0.f;
+ * else
+ * return 1.f;
+ *
+ * Supported by API versions 20 and newer.
+ */
+extern float4 __attribute__((const, overloadable))step(float edge, float4 v);
+#endif
+
 #if (defined(RS_VERSION) && (RS_VERSION >= 9))
 /*
  * Return the sign of a value.