am 142f2d34: am f46cf902: am 3a7a4696: Merge "Replace "mips" with "mipmaps" since the MIPS gcc compiler defines mips to 1."

* commit '142f2d34bc8c1249c152934de18d11767d03fb68':
  Replace "mips" with "mipmaps" since the MIPS gcc compiler defines mips to 1.
diff --git a/api/gen_runtime.cpp b/api/gen_runtime.cpp
new file mode 100644
index 0000000..a545a2e
--- /dev/null
+++ b/api/gen_runtime.cpp
@@ -0,0 +1,393 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <vector>
+#include <list>
+#include <string>
+
+using namespace std;
+
+FILE *gIn;
+FILE *gOut;
+
+class Func {
+public:
+    Func() {
+        mMinVersion = 0;
+        mMaxVersion = 0;
+    }
+
+    string mName;
+    int mMinVersion;
+    int mMaxVersion;
+
+    vector<vector<string> > mReplaceables;
+    vector<string> mArgs;
+    string mRet;
+    vector<string> mComment;
+    vector<string> mInline;
+
+};
+
+vector<Func *> gFuncs;
+
+bool getNextLine(FILE *in, string *s) {
+    s->clear();
+    while (1) {
+        int c = fgetc(in);
+        if (c == EOF) return s->size() != 0;
+        if (c == '\n') break;
+        s->push_back((char)c);
+    }
+    return true;
+}
+
+void trim(string *s, size_t start) {
+    if (start > 0) {
+        s->erase(0, start);
+    }
+
+    while (s->size() && (s->at(0) == ' ')) {
+        s->erase(0, 1);
+    }
+
+    size_t p = s->find_first_of("\n\r");
+    if (p != string::npos) {
+        s->erase(p);
+    }
+
+    while ((s->size() > 0) && (s->at(s->size()-1) == ' ')) {
+        s->erase(s->size() -1);
+    }
+}
+
+Func * scanFunction(FILE *in) {
+    Func *f = new Func();
+    bool modeComment = false;
+    bool modeInline = false;
+    size_t replacables = 0;
+
+    while (1) {
+        string s;
+        bool ret = getNextLine(in, &s);
+        if (!ret) break;
+
+        if (modeComment) {
+            if (!s.size() || (s[0] == ' ')) {
+                trim(&s, 0);
+                f->mComment.push_back(s);
+                continue;
+            } else {
+                modeComment = false;
+            }
+        }
+
+        if (modeInline) {
+            if (!s.size() || (s[0] == ' ')) {
+                trim(&s, 0);
+                f->mInline.push_back(s);
+                continue;
+            } else {
+                modeInline = false;
+            }
+        }
+
+        if (s[0] == '#') {
+            continue;
+        }
+
+        if (s.compare(0, 5, "name:") == 0) {
+            trim(&s, 5);
+            f->mName = s;
+            continue;
+        }
+
+        if (s.compare(0, 4, "arg:") == 0) {
+            trim(&s, 4);
+            f->mArgs.push_back(s);
+            continue;
+        }
+
+        if (s.compare(0, 4, "ret:") == 0) {
+            trim(&s, 4);
+            f->mRet = s;
+            continue;
+        }
+
+        if (s.compare(0, 4, "end:") == 0) {
+            return f;
+        }
+
+        if (s.compare(0, 8, "comment:") == 0) {
+            modeComment = true;
+            continue;
+        }
+
+        if (s.compare(0, 7, "inline:") == 0) {
+            modeInline = true;
+            continue;
+        }
+
+        if (s.compare(0, 8, "version:") == 0) {
+            trim(&s, 8);
+            sscanf(s.c_str(), "%i %i", &f->mMinVersion, &f->mMaxVersion);
+            continue;
+        }
+
+        if (s.compare(0, 8, "start:") == 0) {
+            continue;
+        }
+
+        if (s.compare(0, 2, "w:") == 0) {
+            vector<string> t;
+            if (s.find("1") != string::npos) {
+                t.push_back("");
+            }
+            if (s.find("2") != string::npos) {
+                t.push_back("2");
+            }
+            if (s.find("3") != string::npos) {
+                t.push_back("3");
+            }
+            if (s.find("4") != string::npos) {
+                t.push_back("4");
+            }
+            f->mReplaceables.push_back(t);
+            continue;
+        }
+
+        if (s.compare(0, 2, "t:") == 0) {
+            vector<string> t;
+            if (s.find("f16") != string::npos) {
+                t.push_back("half");
+            }
+            if (s.find("f32") != string::npos) {
+                t.push_back("float");
+            }
+            if (s.find("f64") != string::npos) {
+                t.push_back("double");
+            }
+            if (s.find("i8") != string::npos) {
+                t.push_back("char");
+            }
+            if (s.find("u8") != string::npos) {
+                t.push_back("uchar");
+            }
+            if (s.find("i16") != string::npos) {
+                t.push_back("short");
+            }
+            if (s.find("u16") != string::npos) {
+                t.push_back("ushort");
+            }
+            if (s.find("i32") != string::npos) {
+                t.push_back("int");
+            }
+            if (s.find("u32") != string::npos) {
+                t.push_back("uint");
+            }
+            if (s.find("i64") != string::npos) {
+                t.push_back("long");
+            }
+            if (s.find("u64") != string::npos) {
+                t.push_back("ulong");
+            }
+            f->mReplaceables.push_back(t);
+            continue;
+        }
+
+        if (s.size() == 0) {
+            // eat empty line
+            continue;
+        }
+
+        printf("Error, line:\n");
+        printf("  %s\n", s.c_str());
+    }
+
+    delete f;
+    return NULL;
+}
+
+string stringReplace(string s, string match, string rep) {
+    while(1) {
+        size_t p = s.find(match);
+        if (p == string::npos) break;
+
+        s.erase(p, match.size());
+        s.insert(p, rep);
+    }
+    return s;
+}
+
+string stringExpand(string s, const Func *f, int i1, int i2, int i3, int i4) {
+    if (f->mReplaceables.size() > 0) {
+        s = stringReplace(s, "#1", f->mReplaceables[0][i1]);
+    }
+    if (f->mReplaceables.size() > 1) {
+        s = stringReplace(s, "#2", f->mReplaceables[1][i2]);
+    }
+    if (f->mReplaceables.size() > 2) {
+        s = stringReplace(s, "#3", f->mReplaceables[2][i3]);
+    }
+    if (f->mReplaceables.size() > 3) {
+        s = stringReplace(s, "#4", f->mReplaceables[3][i4]);
+    }
+    return s;
+}
+
+void writeHeaderFunc(FILE *o, const Func *f, int i1, int i2, int i3, int i4) {
+    string s;
+
+    if (f->mMinVersion || f->mMaxVersion) {
+        if (f->mMaxVersion) {
+            fprintf(o, "#if (defined(RS_VERSION) && (RS_VERSION >= %i) && (RS_VERSION < %i))\n",
+                    f->mMinVersion, f->mMaxVersion);
+        } else {
+            fprintf(o, "#if (defined(RS_VERSION) && (RS_VERSION >= %i))\n",
+                    f->mMinVersion);
+        }
+    }
+
+    fprintf(o, "/*\n");
+    for (size_t ct=0; ct < f->mComment.size(); ct++) {
+        s = stringExpand(f->mComment[ct], f, i1, i2, i3, i4);
+        if (s.size()) {
+            fprintf(o, " * %s\n", s.c_str());
+        } else {
+            fprintf(o, " *\n");
+        }
+    }
+    fprintf(o, " *\n");
+    if (f->mMinVersion || f->mMaxVersion) {
+        if (f->mMaxVersion) {
+            fprintf(o, " * Suppored by API versions %i - %i\n",
+                    f->mMinVersion, f->mMaxVersion);
+        } else {
+            fprintf(o, " * Supported by API versions %i and newer.\n",
+                    f->mMinVersion);
+        }
+    }
+
+    fprintf(o, " */\n");
+
+    s.clear();
+    s += "extern ";
+    s += f->mRet;
+    s += " __attribute__((const, overloadable))";
+    s += f->mName;
+    s += "(";
+    if (f->mArgs.size()) {
+        s += f->mArgs[0];
+    }
+    for (size_t ct=1; ct < f->mArgs.size(); ct++) {
+        s += ", ";
+        s += f->mArgs[0];
+    }
+    s += ");";
+    s = stringExpand(s, f, i1, i2, i3, i4);
+    fprintf(o, "%s\n", s.c_str());
+
+
+    if (f->mMinVersion || f->mMaxVersion) {
+        fprintf(o, "#endif\n");
+    }
+
+    fprintf(o, "\n", s.c_str());
+}
+
+
+void writeHeaderFuncs(FILE *o, const Func *f) {
+    switch(f->mReplaceables.size()) {
+    case 0:
+        writeHeaderFunc(o, f, -1, -1, -1, -1);
+        break;
+    case 1:
+        for (size_t i1 = 0; i1 < f->mReplaceables[0].size(); i1++) {
+            writeHeaderFunc(o, f, i1, -1, -1, -1);
+        }
+        break;
+    case 2:
+        for (size_t i2 = 0; i2 < f->mReplaceables[1].size(); i2++) {
+            for (size_t i1 = 0; i1 < f->mReplaceables[0].size(); i1++) {
+                writeHeaderFunc(o, f, i1, i2, -1, -1);
+            }
+        }
+        break;
+    case 3:
+        for (size_t i3 = 0; i3 < f->mReplaceables[2].size(); i3++) {
+            for (size_t i2 = 0; i2 < f->mReplaceables[1].size(); i2++) {
+                for (size_t i1 = 0; i1 < f->mReplaceables[0].size(); i1++) {
+                    writeHeaderFunc(o, f, i1, i2, i3, -1);
+                }
+            }
+        }
+        break;
+    case 4:
+        for (size_t i4 = 0; i4 < f->mReplaceables[3].size(); i4++) {
+            for (size_t i3 = 0; i3 < f->mReplaceables[2].size(); i3++) {
+                for (size_t i2 = 0; i2 < f->mReplaceables[1].size(); i2++) {
+                    for (size_t i1 = 0; i1 < f->mReplaceables[0].size(); i1++) {
+                        writeHeaderFunc(o, f, i1, i2, i3, i4);
+                    }
+                }
+            }
+        }
+        break;
+    }
+}
+
+
+
+int main(int argc, char* argv[])
+{
+    const char *inpath = "runtime.spec";
+    const char *outpath = "rs_core_math.rsh";
+
+    gIn = fopen(inpath, "rt");
+    if (!gIn) {
+        printf("Error opening input file: %s", inpath);
+        return -1;
+    }
+
+    while (1) {
+        Func *f = scanFunction(gIn);
+        if (f != NULL) {
+            gFuncs.push_back(f);
+        } else {
+            break;
+        }
+    }
+
+    gOut = fopen(outpath, "wt");
+    if (!gOut) {
+        printf("Error opening output file: %s", outpath);
+        return -1;
+    }
+
+    for (size_t ct=0; ct < gFuncs.size(); ct++) {
+        writeHeaderFuncs(gOut, gFuncs[ct]);
+    }
+
+    fclose (gIn);
+    fclose (gOut);
+
+    printf("%i Functions processed.\n", (int)gFuncs.size());
+
+    return 0;
+}
+
+
diff --git a/api/runtime.spec b/api/runtime.spec
new file mode 100644
index 0000000..65e29ea
--- /dev/null
+++ b/api/runtime.spec
@@ -0,0 +1,1301 @@
+#
+# Copyright (C) 2013 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+start:
+w: 2, 3, 4
+t: u8, u16, u32, u64, i8, i16, i32, i64, f32, f64
+t: u8, u16, u32, u64, i8, i16, i32, i64, f32, f64
+name: convert_uchar#1
+arg: #2#1
+ret: #3#1
+comment:
+ Component wise conversion from #2#1 to #3#1
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: acos
+ret: #2#1
+arg: #2#1
+comment:
+ acos
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: acosh
+ret: #2#1
+arg: #2#1
+comment:
+ acosh
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: acospi
+ret: #2#1
+arg: #2#1
+comment:
+ acospi
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: asin
+ret: #2#1
+arg: #2#1
+comment:
+ asin
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: asinh
+ret: #2#1
+arg: #2#1
+comment:
+ asinh
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: asinpi
+ret: #2#1
+arg: #2#1
+comment:
+ Return the inverse sine divided by PI.
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: atan
+ret: #2#1
+arg: #2#1
+comment:
+ Return the inverse tangent.
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: atan2
+ret: #2#1
+arg: #2#1 y
+arg: #2#1 x
+comment:
+ Return the inverse tangent of y / x.
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: atanh
+ret: #2#1
+arg: #2#1
+comment:
+ Return the inverse hyperbolic tangent.
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: atanpi
+ret: #2#1
+arg: #2#1
+comment:
+ Return the inverse tangent divided by PI.
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: atan2pi
+ret: #2#1
+arg: #2#1 y
+arg: #2#1 x
+comment:
+ Return the inverse tangent of y / x, divided by PI.
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: cbrt
+ret: #2#1
+arg: #2#1
+comment:
+ Return the cube root.
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: ceil
+ret: #2#1
+arg: #2#1
+comment:
+ Return the smallest integer not less than a value.
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: copysign
+ret: #2#1
+arg: #2#1 x
+arg: #2#1 y
+comment:
+ Copy the sign bit from y to x.
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: cos
+ret: #2#1
+arg: #2#1
+comment:
+ Return the cosine.
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: cosh
+ret: #2#1
+arg: #2#1
+comment:
+ Return the hypebolic cosine.
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: cospi
+ret: #2#1
+arg: #2#1
+comment:
+ Return the cosine of the value * PI.
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: erfc
+ret: #2#1
+arg: #2#1
+comment:
+ Return the complementary error function.
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: erf
+ret: #2#1
+arg: #2#1
+comment:
+ Return the error function.
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: exp
+ret: #2#1
+arg: #2#1
+comment:
+ Return e ^ value.
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: exp2
+ret: #2#1
+arg: #2#1
+comment:
+ Return 2 ^ value.
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: exp10
+ret: #2#1
+arg: #2#1
+comment:
+ Return 10 ^ value.
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: expm1
+ret: #2#1
+arg: #2#1
+comment:
+ Return (e ^ value) - 1.
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: fabs
+ret: #2#1
+arg: #2#1
+comment:
+ Return the absolute value of a value.
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: fdim
+ret: #2#1
+arg: #2#1
+comment:
+ Return the positive difference between two values.
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: floor
+ret: #2#1
+arg: #2#1
+comment:
+ Return the smallest integer not greater than a value.
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: fma
+ret: #2#1
+arg: #2#1 a
+arg: #2#1 b
+arg: #2#1 c
+comment:
+ Return (a * b) + c.
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: fmax
+ret: #2#1
+arg: #2#1 x
+arg: #2#1 y
+comment:
+ Return (x < y ? y : x)
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: fmax
+ret: #2#1
+arg: #2#1 x
+arg: #2 y
+comment:
+ Return (x < y ? y : x)
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: fmin
+ret: #2#1
+arg: #2#1 x
+arg: #2#1 y
+comment:
+ Return (x > y ? y : x)
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: fmin
+ret: #2#1
+arg: #2#1 x
+arg: #2 y
+comment:
+ Return (x > y ? y : x)
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: fmod
+ret: #2#1
+arg: #2#1 x
+arg: #2#1 y
+comment:
+ Return the remainder from x / y
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: fract
+ret: #2#1
+arg: #2#1 v
+arg: #2#1 *iptr
+comment:
+ Return fractional part of v
+
+ @param iptr  iptr[0] will be set to the floor of the input value.
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: fract
+ret: #2#1
+arg: #2#1 v
+comment:
+ Return fractional part of v
+inline:
+    #2#1 unused;
+    return fract(v, &unused);
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: frexp
+ret: #2#1
+arg: #2#1 v
+arg: int#1 *iptr
+comment:
+ Return the mantissa and place the exponent into iptr[0]
+
+ @param v Supports float, float2, float3, float4.
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: hypot
+ret: #2#1
+arg: #2#1 x
+arg: #2#1 y
+comment:
+ Return sqrt(x*x + y*y)
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: ilogb
+ret: #2#1
+arg: #2#1
+comment:
+ Return the integer exponent of a value
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: ilogb
+ret: #2#1
+arg: #2#1
+arg: int#1
+comment:
+ Return (x * 2^y)
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: ilogb
+ret: #2#1
+arg: #2#1
+arg: int
+comment:
+ Return (x * 2^y)
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: lgamma
+ret: #2#1
+arg: #2#1 x
+comment:
+ Return the log gamma and sign
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: lgamma
+ret: #2#1
+arg: #2#1 x
+arg: int#1 *y
+comment:
+ Return the log gamma and sign
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: log
+ret: #2#1
+arg: #2#1 x
+comment:
+ Return the natural logarithm.
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: log2
+ret: #2#1
+arg: #2#1 x
+comment:
+ Return the base 2 logarithm.
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: log10
+ret: #2#1
+arg: #2#1 x
+comment:
+ Return the base 10 logarithm.
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: log1p
+ret: #2#1
+arg: #2#1 x
+comment:
+ Return the natural logarithm of (v + 1.0f)
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: logb
+ret: #2#1
+arg: #2#1 x
+comment:
+ Compute the exponent of the value.
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: mad
+ret: #2#1
+arg: #2#1 a
+arg: #2#1 b
+arg: #2#1 c
+comment:
+ Compute (a * b) + c
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: modf
+ret: #2#1
+arg: #2#1 x
+arg: #2#1 *iret
+comment:
+ Return the integral and fractional components of a number.
+
+ @param x Source value
+ @param iret iret[0] will be set to the integral portion of the number.
+ @return The floating point portion of the value.
+version: 9
+end:
+
+start:
+w: 1
+t: f32
+name: nan
+ret: #2#1
+arg: uint#1
+comment:
+ generate a nan
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: nextafter
+ret: #2#1
+arg: #2#1 x
+arg: #2#1 y
+comment:
+ Return the next floating point number from x towards y.
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: pow
+ret: #2#1
+arg: #2#1 x
+arg: #2#1 y
+comment:
+ Return x ^ y.
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: pown
+ret: #2#1
+arg: #2#1 x
+arg: int#1 y
+comment:
+ Return x ^ y.
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: powr
+ret: #2#1
+arg: #2#1 x
+arg: #2#1 y
+comment:
+ Return x ^ y.
+ y must be > 0
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: remainder
+ret: #2#1
+arg: #2#1 x
+arg: #2#1 y
+comment:
+ Return round x/y to the nearest integer then compute the remander.
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: remquo
+ret: #2#1
+arg: #2#1
+arg: #2#1
+arg: int#1 *
+comment:
+ todo
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: rint
+ret: #2#1
+arg: #2#1
+comment:
+ Round to the nearest integral value.
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: rootn
+ret: #2#1
+arg: #2#1 v
+arg: int#1 n
+comment:
+ Compute the Nth root of a value.
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: round
+ret: #2#1
+arg: #2#1
+comment:
+ Round to the nearest integral value.  Half values are rounded away from zero.
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: rsqrt
+ret: #2#1
+arg: #2#1
+comment:
+ Return (1 / sqrt(value)).
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: sqrt
+ret: #2#1
+arg: #2#1
+comment:
+ Return the square root of a value.
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: sin
+ret: #2#1
+arg: #2#1
+comment:
+ Return the sine of a value specified in radians.
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: sincos
+ret: #2#1
+arg: #2#1 v
+arg: #2#1 *cosptr
+comment:
+ Return the sine and cosine of a value.
+
+ @return sine
+ @param v The incoming value in radians
+ @param *cosptr cosptr[0] will be set to the cosine value.
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: sinh
+ret: #2#1
+arg: #2#1
+comment:
+ Return the hyperbolic sine of a value specified in radians.
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: sinpi
+ret: #2#1
+arg: #2#1
+comment:
+ Return the sin(v * PI).
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: tan
+ret: #2#1
+arg: #2#1
+comment:
+ Return the tangent of a value.
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: tanh
+ret: #2#1
+arg: #2#1
+comment:
+ Return the hyperbolic tangent of a value.
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: tanpi
+ret: #2#1
+arg: #2#1
+comment:
+ Return tan(v * PI)
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: tgamma
+ret: #2#1
+arg: #2#1
+comment:
+ Compute the gamma function of a value.
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: trunc
+ret: #2#1
+arg: #2#1
+comment:
+ ound to integral using truncation.
+version: 9
+end:
+
+# int functions
+
+start:
+w: 1, 2, 3, 4
+t: i8, i16, i32
+name: abs
+ret: #2#1
+arg: #2#1 value
+comment:
+ Return the absolute value of a value.
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: u8, u16, u32, i8, i16, i32
+name: clz
+ret: #2#1
+arg: #2#1 value
+comment:
+ Return the number of leading 0-bits in a value.
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: min
+ret: #2#1
+arg: #2#1
+arg: #2#1
+comment:
+ Return the minimum value from two arguments
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: i8 i16 i32 u8 u16 u32
+name: min
+ret: #2#1
+arg: #2#1 v1
+arg: #2#1 v2
+comment:
+ Return the minimum value from two arguments
+inline:
+ return (v1 < v2 ? v1 : v2);
+version: 9 19
+end:
+
+start:
+w: 1, 2, 3, 4
+t: i8 i16 i32 i64 u8 u16 u32 u64
+name: min
+ret: #2#1
+arg: #2#1 v1
+arg: #2#1 v2
+comment:
+ Return the minimum value from two arguments
+version: 19
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: max
+ret: #2#1
+arg: #2#1
+arg: #2#1
+comment:
+ Return the maximum value from two arguments
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: i8 i16 i32 u8 u16 u32
+name: max
+ret: #2#1
+arg: #2#1 v1
+arg: #2#1 v2
+comment:
+ Return the maximum value from two arguments
+inline:
+ return (v1 < v2 ? v1 : v2);
+version: 9 19
+end:
+
+start:
+w: 1, 2, 3, 4
+t: i8 i16 i32 i64 u8 u16 u32 u64
+name: max
+ret: #2#1
+arg: #2#1 v1
+arg: #2#1 v2
+comment:
+ Return the maximum value from two arguments
+version: 19
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: clamp
+ret: #2#1
+arg: #2#1 value
+arg: #2#1 min_value
+arg: #2#1 max_value
+comment:
+ Clamp a value to a specified high and low bound.
+
+ @param amount value to be clamped.  Supports 1,2,3,4 components
+ @param min_value Lower bound, must be scalar or matching vector.
+ @param max_value High bound, must match type of low
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: clamp
+ret: #2#1
+arg: #2#1 value
+arg: #2 min_value
+arg: #2 max_value
+comment:
+ Clamp a value to a specified high and low bound.
+
+ @param amount value to be clamped.  Supports 1,2,3,4 components
+ @param min_value Lower bound, must be scalar or matching vector.
+ @param max_value High bound, must match type of low
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: u8, u16, u32, u64, i8, i16, i32, i64
+name: clamp
+ret: #2#1
+arg: #2#1 value
+arg: #2#1 min_value
+arg: #2#1 max_value
+comment:
+ Clamp a value to a specified high and low bound.
+
+ @param amount value to be clamped.  Supports 1,2,3,4 components
+ @param min_value Lower bound, must be scalar or matching vector.
+ @param max_value High bound, must match type of low
+version: 19
+end:
+
+start:
+w: 1, 2, 3, 4
+t: u8, u16, u32, u64, i8, i16, i32, i64
+name: clamp
+ret: #2#1
+arg: #2#1 value
+arg: #2 min_value
+arg: #2 max_value
+comment:
+ Clamp a value to a specified high and low bound.
+
+ @param amount value to be clamped.  Supports 1,2,3,4 components
+ @param min_value Lower bound, must be scalar or matching vector.
+ @param max_value High bound, must match type of low
+version: 19
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: degrees
+ret: #2#1
+arg: #2#1 value
+comment:
+ Convert from radians to degrees.
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: mix
+ret: #2#1
+arg: #2#1 start
+arg: #2#1 stop
+arg: #2#1 amount
+comment:
+ return start + ((stop - start) * amount)
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: mix
+ret: #2#1
+arg: #2#1 start
+arg: #2#1 stop
+arg: #2 amount
+comment:
+ return start + ((stop - start) * amount)
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: radians
+ret: #2#1
+arg: #2#1 value
+comment:
+ Convert from degrees to radians.
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: step
+ret: #2#1
+arg: #2#1 value
+comment:
+ if (v < edge)
+     return 0.f;
+ else
+     return 1.f;
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: step
+ret: #2#1
+arg: #2 edge
+arg: #2 v
+comment:
+ if (v < edge)
+     return 0.f;
+ else
+     return 1.f;
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: sign
+ret: #2#1
+arg: #2 v
+comment:
+ Return the sign of a value.
+
+ if (v < 0) return -1.f;
+ else if (v > 0) return 1.f;
+ else return 0.f;
+version: 9
+end:
+
+start:
+w: 3, 4
+t: f32
+name: cross
+ret: #2#1
+arg: #2#1 lhs
+arg: #2#1 rhs
+comment:
+ Compute the cross product of two vectors.
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: dot
+ret: #2
+arg: #2#1 lhs
+arg: #2#1 rhs
+comment:
+ Compute the dot product of two vectors.
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: length
+ret: #2
+arg: #2#1 v
+comment:
+ Compute the length of a vector.
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: distance
+ret: #2
+arg: #2#1 lhs
+arg: #2#1 rhs
+comment:
+ Compute the distance between two points.
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: normalize
+ret: #2#1
+arg: #2#1 v
+comment:
+ Normalize a vector.
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: half_recip
+ret: #2#1
+arg: #2#1 v
+comment:
+ Return the approximate reciprocal of a value.
+version: 17
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: half_sqrt
+ret: #2#1
+arg: #2#1 v
+comment:
+ Return the approximate square root of a value.
+version: 17
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: half_rsqrt
+ret: #2#1
+arg: #2#1 v
+comment:
+ Return the approximate value of (1.f / sqrt(value)).
+version: 17
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: fast_length
+ret: #2
+arg: #2#1 v
+comment:
+ Compute the approximate length of a vector.
+version: 17
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: fast_distance
+ret: #2
+arg: #2#1 lhs
+arg: #2#1 rhs
+comment:
+ Compute the approximate distance between two points.
+version: 17
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: fast_normalize
+ret: #2#1
+arg: #2#1 v
+comment:
+ Approximately normalize a vector.
+version: 17
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: native_exp
+ret: #2#1
+arg: #2#1 v
+comment:
+ Fast approximate exp
+ valid for inputs -86.f to 86.f
+ Max 8192 ulps of error
+version: 18
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: native_exp2
+ret: #2#1
+arg: #2#1 v
+comment:
+ Fast approximate exp2
+ valid for inputs -125.f to 125.f
+ Max 8192 ulps of error
+version: 18
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: native_exp10
+ret: #2#1
+arg: #2#1 v
+comment:
+ Fast approximate exp10
+ valid for inputs -37.f to 37.f
+ Max 8192 ulps of error
+version: 18
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: native_log
+ret: #2#1
+arg: #2#1 v
+comment:
+ Fast approximate log
+version: 18
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: native_log2
+ret: #2#1
+arg: #2#1 v
+comment:
+ Fast approximate log2
+version: 18
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: native_log10
+ret: #2#1
+arg: #2#1 v
+comment:
+ Fast approximate log10
+version: 18
+end:
+
+start:
+w: 1, 2, 3, 4
+t: f32
+name: native_powr
+ret: #2#1
+arg: #2#1 v
+arg: #2#1 y
+comment:
+ Fast approximate v ^ y
+version: 18
+end:
+
+
diff --git a/cpp/Android.mk b/cpp/Android.mk
index d266d14..b32d7f1 100644
--- a/cpp/Android.mk
+++ b/cpp/Android.mk
@@ -21,9 +21,11 @@
   RS_VERSION := "(1 + $(PLATFORM_SDK_VERSION))"
 endif
 local_cflags_for_rs_cpp += -DRS_VERSION=$(RS_VERSION)
+local_cflags_for_rs_cpp += -Wno-unused-parameter
 
 LOCAL_SRC_FILES := $(rs_cpp_SRC_FILES)
 
+LOCAL_CLANG := true
 LOCAL_CFLAGS += $(local_cflags_for_rs_cpp)
 
 LOCAL_SHARED_LIBRARIES := \
@@ -47,6 +49,7 @@
 
 include $(CLEAR_VARS)
 
+LOCAL_CLANG := true
 LOCAL_CFLAGS += $(local_cflags_for_rs_cpp)
 
 LOCAL_SRC_FILES := $(rs_cpp_SRC_FILES)
diff --git a/java/tests/Balls/src/com/example/android/rs/balls/ball_physics.rs b/java/tests/Balls/src/com/example/android/rs/balls/ball_physics.rs
index 5b5d2e0..a8c781d 100644
--- a/java/tests/Balls/src/com/example/android/rs/balls/ball_physics.rs
+++ b/java/tests/Balls/src/com/example/android/rs/balls/ball_physics.rs
@@ -60,11 +60,11 @@
             float2 vec2 = vec * vec;
             float len2 = vec2.x + vec2.y;
 
-            if ((len2 < 10000.f) && (len2 > 0.f)) {
-                float t = native_powr(len2, 1.5f) + 16.0f;
-                float2 pfv = (vec / t) * 16000.f;
-                pressure += length(pfv);
-                fv -= pfv;
+            if ((len2 < 10000.f) && (len2 > 0.001f)) {
+                float len = rsqrt(len2 + 4.f);
+                float f = (len * len * len) * 20000.f;
+                fv -= vec * f;
+                pressure += f;
             }
         }
     }
@@ -137,7 +137,7 @@
     }
 
     // low pressure ~500, high ~2500
-    pressure = max(pressure - 400.f, 0.f);
+    pressure *= 12.f;
     ball->pressure = pressure;
 
     //rsDebug("p ", pressure);
diff --git a/java/tests/Balls/src/com/example/android/rs/balls/balls.rs b/java/tests/Balls/src/com/example/android/rs/balls/balls.rs
index 9be9f38..077916d 100644
--- a/java/tests/Balls/src/com/example/android/rs/balls/balls.rs
+++ b/java/tests/Balls/src/com/example/android/rs/balls/balls.rs
@@ -46,8 +46,9 @@
     int2 gridDims = (int2){ rsAllocationGetDimX(gGrid),
                             rsAllocationGetDimY(gGrid) };
 
-    rs_allocation ain = rsGetAllocation(balls);
-    int32_t dimX = rsAllocationGetDimX(ain);
+    rs_allocation aNull;  // Empty rs_allocation, since we don't have an input.
+    rs_allocation aout = rsGetAllocation(balls);
+    int32_t dimX = rsAllocationGetDimX(aout);
 
     // Binning
     // Clear the particle list
@@ -92,7 +93,7 @@
     }
 
 
-    rsForEach(physics_script, ain, ain);
+    rsForEach(physics_script, aNull, aout);
 
     for (uint32_t ct=0; ct < dimX; ct++) {
         point[ct].position = balls[ct].position;
diff --git a/java/tests/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java b/java/tests/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java
index 1a36417..77f554a 100644
--- a/java/tests/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java
+++ b/java/tests/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java
@@ -112,7 +112,6 @@
      * Define enum type for test names
      */
     public enum TestName {
-        // totally there are 38 test cases
         LEVELS_VEC3_RELAXED ("Levels Vec3 Relaxed"),
         LEVELS_VEC4_RELAXED ("Levels Vec4 Relaxed"),
         LEVELS_VEC3_FULL ("Levels Vec3 Full"),
@@ -169,8 +168,6 @@
         }
     }
 
-    Bitmap mBitmapIn;
-    Bitmap mBitmapIn2;
     Bitmap mBitmapOut;
 
     private Spinner mSpinner;
@@ -423,7 +420,7 @@
             break;
         }
 
-        mTest.createBaseTest(this, mBitmapIn, mBitmapIn2, mBitmapOut);
+        mTest.createBaseTest(this);
         setupBars();
 
         mTest.runTest();
@@ -448,10 +445,15 @@
             };
 
     void init() {
-        mBitmapIn = loadBitmap(R.drawable.img1600x1067);
-        mBitmapIn2 = loadBitmap(R.drawable.img1600x1067b);
-        mBitmapOut = Bitmap.createBitmap(mBitmapIn.getWidth(), mBitmapIn.getHeight(),
-                                         mBitmapIn.getConfig());
+        mRS = RenderScript.create(this);
+        mInPixelsAllocation = Allocation.createFromBitmapResource(
+                mRS, getResources(), R.drawable.img1600x1067);
+        mInPixelsAllocation2 = Allocation.createFromBitmapResource(
+                mRS, getResources(), R.drawable.img1600x1067b);
+        mBitmapOut = Bitmap.createBitmap(mInPixelsAllocation.getType().getX(),
+                                         mInPixelsAllocation.getType().getY(),
+                                         Bitmap.Config.ARGB_8888);
+        mOutPixelsAllocation = Allocation.createFromBitmap(mRS, mBitmapOut);
 
         mDisplayView = (ImageView) findViewById(R.id.display);
         mDisplayView.setImageBitmap(mBitmapOut);
@@ -482,21 +484,6 @@
         mBenchmarkResult = (TextView) findViewById(R.id.benchmarkText);
         mBenchmarkResult.setText("Result: not run");
 
-
-        mRS = RenderScript.create(this);
-        mInPixelsAllocation = Allocation.createFromBitmap(mRS, mBitmapIn,
-                                                          Allocation.MipmapControl.MIPMAP_NONE,
-                                                          Allocation.USAGE_SHARED |
-                                                          Allocation.USAGE_GRAPHICS_TEXTURE |
-                                                          Allocation.USAGE_SCRIPT);
-        mInPixelsAllocation2 = Allocation.createFromBitmap(mRS, mBitmapIn2,
-                                                           Allocation.MipmapControl.MIPMAP_NONE,
-                                                           Allocation.USAGE_SHARED |
-                                                           Allocation.USAGE_GRAPHICS_TEXTURE |
-                                                           Allocation.USAGE_SCRIPT);
-        mOutPixelsAllocation = Allocation.createFromBitmap(mRS, mBitmapOut);
-
-
         setupTests();
         changeTest(TestName.LEVELS_VEC3_RELAXED);
     }
@@ -518,8 +505,6 @@
         mInPixelsAllocation = null;
         mInPixelsAllocation2 = null;
         mOutPixelsAllocation = null;
-        mBitmapIn = null;
-        mBitmapIn2 = null;
         mBitmapOut = null;
     }
 
@@ -546,12 +531,6 @@
         init();
     }
 
-    private Bitmap loadBitmap(int resource) {
-        final BitmapFactory.Options options = new BitmapFactory.Options();
-        options.inPreferredConfig = Bitmap.Config.ARGB_8888;
-        return BitmapFactory.decodeResource(getResources(), resource, options);
-    }
-
     // button hook
     public void benchmark(View v) {
         float t = getBenchmark();
diff --git a/java/tests/ImageProcessing/src/com/android/rs/image/TestBase.java b/java/tests/ImageProcessing/src/com/android/rs/image/TestBase.java
index a353d9c..cfa9897 100644
--- a/java/tests/ImageProcessing/src/com/android/rs/image/TestBase.java
+++ b/java/tests/ImageProcessing/src/com/android/rs/image/TestBase.java
@@ -19,9 +19,7 @@
 import android.app.Activity;
 import android.content.Context;
 import android.os.Bundle;
-import android.graphics.BitmapFactory;
 import android.graphics.Bitmap;
-import android.graphics.Canvas;
 import android.renderscript.ScriptC;
 import android.renderscript.RenderScript;
 import android.renderscript.Type;
@@ -104,7 +102,7 @@
         return false;
     }
 
-    public final void createBaseTest(ImageProcessingActivity ipact, Bitmap b, Bitmap b2, Bitmap outb) {
+    public final void createBaseTest(ImageProcessingActivity ipact) {
         act = ipact;
         mRS = ipact.mRS;
         mRS.setMessageHandler(new MessageProcessor(act));
diff --git a/java/tests/ImageProcessing_jb/src/com/android/rs/image/Blend.java b/java/tests/ImageProcessing_jb/src/com/android/rs/image/Blend.java
index 098830b..63c0c9c 100644
--- a/java/tests/ImageProcessing_jb/src/com/android/rs/image/Blend.java
+++ b/java/tests/ImageProcessing_jb/src/com/android/rs/image/Blend.java
@@ -121,10 +121,10 @@
         image2.copy2DRangeFrom(0, 0, mInPixelsAllocation2.getType().getX(), mInPixelsAllocation2.getType().getY(), mInPixelsAllocation2, 0, 0);
 
         mBlendHelper.set_alpha(image1Alpha);
-        mBlendHelper.forEach_setImageAlpha(image1);
+        mBlendHelper.forEach_setImageAlpha(image1, image1);
 
         mBlendHelper.set_alpha(image2Alpha);
-        mBlendHelper.forEach_setImageAlpha(image2);
+        mBlendHelper.forEach_setImageAlpha(image2, image2);
 
         switch (currentIntrinsic) {
         case 0:
diff --git a/java/tests/ImageProcessing_jb/src/com/android/rs/image/blend.rs b/java/tests/ImageProcessing_jb/src/com/android/rs/image/blend.rs
index 63e7ea5..3f2fdc5 100644
--- a/java/tests/ImageProcessing_jb/src/com/android/rs/image/blend.rs
+++ b/java/tests/ImageProcessing_jb/src/com/android/rs/image/blend.rs
@@ -17,8 +17,10 @@
 
 uchar alpha = 0x0;
 
-void setImageAlpha(uchar4 *v_out, uint32_t x, uint32_t y) {
-  v_out->rgba = convert_uchar4((convert_uint4(v_out->rgba) * alpha) >> (uint4)8);
-  v_out->a = alpha;
+uchar4 __attribute__((kernel)) setImageAlpha(uchar4 in, uint32_t x, uint32_t y) {
+    uchar4 out;
+    out.rgba = convert_uchar4((convert_uint4(in.rgba) * alpha) >> (uint4)8);
+    out.a = alpha;
+    return out;
 }
 
diff --git a/java/tests/LivePreview/src/com/android/rs/livepreview/RsYuv.java b/java/tests/LivePreview/src/com/android/rs/livepreview/RsYuv.java
index 12d3185..15cd72a 100644
--- a/java/tests/LivePreview/src/com/android/rs/livepreview/RsYuv.java
+++ b/java/tests/LivePreview/src/com/android/rs/livepreview/RsYuv.java
@@ -27,6 +27,7 @@
 import android.renderscript.RenderScript;
 import android.util.Log;
 import android.view.TextureView;
+import android.view.Surface;
 import android.view.View;
 
 import android.content.res.Resources;
@@ -44,7 +45,7 @@
     private ScriptC_yuv mScript;
     private ScriptIntrinsicYuvToRGB mYuv;
     private boolean mHaveSurface;
-    private SurfaceTexture mSurface;
+    private Surface mSurface;
     private ScriptGroup mGroup;
 
     RsYuv(RenderScript rs) {
@@ -55,7 +56,7 @@
 
     void setupSurface() {
         if (mAllocationOut != null) {
-            mAllocationOut.setSurfaceTexture(mSurface);
+            mAllocationOut.setSurface(mSurface);
         }
         if (mSurface != null) {
             mHaveSurface = true;
@@ -116,7 +117,7 @@
 
             //mYuv.forEach(mAllocationOut);
             //mScript.forEach_root(mAllocationOut, mAllocationOut);
-            mAllocationOut.ioSendOutput();
+            mAllocationOut.ioSend();
         }
     }
 
@@ -125,21 +126,21 @@
     @Override
     public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
         android.util.Log.v("cpa", "onSurfaceTextureAvailable " + surface);
-        mSurface = surface;
+        mSurface = new Surface(surface);
         setupSurface();
     }
 
     @Override
     public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
         android.util.Log.v("cpa", "onSurfaceTextureSizeChanged " + surface);
-        mSurface = surface;
+        mSurface = new Surface(surface);
         setupSurface();
     }
 
     @Override
     public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
         android.util.Log.v("cpa", "onSurfaceTextureDestroyed " + surface);
-        mSurface = surface;
+        mSurface = null;
         setupSurface();
         return true;
     }
diff --git a/java/tests/SampleTest/src/com/android/rs/sample/SampleRSActivity.java b/java/tests/SampleTest/src/com/android/rs/sample/SampleRSActivity.java
index dd4a98a..feaa81d 100644
--- a/java/tests/SampleTest/src/com/android/rs/sample/SampleRSActivity.java
+++ b/java/tests/SampleTest/src/com/android/rs/sample/SampleRSActivity.java
@@ -157,7 +157,7 @@
         long t = java.lang.System.currentTimeMillis();
         mScript.invoke_setSampleData(alloc, mTwoByTwoAlloc, sampler);
         mScript.forEach_root(alloc);
-        alloc.ioSendOutput();
+        alloc.ioSend();
         mRS.finish();
         t = java.lang.System.currentTimeMillis() - t;
         Log.i(TAG, "Filter time is: " + t + " ms");
diff --git a/rs.h b/rs.h
index 566d9ea..e31762d 100644
--- a/rs.h
+++ b/rs.h
@@ -45,10 +45,10 @@
     // Allocation update
     const void* rsaAllocationGetType(RsContext con, RsAllocation va);
     // Type update
-    void rsaTypeGetNativeData(RsContext, RsType, uint32_t *typeData, uint32_t typeDataSize);
+    void rsaTypeGetNativeData(RsContext, RsType, uintptr_t *typeData, uint32_t typeDataSize);
     // Element update
-    void rsaElementGetNativeData(RsContext, RsElement, uint32_t *elemData, uint32_t elemDataSize);
-    void rsaElementGetSubElements(RsContext, RsElement, uint32_t *ids, const char **names,
+    void rsaElementGetNativeData(RsContext, RsElement, uintptr_t *elemData, uint32_t elemDataSize);
+    void rsaElementGetSubElements(RsContext, RsElement, uintptr_t *ids, const char **names,
                                   uint32_t *arraySizes, uint32_t dataSize);
 
     RsDevice rsDeviceCreate();
diff --git a/rsContext.cpp b/rsContext.cpp
index 01debb2..145759e 100644
--- a/rsContext.cpp
+++ b/rsContext.cpp
@@ -319,14 +319,14 @@
 #define OVERRIDE_RS_DRIVER_STRING STR(OVERRIDE_RS_DRIVER)
 
     if (getProp("debug.rs.default-CPU-driver") != 0) {
-        ALOGE("Skipping override driver and loading default CPU driver");
+        ALOGD("Skipping override driver and loading default CPU driver");
     } else if (rsc->mForceCpu) {
         ALOGV("Application requested CPU execution");
     } else if (rsc->getContextType() == RS_CONTEXT_TYPE_DEBUG) {
         ALOGV("Application requested debug context");
     } else {
         if (loadRuntime(OVERRIDE_RS_DRIVER_STRING, rsc)) {
-            ALOGE("Successfully loaded runtime: %s", OVERRIDE_RS_DRIVER_STRING);
+            ALOGV("Successfully loaded runtime: %s", OVERRIDE_RS_DRIVER_STRING);
             loadDefault = false;
         } else {
             ALOGE("Failed to load runtime %s, loading default", OVERRIDE_RS_DRIVER_STRING);